<?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 = 'Customers';
$rows = crm_pdo()->query("SELECT id, name, contact_person, phone, city FROM customers WHERE active = 1 ORDER BY id DESC")->fetchAll();
include __DIR__ . '/../includes/header.php';
?>
<div class="page-header"><div class="page-header-title"><h1>Customers</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>Name</th><th>Contact</th><th>Phone</th><th>City</th><th></th></tr></thead><tbody>
<?php foreach ($rows as $row): ?><tr>
<td><?php echo (int)$row['id']; ?></td><td><?php echo h($row['name']); ?></td><td><?php echo h($row['contact_person']); ?></td><td><?php echo h($row['phone']); ?></td><td><?php echo h($row['city']); ?></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'; ?>
