<!DOCTYPE html>
<html lang="en">

<head>
    <title>Data Pelanggaran Santri</title>
    <style>
        table,
        th,
        td {
            border: 1px solid black;
            border-collapse: collapse;
        }

        th,
        td {
            padding: 6px;
        }
    </style>
</head>

<body>
    <table>
        <tr>
            <th>No</th>
            <th>NIS</th>
            <th>Nama Santri</th>
            <th>Kelas Diniyah</th>
            <th>Jumlah Pelanggaran</th>
            <th>Keterangan</th>
        </tr>
        <?php
        $kelas_diniyah = [
            1 => 'Al-Wadhih Banin',
            2 => 'Al-Wadhih Banat',
            3 => 'Al-Jurūmiyyah Banin',
            4 => 'Al-Jurūmiyyah Banat',
            5 => 'Al-Imriti Banin',
            6 => 'Al-Imriti Banat',
            7 => 'Alfiyah Ula Banin',
            8 => 'Alfiyah Ula Banat',
            9 => 'Alfiyah Tsani Banin',
            10 => 'Alfiyah Tsani Banat',
            11 => 'Alfiyah Tsalits Banin',
            12 => 'Alfiyah Tsalits Banat'
        ];

        $no = 1;
        foreach ($rekap as $r) : ?>
            <tr>
                <td><?= $no++ ?></td>
                <td><?= $r['NIS'] ?></td>
                <td><?= $r['nama_santri'] ?></td>
                <td><?= $kelas_diniyah[$r['kelas_diniyah']] ?? 'Tidak Diketahui' ?></td>
                <td><?= $r['jumlah_pelanggaran'] ?> pelanggaran</td>
                <td>
                    <?php if (!empty($r['sanksi_ada'])): ?>
                        Sudah Disanksi: <?= implode(', ', $r['sanksi_ada']) ?><br>
                    <?php endif; ?>

                    <?php if (!empty($r['sanksi_kosong'])): ?>
                        Belum Disanksi: <?= implode(', ', $r['sanksi_kosong']) ?>
                    <?php endif; ?>
                </td>

            </tr>
        <?php endforeach; ?>
    </table>
</body>

</html>