<?php
header('Content-Type: application/json');
require 'config/db.php';
$res = [];
$res['statuses'] = $pdo->query("SELECT last_status, count(*) as c FROM tbl_bookings GROUP BY last_status")->fetchAll(PDO::FETCH_ASSOC);
$res['total_shipments'] = $pdo->query("SELECT count(*) FROM tbl_bookings")->fetchColumn();
$res['branches'] = $pdo->query("SELECT count(*) FROM tbl_branch")->fetchColumn();
$res['companies'] = $pdo->query("SELECT count(*) FROM tbl_company")->fetchColumn();
$res['employees'] = $pdo->query("SELECT count(*) FROM tbl_employees")->fetchColumn();
$res['branch_statuses'] = $pdo->query("SELECT status, count(*) FROM tbl_branch GROUP BY status")->fetchAll(PDO::FETCH_ASSOC);
echo json_encode($res);
?>