49 lines
1.9 KiB
PHP
49 lines
1.9 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
require_once __DIR__ . '/includes/db_init.php';
|
|
|
|
$db = db();
|
|
$date = $_GET['date'] ?? date('Y-m-d');
|
|
$role = $_GET['role'] ?? 'admin';
|
|
|
|
$recap = $db->prepare("SELECT c.name as class_name,
|
|
SUM(CASE WHEN a.status = 'hadir' THEN 1 ELSE 0 END) as hadir,
|
|
SUM(CASE WHEN a.status = 'sakit' THEN 1 ELSE 0 END) as sakit,
|
|
SUM(CASE WHEN a.status = 'izin' THEN 1 ELSE 0 END) as izin,
|
|
SUM(CASE WHEN a.status = 'alpa' THEN 1 ELSE 0 END) as alpa
|
|
FROM classes c
|
|
LEFT JOIN attendance a ON c.id = a.class_id AND a.attendance_date = ?
|
|
GROUP BY c.id");
|
|
$recap->execute([$date]);
|
|
$data = $recap->fetchAll();
|
|
?>
|
|
<!doctype html>
|
|
<html lang="id">
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
<title>Rekap Absensi — <?= htmlspecialchars($date) ?></title>
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
</head>
|
|
<body class="p-4">
|
|
<nav class="mb-4"><a href="/?role=<?= htmlspecialchars($role) ?>">← Kembali ke Dashboard</a></nav>
|
|
<h1 class="h3 mb-4">Rekap Absensi: <?= htmlspecialchars($date) ?></h1>
|
|
<table class="table table-striped">
|
|
<thead>
|
|
<tr><th>Kelas</th><th>Hadir</th><th>Sakit</th><th>Izin</th><th>Alpa</th></tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php foreach ($data as $row): ?>
|
|
<tr>
|
|
<td><?= htmlspecialchars($row['class_name']) ?></td>
|
|
<td><?= (int)$row['hadir'] ?></td>
|
|
<td><?= (int)$row['sakit'] ?></td>
|
|
<td><?= (int)$row['izin'] ?></td>
|
|
<td><?= (int)$row['alpa'] ?></td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
</body>
|
|
</html>
|