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

<head>
    <meta charset="UTF-8">
    <title><?= $title ?></title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.1/dist/css/bootstrap.min.css">
    <style>
        body {
            font-family: 'Times New Roman', Times, serif;
            color: black;
            background-color: white;
            padding: 20px;
        }

        .kop-surat {
            text-align: center;
            margin-bottom: 20px;
        }

        .garis-kop {
            border-top: 3px solid black;
            margin-top: 15px;
            margin-bottom: 2px;
        }

        .garis-kop-bawah {
            border-top: 1px solid black;
            margin-top: 0px;
            margin-bottom: 20px;
        }

        .table-print th,
        .table-print td {
            border: 1px solid black !important;
            padding: 5px;
            font-size: 13px;
        }

        .table-print th {
            background-color: #f2f2f2 !important;
            text-align: center;
        }
    </style>
</head>

<body>

    <div class="kop-surat">
        <h2 class="mb-0"><b>KELOMPOK TANI SARI RASA</b></h2>
        <h5>Desa Trahean, Kecamatan Teweh Baru, Kabupaten Barito Utara</h5>
        <p>Sekretariat: Jl. Pertanian No. 12 | Email: sarirasa@kelompoktani.id | Telp: 0812-3456-7890</p>
    </div>
    <hr class="garis-kop">
    <hr class="garis-kop-bawah">

    <div class="text-center mb-4">
        <h4 style="text-decoration: underline;"><b>LAPORAN ALOKASI KUOTA PUPUK (e-RDKK)</b></h4>
        <p>Tahun Tanam: <?= date('Y') ?></p>
    </div>

    <table class="table table-print w-100">
        <thead>
            <tr>
                <th>No</th>
                <th>NIK Petani</th>
                <th>Nama Petani</th>
                <th>Jenis Pupuk</th>
                <th>Jatah (Kg)</th>
                <th>Terpakai (Kg)</th>
                <th>Sisa (Kg)</th>
            </tr>
        </thead>
        <tbody>
            <?php $no = 1;
            foreach ($alokasi as $a):
                $sisa = $a['jatah_kg'] - $a['terpakai_kg'];
            ?>
                <tr>
                    <td class="text-center"><?= $no++ ?></td>
                    <td><?= $a['nik'] ?></td>
                    <td><?= $a['nama_petani'] ?></td>
                    <td class="text-center"><?= $a['nama_pupuk'] ?></td>
                    <td class="text-right"><?= number_format($a['jatah_kg'], 1) ?></td>
                    <td class="text-right"><?= number_format($a['terpakai_kg'], 1) ?></td>
                    <td class="text-right"><b><?= number_format($sisa, 1) ?></b></td>
                </tr>
            <?php endforeach; ?>
        </tbody>
    </table>

    <div class="row mt-5">
        <div class="col-7"></div>
        <div class="col-5 text-center">
            <p>Sari Rasa, <?= date('d F Y') ?><br><b>Ketua Kelompok Tani,</b></p>
            <br><br><br>
            <p><u><b>Bpk. H. Karsidi</b></u></p>
        </div>
    </div>

    <script>
        window.onload = function() {
            window.print();
        }
    </script>
</body>

</html>