111 lines
5.4 KiB
PHP
111 lines
5.4 KiB
PHP
<?php
|
|
// Ambil semua kelas untuk dropdown filter
|
|
$kelas_list = get_all_kelas();
|
|
|
|
// Inisialisasi variabel
|
|
$selected_kelas_id = $_GET['kelas_id'] ?? null;
|
|
$start_date = $_GET['start_date'] ?? date('Y-m-01');
|
|
$end_date = $_GET['end_date'] ?? date('Y-m-t');
|
|
$rekap_absensi = [];
|
|
|
|
// Jika kelas dipilih, ambil data rekap
|
|
if ($selected_kelas_id) {
|
|
$rekap_absensi = get_rekap_absensi($selected_kelas_id, $start_date, $end_date);
|
|
}
|
|
|
|
?>
|
|
|
|
<div class="container-fluid">
|
|
<h1 class="h3 mb-4 text-gray-800">Laporan Absensi Murid</h1>
|
|
|
|
<!-- Filter Form -->
|
|
<div class="card shadow mb-4">
|
|
<div class="card-header py-3">
|
|
<h6 class="m-0 font-weight-bold text-primary">Filter Laporan</h6>
|
|
</div>
|
|
<div class="card-body">
|
|
<form method="GET">
|
|
<input type="hidden" name="page" value="reports">
|
|
<div class="form-row">
|
|
<div class="form-group col-md-4">
|
|
<label for="kelas_id">Kelas</label>
|
|
<select name="kelas_id" id="kelas_id" class="form-control" required>
|
|
<option value="">-- Pilih Kelas --</option>
|
|
<?php foreach ($kelas_list as $kelas) : ?>
|
|
<option value="<?php echo $kelas['id']; ?>" <?php echo ($selected_kelas_id == $kelas['id']) ? 'selected' : ''; ?>>
|
|
<?php echo htmlspecialchars($kelas['nama_kelas']); ?>
|
|
</option>
|
|
<?php endforeach; ?>
|
|
</select>
|
|
</div>
|
|
<div class="form-group col-md-3">
|
|
<label for="start_date">Dari Tanggal</label>
|
|
<input type="date" name="start_date" id="start_date" class="form-control" value="<?php echo $start_date; ?>">
|
|
</div>
|
|
<div class="form-group col-md-3">
|
|
<label for="end_date">Sampai Tanggal</label>
|
|
<input type="date" name="end_date" id="end_date" class="form-control" value="<?php echo $end_date; ?>">
|
|
</div>
|
|
<div class="form-group col-md-2 d-flex align-items-end">
|
|
<button type="submit" class="btn btn-primary btn-block">Tampilkan</button>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Attendance Report Table -->
|
|
<?php if ($selected_kelas_id) : ?>
|
|
<div class="card shadow mb-4">
|
|
<div class="card-header py-3 d-flex justify-content-between align-items-center">
|
|
<h6 class="m-0 font-weight-bold text-primary">Rekapitulasi Absensi</h6>
|
|
<form action="export_laporan.php" method="POST" target="_blank">
|
|
<input type="hidden" name="kelas_id" value="<?php echo $selected_kelas_id; ?>">
|
|
<input type="hidden" name="start_date" value="<?php echo $start_date; ?>">
|
|
<input type="hidden" name="end_date" value="<?php echo $end_date; ?>">
|
|
<button type="submit" class="btn btn-success btn-sm">
|
|
<i class="fas fa-file-excel"></i> Ekspor ke Excel
|
|
</button>
|
|
</form>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="table-responsive">
|
|
<table class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
|
|
<thead>
|
|
<tr>
|
|
<th>No</th>
|
|
<th>NIS</th>
|
|
<th>Nama Lengkap</th>
|
|
<th>Hadir</th>
|
|
<th>Sakit</th>
|
|
<th>Izin</th>
|
|
<th>Alpa</th>
|
|
<th>Total Jam</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php if (empty($rekap_absensi)) : ?>
|
|
<tr>
|
|
<td colspan="8" class="text-center">Tidak ada data absensi untuk periode dan kelas yang dipilih.</td>
|
|
</tr>
|
|
<?php else : ?>
|
|
<?php foreach ($rekap_absensi as $index => $rekap) : ?>
|
|
<tr>
|
|
<td><?php echo $index + 1; ?></td>
|
|
<td><?php echo htmlspecialchars($rekap['nis']); ?></td>
|
|
<td><?php echo htmlspecialchars($rekap['nama_lengkap']); ?></td>
|
|
<td><?php echo (int)$rekap['total_hadir']; ?></td>
|
|
<td><?php echo (int)$rekap['total_sakit']; ?></td>
|
|
<td><?php echo (int)$rekap['total_izin']; ?></td>
|
|
<td><?php echo (int)$rekap['total_alpa']; ?></td>
|
|
<td><?php echo (int)$rekap['total_absensi']; ?></td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
<?php endif; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|