Initial commit

This commit is contained in:
Porawit Dongwang
2026-09-16 23:20:08 +07:00
commit 0041668dbb
32577 changed files with 3687927 additions and 0 deletions
@@ -0,0 +1,35 @@
<?php
require_once '../includes/auth.php';
require_once '../includes/db.php';
header('Content-Type: application/json; charset=utf-8');
$vehicle_id = isset($_GET['vehicle_id']) ? intval($_GET['vehicle_id']) : 0;
if ($vehicle_id === 0) {
echo json_encode(['success' => false, 'message' => 'Invalid vehicle ID']);
exit;
}
try {
$stmt = $pdo->prepare("
SELECT vi.*, d.first_name, d.last_name
FROM vehicle_inspections vi
LEFT JOIN drivers d ON vi.inspector_cid COLLATE utf8mb4_unicode_ci = d.hr_cid COLLATE utf8mb4_unicode_ci
WHERE vi.vehicle_id = ?
ORDER BY vi.inspection_date DESC, vi.inspection_time DESC
LIMIT 50
");
$stmt->execute([$vehicle_id]);
$history = $stmt->fetchAll(PDO::FETCH_ASSOC);
// Decode JSON items for each record
foreach ($history as &$record) {
$record['items'] = json_decode($record['items_json'], true);
unset($record['items_json']);
}
echo json_encode(['success' => true, 'data' => $history]);
} catch (PDOException $e) {
echo json_encode(['success' => false, 'message' => 'Database error: ' . $e->getMessage()]);
}