<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>Rekap Pelanggaran dan Penghargaan Murid</title>

    <style>
        body {
            font-family: DejaVu Sans, sans-serif;
            font-size: 12px;
            color: #000;
        }

        h2,
        h3,
        p {
            margin: 0;
            padding: 0;
        }

        .judul {
            text-align: center;
            margin-bottom: 18px;
        }

        .judul h2 {
            font-size: 18px;
        }

        .judul h3 {
            font-size: 15px;
            margin-top: 4px;
        }

        table {
            width: 100%;
            border-collapse: collapse;
        }

        .info td {
            padding: 4px;
            vertical-align: top;
        }

        .tabel {
            margin-top: 10px;
        }

        .tabel th,
        .tabel td {
            border: 1px solid #000;
            padding: 6px;
        }

        .tabel th {
            background: #e8e8e8;
            text-align: center;
        }

        .center {
            text-align: center;
        }

        .right {
            text-align: right;
        }

        .section {
            margin-top: 20px;
            margin-bottom: 5px;
            font-size: 14px;
            font-weight: bold;
        }

        .ttd {
            margin-top: 40px;
        }

        .ttd td {
            width: 50%;
            text-align: center;
        }

        .nama {
            margin-top: 70px;
            font-weight: bold;
            text-decoration: underline;
        }
    </style>

</head>

<body>

    <div class="judul">

        <h2>REKAP PELANGGARAN DAN PENGHARGAAN MURID</h2>

        <h3>SMP NEGERI 5 BANDUNG</h3>

    </div>


    <table class="info">

        <tr>

            <td width="18%"><b>Nama</b></td>
            <td width="2%">:</td>
            <td width="30%"><?= $murid['nama']; ?></td>

            <td width="18%"><b>Kelas</b></td>
            <td width="2%">:</td>
            <td><?= $murid['nama_kelas']; ?></td>

        </tr>

        <tr>

            <td><b>NIS</b></td>
            <td>:</td>
            <td><?= $murid['nis']; ?></td>

            <td><b>Wali Kelas</b></td>
            <td>:</td>
            <td><?= $walikelas['nama'] ?? '-'; ?></td>

        </tr>

        <tr>

            <td><b>Total Skor Pelanggaran</b></td>
            <td>:</td>
            <td><?= $totalSkor; ?></td>

            <td><b>Total Poin Prestasi</b></td>
            <td>:</td>
            <td><?= $totalPoin; ?></td>

        </tr>

        <tr>

            <td><b>Tanggal Cetak</b></td>
            <td>:</td>
            <td><?= $tanggal; ?></td>

            <td><b>Jam Cetak</b></td>
            <td>:</td>
            <td><?= $jam; ?></td>

        </tr>

    </table>


    <div class="section">
        RIWAYAT PELANGGARAN
    </div>

    <table class="tabel">

        <thead>

            <tr>

                <th width="5%">No</th>

                <th width="15%">Tanggal</th>

                <th>Pelanggaran</th>
                <th>Keterangan</th>

                <th width="20%">Guru Pencatat</th>

                <th width="12%">Skor</th>

            </tr>

        </thead>

        <tbody>

            <?php if (!empty($pelanggaran)): ?>

                <?php
                $no = 1;

                foreach ($pelanggaran as $p):
                ?>

                    <tr>

                        <td class="center"><?= $no++; ?></td>

                        <td class="center"><?= date('d-m-Y H:i:s', strtotime($p['tanggal'])); ?></td>

                        <td><?= $p['nama_pelanggaran']; ?></td>
                        <td><?= $p['keterangan_tambahan']; ?></td>
                        <td><?= $p['nama_guru']; ?></td>

                        <td class="center"><?= $p['skor']; ?></td>

                    </tr>

                <?php endforeach; ?>

            <?php else: ?>

                <tr>

                    <td colspan="5" class="center">

                        Belum ada data pelanggaran.

                    </td>

                </tr>

            <?php endif; ?>

        </tbody>

        <tfoot>

            <tr>

                <th colspan="5" class="right">

                    TOTAL SKOR PELANGGARAN

                </th>

                <th class="center">

                    <?= $totalSkor; ?>

                </th>

            </tr>

        </tfoot>

    </table>



    <div class="section">

        RIWAYAT PENGHARGAAN

    </div>

    <table class="tabel">

        <thead>

            <tr>

                <th width="5%">No</th>

                <th width="15%">Tanggal</th>

                <th>Penghargaan</th>
                <th>Keterangan</th>

                <th width="20%">Guru Pencatat</th>

                <th width="12%">Poin</th>

            </tr>

        </thead>

        <tbody>

            <?php if (!empty($penghargaan)): ?>

                <?php
                $no = 1;

                foreach ($penghargaan as $p):
                ?>

                    <tr>

                        <td class="center"><?= $no++; ?></td>

                        <td class="center"><?= date('d-m-Y H:i:s', strtotime($p['tanggal'])); ?></td>

                        <td><?= $p['nama_penghargaan']; ?></td>
                        <td><?= $p['keterangan_tambahan']; ?></td>

                        <td><?= $p['nama_guru']; ?></td>

                        <td class="center"><?= $p['poin']; ?></td>

                    </tr>

                <?php endforeach; ?>

            <?php else: ?>

                <tr>

                    <td colspan="5" class="center">

                        Belum ada data penghargaan.

                    </td>

                </tr>

            <?php endif; ?>

        </tbody>

        <tfoot>

            <tr>

                <th colspan="5" class="right">

                    TOTAL POIN PENGHARGAAN

                </th>

                <th class="center">

                    <?= $totalPoin; ?>

                </th>

            </tr>

        </tfoot>

    </table>


    <table class="ttd" width="100%">
        <tr>

            <td style="padding-top:40px;">
                Guru BK
                <div class="nama">
                    <?= $gurubk['nama'] ?? '(...................................)'; ?>
                </div>
            </td>

            <td style="padding-top:40px;">
                Bandung, <?= $tanggal; ?><br>
                Wali Kelas
                <div class="nama">
                    <?= $gurubk['nama'] ?? '(...................................)'; ?>
                </div>
            </td>

        </tr>
        <tr></tr>
        <tr></tr>
        <tr>

            <td>
                Mengetahui,<br>
                Plt. Kepala SMP Negeri 5 Bandung
                <div class="nama">
                    Trismawati, S.S., M.Pd.
                </div>
            </td>

            <td>

                Wakasek Kesiswaan
                <div class="nama">
                    <?= $kesiswaan['nama'] ?? '(...................................)'; ?>
                </div>
            </td>

        </tr>



    </table>

</body>

</html>