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

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Laporan Pesanan Buku — <?php echo e($user->nama_sekolah ?? $user->name); ?></title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: Arial, sans-serif;
            font-size: 10px;
            color: #000;
            background: #fff;
            padding: 15mm 15mm 10mm 15mm;
        }

        /* Letterhead */
        .letterhead {
            text-align: center;
            border-bottom: 3px double #000;
            padding-bottom: 10px;
            margin-bottom: 12px;
        }

        .letterhead img {
            height: 70px;
            margin-bottom: 5px;
        }

        .letterhead h1 {
            font-size: 16px;
            text-transform: uppercase;
            letter-spacing: 1px;
            margin-bottom: 2px;
        }

        .letterhead h2 {
            font-size: 13px;
            text-transform: uppercase;
            margin-bottom: 1px;
        }

        .letterhead h3 {
            font-size: 12px;
            text-transform: uppercase;
            font-weight: normal;
        }

        .letterhead h4 {
            font-size: 12px;
            font-weight: bold;
            margin-top: 8px;
            text-decoration: underline;
            text-transform: uppercase;
        }

        /* School info */
        .sekolah-info {
            border: 1px solid #555;
            border-radius: 4px;
            padding: 7px 12px;
            margin-bottom: 14px;
            background: #f9f9f9;
        }

        .sekolah-info table {
            width: 100%;
            border-collapse: collapse;
        }

        .sekolah-info td {
            padding: 2px 6px;
            font-size: 10px;
        }

        .sekolah-info td:nth-child(odd) {
            font-weight: bold;
            width: 22%;
            white-space: nowrap;
        }

        /* Darjah section */
        .darjah-section {
            margin-bottom: 16px;
            page-break-inside: avoid;
        }

        .darjah-title {
            background: #2c3e50;
            color: #fff;
            font-size: 11px;
            font-weight: bold;
            padding: 5px 10px;
            border-radius: 3px 3px 0 0;
        }

        /* Table */
        table.data-table {
            width: 100%;
            border-collapse: collapse;
            font-size: 9px;
        }

        table.data-table th {
            background: #3d5a80;
            color: #fff;
            text-align: center;
            padding: 4px 3px;
            border: 1px solid #2c3e50;
            font-size: 8.5px;
            line-height: 1.3;
        }

        table.data-table td {
            padding: 3px 4px;
            border: 1px solid #aaa;
            vertical-align: middle;
        }

        table.data-table tbody tr:nth-child(even) {
            background: #f4f8ff;
        }

        table.data-table td.num {
            text-align: center;
            font-weight: bold;
        }

        table.data-table td.highlight {
            background: #e8f5e9;
            font-weight: bold;
            text-align: center;
            color: #1a7a2e;
        }

        table.data-table tfoot td {
            background: #dce6f1;
            font-weight: bold;
            text-align: center;
            border: 1px solid #2c3e50;
            font-size: 9px;
        }

        .tiada {
            text-align: center;
            padding: 8px;
            color: #888;
            font-style: italic;
            border: 1px solid #ddd;
            background: #fafafa;
        }

        /* Footer */
        .footer {
            margin-top: 20px;
            border-top: 1px solid #aaa;
            padding-top: 10px;
            display: flex;
            justify-content: space-between;
        }

        .footer .sign-box {
            width: 45%;
        }

        .footer .sign-box p {
            font-size: 9.5px;
            margin-bottom: 35px;
        }

        .footer .sign-line {
            border-top: 1px solid #000;
            font-size: 9px;
            padding-top: 3px;
        }

        .print-btn {
            position: fixed;
            top: 15px;
            right: 20px;
            background: #2c3e50;
            color: #fff;
            border: none;
            padding: 8px 18px;
            font-size: 12px;
            border-radius: 4px;
            cursor: pointer;
            z-index: 999;
        }

        .print-btn:hover {
            background: #1a252f;
        }

        @media print {
            .print-btn {
                display: none;
            }

            body {
                padding: 10mm;
            }
        }
    </style>
</head>

