<?php
require_once __DIR__ . '/../../app/core/bootstrap.php';
require_once __DIR__ . '/../../app/core/project_permissions.php';
require_once __DIR__ . '/../../app/core/access_guards.php';
auth_require_login();
$pdo = crm_pdo();
gp_require_staff_access($pdo);
$page_title = 'Vehicles';
$rows = crm_pdo()->query("SELECT id, license_plate, brand, model, vehicle_type FROM vehicles ORDER BY id DESC")->fetchAll();
include __DIR__ . '/../includes/header.php';
?>
<div class="page-header"><div class="page-header-title"><h1>Vehicles</h1><span>Base module list</span></div><div class="page-header-actions"><a class="btn btn-primary btn-sm" href="edit.php">+ New</a></div></div>
<div class="card"><div class="table-responsive"><table class="table"><thead><tr><th>ID</th><th>Plate</th><th>Brand</th><th>Model</th><th>Type</th><th></th></tr></thead><tbody>
<?php foreach ($rows as $row): ?><tr>
<td><?php echo (int)$row['id']; ?></td><td><?php echo h($row['license_plate']); ?></td><td><?php echo h($row['brand']); ?></td><td><?php echo h($row['model']); ?></td><td><?php echo h($row['vehicle_type']); ?></td>
<td><a class="btn btn-sm btn-outline-light" href="edit.php?id=<?php echo (int)$row['id']; ?>">Open</a></td>
</tr><?php endforeach; ?>
</tbody></table></div></div>
<?php include __DIR__ . '/../includes/footer.php'; ?>
