<?= $this->extend('layout/template') ?>

<?= $this->section('content') ?>
<div class="container-fluid">
    <div class="d-flex justify-content-between align-items-center mb-4">
        <div>
            <h1 class="h3 mb-1 text-gray-800 fw-bold">Verifikasi Laporan</h1>
            <p class="mb-0 text-muted">Daftar laporan kinerja OPD yang perlu diperiksa</p>
        </div>
    </div>

    <div class="card shadow mb-4">
        <div class="card-header py-3">
            <h6 class="m-0 font-weight-bold text-primary">Laporan Masuk</h6>
        </div>
        <div class="card-body">
            <div class="table-responsive">
                <table class="table table-bordered table-hover" width="100%" cellspacing="0">
                    <thead>
                        <tr>
                            <th width="5%">No</th>
                            <th>Nama OPD</th>
                            <th>Kegiatan / Sub Kegiatan</th>
                            <th>Triwulan</th>
                            <th>Status</th>
                            <th>Tanggal Kirim</th>
                            <th class="text-center">Aksi</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php if(empty($laporan)): ?>
                            <tr>
                                <td colspan="7" class="text-center py-5 text-muted">
                                    <i class="fas fa-inbox fa-3x mb-3 d-block"></i>
                                    Belum ada laporan yang perlu diverifikasi saat ini.
                                </td>
                            </tr>
                        <?php else: ?>
                            <?php foreach($laporan as $index => $row): ?>
                            <tr>
                                <td><?= $index + 1 ?></td>
                                <td><?= $row['nama_opd'] ?></td>
                                <td>
                                    <strong><?= $row['nama_kegiatan'] ?></strong><br>
                                    <small class="text-muted"><?= $row['nama_sub_kegiatan'] ?></small>
                                </td>
                                <td>TW <?= $row['triwulan'] ?></td>
                                <td>
                                    <?php 
                                        $badgeClass = 'bg-secondary';
                                        if($row['status'] == 'Diajukan') $badgeClass = 'bg-warning text-dark';
                                        elseif($row['status'] == 'Disetujui') $badgeClass = 'bg-success';
                                        elseif($row['status'] == 'Ditolak') $badgeClass = 'bg-danger';
                                        elseif($row['status'] == 'Revisi') $badgeClass = 'bg-info';
                                    ?>
                                    <span class="badge <?= $badgeClass ?>"><?= $row['status'] ?></span>
                                </td>
                                <td><?= date('d M Y H:i', strtotime($row['created_at'])) ?></td>
                                <td class="text-center">
                                    <a href="<?= base_url('admin_bidang/detail_verifikasi/'.$row['id']) ?>" class="btn btn-primary btn-sm">
                                        <i class="fas fa-search-plus"></i> Periksa
                                    </a>
                                </td>
                            </tr>
                            <?php endforeach; ?>
                        <?php endif; ?>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
<?= $this->endSection() ?>
