prepare("SELECT * FROM employees WHERE id = ?"); $employee->execute([$id]); $employee = $employee->fetch(); if (!$employee) { die("Employee not found."); } $pageTitle = "Employee Detail: " . htmlspecialchars($employee['name']); include __DIR__ . '/includes/header.php'; // Fetch recent labour entries $stmt = $db->prepare(" SELECT l.*, p.name as project_name, lt.name as labour_type FROM labour_entries l JOIN projects p ON l.project_id = p.id JOIN labour_types lt ON l.labour_type_id = lt.id WHERE l.employee_id = ? ORDER BY l.entry_date DESC LIMIT 20 "); $stmt->execute([$id]); $entries = $stmt->fetchAll(); // Fetch summary stats $stats = $db->prepare("SELECT SUM(hours) as total_hours, COUNT(*) as entry_count FROM labour_entries WHERE employee_id = ?"); $stats->execute([$id]); $stats = $stats->fetch(); ?>
= htmlspecialchars($employee['position'] ?? 'Staff') ?>
| Date | Project | Type | Hours | Notes |
|---|---|---|---|---|
| No entries found for this employee. | ||||
| = date('Y-m-d', strtotime($e['entry_date'])) ?> | = htmlspecialchars($e['project_name']) ?> | = htmlspecialchars($e['labour_type']) ?> | = number_format($e['hours'], 1) ?> | = htmlspecialchars(substr($e['notes'], 0, 50)) ?>= strlen($e['notes']) > 50 ? '...' : '' ?> |