57 lines
2.2 KiB
PHP
57 lines
2.2 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
require_once __DIR__ . '/includes/layout.php'; require_role('admin');
|
|
|
|
render_header('Truck Expiry Report', 'admin', true);
|
|
?>
|
|
|
|
<div class="row g-0">
|
|
<div class="col-md-2 bg-white border-end min-vh-100">
|
|
<?php render_admin_sidebar('truck_owners'); ?>
|
|
</div>
|
|
<div class="col-md-10 p-4">
|
|
<h1 class="section-title mb-4">Truck Expiry Report</h1>
|
|
|
|
<div class="panel p-4">
|
|
<table class="table table-bordered">
|
|
<thead>
|
|
<tr>
|
|
<th>Owner</th>
|
|
<th>Plate No</th>
|
|
<th>Registration Expiry</th>
|
|
<th>Insurance Expiry</th>
|
|
<th>Status</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php
|
|
$trucks = db()->query("
|
|
SELECT t.*, u.full_name as owner_name
|
|
FROM trucks t
|
|
JOIN users u ON t.user_id = u.id
|
|
WHERE t.registration_expiry_date < DATE_ADD(NOW(), INTERVAL 30 DAY)
|
|
OR t.insurance_expiry_date < DATE_ADD(NOW(), INTERVAL 30 DAY)
|
|
")->fetchAll();
|
|
|
|
foreach ($trucks as $truck):
|
|
$regExpired = strtotime($truck['registration_expiry_date']) < time();
|
|
$insExpired = strtotime($truck['insurance_expiry_date']) < time();
|
|
$isExpired = $regExpired || $insExpired;
|
|
?>
|
|
<tr class="<?= $isExpired ? 'table-danger' : 'table-warning' ?>">
|
|
<td><?= e($truck['owner_name']) ?></td>
|
|
<td><?= e($truck['plate_no']) ?></td>
|
|
<td><?= e($truck['registration_expiry_date']) ?></td>
|
|
<td><?= e($truck['insurance_expiry_date']) ?></td>
|
|
<td><?= $isExpired ? 'Expired' : 'Near Expiry' ?></td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<?php render_footer(); ?>
|