<?= $this->extend('layouts/main') ?>

<?= $this->section('title') ?>
Semua Pengajuan
<?= $this->endSection() ?>

<?= $this->section('page_title') ?>
Monitoring Seluruh Pengajuan KP
<?= $this->endSection() ?>

<?= $this->section('content') ?>
<div class="row">
    <div class="col-lg-12">
        <div class="glass-card mb-4">
            <h4 class="mb-4">Daftar Pengajuan Kenaikan Pangkat</h4>

            <div class="table-responsive">
                <table class="table table-hover align-middle">
                    <thead>
                        <tr class="text-secondary small fw-bold opacity-75">
                            <th>#ID</th>
                            <th>TARGET PEGAWAI</th>
                            <th>NIP</th>
                            <th>DIUSULKAN OLEH</th>
                            <th>JENIS KP</th>
                            <th>STATUS</th>
                            <th class="text-center">AKSI</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php if (empty($pengajuan)): ?>
                            <tr>
                                <td colspan="8" class="text-center py-5 text-muted">Belum ada pengajuan yang masuk ke
                                    sistem.</td>
                            </tr>
                        <?php else: ?>
                            <?php foreach ($pengajuan as $row): ?>
                                <tr>
                                    <td>#<?= $row['id'] ?></td>
                                    <td><span class="fw-bold text-dark"><?= $row['target_nama'] ?? 'Unknown' ?></span></td>
                                    <td><code><?= $row['target_nip'] ?? '-' ?></code></td>
                                    <td><span class="small"><?= $row['pengaju_nama'] ?? 'System' ?></span></td>
                                    <td><span
                                            class="badge bg-light text-dark rounded-pill border"><?= $row['jenis_kp'] ?></span>
                                    </td>
                                    <td>
                                        <?php if ($row['status'] == 'PENDING'): ?>
                                            <span class="badge badge-status bg-warning text-dark">Pending</span>
                                        <?php elseif ($row['status'] == 'VERIFIED'): ?>
                                            <span class="badge badge-status bg-info text-white">Verified</span>
                                        <?php elseif ($row['status'] == 'REJECTED'): ?>
                                            <span class="badge badge-status bg-danger text-white">Rejected</span>
                                        <?php elseif ($row['status'] == 'REVISION'): ?>
                                            <span class="badge badge-status bg-secondary text-white">Revision</span>
                                        <?php elseif ($row['status'] == 'APPROVED'): ?>
                                            <span class="badge badge-status bg-success text-white">Approved</span>
                                        <?php elseif ($row['status'] == 'PROSES_BKN'): ?>
                                            <span class="badge badge-status bg-primary text-white">Proses BKN</span>
                                        <?php elseif ($row['status'] == 'PERTEK_BKN'): ?>
                                            <span class="badge badge-status bg-info text-dark">Pertek BKN</span>
                                        <?php elseif ($row['status'] == 'TOLAK_BKN'): ?>
                                            <span class="badge badge-status bg-danger text-white">Tolak BKN</span>
                                        <?php elseif ($row['status'] == 'WAITING_SK'): ?>
                                            <span class="badge badge-status bg-warning text-dark">Tunggu SK</span>
                                        <?php elseif ($row['status'] == 'SK_FINISH'): ?>
                                            <span class="badge badge-status bg-success text-white"><i
                                                    class="bi bi-check-circle me-1"></i> SK Selesai</span>
                                        <?php endif; ?>
                                    </td>
                                    <td class="text-center">
                                        <a href="<?= base_url('verifikator/detail/' . $row['id']) ?>"
                                            class="btn btn-light btn-sm rounded-pill shadow-sm"><i class="bi bi-eye-fill"></i>
                                            Detail</a>
                                    </td>
                                </tr>
                            <?php endforeach; ?>
                        <?php endif; ?>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
<?= $this->endSection() ?>