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

<?php $is_edit = isset($pegawai_edit); ?>

<div class="row mb-4 align-items-center">
    <div class="col-md-6">
        <h4 class="fw-bold text-success"><i class="fa-solid <?= $is_edit ? 'fa-user-pen' : 'fa-user-plus' ?> me-2"></i> <?= $is_edit ? 'Edit Data Pegawai' : 'Tambah Data Pegawai' ?></h4>
    </div>
    <div class="col-md-6 text-md-end mt-3 mt-md-0">
        <a href="<?= base_url('pegawai') ?>" class="btn btn-outline-secondary rounded-pill shadow-sm"><i class="fa-solid fa-arrow-left me-2"></i> Kembali</a>
    </div>
</div>

<div class="card shadow-sm border-0">
    <div class="card-body p-4">
        <form action="<?= $is_edit ? base_url('pegawai/update/'.$pegawai_edit['id_pegawai']) : base_url('pegawai/simpan') ?>" method="POST">
            <div class="row">
                <div class="col-md-6 mb-3">
                    <label class="form-label fw-bold">Nama Lengkap</label>
                    <input type="text" class="form-control" name="nama_pegawai" value="<?= $is_edit ? $pegawai_edit['nama_pegawai'] : '' ?>" required>
                </div>
                <div class="col-md-6 mb-3">
                    <label class="form-label fw-bold">NIP</label>
                    <input type="text" class="form-control" name="nip" value="<?= $is_edit ? $pegawai_edit['nip'] : '' ?>" required>
                </div>
            </div>
            <div class="row">
                <div class="col-md-4 mb-3">
                    <label class="form-label fw-bold">Jabatan / Posisi</label>
                    <input type="text" class="form-control" name="jabatan" value="<?= $is_edit ? $pegawai_edit['jabatan'] : '' ?>" required>
                </div>
                <div class="col-md-4 mb-3">
                    <label class="form-label fw-bold">Nomor WhatsApp</label>
                    <input type="text" class="form-control" name="no_hp" value="<?= $is_edit ? $pegawai_edit['no_hp'] : '' ?>" required>
                </div>
                <div class="col-md-4 mb-3">
                    <label class="form-label fw-bold">Status Pegawai</label>
                    <select class="form-select" name="status" required>
                        <option value="Aktif" <?= ($is_edit && $pegawai_edit['status'] == 'Aktif') ? 'selected' : '' ?>>Aktif</option>
                        <option value="Nonaktif" <?= ($is_edit && $pegawai_edit['status'] == 'Nonaktif') ? 'selected' : '' ?>>Nonaktif</option>
                    </select>
                </div>
            </div>
            <hr class="mt-4 mb-4">
            <div class="text-end">
                <button type="submit" class="btn btn-success px-4 rounded-pill shadow-sm"><i class="fa-solid fa-save me-2"></i> Simpan Data</button>
            </div>
        </form>
    </div>
</div>
<?= $this->endSection() ?>