<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">TEGURAN BIAYA PERKARA</td>
                    </tr>
                    <tr>
                        <td bgcolor='#008C4B'><font color='#fff'>Nomor Perkara</td>
                        <td><?php echo $nomor_perkara;?></td>
                    </tr>
                    <tr>
                        <td bgcolor='#008C4B'><font color='#fff'>Tanggal Pendaftaran</td>
                        <td><?php echo $this->tanggalhelper->convertDayDate($tanggal_pendaftaran);?></td>
                    </tr>
                    <?php
                    if(($alur_perkara_id==1|| $alur_perkara_id==15) && $tahapan_terakhir_id<20){
                      echo "
                            <tr>
                                <td bgcolor='#008C4B'><font color='#fff'>Penggugat</td>
                                <td>".$pihak1_text."</td>
                            </tr>
                            <tr>
                                <td bgcolor='#008C4B'><font color='#fff'>Tergugat</td>
                                <td>".$pihak2_text."</td>
                            </tr>";
                    }elseif(($alur_perkara_id==2||$alur_perkara_id==16) && $tahapan_terakhir_id<20){
                      echo "<tr>
                                <td bgcolor='#008C4B'><font color='#fff'>Pemohon</td>
                                <td>".$pihak1_text."</td>
                            </tr>";

                    }elseif(($alur_perkara_id==1 || $alur_perkara_id==2 || $alur_perkara_id==15) && $tahapan_terakhir_id==20){
                      echo "
                            <tr>
                                <td bgcolor='#008C4B'><font color='#fff'>Pembanding/Tergugat</td>
                                <td>".$pihak2_text."</td>
                            </tr>
                            <tr>
                                <td bgcolor='#008C4B'><font color='#fff'>Terbanding/Penggugat</td>
                                <td>".$pihak1_text."</td>
                            </tr>";

                    }elseif(($alur_perkara_id==1 || $alur_perkara_id==2 || $alur_perkara_id==15 || $alur_perkara_id==16) && $tahapan_terakhir_id==30){
                      echo "
                            <tr>
                                <td bgcolor='#008C4B'><font color='#fff'>Pemohon Kasasi/Penggugat</td>
                                <td>".$pihak1_text."</td>
                            </tr>
                    
                            <tr>
                                <td bgcolor='#008C4B'><font color='#fff'>Termohon Kasasi/Tergugat</td>
                                <td>".$pihak2_text."</td>
                            </tr>";

                    }elseif(($alur_perkara_id==1 || $alur_perkara_id==2 || $alur_perkara_id==15 || $alur_perkara_id==16) && $tahapan_terakhir_id==40){
                      echo "
                            <tr>
                                <td bgcolor='#008C4B'><font color='#fff'>Pemohon PK/Tergugat</td>
                                <td>".$pihak2_text."</td>
                            </tr>
                            <tr>
                                <td bgcolor='#008C4B'><font color='#fff'>Termohon PK/Penggugat</td>
                                <td>".$pihak1_text."</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/validateInput';?>">
            <table id="tableDetilPerkara" style="font-size:14px;">
                <col width="30%">
                <col width="70%">
                    <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'>Pihak</td>
                            <td style="padding:0px;padding-left:5px;">
                                <span class="custom-dropdown custom-dropdown--emerald" style="width:300px">
                                    <select name="fpihak_ke" id="fpihak_ke" style='width:300px;' class="custom-dropdown__select custom-dropdown__select--white">
                                        <?php 
                                            $alurPerkaraID = $this->encrypt->decode(base64_decode($alur_perkara));
                                            if($alurPerkaraID==2 OR $alurPerkaraID==3 OR $alurPerkaraID==4 OR $alurPerkaraID==16){
                                                $pihak1 = 'Pemohon';
                                                $pihak2 = 'Termohon';
                                            }else{
                                                $pihak1 = 'Penggugat';
                                                $pihak2 = 'Tergugat';
                                            }
                                         ?>
                                        <option value="">Pilih Pihak Pembayar</option>
                                        <option value="1"><?php echo $pihak1; ?></option>
                                        <option value="2"><?php echo $pihak2; ?></option>
                                    </select>
                                </span>

                            </td>
                        </tr>
                        <tr>
                            <td bgcolor='#008C4B'><font color='#fff'>Pihak yang membayar</td>
                            <td style="padding:0px;padding-left:5px;">
                                <span class="custom-dropdown custom-dropdown--emerald" style="width:300px">
                                    <select name="pihak_pembayar" id="pihak_pembayar" style='width:300px;' class="custom-dropdown__select custom-dropdown__select--white">
                                        <option value="">Pilih Nama Pihak</option>
                                        <?php
                                            if($pihak_pembayar!=''){
                                                if($pihak_pembayar->num_rows>0){
                                                    foreach ($pihak_pembayar->result() as $row) {
                                                        echo '<option class="jpembayar" id="'.$row->pihak_ke.'" value="'.$row->pihak_id.'" ';echo ($row->pihak_id == $pihak_id) ? 'selected' : ''; echo ' >'.$row->nama.'</option>';
                                                    }
                                                }
                                            }
                                        ?>
                                    </select>
                                </span>

                            </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->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="idperkara" name="idperkara" value="<?php echo $idperkara; ?>">
                            <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 $tanggal_pendaftaran;?>">
                            <input type="hidden" id="idkat" name="idkat" value="<?php echo $id_kategori_biaya;?>">
                            <input type="hidden" id="e_pihakke" name="e_pihakke" value="<?php echo $pihak_ke;?>">
                            <input type="button" id='close_add_biaya' id="kembali" value="Kembali" class="btn">
                            <input type="submit" id="simpan_btn" value="Cetak - Belum berfungsi" 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'});

});

$('#jenis_biaya').prop('disabled', true);

var katidbiaya=$('#idkat').val();
if(katidbiaya!=''){
$('#kategori_biaya option[value=<?php echo $id_kategori_biaya; ?>]').prop('selected', true).parent().change();
$('#jenis_biaya').prop('disabled', false);
$('.jBiaya').not('#'+katidbiaya).hide();
}

$('#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) ;
});


$('#pihak_pembayar').prop('disabled', true);

var epihakke=$('#e_pihakke').val();
if(epihakke!=''){
$('#fpihak_ke option[value=<?php echo $pihak_ke; ?>]').prop('selected', true).parent().change();
$('#pihak_pembayar').prop('disabled', false);
$('.jpembayar').not('#'+epihakke).hide();
}

$('#fpihak_ke').change(function(e){
    $('#pihak_pembayar').val("")
    $('.jpembayar').show();
    var pihakke = $(this).val();
    $('.jpembayar').not('#'+pihakke).hide();
    if($(this).val()==""){
        
        $('#pihak_pembayar').prop('disabled', true);
    }else{
        $('#pihak_pembayar').prop('disabled', false);
    }
});




$('#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 date = $(this).datepicker('getDate');
                var dayOfWeek = weekday[date.getDay()];
                var error = 0;
                var message ='';
                if(dayOfWeek=='Sunday' || dayOfWeek=='Saturday'){
                    message ='Tidak Dapat Memilih diluar Hari Kerja (Sabtu & Minggu).';
                    error = 1;
                }
                
                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,
});

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


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

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


</script>        