<?php
require_once '../config/headers.php';
require_once '../config/database.php';
require_once '../utils/response.php';

if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
    sendResponse(405, 'error', 'Method not allowed');
}

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

if (empty($data->id) || empty($data->status)) {
    sendResponse(400, 'error', 'ID and status are required');
}

$database = new Database();
$db = $database->getConnection();

try {
    $stmt = $db->prepare("UPDATE hotel_bookings SET booking_status = :status WHERE id = :id");
    $stmt->execute([
        ':status' => $data->status,
        ':id' => $data->id
    ]);

    sendResponse(200, 'success', 'Hotel booking status updated successfully');
} catch (PDOException $e) {
    sendResponse(500, 'error', 'Database error: ' . $e->getMessage());
}
?>