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

<head>
    <meta charset="UTF-8">
    <title>Laporan Pesanan Buku — Semua Daerah — <?php echo e($tahun); ?></title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: Arial, sans-serif;
            font-size: 10px;
            color: #000;
        }

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

        .letterhead img {
            height: 65px;
            margin-bottom: 4px;
        }

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

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

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

        .report-info {
            text-align: center;
            margin: 10px 0 14px;
        }

        .report-info h4 {
            font-size: 12px;
            text-transform: uppercase;
            text-decoration: underline;
            margin-bottom: 3px;
        }

        .report-info p {
            font-size: 10px;
        }

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

        .darjah-header {
            background: #333;
            color: #fff;
            padding: 5px 10px;
            font-size: 12px;
            font-weight: bold;
            text-align: center;
            border: 1.5px solid #000;
        }

        table.report-table {
            width: 100%;
            border-collapse: collapse;
            border: 1.5px solid #000;
        }

        table.report-table th,
        table.report-table td {
            border: 1px solid #999;
            padding: 2px 4px;
            text-align: center;
            font-size: 9px;
        }

        table.report-table th {
            background: #e9ecef;
            font-size: 8px;
            white-space: nowrap;
        }

        table.report-table td.text-left {
            text-align: left;
        }

        table.report-table .total-row td {
            font-weight: bold;
            background: #f5f5f5;
        }

        .empty-msg {
            padding: 8px;
            text-align: center;
            color: #999;
            font-style: italic;
            border: 1.5px solid #000;
            border-top: none;
        }

        .footer {
            margin-top: 20px;
            font-size: 9px;
            display: flex;
            justify-content: space-between;
        }

        .footer .signature {
            margin-top: 30px;
            width: 45%;
        }

        .signature .line {
            border-top: 1px solid #000;
            margin-top: 40px;
            padding-top: 3px;
        }

        @media print {
            body {
                padding: 5mm 8mm;
            }

            @page {
                size: A4 landscape;
                margin: 8mm;
            }

            .no-print-btn {
                display: none !important;
            }

            .page-wrap {
                box-shadow: none;
            }
        }

        @media screen {
            body {
                max-width: 297mm;
                margin: 0 auto;
                background: #f0f0f0;
                padding: 15mm;
            }

            .page-wrap {
                background: #fff;
                padding: 12mm;
                box-shadow: 0 0 10px rgba(0, 0, 0, 0.15);
            }

            .no-print-btn {
                text-align: center;
                margin-bottom: 12px;
            }

            .no-print-btn button {
                padding: 8px 20px;
                font-size: 14px;
                border: none;
                border-radius: 4px;
                cursor: pointer;
                margin: 0 4px;
            }

            .btn-print {
                background: #007bff;
                color: #fff;
            }

            .btn-print:hover {
                background: #0056b3;
            }

            .btn-close {
                background: #6c757d;
                color: #fff;
            }

            .btn-close:hover {
                background: #545b62;
            }
        }
    </style>
</head>

<body>
    <div class="no-print-btn">
        <button class="btn-print" onclick="window.print()">🖨️ Cetak / Simpan PDF</button>
        <button class="btn-close" onclick="window.close()">✖ Tutup</button>
    </div>

    <div class="page-wrap">
        
        <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>
        </div>

        
        <div class="report-info">
            <h4>Laporan Pesanan Buku Tahun <?php echo e($tahun + 1); ?></h4>
            <p><strong>Tahun Data:</strong> <?php echo e($tahun); ?> &nbsp;|&nbsp;
                <?php if($daerah): ?>
                    <strong>Daerah:</strong> <?php echo e($daerah); ?>

                <?php else: ?>
                    <strong>Semua Daerah Selangor</strong>
                <?php endif; ?>
            </p>
        </div>

        
        <?php $__currentLoopData = $tables; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $table): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
            <div class="darjah-section">
                <div class="darjah-header"><?php echo e($table['darjah']); ?></div>
                <?php if($table['rows']->isNotEmpty()): ?>
                    <table class="report-table">
                        <thead>
                            <tr>
                                <th style="width:25px">Bil</th>
                                <th style="width:60px">Kod Buku</th>
                                <th style="min-width:100px">Judul Buku</th>
                                <?php $__currentLoopData = $senarai_daerah; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $d): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <th><?php echo e($d); ?></th>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                <th style="width:50px">JUMLAH</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php $__currentLoopData = $table['rows']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $idx => $row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <tr>
                                    <td><?php echo e($idx + 1); ?></td>
                                    <td><?php echo e($row['kod_buku']); ?></td>
                                    <td class="text-left"><?php echo e($row['judul']); ?></td>
                                    <?php $__currentLoopData = $senarai_daerah; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $d): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <td><?php echo e($row['daerah'][$d] > 0 ? number_format($row['daerah'][$d]) : '-'); ?></td>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                    <td><strong><?php echo e(number_format($row['jumlah'])); ?></strong></td>
                                </tr>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            <tr class="total-row">
                                <td colspan="3" style="text-align:right"><strong>JUMLAH:</strong></td>
                                <?php $__currentLoopData = $senarai_daerah; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $d): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <td><?php echo e($table['colTotals'][$d] > 0 ? number_format($table['colTotals'][$d]) : '-'); ?>

                                    </td>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                <td><strong><?php echo e(number_format($table['grandTotal'])); ?></strong></td>
                            </tr>
                        </tbody>
                    </table>
                <?php else: ?>
                    <div class="empty-msg">Tiada data pesanan untuk darjah ini.</div>
                <?php endif; ?>
            </div>
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

        
        <div class="footer">
            <div class="signature">
                <div class="line">
                    <strong>Disediakan oleh:</strong><br>
                    Pentadbir Sistem MySpBT
                </div>
            </div>
            <div class="signature" style="text-align:right">
                <div class="line">
                    <strong>Tarikh Cetak:</strong><br>
                    <?php echo e(now()->format('d/m/Y H:i')); ?>

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

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