<?php
require_once 'config.php';

checkAccess(['admin', 'programmer', 'board']);

$data = json_decode(file_get_contents("php://input"), true);

if (!isset($data['id'])) response(["error" => "ID faltante"], 400);

try {
    $stmt = $pdo->prepare("UPDATE data_forms SET status = IF(status='Activo', 'Cerrado', 'Activo') WHERE id = ?");
    $stmt->execute([$data['id']]);
    response(["success" => true]);
} catch (PDOException $e) {
    response(["error" => $e->getMessage()], 500);
}
?>