<style>
    .table th, .table td {
        padding: 0.75rem !important;
    }
</style>
<script type="text/javascript">
    $(document).ready(function() {
        // total_approval();


        $(document).on('click','.btn_revisi',function(){
            $("#form_input #id_revisi").val($(this).attr("baris-ke"));
            $("#ket_revisi_modal").val("");
            $('#modal_revisi').modal({backdrop: 'static', keyboard: false});
            $('#modal_revisi').modal('show');
        });

        $(document).on('click','.btn_submit_revisi',function(){
            row = $("#form_input #id_revisi").val();
            ket_revisi = $("#ket_revisi_modal").val();

            // validasi keterangan
            if (ket_revisi == '') {
                $("#msg_modal_revisi").attr("class","show");
                $("#ket_revisi_modal").focus();
            }else{
                // kolom tolak
                $("#kolom_ditolak_"+row).text("");
                $("#ket_ditolak_"+row).val("");
                // kolom revisi
                $("#kolom_"+row).text(ket_revisi);
                $("#ket_revisi_"+row).val(ket_revisi);
                // kolom approve
                $("#kolom_approve_"+row).text("");
                $("#ket_approve_"+row).val("");
                // show msg
                $("#msg_modal_revisi").attr("class","hidden");
                $('#modal_revisi').modal('hide');
            }
            //document.getElementById('revisi_'+row).style.backgroundColor = 'yellow';
        });

        $(document).on('click','.btn_ditolak',function(){
            $("#form_ditolak #id_ditolak").val($(this).attr("baris-ke"));
            $("#ket_ditolak_modal").val("");
            $('#modal_ditolak').modal({backdrop: 'static', keyboard: false});
            $('#modal_ditolak').modal('show');
        });

        $(document).on('click','.btn_submit_ditolak',function(){
            row = $("#form_ditolak #id_ditolak").val();
            ket_ditolak = $("#ket_ditolak_modal").val();

            // validasi keterangan
            if (ket_ditolak == '') {
                $("#msg_modal_ditolak").attr("class","show");
                $("#ket_ditolak_modal").focus();
            }else{
                // kolom tolak
                $("#kolom_ditolak_"+row).text(ket_ditolak);
                $("#ket_ditolak_"+row).val(ket_ditolak);
                // kolom revisi
                $("#kolom_"+row).text("");
                $("#ket_revisi_"+row).val("");
                // kolom approve
                $("#kolom_approve_"+row).text("");
                $("#ket_approve_"+row).val("");
                // show msg
                $("#msg_modal_ditolak").attr("class","hidden");
                $('#modal_ditolak').modal('hide');
            }

            //document.getElementById('tolak_'+row).style.backgroundColor = 'red';

        });

        $(document).on('click','.btn_approve',function(){
            $("#form_approve #id_approve").val($(this).attr("baris-ke"));
            $("#ket_approve_modal").val("");
            $('#modal_approve').modal({backdrop: 'static', keyboard: false});
            $('#modal_approve').modal('show');
        });

        $(document).on('click','.btn_submit_approve',function(){
            row = $("#form_approve #id_approve").val();
            ket_approve = $("#ket_approve_modal").val();
            // kolom tolak
            $("#kolom_ditolak_"+row).text("");
            $("#ket_ditolak_"+row).val("");
            // kolom revisi
            $("#kolom_"+row).text("");
            $("#ket_revisi_"+row).val("");
            // kolom approve
            $("#kolom_approve_"+row).text(ket_approve);
            $("#ket_approve_"+row).val(ket_approve);
            $('#modal_approve').modal('hide');
            // $("#akun_"+row).prop("disabled",false);
            // $("#akun_"+row).val('');
            //document.getElementById('setuju_'+row).style.backgroundColor = 'blue';
        });

           //nominal approval
        $(document).on('click','.btn_nominal',function(){
            var no = $(this).attr("baris-ke");
            var max = $("#max_plafon_"+no).val();
            var nominal = $("#nominal_setuju_"+no).val();
            $("#form_input_nominal #id_setuju").val(no);
            $("#nominal_setuju_modal").val(nominal);
            $("#max_plafon_modal").html("<p id='max_plafon_modal' style='color: red;'>*) Maksimal Nominal Plafon : <b>"+ max +"</b></p>");
            $('#modal_nominal').modal('show');
        });

        $(document).on('click','.btn_submit_nominal',function(){
            row = $("#form_input_nominal #id_setuju").val();
            nominal = $("#nominal_setuju_modal").val();
            asli = numberWithCommas(nominal);
            $("#setuju_"+row).html(asli+"<a class='fa fa-edit btn_nominal' id='nominal' baris-ke='"+ row +"' style='cursor: pointer'></a>");
            $("#nominal_setuju_"+row).val(nominal);
            total_approval();
            $('#modal_nominal').modal('hide');
        });

        function numberWithCommas(x) {
            return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ".");
        }

    });

    function total_number(x) {
            return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ".");
        }

    function total_approval() {
        var jumlah = 0;
        $.each($('.nominal_setuju'), function(){
            var myStr = $(this).val();
            var newStr = myStr.replace(/\./g, '');
            jumlah += parseInt(newStr);
        })
        $("#total_approval").html(total_number(jumlah));
    }

    function hapus_kolom(row,modal) {
        // kolom tolak
        $("#kolom_ditolak_"+row).text("");
        $("#ket_ditolak_"+row).val("");
        $("#msg_modal_ditolak").attr("class","hidden");

        // kolom revisi
        $("#kolom_"+row).text("");
        $("#ket_revisi_"+row).val("");
        $("#msg_modal_revisi").attr("class","hidden");

        // kolom approve
        $("#kolom_approve_"+row).text("");
        $("#ket_approve_"+row).val("");

        $("input:radio[baris-ke="+row+"]").prop('checked',false);
    }

    $(document).ready(function(e) {

        $("#form-hod").on('submit', (function(e) {
            e.preventDefault();
            var loading = Ladda.create(document.getElementById("btn_submit"));

            loading.start();

            var checked=[];
            var unchecked=[];

            $("input:radio").each(function(index){

                var name = $(this).attr('name');

                if($("input:radio[name="+name+"]:checked ").length == 1 ){
                    checked.push(name);
                    console.log("CHECKED =>"+name);
                }else{
                    unchecked.push(name);
                    console.log("UNCHECKED =>"+name);
                }
            });

            if(unchecked.length === 0){
                $.ajax({
                    url: "<?= route('reimburse.save') ?>",
                    type: "POST",
                    data: new FormData(this),
                    contentType: false,
                    cache: false,
                    dataType: 'json',
                    processData: false,
                    success: function(result) {
                        if(result.success == true) {
                            // $('#btn_submit').prop("disabled", true);
                            $('#btn_submit').hide();
                            $('form input[type="radio"]').prop("disabled", true);
                        }

                        $("#msg_alert_submit").html(result.message);
                        $("#msg_alert_submit").attr("class","pr-2 show");
                        // $('#modal_message #message').html(result.message);
                        // $("#modal_message").modal('show');
                        loading.stop();
                    },
                    error: function() {
                        loading.stop();
                        $("#msg_alert_submit").html('<font color="#eb3a28"><i class="fa fa-close (alias)">&nbsp;</i><strong>Gagal : Terjadi Kesalahan</strong></font>');
                        $("#msg_alert_submit").attr("class","pr-2 show");
                        // $('#modal_message #message').html('<font color="#eb3a28"><i class="fa fa-close (alias)">&nbsp;</i><strong>Gagal : Terjadi Kesalahan</strong></font>');
                        // $("#modal_message").modal('show');
                    }
                });
            }else{
                loading.stop();
                $("#msg_alert_submit").html('<font color="#eb3a28"><i class="fa fa-close (alias)">&nbsp;</i><strong>Pilihan approval harus terisi semua</strong></font>');
                $("#msg_alert_submit").attr("class","pr-2 show");
                // $('#modal_message #message').html('<font color="#eb3a28"><i class="fa fa-close (alias)">&nbsp;</i><strong>Pilihan approval harus terisi semua</strong></font>');
                // $("#modal_message").modal('show');
            }
        }));
    });
