<?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)) {
    sendResponse(400, 'error', 'ID is required');
}

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

try {
    $stmt = $db->prepare("DELETE FROM hotel_registrations WHERE id = :id");
    $stmt->execute([':id' => $data->id]);

    if ($stmt->rowCount() > 0) {
        sendResponse(200, 'success', 'Registration deleted successfully');
    } else {
        sendResponse(404, 'error', 'Registration not found');
    }
} catch (PDOException $e) {
    sendResponse(500, 'error', 'Database error: ' . $e->getMessage());
}
?>