<?php
include 'load.php';


$bookedDates = [];
$result = mysqli_query($conn, "SELECT mobileroombooking.checkindate, mobileroombooking.checkoutdate,mobileproducts.proname,mobilecustomers.cname FROM mobileroombooking,mobileproducts,mobilecustomers WHERE mobileroombooking.room=mobileproducts.prid AND mobilecustomers.coid=mobileroombooking.customer");

if ($result && mysqli_num_rows($result) > 0) {
    while ($row = mysqli_fetch_assoc($result)) {
        $startDate = $row['checkindate'];
        $endDate = $row['checkoutdate'];
        $cname = $row['cname'];
        $proname = $row['proname'];
       
        $bookedDates[] = [
            'title' => $proname." | ".$cname,
            'start' => $startDate,
            'end' => date('Y-m-d', strtotime($endDate . ' +1 day')), 
            'backgroundColor' => '#ff0000', 
            'borderColor' => '#ff0000'
        ];
    }
}


header('Content-Type: application/json');
echo json_encode($bookedDates);
?>