<div class="row justify-content-center">
    <div class="col-md-8">
        <div class="card shadow-sm mb-4 border-bottom-primary">
            <div class="card-header bg-white py-3">
                <div class="row">
                    <div class="col">
                        <h4 class="h5 align-middle m-0 font-weight-bold text-primary">
                            Form <?= $title; ?>
                        </h4>
                    </div>
                    <div class="col-auto">
                        <a href="<?= base_url('user') ?>" class="btn btn-sm btn-secondary btn-icon-split">
                            <span class="icon">
                                <i class="fa fa-arrow-left"></i>
                            </span>
                            <span class="text">
                                Kembali
                            </span>
                        </a>
                    </div>
                </div>
            </div>
            <div class="card-body pb-2">
                <?= $this->session->flashdata('pesan'); ?>
                <?= form_open('', [], ['id_user' => $user['id_user']]); ?>
                <div class="row form-group">
                    <label class="col-md-4 text-md-right" for="username">Username</label>
                    <div class="col-md-6">
                        <input value="<?= set_value('username', $user['username']); ?>" type="text" id="username" name="username" class="form-control" placeholder="Username">
                        <?= form_error('username', '<span class="text-danger small">', '</span>'); ?>
                    </div>
                </div>
                <hr>
                <div class="row form-group">
                    <label class="col-md-4 text-md-right" for="nama">Nama</label>
                    <div class="col-md-6">
                        <input value="<?= set_value('nama', $user['nama']); ?>" type="text" id="nama" name="nama" class="form-control" placeholder="Nama">
                        <?= form_error('nama', '<span class="text-danger small">', '</span>'); ?>
                    </div>
                </div>
                <div class="row form-group">
                    <label class="col-md-4 text-md-right" for="email">Email</label>
                    <div class="col-md-6">
                        <input value="<?= set_value('email', $user['email']); ?>" type="text" id="email" name="email" class="form-control" placeholder="Email">
                        <?= form_error('email', '<span class="text-danger small">', '</span>'); ?>
                    </div>
                </div>
                <div class="row form-group">
                    <label class="col-md-4 text-md-right" for="no_telp">Nomor Telepon</label>
                    <div class="col-md-6">
                        <input value="<?= set_value('no_telp', $user['no_telp']); ?>" type="text" id="no_telp" name="no_telp" class="form-control" placeholder="Nomor Telepon">
                        <?= form_error('no_telp', '<span class="text-danger small">', '</span>'); ?>
                    </div>
                </div>
                <div class="row form-group">
                    <label class="col-md-4 text-md-right" for="jabatan">Jabatan</label>
                    <div class="col-md-6">
                        <input value="<?= set_value('jabatan', $user['jabatan']); ?>" type="text" id="jabatan" name="jabatan" class="form-control" placeholder="Masukkan jabatan">
                        <?= form_error('jabatan', '<span class="text-danger small">', '</span>'); ?>
                    </div>
                </div>
                <div class="row form-group">
                    <label class="col-md-4 text-md-right" for="id_depart">Departemen</label>
                    <div class="col-md-6">
                        <div class="input-group">
                            <select name="id_depart" id="id_depart" class="custom-select">
                                <option value="" selected disabled>Pilih Departemen</option>
                                <?php foreach ($departemen as $row) : ?>
                                    <option <?= $user['id_depart'] == $row['id_depart'] ? 'selected' : ''; ?> <?= set_select('id_depart', $row['id_depart']) ?> value="<?= $row['id_depart'] ?>"><?= $row['nama_depart'] ?></option>
                                <?php endforeach; ?>
                            </select>
                            <div class="input-group-append">
                                <a class="btn btn-primary" href="<?= base_url('supplier/add'); ?>"  target="__BLANK"><i class="fa fa-plus"></i></a>
                            </div>
                        </div>
                        <?= form_error('id_depart', '<small class="text-danger">', '</small>'); ?>
                    </div>
                </div>
                <div class="row form-group">
                    <label class="col-md-4 text-md-right" for="role">Role</label>
                    <div class="col-md-6">
                        <div class="custom-control custom-radio">
                            <input <?= $user['role'] == '1' ? 'checked' : ''; ?> <?= set_radio('role', 'pemilik'); ?> value="1" type="radio" id="pemilik" name="role" class="custom-control-input">
                            <label class="custom-control-label" for="pemilik">Administrator</label>
                        </div>
                        <div class="custom-control custom-radio">
                            <input <?= $user['role'] == '2' ? 'checked' : ''; ?> <?= set_radio('role', 'admin'); ?> value="2" type="radio" id="admin" name="role" class="custom-control-input">
                            <label class="custom-control-label" for="admin">Petugas</label>
                        </div>
                        <div class="custom-control custom-radio">
                            <input <?= $user['role'] == '3' ? 'checked' : ''; ?> <?= set_radio('role', 'user'); ?> value="3" type="radio" id="user" name="role" class="custom-control-input">
                            <label class="custom-control-label" for="user">User</label>
                        </div>
                        <?= form_error('role', '<span class="text-danger small">', '</span>'); ?>
                    </div>
                </div>
                <div class="row form-group">
                    <label class="col-md-4 text-md-right" for="cabang_id">Cabang</label>
                    <div class="col-md-6">
                        <div class="input-group">
                            <select name="cabang_id" id="cabang_id" class="custom-select">
                                <option value="" selected disabled>Pilih Cabang</option>
                                <?php foreach ($cabang as $s) : ?>
                                    <option <?= $user['cabang_id'] == $s['id_cabang'] ? 'selected' : ''; ?> <?= set_select('cabang_id', $s['id_cabang']) ?> value="<?= $s['id_cabang'] ?>"><?= $s['nama_cabang'] ?></option>
                                <?php endforeach; ?>
                            </select>
                            <div class="input-group-append">
                                <a class="btn btn-primary" href="<?= base_url('supplier/add'); ?>"  target="__BLANK"><i class="fa fa-plus"></i></a>
                            </div>
                        </div>
                        <?= form_error('cabang_id', '<small class="text-danger">', '</small>'); ?>
                    </div>
                </div>
                <br>
                <div class="row form-group justify-content-end">
                    <div class="col-md-8">
                        <button type="submit" class="btn btn-primary btn-icon-split">
                            <span class="icon"><i class="fa fa-save"></i></span>
                            <span class="text">Simpan</span>
                        </button>
                        <button type="reset" class="btn btn-secondary">Reset</button>
                    </div>
                </div>
                <?= form_close(); ?>
            </div>
        </div>
    </div>
</div>