<script src="<?php echo base_url();?>resources/js/autoNumeric.js"></script>
<div id="popup_add_biaya" class="centering" style="width:840px;margin-top: 1%;">
<div id='add_biaya' style="border: 1px solid #ffffff;">
    <div class="detil" style="padding: 2px;background-color: white;">
        <div id='content' style="margin: 5px;margin-top:10px; ">
            <table width="100%" id='infoPerkara' style="font-size:14px;" >
                <col  width="25%" />
                <col  width="75%" />
                <tbody>
                    <tr>
                        <td colspan="2" style="background:white;border:0px;font-size: 20px;color: #648C03;" align="center">TAMBAH BIAYA PERKARA</td>
                    </tr>
                    <tr>
                        <td bgcolor='#008C4B'><font color='#fff'>Nomor Perkara</td>
                        <td><?php echo $eksekusi_nomor_perkara;?></td>
                    </tr>
                    <tr>
                        <td bgcolor='#008C4B'><font color='#fff'>Tanggal Permohonan Eksekusi</td>
                        <td><?php echo $this->tanggalhelper->convertDayDate($permohonan_eksekusi);?></td>
                    </tr>
                    <tr>
                        <td bgcolor='#008C4B'><font color='#fff'>Pemohon Eksekusi</td>
                        <td><?php echo $pemohon_eksekusi;?></td>
                    </tr>                    
                    <tr>
                        <td bgcolor='#008C4B'><font color='#fff'>Prodeo</td>
                        <td><?php if($prodeo==1){
                                echo "Ya";
                            }else{
                                echo "Tidak";
                            }
                            ?></td>
                    </tr>
                </tbody>
            </table>
        <p>
        <form id="frm_add_biaya" style="background:white;margin:0;" method="post" action="<?php echo base_url().'detil_biaya_ht/validateInput';?>">
            <table id="tableDetilPerkara" style="font-size:14px;">
                <col width="25%">
                <col width="75%">
                    <tbody>

                        <tr>
                            <td bgcolor='#008C4B'><font color='#fff'>Tanggal Transaksi</td>
                            <td style="padding:0px;padding-left:5px;">
                                <input id="tgl_transaksi" name="tgl_transaksi" value="<?php echo (!empty($tgl_transaksi) ? $this->tanggalhelper->convertToInputDate($tgl_transaksi) : '');?>" class="datepicker" maxlength="10" placeholder="tgl/bln/tahun">
                            </td>
                        </tr>
                        <tr>
                            <td bgcolor='#008C4B'><font color='#fff'>Kategori Biaya</td>
                            <td style="padding:0px;padding-left:5px;">
                                <span class="custom-dropdown custom-dropdown--emerald" style="width:300px">
                                    <select name="kategori_biaya" id="kategori_biaya" style='width:300px;' class="custom-dropdown__select custom-dropdown__select--white">
                                        <option value="">Pilih Kategori Biaya</option>
                                        <?php
                                            if($data_kategori_biaya!=''){
                                                if($data_kategori_biaya->num_rows>0){
                                                    
                                                    foreach ($data_kategori_biaya->result() as $row) {
                                                        echo '<option value="'.$row->id.'" ';echo ($row->id == $id_kategori_biaya) ? 'selected' : ''; echo ' >'.$row->nama.'</option>';
                                                    }
                                                }
                                            }
                                        ?>
                                    </select>
                                </span>

                            </td>
                        </tr>
                        <tr>
                            <td bgcolor='#008C4B'><font color='#fff'>Jenis Biaya</td>
                            <td style="padding:0px;padding-left:5px;">
                                <span class="custom-dropdown custom-dropdown--emerald" style="width:300px">
                                    <select name="jenis_biaya" id="jenis_biaya" style='width:300px;' class="custom-dropdown__select custom-dropdown__select--white">
                                        <option value="">Pilih Jenis Biaya</option>
                                        <?php
                                            if($data_jenis_biaya!=''){
                                                if($data_jenis_biaya->num_rows>0){
                                                    
                                                    foreach ($data_jenis_biaya->result() as $row) {
                                                        echo '<option class="jBiaya" id="'.$row->kategori_id.'" value="'.$row->id.'" ';echo ($row->id == $id_jenis_biaya) ? 'selected' : ''; echo ' >'.$row->nama.'</option>';
                                                    }
                                                }
                                            }
                                        ?>

                                    </select>
                                </span>

                            </td>
                        </tr>
                        <tr>
                            <td bgcolor='#008C4B'><font color='#fff'>Uraian</td>
                            <td style="padding:0px;padding-left:5px;">
                                <textarea id="uraian" name="uraian" class="standard-input" style="resize: none;margin: 0px; width: 600px; height: 60px;" ><?php echo (!empty($uraian) ? $uraian : '');?></textarea>
                                
                            </td>
                        </tr>
                        <tr>
                            <td bgcolor='#008C4B'><font color='#fff'>Jumlah</td>
                            <td style="padding:0px;padding-left:5px;">
                                <input data-a-sep="." data-a-dec="," type="text" id="jumlah" name="jumlah" value="<?php echo (!empty($jumlah) ? $jumlah : '');?>" class="standard-input" style="width:220px;">

                            </td>
                        </tr>

                        <tr>
                            <td bgcolor='#008C4B'><font color='#fff'>Keterangan</td>
                            <td style="padding:0px;padding-left:5px;">
                                <textarea id="keterangan" name="keterangan" class="standard-input" style="resize: none;margin: 0px; width: 600px; height: 60px;" ><?php echo (!empty($keterangan) ? $keterangan : '');?></textarea>
                                
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2" style="background:white;" align="center">
                            <?php
                            
                            ?>
                            <input type="hidden" id="alur_perkara_id" name="alur_perkara_id" value="<?php echo $alur_perkara;?>">
                            <input type="hidden" id="aksi" name="aksi" value="<?php echo $aksi;?>">
                            <input type="hidden" id="idbiayaperkara" name="idbiayaperkara" value="<?php echo $idbiayaperkara;?>">
                            <input type="hidden" id="tahapan_terakhir_id" name="tahapan_terakhir_id" value="<?php echo $tahapan;?>">
                            <input type="hidden" id="ht_id" name="ht_id" value="<?php echo $ht_id; ?>">
                            <input type="hidden" id="curr_date" name="curr_date" value="<?php echo $tgl_sekarang;?>">
                            <input type="hidden" id="tanggal_pendaftaran" name="tanggal_pendaftaran" value="<?php echo $permohonan_eksekusi;?>">
                            <input type="button" id='close_add_biaya' id="kembali" value="Kembali" class="btn">
                            <input type="submit" id="simpan_btn" value="Simpan" class="btn">
                                <?php
                                if($aksi!=''){
                                    echo '<input type="button" id="hapus" value="Hapus" style="text-decoration:none" class="btn btn-danger">';    
                                }
                                ?>
                        </td>
                        </tr>
                    </tbody>

            </table>
        </form>

        </div>
    </div>
