<?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', 'Enquiry ID is required');
}

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

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

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