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

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Print 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>Pelanggaran</th>
            <th>Tanggal</th>
            <th>Sanksi</th>
            <th>Keterangan</th>
        </tr>
        <?php $no = 1;
        foreach ($pelanggaransantri as $pgnstr) :
            $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'
            ]; ?>
            <tr>
                <td><?= $no++ ?></td>
                <td><?= $pgnstr->NIS ?></td>
                <td><?= $pgnstr->nama_santri ?></td>
                <td><?= $kelas_diniyah[$pgnstr->kelas_diniyah] ?? 'Kelas Diniyah Tidak Valid' ?></td>
                <td><?= $pgnstr->pelanggaran ?></td>
                <td><?= date('d/m/Y', strtotime($pgnstr->tanggal)) ?></td>
                <td><?= $pgnstr->sanksi ?></td>
                <td><?= $pgnstr->keterangan ?></td>
            </tr>
        <?php endforeach ?>
    </table>

    <script type="text/javascript">
        window.print();
    </script>
</body>

</html>