<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Laporan Peminjaman - <?php echo e(ucfirst($jenis)); ?></title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        body {
            font-family: Arial, sans-serif;
            font-size: 12px;
            line-height: 1.4;
            padding: 20px;
        }
        .header {
            text-align: center;
            margin-bottom: 20px;
            border-bottom: 2px solid #000;
            padding-bottom: 15px;
        }
        .header h2 {
            margin: 5px 0;
            font-size: 18px;
        }
        .header h3 {
            margin: 5px 0;
            font-size: 14px;
            font-weight: normal;
        }
        .header p {
            margin: 3px 0;
            font-size: 11px;
        }
        .meta-info {
            margin: 15px 0;
            font-size: 11px;
        }
        .meta-info table {
            width: 100%;
        }
        .meta-info td {
            padding: 2px 0;
        }
        table.data {
            width: 100%;
            border-collapse: collapse;
            margin-top: 15px;
        }
        table.data th,
        table.data td {
            border: 1px solid #333;
            padding: 6px 4px;
            text-align: left;
        }
        table.data th {
            background-color: #f0f0f0;
            font-weight: bold;
            text-align: center;
        }
        table.data td.number {
            text-align: center;
        }
        table.data td.amount {
            text-align: right;
        }
        .footer {
            margin-top: 30px;
            font-size: 11px;
        }
        .signature {
            margin-top: 40px;
            text-align: right;
        }
        .signature-box {
            display: inline-block;
            text-align: center;
            min-width: 200px;
        }
        .signature-line {
            margin-top: 60px;
            border-top: 1px solid #000;
            padding-top: 5px;
        }
        .badge-overdue {
            background-color: #f8d7da;
            color: #721c24;
            padding: 2px 6px;
            border-radius: 3px;
            font-size: 10px;
        }
        .badge-warning {
            background-color: #fff3cd;
            color: #856404;
            padding: 2px 6px;
            border-radius: 3px;
            font-size: 10px;
        }
    </style>
</head>
<body>
    <div class="header">
        <h2>SISTEM PERPUSTAKAAN</h2>
        <h3>SMA NEGERI 1 PANGURURAN</h3>
        <p>Jl. Sisingamangaraja No. 1, Pangururan, Kabupaten Samosir</p>
        <p>Telp: (0625) 123456 | Email: perpustakaan@sman1pangururan.sch.id</p>
    </div>

    <div class="meta-info">
        <table>
            <tr>
                <td width="15%"><strong>Judul Laporan</strong></td>
                <td width="2%">:</td>
                <td><strong>LAPORAN PEMINJAMAN <?php echo e(strtoupper($jenis)); ?></strong></td>
            </tr>
            <tr>
                <td><strong>Tanggal Cetak</strong></td>
                <td>:</td>
                <td><?php echo e($tanggal_cetak); ?></td>
            </tr>
            <tr>
                <td><strong>Total Data</strong></td>
                <td>:</td>
                <td><?php echo e(count($peminjaman)); ?> peminjaman</td>
            </tr>
        </table>
    </div>

    <table class="data">
        <thead>
            <tr>
                <th width="4%">No</th>
                <th width="10%">Tgl Pinjam</th>
                <th width="15%">Peminjam</th>
                <th width="20%">Judul Buku</th>
                <th width="10%">No. Aset</th>
                <th width="10%">Jatuh Tempo</th>
                <th width="10%">Tgl Kembali</th>
                <th width="10%">Status</th>
                <th width="6%">Terlambat</th>
                <th width="10%">Denda</th>
            </tr>
        </thead>
        <tbody>
            <?php $__empty_1 = true; $__currentLoopData = $peminjaman; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $index => $p): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                <?php
                    $keterlambatan = 0;
                    if ($p->tanggal_kembali) {
                        $jatuhTempo = \Carbon\Carbon::parse($p->tanggal_jatuh_tempo);
                        $kembali = \Carbon\Carbon::parse($p->tanggal_kembali);
                        if ($kembali->gt($jatuhTempo)) {
                            $keterlambatan = $kembali->diffInDays($jatuhTempo);
                        }
                    } elseif ($p->status_peminjaman == 'Dipinjam') {
                        $jatuhTempo = \Carbon\Carbon::parse($p->tanggal_jatuh_tempo);
                        $now = \Carbon\Carbon::now();
                        if ($now->gt($jatuhTempo)) {
                            $keterlambatan = $now->diffInDays($jatuhTempo);
                        }
                    }
                ?>
                <tr>
                    <td class="number"><?php echo e($index + 1); ?></td>
                    <td class="number"><?php echo e(\Carbon\Carbon::parse($p->tanggal_pinjam)->format('d/m/Y')); ?></td>
                    <td><?php echo e($p->user->nama ?? '-'); ?></td>
                    <td><?php echo e($p->asetBuku->buku->judul ?? '-'); ?></td>
                    <td class="number"><?php echo e($p->asetBuku->nomor_aset ?? '-'); ?></td>
                    <td class="number"><?php echo e(\Carbon\Carbon::parse($p->tanggal_jatuh_tempo)->format('d/m/Y')); ?></td>
                    <td class="number">
                        <?php if($p->tanggal_kembali): ?>
                            <?php echo e(\Carbon\Carbon::parse($p->tanggal_kembali)->format('d/m/Y')); ?>

                        <?php else: ?>
                            -
                        <?php endif; ?>
                    </td>
                    <td class="number"><?php echo e($p->status_peminjaman); ?></td>
                    <td class="number">
                        <?php if($keterlambatan > 0): ?>
                            <?php echo e($keterlambatan); ?> hari
                        <?php else: ?>
                            -
                        <?php endif; ?>
                    </td>
                    <td class="amount">
                        <?php if($p->denda > 0): ?>
                            Rp <?php echo e(number_format($p->denda, 0, ',', '.')); ?>

                        <?php else: ?>
                            -
                        <?php endif; ?>
                    </td>
                </tr>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                <tr>
                    <td colspan="10" style="text-align: center; padding: 20px;">
                        Tidak ada data peminjaman
                    </td>
                </tr>
            <?php endif; ?>
        </tbody>
        <?php if(count($peminjaman) > 0): ?>
            <tfoot>
                <tr style="background-color: #f0f0f0;">
                    <td colspan="9" style="text-align: right; font-weight: bold;">Total Denda:</td>
                    <td class="amount" style="font-weight: bold;">
                        Rp <?php echo e(number_format($peminjaman->sum('denda'), 0, ',', '.')); ?>

                    </td>
                </tr>
            </tfoot>
        <?php endif; ?>
    </table>

    <div class="footer">
        <p><strong>Catatan:</strong></p>
        <ul style="margin-left: 20px; margin-top: 5px;">
            <li>Laporan ini dibuat secara otomatis oleh sistem</li>
            <li>Denda dihitung berdasarkan keterlambatan pengembalian buku</li>
            <li>Status "Dipinjam" menunjukkan buku belum dikembalikan</li>
        </ul>
    </div>

    <div class="signature">
        <div class="signature-box">
            <p>Pangururan, <?php echo e(\Carbon\Carbon::now()->format('d F Y')); ?></p>
            <p>Petugas Perpustakaan</p>
            <div class="signature-line">
                <p><?php echo e(auth()->user()->nama ?? '(.....................)'); ?></p>
            </div>
        </div>
    </div>
</body>
</html>
<?php /**PATH C:\Users\hizkia\Desktop\TUBES_MSBD\Perpustakaan-SMAN-1-Pangururan\resources\views/admin/laporan/pdf/peminjaman.blade.php ENDPATH**/ ?>