<script type="text/javascript">
    $(document).ready(function() {
        $('#form_input #id_cabang').select2({
            placeholder: '<?= $this->lang->line('pilih_cabang') ?>',
            ajax: {
                // type: 'POST',
                url: '<?= route("dropdown.cabang") ?>',
                dataType: 'json',
                delay: 250,
                processResults: function (data) {
                return {
                        results: data
                    };
                },
                cache: true
            },
            minLength: 3,
        });
    });
</script>

<div class="card-header" style="border-top-left-radius: 0px; border-top-right-radius: 0px;">
    <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_master_cp" class="form-control" value="<?= ((isset($data))?md5($data->id):'') ?>">
    <?php
        if (in_array($this->level_user, array("1")) || $this->multi_cabang == true) {
    ?>
            <div class="form-group">
                <label><?= $this->lang->line('cabang') ?> <i class="text-danger">*</i></label>
                <select id="id_cabang" class="form-control select2" style="width:100%">
                    <option value="0"><?= $this->lang->line('pilih_cabang') ?></option>
                    <?php
                        if(isset($data)){
                            echo '<option value="'.$data->id_cabang.'" selected>'.$data->kode_cabang.' - '.$data->nama_cabang.'</option>';
                        }
                    ?>
                </select>
            </div>
    <?php
        }
    ?>
        
    <div class="form-group">
        <label><?= $this->lang->line('nama_lokasi') ?> <i class="text-danger">*</i></label>
        <input type="text" id="nm_lokasi" class="form-control" placeholder="Example: 2nd Floor Room A" value="<?= ((isset($data))?$data->nm_lokasi:'') ?>">
    </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" onclick="new_input(this)" style="display:none"><?= $this->lang->line('button_form_tambah_baru') ?></button>
            <button class="btn_save ladda-button" data-style="expand-left"></button>
        </div>
    </div>
</div>