<?php require_once __DIR__.'/../includes/auth.php'; require_login(['manager','admin']); require __DIR__.'/../includes/header.php';
$users=db()->query('SELECT u.*, COUNT(DISTINCT cp.id) completed_courses FROM users u LEFT JOIN course_progress cp ON cp.user_id=u.id AND cp.status="passed" WHERE u.role="staff" GROUP BY u.id ORDER BY u.created_at DESC')->fetchAll(); ?>
<div class="card"><h1>Manager Dashboard</h1><a class="btn" href="../admin/users.php">Onboard staff</a> <a class="btn dark" href="signoffs.php">Practical sign-offs</a></div><div class="card"><h2>Staff Progress</h2><table><tr><th>Employee</th><th>Position</th><th>Brand</th><th>Courses Passed</th></tr><?php foreach($users as $u): ?><tr><td><?= htmlspecialchars($u['first_name'].' '.$u['last_name']) ?></td><td><?= htmlspecialchars($u['position']) ?></td><td><?= htmlspecialchars($u['brand']) ?></td><td><?= $u['completed_courses'] ?></td></tr><?php endforeach; ?></table></div><?php require __DIR__.'/../includes/footer.php'; ?>