</script>
<div class="content-header">
    <div class="row align-items-center">
        <div class="content-header-left col-md-6 col-12 mb-md-0 mb-1">
            <h3 class="content-header-title"><?= $judul ?></h3>
            <div class="row breadcrumbs-top">
                <div class="breadcrumb-wrapper col-12">
                    <ol class="breadcrumb">
                        <li class="breadcrumb-item"><a href="#">Reimbursement</a>
                        </li>
                        <li class="breadcrumb-item active"><?= $judul ?>
                        </li>
                    </ol>
                </div>
            </div>
        </div>
        <div class="content-header-right col-md-6 col-12">
            <!-- <div class="float-md-right">
                <a href="<?= site_url(); ?>/informasi/gaji/import-main">
                <button type="button" class="btn_tambah btn btn-biru">
                    <i class="fa fa-upload"></i> Import Data
                </button>
                </a>
            </div> -->
        </div>
    </div>
</div>

<div class="card card-rounded">
    <div class="card-content">
        <div class="card-body">
            <div class="row">
                <div class="col-md-6">
                    <div class="row">
                        <div class="col-md-4" style="color: black; font-weight: bold;">Nama Karyawan</div>
                        <div class="col-md-8" style="color: black; font-weight: bold;">: <?= ((isset($data_pengajuan->nama_karyawan))?$data_pengajuan->nik." - ".$data_pengajuan->nama_karyawan:"") ?></div>
                    </div>
                    <div class="row">
                        <div class="col-md-4" style="color: black; font-weight: bold;">Jabatan</div>
                        <div class="col-md-8" style="color: black; font-weight: bold;">: <?= ((isset($data_pengajuan->nama_jabatan))?$data_pengajuan->kode_jabatan." - ".$data_pengajuan->nama_jabatan:"") ?></div>
                    </div>
                    <div class="row">
                        <div class="col-md-4" style="color: black; font-weight: bold;">Cabang</div>
                        <div class="col-md-8" style="color: black; font-weight: bold;">: <?= ((isset($data_pengajuan->nama_cabang))?$data_pengajuan->kode_cabang." - ".$data_pengajuan->nama_cabang:"") ?></div>
                    </div>
                    <div class="row">
                        <div class="col-md-4" style="color: black; font-weight: bold;">Departemen</div>
                        <div class="col-md-8" style="color: black; font-weight: bold;">: <?= ((isset($data_pengajuan->departemen_karyawan))?$data_pengajuan->kode_departemen." - ".$data_pengajuan->departemen_karyawan:"") ?></div>
                    </div>
                </div>
                <div class="col-md-6">
                    <div class="row">
                        <div class="col-md-4" style="color: black; font-weight: bold;">Nomor Pengajaun</div>
                        <div class="col-md-8" style="color: black; font-weight: bold;">: <?= ((isset($data_pengajuan->no_pengajuan))?$data_pengajuan->no_pengajuan:"") ?></div>
                    </div>
                    <div class="row">
                        <div class="col-md-4" style="color: black; font-weight: bold;">Tanggal Pengajuan</div>
                        <div class="col-md-8" style="color: black; font-weight: bold;">: <?= ((isset($data_pengajuan->tgl_pengajuan))?date_format(date_create($data_pengajuan->tgl_pengajuan),"d-m-Y"):"") ?></div>
                    </div>
                    <div class="row">
                        <div class="col-md-4" style="color: black; font-weight: bold;">Keterangan</div>
                        <div class="col-md-8" style="color: black; font-weight: bold;">: <?= ((isset($data_pengajuan->keterangan))?$data_pengajuan->keterangan:"") ?></div>
                    </div>
                </div>
            </div><br>

            <div class="row">
                <div class="col-md-12" style="overflow-x: auto;">
                    <form id="form-hod">
                    <input type="hidden" id="id_pengajuan_reimburse" name="id_pengajuan_reimburse" value="<?= ((isset($data_pengajuan->id))?$data_pengajuan->id:"") ?>">
                    <table class="table table-bordered table-hover" style="width: 100%;">
                        <thead style="background-color: #1c77d4; color:#fff; font-weight:600;">
                            <tr class="bg-tr">
                                <th class="text-center" style="width: 5px;">NO</th>
                                <th class="text-center">PLAFON</th>
                                <th class="text-center">MAX PLAFON</th>
                                <th class="text-center">NOMINAL<br>PENGAJUAN</th>
                                <th class="text-center">KETERANGAN</th>
                                <th class="text-center">TANGGAL BUKTI</th>
                                <?php
                                    if (($status == '1' && $this->adm_reimbursement == true) || $status == '5') {
                                ?>
                                        <th style="text-align: center;">NOMINAL<br>APPROVAL</th>
                                <?php
                                    }
                                ?>
                                <th class="text-center">BUKTI NOTA</th>
                                <?php if ((($approve_sebagai == 4 && $this->adm_reimbursement == true && $status == "1") || ($status != "1" && $this->adm_reimbursement == true) && $aktif == "reimburse")) {?>
                                    <th class="text-center">AKUN REIMBURSEMENT</th>
                                <?php } ?>
                                <th class="text-center">KETERANGAN<br>DITOLAK</th>
                                <th class="text-center">KETERANGAN<br>REVISI</th>
                                <?php if ($approve_sebagai != 4) { ?>
                                    <th class="text-center">KETERANGAN<br>APPROVE</th>
                                <?php
                                }else{
                                ?>
                                    <th class="text-center">CATATAN<br>APPROVE</th>
                                <?php } ?>
                                <th class="text-center">DITOLAK</th>
                                <th class="text-center">REVISI</th>
                                <th class="text-center">APPROVE</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php
                                $total_pengajuan = 0;
                                $total_approval = 0;
                                $no=0; // penomoran data table
                                // $ke_=0; // penomoran id termasuk data yang tidak tampil

                                foreach($list_pengajuan as $rows){
                                    // $ke_++;
                                    if ($this->level_user == "7") {
                                        $apv_user = $rows->apv_spv;
                                    }else if($this->level_user == "2"){
                                        $apv_user = $rows->apv_kedep;
                                    }else if($this->level_user == "5"){
                                        $apv_user = $rows->apv_kacab;
                                    }else if($this->level_user == "4"){
                                        $apv_user = $rows->apv_direksi;
                                    }else{
                                        $apv_user = "";
                                    }


                                    // tolak sebagai
                                    switch ($tolak_sebagai[($no+1)]) {
                                        case 0:
                                            $apv_user_sebelumnya = $rows->apv_spv;
                                            break;

                                        case 1:
                                            $apv_user_sebelumnya = $rows->apv_kedep;
                                            break;

                                        case 2:
                                            $apv_user_sebelumnya = $rows->apv_kacab;
                                            break;

                                        case 3:
                                            $apv_user_sebelumnya = $rows->apv_direksi;
                                            break;

                                        case 4:
                                            $apv_user_sebelumnya = $rows->apv_finance;
                                            break;

                                        default:
                                            $apv_user_sebelumnya = '';
                                            break;
                                    }

                                    // catatan approval / keterangan approval
                                    $catatan = '<br><br><b>CATATAN '.$ket_arr[1].'</b><br>';
                                    switch ($ket_arr[0]) {
                                        case 0:
                                            // spv
                                            $ket_approve = $rows->ket_apv_spv;
                                            if (empty($apv_user_sebelumnya)) {
                                                $apv_user_sebelumnya = $rows->apv_spv;
                                            }
                                            // $ket_revisi = $rows->ket_rev_spv;
                                            // $ket_tolak = $rows->ket_tolak_spv;
                                            break;

                                        case 1:
                                            // kedep
                                            $ket_approve = $rows->ket_apv_kedep;
                                            if (empty($apv_user_sebelumnya)) {
                                                $apv_user_sebelumnya = $rows->apv_kedep;
                                            }
                                            // $ket_revisi = $rows->ket_rev_kedep;
                                            // $ket_tolak = $rows->ket_tolak_kedep;
                                            break;

                                        case 2:
                                            // kacab
                                            $ket_approve = $rows->ket_apv_kacab;
                                            if (empty($apv_user_sebelumnya)) {
                                                $apv_user_sebelumnya = $rows->apv_kacab;
                                            }
                                            // $ket_revisi = $rows->ket_rev_kacab;
                                            // $ket_tolak = $rows->ket_tolak_kacab;
                                            break;

                                        case 3:
                                            // direksi
                                            $ket_approve = $rows->ket_apv_direksi;
                                            if (empty($apv_user_sebelumnya)) {
                                                $apv_user_sebelumnya = $rows->apv_direksi;
                                            }
                                            // $ket_revisi = $rows->ket_rev_direksi;
                                            // $ket_tolak = $rows->ket_tolak_direksi;
                                            break;

                                        case 4:
                                            // adm finance
                                            $ket_approve = $rows->ket_apv_finance;
                                            if (empty($apv_user_sebelumnya)) {
                                                $apv_user_sebelumnya = $rows->apv_finance;
                                            }
                                            break;

                                        default:
                                            $apv_user_sebelumnya = '';
                                            $ket_approve = '';
                                            break;
                                    }

                                    // jika klik verifikasi sebagai spv
                                    if ($approve_sebagai == 0) {
                                        $catatan = '';
                                    }else{
                                        // cek jika ada catatan
                                        if (!empty($ket_approve)) {
                                            $catatan .= $ket_approve;
                                        }else{
                                            $catatan = '';
                                        }
                                    }

                                    // jika data tidak ditolak
                                    if ($apv_user_sebelumnya != '3' || $status != '1') {
                                        $no++;
                                        $total_pengajuan    = $total_pengajuan + $rows->nominal;
                                        $total_approval     = $total_approval + $rows->nominal_disetujui;
                                        $isHidden = '';
                                    }else{
                                        $isHidden = 'hidden';
                                    }
                                    if ($isHidden != "hidden") {
                            ?>
                                        <tr id="rows_colom">
                                            <input type="hidden" id="id_reimburse_<?= $no ?>" name="id_reimburse_<?= $no ?>" value="<?= $rows->id ?>">
                                            <input type="hidden" id="nm_plafon_<?= $no ?>" name="nm_plafon_<?= $no ?>" value="<?=$rows->jenis_plafon ?>">
                                            <?php
                                                if ($apv_user_sebelumnya == '3' && $status != '1') {
                                            ?>
                                                    <input type="hidden" id="ket_ditolak_<?= $no ?>" name="ket_ditolak_<?= $no ?>" value="<?= $ket_tolak ?>">
                                            <?php
                                                }else{
                                            ?>
                                                    <input type="hidden" id="ket_ditolak_<?= $no ?>" name="ket_ditolak_<?= $no ?>" value="">
                                            <?php
                                                }
                                            ?>

                                            <?php
                                                if ($apv_user_sebelumnya == '4' && $status != '1') {
                                            ?>
                                            <input type="hidden" id="ket_revisi_<?= $no ?>" name="ket_revisi_<?= $no ?>" value="<?= $ket_revisi ?>">
                                            <?php
                                                }else{
                                            ?>
                                            <input type="hidden" id="ket_revisi_<?= $no ?>" name="ket_revisi_<?= $no ?>" value="">
                                            <?php
                                                }
                                            ?>

                                            <?php
                                                if ($apv_user_sebelumnya == '5' && $status != '1') {
                                            ?>
                                            <input type="hidden" id="ket_approve_<?= $no ?>" name="ket_approve_<?= $no ?>" value="<?= $ket_approve ?>">
                                            <?php
                                                }else{
                                            ?>
                                            <input type="hidden" id="ket_approve_<?= $no ?>" name="ket_approve_<?= $no ?>" value="">
                                            <?php
                                                }
                                            ?>
                                            <?php
                                                if ($rows->nominal_disetujui != 0) {
                                                    $nominal_asli = $rows->nominal_disetujui;
                                                }else{
                                                    $nominal_asli = $rows->nominal;
                                                }
                                            ?>
                                            <input type="hidden" class="nominal_setuju" id="nominal_setuju_<?= $no ?>" name="nominal_setuju_<?= $no ?>" value="<?= number_format($nominal_asli,0,',','.') ?>">
                                            <input type="hidden" id="max_plafon_<?= $no ?>" value="<?= number_format($rows->max_nominal_plafon,0,',','.') ?>">
                                            <td class="text-center <?= $isHidden ?>"><?= $no ?></td>
                                            <td class="<?= $isHidden ?>"><?= $rows->jenis_plafon ?></td>
                                            <td class="text-right <?= $isHidden ?>"><?= number_format($rows->max_nominal_plafon,0,",",".") ?></td>
                                            <td class="text-right <?= $isHidden ?>"><?= number_format($rows->nominal,0,",",".") ?></td>
                                            <td class="<?= $isHidden ?>"><?= $rows->ket_reimburse.$catatan ?></td>
                                            <td class="text-center <?= $isHidden ?>"><?= date_format(date_create($rows->tgl_bukti),"d-m-Y")  ?></td>
                                            <!-- <td class="text-center"><a href="<?= $rows->file ?>" target="_blank">Lihat Nota</a></td> -->
                                            <?php
                                                if (($status == '1' && $this->adm_reimbursement == true) || $status == "5") {
                                            ?>
                                                    <td class="text-right <?= $isHidden ?>" id="setuju_<?= $no ?>">
                                                        <?php
                                                            if ($rows->nominal_disetujui != 0) {
                                                                $nominal = $rows->nominal_disetujui;
                                                            }else{
                                                                $nominal = $rows->nominal;
                                                            }
                                                            echo number_format($nominal,0,",",".");
                                                            if($approve_sebagai == 4 && $aktif == "reimburse" && $this->adm_reimbursement == true){
                                                                echo ' <a href="#" class="fa fa-edit btn_nominal" id="nominal" baris-ke="'.$no.'"></a>';
                                                            }
                                                        ?>
                                                    </td>
                                            <?php
                                                }
                                            ?>
                                            <td class="text-center <?= $isHidden ?>">
                                                <a href="#" id="<?= md5($rows->id) ?>">
                                                    <?php
                                                        $file = $this->config->item('base_image').'image?_t=image&_d='.$rows->file;
                                                    ?>
                                                    <input type="hidden" name="gambar" id="<?= $rows->id ?>" value="<?= $rows->file ?>" image="<?= $file ?>">
                                                    Lihat Gambar
                                                </a>
                                            </td>
                                            <?php
                                                if ($status != '1' && $this->adm_reimbursement == true && $aktif == "reimburse"){ ?>
                                                    <td id="akun_<?= $no ?>">
                                                        <?= $rows->kode_akun ?>
                                                    </td>
                                            <?php }else{
                                                    if ($approve_sebagai == 4 && $aktif == "reimburse" && $this->adm_reimbursement == true) {
                                                        ?>
                                                        <td id="akun_<?= $no ?>" class="<?= $isHidden ?>">
                                                            <select class="form-control" name="id_akun_<?= $no ?>" >
                                                                <option value="">Pilih</option>
                                                                <?php foreach ($list_akun as $akun) { ?>
                                                                    <option value="<?= $akun->kode_akun."-".$akun->nama_akun ?>"<?= ($rows->kode_akun == $akun->kode_akun."-".$akun->nama_akun) ? "selected" : "" ?>>
                                                                        <?= $akun->kode_akun."-".$akun->nama_akun ?>
                                                                    </option>
                                                                    <?php } ?>
                                                            </select>
                                                        </td>
                                            <?php
                                                    }
                                                }
                                            ?>
                                            <script type="text/javascript">
                                                $("#<?= md5($rows->id) ?>").on("click", function() {
                                                    $('#imagepreview').attr('src', $('#<?= $rows->id ?>').attr("image"));
                                                    $('#imagemodal').modal('show'); // imagemodal is the id attribute assigned to the bootstrap modal, then i use the show function
                                                });
                                            </script>
                                            <td id="kolom_ditolak_<?= $no ?>" class="<?= $isHidden ?>"></td>
                                            <td id="kolom_<?= $no ?>" class="<?= $isHidden ?>"></td>
                                            <td id="kolom_approve_<?= $no ?>" class="<?= $isHidden ?>"></td>
                                            <td class="text-center <?= $isHidden ?>" style="width:100px" id="tolak_<?= $no ?>">
                                                <div class="form-check">
                                                    <?php
                                                        if ($aktif == "reimburse_saya"){
                                                            $radio_disable = ' disabled="true"';
                                                        }else{
                                                            if ($status == "1") {
                                                                $radio_disable = "";
                                                            }else{
                                                                $radio_disable = ' disabled="true"';
                                                            }
                                                        }

                                                        if ($apv_user_sebelumnya == '3' && $status != '1'){ # ditolak
                                                    ?>
                                                            <input type="radio" id="exampleRadios1_<?= $no ?>" name="status_reimburse_<?= $no ?>" class="1 status_reimburse form-check-input btn_ditolak" baris-ke="<?= $no ?>" value="3" <?php echo ($apv_user_sebelumnya=='3')?'checked':'' ?> disabled="true">
                                                    <?php
                                                        }else{ # jika tidak ditolak

                                                            # JIKA TIDAK PENGAJUAN DAN TIDAK ADMIN REIMBURSE
                                                            if ($status != '1' && $this->adm_reimbursement == false ) {
                                                    ?>
                                                                    <input type="radio" id="exampleRadios1_<?= $no ?>" name="status_reimburse_<?= $no ?>" class="2 status_reimburse form-check-input btn_ditolak" baris-ke="<?= $no ?>" value="" disabled="true">
                                                    <?php
                                                            }else{
                                                                if (!in_array($apv_user, ["0","1"]) && $this->adm_reimbursement == false ) {
                                                    ?>
                                                                    <input type="radio" id="exampleRadios1_<?= $no ?>" name="status_reimburse_<?= $no ?>" class="3 status_reimburse form-check-input btn_ditolak" baris-ke="<?= $no ?>" value="" disabled="true">
                                                    <?php
                                                                }else{
                                                    ?>
                                                                    <input type="radio" id="exampleRadios1_<?= $no ?>" name="status_reimburse_<?= $no ?>" class="4 status_reimburse form-check-input btn_ditolak" baris-ke="<?= $no ?>" value="3" <?= $radio_disable ?>>
                                                    <?php
                                                                }
                                                            }
                                                        }
                                                    ?>
                                                    <label class="form-check-label" for="exampleRadios1_<?= $no ?>" >&nbsp;</label>
                                                </div>
                                            </td>
                                            <td class="text-center <?= $isHidden ?>" style="width:100px" id="revisi_<?= $no ?>">
                                                <div class="form-check">
                                                    <?php
                                                        if($apv_user_sebelumnya == '4' && $status != '1'){
                                                    ?>
                                                            <input type="radio" id="exampleRadios2_<?= $no ?>" name="status_reimburse_<?= $no ?>" class="status_reimburse form-check-input btn_revisi" baris-ke="<?= $no ?>" value="4" <?php echo ($apv_user_sebelumnya=='4')?'checked':'' ?> disabled="true">
                                                    <?php
                                                        }else{
                                                            if ($status != '1' && $this->adm_reimbursement == false) {
                                                    ?>
                                                                <input type="radio" id="exampleRadios2_<?= $no ?>" name="status_reimburse_<?= $no ?>" class="status_reimburse form-check-input btn_revisi" baris-ke="<?= $no ?>" value="" disabled="true">
                                                    <?php
                                                            }else{
                                                                if (!in_array($apv_user, ["0","1"]) && $this->adm_reimbursement == false ) {
                                                    ?>
                                                                    <input type="radio" id="exampleRadios2_<?= $no ?>" name="status_reimburse_<?= $no ?>" class="status_reimburse form-check-input btn_revisi" baris-ke="<?= $no ?>" value="" disabled="true">
                                                    <?php
                                                                }else{
                                                    ?>
                                                                    <input type="radio" id="exampleRadios2_<?= $no ?>" name="status_reimburse_<?= $no ?>" class="status_reimburse form-check-input btn_revisi" baris-ke="<?= $no ?>" value="4" <?= $radio_disable ?>>
                                                    <?php
                                                                }
                                                            }
                                                        }
                                                    ?>
                                                    <label class="form-check-label" for="exampleRadios2_<?= $no ?>" >&nbsp;</label>
                                                </div>
                                            </td>
                                            <td class="text-center <?= $isHidden ?>" style="width:100px" id="setuju_<?= $no ?>">
                                                <div class="form-check">
                                                    <?php
                                                        if($apv_user_sebelumnya == '5' && $status != '1'){
                                                    ?>
                                                            <input type="radio" id="exampleRadios3_<?= $no ?>" name="status_reimburse_<?= $no ?>" class="status_reimburse form-check-input btn_approve" value="5" baris-ke="<?= $no ?>" <?php echo ($apv_user_sebelumnya=='5')?'checked':'' ?> disabled="true">
                                                    <?php
                                                        }else{
                                                            if ($status != '1' && $this->adm_reimbursement == false) {
                                                    ?>
                                                                <input type="radio" id="exampleRadios3_<?= $no ?>" name="status_reimburse_<?= $no ?>" class="status_reimburse form-check-input btn_approve" value="" baris-ke="<?= $no ?>" disabled="true">
                                                    <?php
                                                            }else{
                                                                if (!in_array($apv_user, ["0","1"]) && $this->adm_reimbursement == false ) {
                                                    ?>
                                                                    <input type="radio" id="exampleRadios3_<?= $no ?>" name="status_reimburse_<?= $no ?>" class="status_reimburse form-check-input btn_approve" value="" baris-ke="<?= $no ?>" disabled="true">
                                                    <?php
                                                                }else{
                                                    ?>
                                                                    <input type="radio" id="exampleRadios3_<?= $no ?>" name="status_reimburse_<?= $no ?>" class="status_reimburse form-check-input btn_approve" value="5" baris-ke="<?= $no ?>" <?= $radio_disable ?>>
                                                    <?php
                                                                }
                                                            }
                                                        }
                                                    ?>
                                                    <label class="form-check-label" for="exampleRadios3_<?= $no ?>">&nbsp;</label>
                                                </div>
                                            </td>
                                        </tr>
                            <?php
                                    }
                                }
                            ?>
                        </tbody>
                        <tfoot>
                            <tr class="noBorder" style="background-color: #e9ecef; color: black;">
                                <th colspan="3" class="text-right">TOTAL</th>
                                <th class="text-right"><?= number_format($total_pengajuan,0,",",".") ?></th>
                                <th>&nbsp;</th>
                                <?php
                                    if (($status == '1' && $this->adm_reimbursement == true) || $status == '5') {
                                ?>
                                <th class="text-center">TOTAL APPROVAL</th>
                                <th class="text-right" id="total_approval"><?= number_format($total_approval,0,",",".") ?></th>
                                <?php
                                    }
                                ?>
                                <th colspan="10" class="text-right">
                                    <input type="hidden" name="jumlah_data" id="jumlah_data" value="<?= $no ?>">
                                    <input type="hidden" name="approve_sebagai" id="approve_sebagai" value="<?= ($this->adm_reimbursement && $approve_sebagai == 4)?$approve_sebagai:"" ?>">
                                    <label id="msg_alert_submit" class="pr-2 hidden">
                                        <!-- <font color="#eb3a28"><i class="fa fa-close (alias)">&nbsp;</i><strong>Pilihan approval harus terisi semua</strong></font> -->
                                    </label>
                                    <a href="#" onclick="history.back()" class="btn btn-secondary"><i class="fa fa-arrow-left"></i> KEMBALI</a>
                                    <?php

                                        $btn_submit = '<button type="submit" id="btn_submit" class="btn btn-success ladda-button" data-style="expand-left"><i class="fa fa-check-circle-o"></i> SUBMIT</button>';
                                        // adm reimburse
                                        if ($this->adm_reimbursement == true && $status == '1' && $aktif == "reimburse"){
                                            echo $btn_submit;
                                        }else{
                                            if($this->level_user == '7' && $approve_sebagai == '0' && $status == '1'){  // supervisi
                                                echo $btn_submit;
                                            }else if($this->level_user == '2' && $approve_sebagai == '1' && $status == '1'){    // kepala departemen
                                                echo $btn_submit;
                                            }else if($this->level_user == '5' && $approve_sebagai == '2' && $status == '1'){  // kepala cabang
                                                echo $btn_submit;
                                            }else if($this->level_user == '4' && $approve_sebagai == '3' && $status == '1'){  // direksi
                                                echo $btn_submit;
                                            }
                                        }
                                    ?>
                                </th>
                            </tr>
                            <style type="text/css">
                                tr.noBorder td {
                                    border: 0;
                                }
                            </style>
                        </tfoot>
                    </table>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- START TAMPIL MODAL -->
