<?php
// Include the database connection
header('Access-Control-Allow-Origin: *');
header("Content-Type: application/json; charset=UTF-8");
header("Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS");
header("Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With, access");
header("Access-Control-Allow-Credentials: true");
include 'db.php';

// Query to count pending bookings
$sql = "SELECT COUNT(*) AS pendingCount FROM new_trip_booking WHERE status = 'pending'";

$result = $conn->query($sql);

if ($result) {
    $row = $result->fetch_assoc();
    // Output the result as JSON
    header('Content-Type: application/json');
    echo json_encode($row);
} else {
    // Handle query error
    echo json_encode(['error' => 'Failed to retrieve pending bookings']);
}

// Close the database connection
$conn->close();
?>
