<?php
require_once 'db.php';

// Count beds
$totalBeds = $conn->query("SELECT COUNT(*) AS cnt FROM beds")->fetch_assoc()['cnt'] ?? 0;
$occupiedBeds = $conn->query("SELECT COUNT(*) AS cnt FROM beds WHERE is_occupied = 1")->fetch_assoc()['cnt'] ?? 0;
$availableBeds = $totalBeds - $occupiedBeds;

echo json_encode([
    'occupied' => $occupiedBeds,
    'available' => $availableBeds
]);
