Initial commit: Retribusi frontend dengan dashboard, event logs, dan settings
This commit is contained in:
43
api/dashboard/chart.php
Normal file
43
api/dashboard/chart.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
header("Access-Control-Allow-Origin: *");
|
||||
header("Access-Control-Allow-Methods: GET, POST, OPTIONS");
|
||||
header("Access-Control-Allow-Headers: Content-Type, Authorization, X-API-KEY");
|
||||
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
|
||||
http_response_code(200);
|
||||
exit;
|
||||
}
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
// TODO: Implementasi logic chart di sini
|
||||
// Validasi Authorization token
|
||||
/*
|
||||
$headers = getallheaders();
|
||||
if (!isset($headers['Authorization'])) {
|
||||
http_response_code(401);
|
||||
echo json_encode(['error' => 'unauthorized']);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Validasi X-API-KEY
|
||||
if (!isset($_SERVER['HTTP_X_API_KEY']) || $_SERVER['HTTP_X_API_KEY'] !== 'RETRIBUSI-DASHBOARD-KEY') {
|
||||
http_response_code(401);
|
||||
echo json_encode(['error' => 'unauthorized']);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Logic chart
|
||||
$date = $_GET['date'] ?? date('Y-m-d');
|
||||
$location_code = $_GET['location_code'] ?? null;
|
||||
|
||||
// ... kode chart yang sudah ada ...
|
||||
|
||||
echo json_encode([
|
||||
'labels' => ['00','01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23'],
|
||||
'motor' => array_fill(0, 24, 0),
|
||||
'car' => array_fill(0, 24, 0),
|
||||
'person' => array_fill(0, 24, 0)
|
||||
]);
|
||||
*/
|
||||
Reference in New Issue
Block a user