35 lines
1.1 KiB
PHP
35 lines
1.1 KiB
PHP
<?php
|
|
// api/analytics.php
|
|
require_once dirname(__DIR__) . '/config/config.php';
|
|
require_once dirname(__DIR__) . '/config/database.php';
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
// Need to be logged in
|
|
if (!isset($_SESSION['user_id'])) {
|
|
echo json_encode(['status' => 'error', 'message' => 'Unauthorized']);
|
|
exit;
|
|
}
|
|
|
|
$action = $_REQUEST['action'] ?? '';
|
|
|
|
// In a real application, these queries would join the `jobs` and `job_timelines` tables
|
|
// to calculate precise response times and SLAs.
|
|
if ($action === 'get_dashboard_stats') {
|
|
// Mock response for dashboard
|
|
$data = [
|
|
'avg_response_time' => 2.5,
|
|
'sla_compliance' => 94.2,
|
|
'total_jobs_today' => 128,
|
|
'trend' => [150, 140, 160, 180, 190, 120, 110],
|
|
'sla_breakdown' => [
|
|
'labels' => ['ER', 'OPD1', 'OPD2', 'IPD1', 'IPD2', 'X-Ray', 'OR'],
|
|
'passed' => [50, 45, 30, 40, 35, 60, 20],
|
|
'failed' => [5, 2, 1, 4, 2, 3, 0]
|
|
]
|
|
];
|
|
echo json_encode(['status' => 'success', 'data' => $data]);
|
|
} else {
|
|
echo json_encode(['status' => 'error', 'message' => 'Unknown action']);
|
|
}
|