<div id="modal_approve" class="modal fade in">
    <div class="modal-dialog modal-md">
        <div class="modal-content">
            <div class="card-header">
                <h3 class="modal-title"><?= ($this->adm_reimbursement && $approve_sebagai == 4) ? 'KETERANGAN APPROVE' : 'CATATAN UNTUK ATASAN' ?></h3>
            </div>
            <div id="form_approve" class="card-body">
                <input type="hidden" id="id_approve">
                <div class="form-group">
                    <textarea id="ket_approve_modal" class="form-control" rows="3"></textarea>
                </div>
            </div>
            <div class="card-footer">
                <div class="row">
                    <div class="col-md-12 text-right">
                        <button class="btn btn-secondary cancel" onclick="hapus_kolom($('#form_approve #id_approve').val(),'modal_approve')" data-dismiss="modal"><i class="fa fa-arrow-left"></i> CANCEL</button>
                        <button class="btn_submit_approve btn btn-success ladda-button" data-style="expand-left"><i class="fa fa-check-circle-o"></i> SUBMIT</button>
                    </div>
                </div><!-- ./row -->
            </div>
        </div>
    </div>
</div>
<!-- END TAMPIL MODAL -->

<!-- START TAMPIL MODAL -->
<div id="modal_revisi" class="modal fade in">
    <div class="modal-dialog modal-md">
        <div class="modal-content">
            <div class="card-header">
                <h3 class="modal-title">KETERANGAN REVISI</h3>
            </div>
            <div id="form_input" class="card-body">
                <input type="hidden" id="id_revisi">
                <div class="form-group">
                    <textarea id="ket_revisi_modal" class="form-control" rows="3" required></textarea>
                </div>
            </div>
            <div class="card-footer">
                <div class="row">
                    <div class="col-md-6 text-left d-flex my-auto">
                        <div id="msg_modal_revisi" class="hidden">
                            <font color="#eb3a28"><i class="fa fa-close (alias)">&nbsp;</i><strong>Keterangan revisi harus diisi</strong></font>
                        </div>
                    </div>
                    <div class="col-md-6 text-right">
                        <button class="btn btn-secondary cancel" onclick="hapus_kolom($('#form_input #id_revisi').val(),'modal_revisi')" data-dismiss="modal"><i class="fa fa-arrow-left"></i> CANCEL</button>
                        <button class="btn_submit_revisi btn btn-success ladda-button" data-style="expand-left"><i class="fa fa-check-circle-o"></i> SUBMIT</button>
                    </div>
                </div><!-- ./row -->
            </div>
        </div>
    </div>
