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

<div class="card shadow border-0">

    <div class="card-header bg-warning text-white d-flex justify-content-between align-items-center">
        <strong><i class="fas fa-edit"></i> EDIT MENU</strong>
        <a href="<?= site_url('setting/menus') ?>" class="btn btn-light btn-sm">
            <i class="fas fa-arrow-left"></i> Kembali
        </a>
    </div>

    <div class="card-body">

        <form action="<?= site_url('setting/menus/update') ?>" method="post">
        <input type="hidden" name="id" value="<?= $menu->id ?>">

        <div class="row">

            <!-- JUDUL -->
            <div class="col-md-6 form-group">
                <label><b>Judul Menu</b></label>
                <input type="text" name="title" class="form-control"
                       value="<?= $menu->title ?>" required>
            </div>

            <!-- URL -->
            <div class="col-md-6 form-group">
                <label><b>URL</b></label>
                <input type="text" name="url" class="form-control"
                       value="<?= $menu->url ?>" placeholder="contoh: master/barang">
            </div>

            <!-- ICON -->
            <div class="col-md-6 form-group">
                <label><b>Icon Class</b></label>
                <input type="text" name="icon" class="form-control"
                       value="<?= $menu->icon ?>" placeholder="fas fa-box">
                <small class="text-muted">Gunakan class FontAwesome</small>
            </div>

            <!-- PARENT -->
            <div class="col-md-6 form-group">
                <label><b>Parent Menu</b></label>
                <select name="parent_id" class="form-control">
                    <option value="">-- MENU UTAMA --</option>
                    <?php foreach($parents as $p): ?>
                        <option value="<?= $p->id ?>"
                            <?= $menu->parent_id == $p->id ? 'selected' : '' ?>>
                            <?= $p->title ?>
                        </option>
                    <?php endforeach ?>
                </select>
            </div>

            <!-- SORT -->
            <div class="col-md-4 form-group">
                <label><b>Urutan</b></label>
                <input type="number" name="sort_order" class="form-control"
                       value="<?= $menu->sort_order ?>">
            </div>

            <!-- STATUS -->
            <div class="col-md-4 form-group">
                <label><b>Status</b></label>
                <select name="is_active" class="form-control">
                    <option value="1" <?= $menu->is_active ? 'selected' : '' ?>>Aktif</option>
                    <option value="0" <?= !$menu->is_active ? 'selected' : '' ?>>Nonaktif</option>
                </select>
            </div>

        </div>

        <hr>

        <div class="text-right">
            <button class="btn btn-success">
                <i class="fas fa-save"></i> Simpan Perubahan
            </button>

            <a href="<?= site_url('setting/menus') ?>" class="btn btn-secondary">
                Batal
            </a>
        </div>

        </form>

    </div>
</div>

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