<script type="text/javascript">
    $(document).ready(function() {
        $('#id_karyawan').select2({
            placeholder: 'Pilih Karyawan',
            allowClear: true,
            ajax: {
                url: '<?= route("dropdown.karyawan.aktif") ?>',
                dataType: 'json',
                delay: 250,
                processResults: function (data) {
                return {
                        results: data
                    };
                },
                cache: false
            },
            minLength: 3
        });

        $('#id_cabang').select2({
            // tags: true,
            // minLength: 3,
            placeholder: 'Semua Cabang',
            ajax: {
                // type: 'POST',
                url: '<?= route("dropdown.cabang") ?>',
                dataType: 'json',
                delay: 250,
                processResults: function(data) {
                    return {
                        results: data
                    };
                },
                cache: false
            },
        });
    });
</script>

<div class="card-header">
    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
    <h3 class="title modal-title"></h3>
</div>
<div id="form_input" class="card-body" disabled>
    <input type="hidden" id="id" class="form-control" value="<?= ((isset($data))?md5($data->id):'') ?>">
    <div class="form-group">
        <label>Nama Karyawan <i class="text-danger">*</i></label>
        <select id="id_karyawan" style="border-radius: 5px; width: 100%;">
            <?php
                if(isset($data->id_karyawan)){
            ?>
                    <option value="<?= $data->id_karyawan ?>" selected><?= $data->nik." - ".$data->nm_karyawan ?></option>';
            <?php
                }
            ?>
        </select>
    </div>

    <div class="form-group">
        <label>Admin Cabang</label>
        <select id="id_cabang"  multiple="multiple" style="border-radius: 5px; width: 100%;">
        <?php
                if(isset($data->id_cabang) && $data->id_cabang != 'all'){

                    $id_cabang_arr = explode(",",$data->id_cabang);
                    foreach($id_cabang_arr as $row){
            ?>
                        <option value="<?= $cabang_arr[$row]['id_cabang'] ?>" selected><?= $cabang_arr[$row]['nm_cabang'] ?></option>
        <?php
                    }
                }
        ?>
        </select>
    </div>
</div>
<div class="card-footer">
    <div class="row">
        <div class="col-md-7 text-left">
            <div id="message"></div>
        </div>
        <div class="col-md-5 text-right">
            <button id="btn_new_input" class="btn" style="display:none">TAMBAH BARU</button>
            <button class="btn_save ladda-button" data-style="expand-left"></button>
        </div>
    </div><!-- ./row -->
</div>

