<?php
require_once '../includes/config.php';
require_once '../includes/auth.php';

header('Content-Type: application/json');

$response = [
    'totalBookings'      => (int)$pdo->query("SELECT COUNT(*) FROM bookings")->fetchColumn(),
    'completedBookings'  => (int)$pdo->query("SELECT COUNT(*) FROM bookings WHERE status='completed'")->fetchColumn(),
    'pendingBookings'    => (int)$pdo->query("SELECT COUNT(*) FROM bookings WHERE status='pending'")->fetchColumn(),
    'onlineDrivers'      => (int)$pdo->query("SELECT COUNT(*) FROM drivers WHERE is_online=1")->fetchColumn(),
    'totalRevenue'       => (float)($pdo->query("SELECT SUM(final_price) FROM bookings WHERE status='completed'")->fetchColumn() ?? 0)
];

echo json_encode($response);
exit;
