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)
|
||||
]);
|
||||
*/
|
||||
20
api/dashboard/chart.php.example
Normal file
20
api/dashboard/chart.php.example
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
/**
|
||||
* EXAMPLE: Dashboard Chart Endpoint dengan CORS Handler
|
||||
*/
|
||||
|
||||
// ================= CORS HANDLER (WAJIB PALING ATAS) =================
|
||||
header("Access-Control-Allow-Origin: *");
|
||||
header("Access-Control-Allow-Methods: GET, POST, OPTIONS");
|
||||
header("Access-Control-Allow-Headers: Content-Type, Authorization, X-API-KEY");
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
|
||||
http_response_code(200);
|
||||
exit;
|
||||
}
|
||||
// ================= END CORS HANDLER =================
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
// ... logic chart yang sudah ada ...
|
||||
|
||||
45
api/dashboard/chart_monthly.php
Normal file
45
api/dashboard/chart_monthly.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?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 monthly 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 monthly
|
||||
$month = $_GET['month'] ?? date('Y-m');
|
||||
$location_code = $_GET['location_code'] ?? null;
|
||||
|
||||
// ... kode chart monthly yang sudah ada ...
|
||||
|
||||
$daysInMonth = date('t', strtotime($month . '-01'));
|
||||
echo json_encode([
|
||||
'labels' => range(1, $daysInMonth),
|
||||
'motor' => array_fill(0, $daysInMonth, 0),
|
||||
'car' => array_fill(0, $daysInMonth, 0),
|
||||
'person' => array_fill(0, $daysInMonth, 0),
|
||||
'amount' => array_fill(0, $daysInMonth, 0)
|
||||
]);
|
||||
*/
|
||||
20
api/dashboard/chart_monthly.php.example
Normal file
20
api/dashboard/chart_monthly.php.example
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
/**
|
||||
* EXAMPLE: Dashboard Chart Monthly Endpoint dengan CORS Handler
|
||||
*/
|
||||
|
||||
// ================= CORS HANDLER (WAJIB PALING ATAS) =================
|
||||
header("Access-Control-Allow-Origin: *");
|
||||
header("Access-Control-Allow-Methods: GET, POST, OPTIONS");
|
||||
header("Access-Control-Allow-Headers: Content-Type, Authorization, X-API-KEY");
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
|
||||
http_response_code(200);
|
||||
exit;
|
||||
}
|
||||
// ================= END CORS HANDLER =================
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
// ... logic chart monthly yang sudah ada ...
|
||||
|
||||
49
api/dashboard/events.php
Normal file
49
api/dashboard/events.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?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 events 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;
|
||||
}
|
||||
|
||||
// Validasi role admin
|
||||
// ... kode validasi role admin ...
|
||||
|
||||
// Logic events
|
||||
$date = $_GET['date'] ?? null;
|
||||
$location_code = $_GET['location_code'] ?? null;
|
||||
$gate_code = $_GET['gate_code'] ?? null;
|
||||
$category = $_GET['category'] ?? null;
|
||||
$page = intval($_GET['page'] ?? 1);
|
||||
$limit = intval($_GET['limit'] ?? 20);
|
||||
|
||||
// ... kode events yang sudah ada ...
|
||||
|
||||
echo json_encode([
|
||||
'events' => [],
|
||||
'total_pages' => 1,
|
||||
'current_page' => $page
|
||||
]);
|
||||
*/
|
||||
20
api/dashboard/events.php.example
Normal file
20
api/dashboard/events.php.example
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
/**
|
||||
* EXAMPLE: Dashboard Events Endpoint dengan CORS Handler
|
||||
*/
|
||||
|
||||
// ================= CORS HANDLER (WAJIB PALING ATAS) =================
|
||||
header("Access-Control-Allow-Origin: *");
|
||||
header("Access-Control-Allow-Methods: GET, POST, OPTIONS");
|
||||
header("Access-Control-Allow-Headers: Content-Type, Authorization, X-API-KEY");
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
|
||||
http_response_code(200);
|
||||
exit;
|
||||
}
|
||||
// ================= END CORS HANDLER =================
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
// ... logic events yang sudah ada ...
|
||||
|
||||
44
api/dashboard/summary.php
Normal file
44
api/dashboard/summary.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?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 summary 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 summary
|
||||
$date = $_GET['date'] ?? date('Y-m-d');
|
||||
$location_code = $_GET['location_code'] ?? null;
|
||||
|
||||
// ... kode summary yang sudah ada ...
|
||||
|
||||
echo json_encode([
|
||||
'date' => $date,
|
||||
'location_code' => $location_code,
|
||||
'total_vehicle' => 0,
|
||||
'total_person' => 0,
|
||||
'total_amount' => 0
|
||||
]);
|
||||
*/
|
||||
42
api/dashboard/summary.php.example
Normal file
42
api/dashboard/summary.php.example
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/**
|
||||
* EXAMPLE: Dashboard Summary Endpoint dengan CORS Handler
|
||||
*
|
||||
* INSTRUKSI:
|
||||
* 1. Copy kode CORS handler ke paling atas
|
||||
* 2. Pastikan CORS handler dieksekusi SEBELUM logic auth
|
||||
*/
|
||||
|
||||
// ================= CORS HANDLER (WAJIB PALING ATAS) =================
|
||||
header("Access-Control-Allow-Origin: *");
|
||||
header("Access-Control-Allow-Methods: GET, POST, OPTIONS");
|
||||
header("Access-Control-Allow-Headers: Content-Type, Authorization, X-API-KEY");
|
||||
|
||||
// Handle preflight OPTIONS request
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
|
||||
http_response_code(200);
|
||||
exit;
|
||||
}
|
||||
// ================= END CORS HANDLER =================
|
||||
|
||||
// Set header untuk JSON response
|
||||
header('Content-Type: application/json');
|
||||
|
||||
// Logic auth/validation di sini
|
||||
// ... kode auth yang sudah ada ...
|
||||
|
||||
// Logic summary di sini
|
||||
// ... kode summary yang sudah ada ...
|
||||
|
||||
// Example response (sesuaikan dengan logic yang sudah ada)
|
||||
/*
|
||||
$response = [
|
||||
'date' => '2024-01-01',
|
||||
'location_code' => null,
|
||||
'total_vehicle' => 100,
|
||||
'total_person' => 250,
|
||||
'total_amount' => 5000000
|
||||
];
|
||||
echo json_encode($response);
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user