</div>
<!-- END TAMPIL MODAL -->

<!-- START TAMPIL MODAL -->
<div id="modal_ditolak" class="modal fade in">
    <div class="modal-dialog modal-md">
        <div class="modal-content">
            <div class="card-header">
                <h3 class="modal-title">KETERANGAN DITOLAK</h3>
            </div>
            <div id="form_ditolak" class="card-body">
                <input type="hidden" id="id_ditolak">
                <div class="form-group">
                    <textarea id="ket_ditolak_modal" class="form-control" rows="3" required></textarea>
                </div>
            </div>
            <div class="card-footer">
                <div class="row">
                    <div class="col-md-6 text-left d-flex my-auto">
                        <div id="msg_modal_ditolak" class="hidden">
                            <font color="#eb3a28"><i class="fa fa-close (alias)">&nbsp;</i><strong>Keterangan ditolak harus diisi</strong></font>
                        </div>
                    </div>
                    <div class="col-md-6 text-right">
                        <button class="btn btn-secondary cancel" onclick="hapus_kolom($('#form_ditolak #id_ditolak').val(),'modal_ditolak')" data-dismiss="modal"><i class="fa fa-arrow-left"></i> CANCEL</button>
                        <button class="btn_submit_ditolak btn btn-success ladda-button" data-style="expand-left"><i class="fa fa-check-circle-o"></i> SUBMIT</button>
                    </div>
                </div><!-- ./row -->
            </div>
        </div>
    </div>
