<?php
include_once 'shikanisha.kts.php';

$sql = "SELECT
    b.booking_id,
    r.room_name,
    b.user_name AS receptionist,
    b.guest AS client,
    r.price AS cost,
    b.status,
    b.check_in_date,
    b.check_out_date
FROM
    rooms r
INNER JOIN
    bookings b ON r.room_id = b.room_id
WHERE
    b.status = 'checked_in'";

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

$data = array();

if ($result->num_rows > 0) {
    while ($row = $result->fetch_assoc()) {
        $data[] = $row;
    }
}

echo json_encode(['data' => $data]);
?>
