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

<form action="<?= site_url('jamaah/update/' . $jamaah['id']) ?>" method="post" enctype="multipart/form-data">
<?= csrf_field() ?>

<div class="card shadow-sm mb-3">
    <div class="card-header bg-primary text-white">
        <i class="fas fa-user-edit me-1"></i>
        <b>Edit Data Jamaah</b>
        <div class="small opacity-75">Masjid Al Aqso</div>
    </div>

    <div class="card-body">

        <!-- IDENTITAS -->
        <h6 class="text-primary mb-3">
            <i class="fas fa-id-card me-1"></i> Identitas Jamaah
        </h6>

        <div class="row">
            <div class="col-md-4 mb-3">
                <label>No Jamaah</label>
                <input name="no_jamaah" class="form-control" value="<?= esc($jamaah['no_jamaah']) ?>">
            </div>

            <div class="col-md-4 mb-3">
                <label>NIK</label>
                <input name="nik" class="form-control" value="<?= esc($jamaah['nik']) ?>">
            </div>

            <div class="col-md-4 mb-3">
                <label>Nama Lengkap *</label>
                <input name="nama_lengkap" class="form-control" required
                       value="<?= esc($jamaah['nama_lengkap']) ?>">
            </div>

            <div class="col-md-4 mb-3">
                <label>Jenis Kelamin</label>
                <select name="jenis_kelamin" class="form-select">
                    <option value="L" <?= $jamaah['jenis_kelamin']=='L'?'selected':'' ?>>Laki-laki</option>
                    <option value="P" <?= $jamaah['jenis_kelamin']=='P'?'selected':'' ?>>Perempuan</option>
                </select>
            </div>

            <div class="col-md-4 mb-3">
                <label>Tempat Lahir</label>
                <input name="tempat_lahir" class="form-control"
                       value="<?= esc($jamaah['tempat_lahir']) ?>">
            </div>

            <div class="col-md-4 mb-3">
                <label>Tanggal Lahir</label>
                <input type="date" name="tanggal_lahir" class="form-control"
                       value="<?= esc($jamaah['tanggal_lahir']) ?>">
            </div>
        </div>

        <hr>

        <!-- KONTAK & ALAMAT -->
        <h6 class="text-primary mb-3">
            <i class="fas fa-map-marker-alt me-1"></i> Kontak & Alamat
        </h6>

        <div class="row">
            <div class="col-md-4 mb-3">
                <label>No HP (WA)</label>
                <input name="no_hp" class="form-control"
                       value="<?= esc($jamaah['no_hp']) ?>">
            </div>

            <div class="col-md-4 mb-3">
                <label>Email</label>
                <input name="email" class="form-control"
                       value="<?= esc($jamaah['email']) ?>">
            </div>

            <div class="col-md-4 mb-3">
                <label>Alamat</label>
                <input name="alamat" class="form-control"
                       value="<?= esc($jamaah['alamat']) ?>">
            </div>
        </div>

        <hr>

        <!-- KEANGGOTAAN -->
        <h6 class="text-primary mb-3">
            <i class="fas fa-users me-1"></i> Keanggotaan Masjid
        </h6>

        <div class="row">
            <div class="col-md-4 mb-3">
                <label>Status Jamaah</label>
                <select name="status_jamaah" class="form-select">
                    <option value="Aktif" <?= $jamaah['status_jamaah']=='Aktif'?'selected':'' ?>>Aktif</option>
                    <option value="Nonaktif" <?= $jamaah['status_jamaah']=='Nonaktif'?'selected':'' ?>>Nonaktif</option>
                </select>
            </div>

            <div class="col-md-4 mb-3">
                <label>Kategori Jamaah</label>
                <input name="kategori_jamaah" class="form-control"
                       value="<?= esc($jamaah['kategori_jamaah']) ?>">
            </div>

            <div class="col-md-4 mb-3">
                <label>Kelompok</label>
                <input name="kelompok" class="form-control"
                       value="<?= esc($jamaah['kelompok']) ?>">
            </div>
        </div>

        <hr>

        <!-- CATATAN -->
        <h6 class="text-primary mb-3">
            <i class="fas fa-sticky-note me-1"></i> Catatan
        </h6>

        <div class="mb-3">
            <textarea name="catatan" class="form-control" rows="3"><?= esc($jamaah['catatan']) ?></textarea>
        </div>

    </div>

    <div class="card-footer text-end">
        <a href="<?= site_url('jamaah') ?>" class="btn btn-secondary">
            <i class="fas fa-arrow-left me-1"></i> Kembali
        </a>

        <button type="submit" class="btn btn-primary">
            <i class="fas fa-save me-1"></i> Simpan Perubahan
        </button>
    </div>
</div>

</form>

<?= $this->endSection() ?>
