<?php
require_once 'config.php';

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

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

if (!isset($data['id']) || !isset($data['status'])) {
    response(["error" => "Faltan parámetros"], 400);
}

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