</div>
</div>

<script type="text/javascript">

// $('#close_add_biaya').click(function(){
//     window.open("<?php #echo $previous;?>","_self");
// });

$(document).ready(function() {
    $('#jumlah').ForceNumericOnly();
    $('#jumlah').autoNumeric('init', {mDec: '0'});

});

$('#kategori_biaya').change(function(e){
    $('#jenis_biaya').val("")
    $('.jBiaya').show();
    var kat_biaya = $(this).val();
    $('.jBiaya').not('#'+kat_biaya).hide();
    if($(this).val()==""){
        $('#jenis_biaya').prop('disabled', true);
    }else{
        $('#jenis_biaya').prop('disabled', false);
    }
});
$('#jenis_biaya').change(function(e){
  var uraian = $('#jenis_biaya option:selected').text();
  $('#uraian').val(uraian) ;
});

$('#jenis_biaya').prop('disabled', true);
$('#tgl_transaksi').datepicker({
            inline: true,
            showOtherMonths: true,
            dateFormat: 'dd/mm/yy',
            dayNamesMin: ['Ming', 'Sen', 'Sel', 'Rab', 'Kam', 'Jum', 'Sab'],
            beforeShowDay:$.datepicker.noWeekends,
            onSelect: function(dateText, inst) {
                var error = 0;
                
                var tmp = $(this).val().split("/");
                var tmp2 = $('#curr_date').val().split("/");
                if((new Date(tmp[2]+"-"+tmp[1]+"-"+tmp[0]+"T00:00:00").getTime() > new Date(tmp2[2]+"-"+tmp2[1]+"-"+tmp2[0]+"T00:00:00").getTime())){
                    message = 'Tidak Dapat Memilih Melebihi Hari ini. Sekarang Tanggal '+$('#curr_date').val();
                    error = 1
                }

                if(error==1){
                    message_error_show(message);
                    $(this).css("background-color", "red");
                }else{
                    $(this).css("background-color", "#dedbdb");
                }
                error = 0;
            }
        });

$('#frm_add_biaya').SubmitHandling({
    refresh:'1',
    setRefresh:1,
    divRef:'#konten',
    clicked:1,
    btnClicked:'#close_add_biaya',
    whenStatus:1,
    next_step:1   
});

$('#hapus').ButtonClickHandling({
    refresh:'1',
    setRefresh:1,
    divRef:'#konten',
    clicked:1,
    btnClicked:'#close_add_biaya',
    whenStatus:1,
    actions:'<?php echo base_url()?>detil_biaya_ht/hapus_perkara_biaya_ht/<?php echo $idbiayaperkara; ?>',
    formName:'#frm_add_biaya',
    actionName:'Hapus Data'
});

$('#close_add_biaya').click(function(){
    var ht_id = '<?php echo $ht_id; ?>';    
    window.open("<?php echo base_url()?>biaya_detil_ht/"+ht_id,"_self");    
}); 

// $('#close_add_biaya').closingFormWin();

$('.datepicker').ValidateDateInput();


</script>        