<?php
require 'config.php';

// Get all bookings with their statuses
$sql = "SELECT id, status FROM bookings";
$result = $conn->query($sql);

echo "<h1>All Bookings in Database</h1>";
echo "<pre>";
while ($row = $result->fetch_assoc()) {
    echo "ID: {$row['id']}, Status: '{$row['status']}' (Length: " . strlen($row['status']) . ")\n";
}
echo "</pre>";

// Count pending bookings
$pendingSql = "SELECT COUNT(*) as count FROM bookings WHERE LOWER(TRIM(status)) = 'pending'";
$pendingResult = $conn->query($pendingSql);
$pendingRow = $pendingResult->fetch_assoc();
echo "<h2>Pending Bookings Count (with LOWER TRIM): " . $pendingRow['count'] . "</h2>";

// Count confirmed bookings
$confirmedSql = "SELECT COUNT(*) as count FROM bookings WHERE LOWER(TRIM(status)) = 'confirmed'";
$confirmedResult = $conn->query($confirmedSql);
$confirmedRow = $confirmedResult->fetch_assoc();
echo "<h2>Confirmed Bookings Count (with LOWER TRIM): " . $confirmedRow['count'] . "</h2>";

// Show raw count of all bookings
$allSql = "SELECT COUNT(*) as count FROM bookings";
$allResult = $conn->query($allSql);
$allRow = $allResult->fetch_assoc();
echo "<h2>Total Bookings: " . $allRow['count'] . "</h2>";
?>
