<?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 = 'Employees';
$rows = crm_pdo()->query("SELECT id, full_name, phone, role_title, active FROM employees ORDER BY id DESC")->fetchAll();
include __DIR__ . '/../includes/header.php';
?>
<div class="page-header"><div class="page-header-title"><h1>Employees</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>Full name</th><th>Phone</th><th>Role</th><th>Active</th><th></th></tr></thead><tbody>
<?php foreach ($rows as $row): ?><tr>
<td><?php echo (int)$row['id']; ?></td><td><?php echo h($row['full_name']); ?></td><td><?php echo h($row['phone']); ?></td><td><?php echo h($row['role_title']); ?></td><td><?php echo h($row['active']); ?></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'; ?>