<body>
    <button class="print-btn" onclick="window.print()">&#128424; Cetak</button>

    
    <div class="letterhead">
        <img src="<?php echo e(asset('image/JAIS-Logo (3).png')); ?>" alt="Logo JAIS">
        <h1>Skim Pinjaman Buku Teks</h1>
        <h2>Bahagian Pendidikan Islam</h2>
        <h3>Jabatan Agama Islam Selangor</h3>
        <h4><?php echo e($from === 'senarai-sekolah-lebihan' ? 'Laporan Lebihan Buku Darjah' : 'Laporan Pesanan Buku Darjah'); ?> —
            <?php echo e($tahun + 1); ?></h4>
    </div>

    
    <div class="sekolah-info">
        <table>
            <tr>
                <td>Nama Sekolah</td>
                <td>: <?php echo e($user->nama_sekolah ?? '-'); ?></td>
                <td>Kod Sekolah</td>
                <td>: <?php echo e($user->kod_sekolah ?? '-'); ?></td>
            </tr>
            <tr>
                <td>Nama Guru BOSS</td>
                <td>: <?php echo e($user->name); ?></td>
                <td>Daerah</td>
                <td>: <?php echo e($user->daerah ?? '-'); ?></td>
            </tr>
            <tr>
                <td>Nama Penyelia BOSS</td>
                <td>: <?php echo e($supervisor->name); ?></td>
                <td>Tarikh Cetak</td>
                <td>: <?php echo e(now()->format('d/m/Y H:i')); ?></td>
            </tr>
        </table>
    </div>

    
    <?php $__currentLoopData = $data; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
        <?php if($item['maklumat']->isNotEmpty()): ?>
            <div class="darjah-section">
                <div class="darjah-title">
                    &#9658; <?php echo e($item['darjah']); ?>

                </div>
                <table class="data-table">
                    <thead>
                        <tr>
                            <th rowspan="2" style="width:5%">Bil</th>
                            <th rowspan="2" style="width:8%">Kod Buku</th>
                            <th rowspan="2" style="width:28%">Judul</th>
                            <th>Buku di Tangan<br><?php echo e($tahun); ?></th>
                            <th>Unjuran<br><?php echo e($tahun + 1); ?></th>
                            <th>Baki BOSS<br><?php echo e($tahun); ?></th>
                            <th>Elok BOSS<br><?php echo e($tahun); ?></th>
                            <th>Angg. Elok<br><?php echo e($tahun); ?></th>
                            <th style="background:#1a5c30">Stok Hingga Akhir<br><?php echo e($tahun); ?></th>
                            <th style="background:#1a5c30">Elok Hingga Akhir<br><?php echo e($tahun); ?></th>
                            <?php if($from === 'senarai-sekolah-lebihan'): ?>
                                <th style="background:#1a4d8b">Lebihan Buku<br><?php echo e($tahun + 1); ?></th>
                            <?php else: ?>
                                <th style="background:#8b1a1a">Pesanan Buku<br><?php echo e($tahun + 1); ?></th>
                            <?php endif; ?>
                        </tr>
                    </thead>
                    <tbody>
                        <?php $__currentLoopData = $item['maklumat']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $i => $m): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <tr>
                                <td class="num"><?php echo e($i + 1); ?></td>
                                <td class="num"><?php echo e($m->kod_buku); ?></td>
                                <td><?php echo e($m->judul); ?></td>
                                <td class="num"><?php echo e(number_format($m->buku_di_tangan_murid)); ?></td>
                                <td class="num"><?php echo e(number_format($m->unjuran_enrolmen)); ?></td>
                                <td class="num"><?php echo e(number_format($m->baki_buku_boss)); ?></td>
                                <td class="num"><?php echo e(number_format($m->buku_elok_boss)); ?></td>
                                <td class="num"><?php echo e(number_format($m->anggaran_buku_elok_tangan)); ?></td>
                                <td class="highlight"><?php echo e(number_format($m->stok_hingga_akhir)); ?></td>
                                <td class="highlight"><?php echo e(number_format($m->elok_hingga_akhir)); ?></td>
                                <?php if($from === 'senarai-sekolah-lebihan'): ?>
                                    <td class="num" style="background:#e8f0fe;color:#1a4d8b">
                                        <?php echo e(number_format($m->lebihan_buku)); ?></td>
                                <?php else: ?>
                                    <td class="num" style="background:#fdecea;color:#b71c1c">
                                        <?php echo e(number_format($m->pesanan_buku)); ?></td>
                                <?php endif; ?>
                            </tr>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </tbody>
                    <tfoot>
                        <tr>
                            <td colspan="3" style="text-align:left;padding-left:8px;">JUMLAH</td>
                            <td><?php echo e(number_format($item['maklumat']->sum('buku_di_tangan_murid'))); ?></td>
                            <td><?php echo e(number_format($item['maklumat']->sum('unjuran_enrolmen'))); ?></td>
                            <td><?php echo e(number_format($item['maklumat']->sum('baki_buku_boss'))); ?></td>
                            <td><?php echo e(number_format($item['maklumat']->sum('buku_elok_boss'))); ?></td>
                            <td><?php echo e(number_format($item['maklumat']->sum('anggaran_buku_elok_tangan'))); ?></td>
                            <td><?php echo e(number_format($item['maklumat']->sum('stok_hingga_akhir'))); ?></td>
                            <td><?php echo e(number_format($item['maklumat']->sum('elok_hingga_akhir'))); ?></td>
                            <?php if($from === 'senarai-sekolah-lebihan'): ?>
                                <td><?php echo e(number_format($item['maklumat']->sum('lebihan_buku'))); ?></td>
                            <?php else: ?>
                                <td><?php echo e(number_format($item['maklumat']->sum('pesanan_buku'))); ?></td>
                            <?php endif; ?>
                        </tr>
                    </tfoot>
                </table>
            </div>
        <?php endif; ?>
    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

    
    <div class="footer">
        <div class="sign-box">
            <p>Disediakan oleh:</p>
            <div class="sign-line">
                <?php echo e($user->name); ?><br>
                Guru BOSS — <?php echo e($user->nama_sekolah ?? '-'); ?>

            </div>
        </div>
        <div class="sign-box" style="text-align:right;">
            <p>Disemak oleh:</p>
            <div class="sign-line">
                <?php echo e($supervisor->name); ?><br>
                Penyelia BOSS — <?php echo e($supervisor->daerah ?? '-'); ?>

            </div>
        </div>
    </div>
</body>

</html>
<?php /**PATH C:\laragon\www\myspbt\resources\views/supervisor/lihat-buku-cetak.blade.php ENDPATH**/ ?>