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

<div class="row mb-4 align-items-center">
    <div class="col-md-6">
        <h4 class="fw-bold text-success"><i class="fa-solid fa-map-location-dot me-2"></i> Kelola Titik Peta</h4>
        <p class="text-muted mb-0">Manajemen koordinat GIS KPH III.</p>
    </div>
    <div class="col-md-6 text-md-end mt-3 mt-md-0">
        <a href="<?= base_url('peta') ?>" class="btn btn-outline-secondary rounded-pill me-2"><i class="fa-solid fa-eye me-1"></i> Lihat Peta</a>
        <a href="<?= base_url('peta/form') ?>" class="btn btn-success rounded-pill shadow-sm"><i class="fa-solid fa-plus me-1"></i> Tambah Titik Baru</a>
    </div>
</div>

<div class="card shadow-sm border-0">
    <div class="table-responsive">
        <table class="table table-hover align-middle mb-0">
            <thead class="table-light">
                <tr>
                    <th class="ps-4">No</th>
                    <th>Nama Lokasi</th>
                    <th>Kategori</th>
                    <th>Koordinat (Lat, Long)</th>
                    <th class="text-center pe-4">Aksi</th>
                </tr>
            </thead>
            <tbody>
                <?php $no=1; foreach($titik_peta as $row): ?>
                <tr>
                    <td class="ps-4"><?= $no++ ?></td>
                    <td class="fw-bold"><?= $row['nama_lokasi'] ?></td>
                    <td><span class="badge bg-success bg-opacity-10 text-success border border-success"><?= $row['kategori'] ?></span></td>
                    <td class="text-muted small"><?= $row['latitude'] ?>, <?= $row['longitude'] ?></td>
                    <td class="text-center pe-4">
                        <a href="<?= base_url('peta/form/'.$row['id_titik']) ?>" class="btn btn-sm btn-warning rounded-circle shadow-sm"><i class="fa-solid fa-pen text-dark"></i></a>
                        <a href="<?= base_url('peta/hapus/'.$row['id_titik']) ?>" class="btn btn-sm btn-outline-danger rounded-circle shadow-sm" onclick="return confirm('Hapus titik ini?')"><i class="fa-solid fa-trash"></i></a>
                    </td>
                </tr>
                <?php endforeach; ?>
            </tbody>
        </table>
    </div>
</div>
<?= $this->endSection() ?>