</div>
<!-- END TAMPIL MODAL -->

<!-- START TAMPIL MODAL -->
<div id="modal_nominal" class="modal fade in">
    <div class="modal-dialog modal-md">
        <div class="modal-content">
            <div class="card-header">
                <h3 class="modal-title">NOMINAL DISTUJUI</h3>
            </div>
            <div id="form_input_nominal" class="card-body">
                <input type="hidden" id="id_setuju">
                <div class="form-group">
                    <input type="text" id="nominal_setuju_modal" class="form-control testInput">
                    <p id="max_plafon_modal"></p>
                    <script type="text/javascript">
                        $(".testInput").autoNumeric('init', {
                            aSep: '.',
                            aDec: ',',
                            aForm: true,
                            vMax: '999999999',
                            vMin: '0'
                        });
                    </script>
                </div>
            </div>
            <div class="card-footer">
                <div class="row">
                    <div class="col-md-12 text-right">
                        <button class="btn btn-secondary cancel" data-dismiss="modal">BATAL</button>
                        <button class="btn_submit_nominal btn btn-primary ladda-button" data-style="expand-left">SUBMIT</button>
                    </div>
                </div><!-- ./row -->
            </div>
        </div>
    </div>
</div>
<!-- END TAMPIL MODAL -->

<!-- START TAMPIL MODAL MESSAGE-->
<div id="modal_message" class="modal fade in">
    <div class="modal-dialog modal-md">
        <div class="modal-content">
            <div id="message" class="card-body"></div>
            <div class="card-footer">
                <div class="row">
                    <div class="col-md-12 text-right">
                    <button class="btn btn-secondary ladda-button" data-style="expand-left" data-dismiss="modal">TUTUP</button>
                    </div>
                </div><!-- ./row -->
            </div>
        </div>
    </div>
</div>
<!-- END TAMPIL MODAL MESSAGE-->

<!-- Creates the bootstrap modal where the image will appear -->
<div class="modal fade" id="imagemodal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
        <div class="modal-header">
            <h4 class="modal-title" id="myModalLabel">BUKTI NOTA</h4>
            <button type="button" class="close btn btn-secondary" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">TUTUP</span></button>
        </div>
        <div class="modal-body text-center">
            <img src="" id="imagepreview" style="width: 100%;" >
        </div>
        <div class="modal-footer">
            <button type="button" class="btn btn btn-secondary" data-dismiss="modal">TUTUP</button>
        </div>
        </div>
    </div>
</div>
