<?= $this->extend('layout/main') ?>
<?= $this->section('content') ?>

<div class="row mb-3">
    <?php foreach ($rekap_pupuk as $rek): ?>
        <div class="col-md-3">
            <div class="info-box border border-emerald shadow-sm">
                <span class="info-box-icon bg-emerald text-white"><i class="fas fa-truck-loading"></i></span>
                <div class="info-box-content">
                    <span class="info-box-text">Total <?= $rek['nama_pupuk'] ?> Keluar</span>
                    <span class="info-box-number"><?= $rek['total_kg'] ?> Kg</span>
                </div>
            </div>
        </div>
    <?php endforeach; ?>
</div>

<div class="card card-emerald card-outline shadow">
    <div class="card-header">
        <h3 class="card-title">Rincian Penyaluran Pupuk ke Petani</h3>
        <div class="card-tools">
            <button class="btn btn-default btn-sm" onclick="window.print()">
                <i class="fas fa-print"></i> Cetak Laporan
            </button>
        </div>
    </div>
    <div class="card-body p-0">
        <table class="table table-hover table-striped">
            <thead class="bg-light">
                <tr>
                    <th>Tanggal Penebusan</th>
                    <th>No. Invoice</th>
                    <th>Nama Petani</th>
                    <th>Jenis Pupuk</th>
                    <th>Jumlah (Kg)</th>
                </tr>
            </thead>
            <tbody>
                <?php foreach ($distribusi as $d): ?>
                    <tr>
                        <td><?= date('d/m/Y H:i', strtotime($d['tanggal_transaksi'])) ?></td>
                        <td><b><?= $d['no_invoice'] ?></b></td>
                        <td><?= $d['nama_petani'] ?></td>
                        <td><span class="badge badge-info"><?= $d['nama_pupuk'] ?></span></td>
                        <td class="font-weight-bold"><?= $d['jumlah_beli'] ?> Kg</td>
                    </tr>
                <?php endforeach; ?>
            </tbody>
        </table>
    </div>
</div>
<?= $this->endSection() ?>