<link rel="stylesheet" type="text/css" href="<?php echo base_url();?>resources/css/jquery.autocomplete.css">
<script type="text/javascript" src="<?php echo base_url();?>resources/js/jquery.autocomplete.js"></script> 
<script src="<?php echo base_url();?>resources/js/autoNumeric.js"></script>
<hr class="thick-line" style="clear:both;">
<div style="padding:20px;"></div>
	<div class="detil" style="font-size:14px;margin-top:25px;width: 75%;margin: 0 auto;border-color: #FFFFFF;">
		<form id="frm_add_perdata_eksekusi" style="background:white;margin:0;" method="post" action="<?php echo base_url().'add_perdata_eksekusi/validateInput';?>">
			<table id="tableDetilPerkara" style="font-size:14px;" width="750px" >
				<col width="25%">
				<col width="75%">
				<tbody >
                        <tr><td colspan="2" class="divider"><strong><?php echo $lang_pengadilan_negeri;?></td></tr>
                        <tr>
                            <td bgcolor='#5FB85C'><font color='#fff'><?php echo $lang_nomor_perkara;?><font color="red">*</font></td>
                            <td style="padding:0px;padding-left:5px;">
                                <input type="text" class="autocomplete" id='nomor_perkara_pn' name='nomor_perkara_pn' value="" size="50" placeholder="Ketik Nomor Perkara" style="padding: 7px 0;padding-left:4px;border: 1px solid; width: 250px;">                                
                                <input type="button" id="cariPerkara" value="Cari" class="btn" style="padding: 5px 15px;" onclick="pencarianPerkara()">
                            </td>
                         </tr>
                         <tr class="eks_hide">
                            <td bgcolor='#5FB85C'><font color='#fff'>Tanggal Putusan<font color="red">*</font></td>
                            <td style="padding:0px;padding-left:5px;">
                                <input type="text" id='tgl_putusan_pn' name='tgl_putusan_pn' class="standard-input" style="width:15%" readonly="readonly">
                            </td>
                        </tr>
                        <tr class="banding_hide"><td colspan="2" class="divider"><strong>Data Banding</td></tr>
                        <tr class="banding_hide">
                            <td bgcolor='#5FB85C'><font color='#fff'>Nomor Perkara Banding</td>
                            <td style="padding:0px;padding-left:5px;">
                                <input type="text" id='nomor_perkara_banding' name='nomor_perkara_banding' class="standard-input" style="width:220px;" readonly="readonly">
                            </td>

                         </tr>
                         <tr class="banding_hide">                            
                            <td bgcolor='#5FB85C'><font color='#fff'>Tanggal Putusan Banding</td>
                            <td style="padding:0px;padding-left:5px;">
                                <input type="text" id='tgl_putusan_banding' name='tgl_putusan_banding' class="standard-input" style="width:15%" readonly="readonly">
                            </td>

                        </tr >
                        <tr class="kasasi_hide"><td colspan="2" style="background-color:#A3DBA8;padding:5px;"><strong>Data Kasasi</td></tr>
                        <tr class="kasasi_hide">
                            <td bgcolor='#5FB85C'><font color='#fff'>Nomor Perkara Kasasi</td>
                            <td style="padding:0px;padding-left:5px;">
                                <input type="text" id='nomor_perkara_kasasi' name='nomor_perkara_kasasi' class="standard-input" style="width:220px;" readonly="readonly">
                            </td>

                        </tr>
                        <tr class="kasasi_hide">                            
                            <td bgcolor='#5FB85C'><font color='#fff'>Tanggal Putusan Kasasi</td>
                            <td style="padding:0px;padding-left:5px;">
                                <input type="text" id='tgl_putusan_kasasi' name='tgl_putusan_kasasi' class="standard-input" style="width:15%" readonly="readonly">
                            </td>
                        </tr>
                        <tr class="pk_hide"><td colspan="2" style="background-color:#A3DBA8;padding:5px;"><strong>Data Peninjauan Kembali</td></tr>                        
                        <tr class="pk_hide">                            
                            <td bgcolor='#5FB85C'><font color='#fff'>Nomor Perkara Peninjauan Kembali</td>
                            <td style="padding:0px;padding-left:5px;">
                                <input type="text" id='nomor_perkara_pk' name='nomor_perkara_pk' class="standard-input" style="width:220px;" readonly="readonly">
                            </td>
                        </tr>
                        <tr class="pk_hide">                            
                            <td bgcolor='#5FB85C'><font color='#fff'>Tanggal Putusan Peninjauan Kembali</td>
                            <td style="padding:0px;padding-left:5px;">
                                <input type="text" id='tgl_putusan_pk' name='tgl_putusan_pk' class="standard-input" style="width:15%" readonly="readonly">
                            </td>
                        </tr>

                        <tr><td colspan="2" class="divider"><strong>Pemohon Eksekusi</td></tr>
                        <tr id="tr_put_amar">
                            <td bgcolor='#5FB85C'><font color='#fff'>Putusan Yang Dieksekusi<font color="red">*</font></td>
                            <td style="padding:0px;padding-left:5px;" id="td_put_amar" >
                                <span class="custom-dropdown custom-dropdown--emerald" style="width:100px">
                                    <select name="listdataput" id="listdataput" style='width:100px;' class="custom-dropdown__select custom-dropdown__select--white">
                                        <option value="0">- Pilih - </option>
                                        <option id='put_1' value="10">Tk. Pertama</option>
                                        <option id='put_2' value="20">Banding</option>
                                        <option id='put_3' value="30">Kasasi</option>
                                        <option id='put_4' value="40">PK</option>
                                    </select>
                                </span>                            	
                            </td>
                         </tr>
                         <tr>                            
                            <td bgcolor='#5FB85C'><font color='#fff'>Nomor Perkara Yang di Eksekusi<font color="red">*</font></td>
                            <td style="padding:0px;padding-left:5px;">
								<input type="text" id="no_perkara_mhn_eksekusi" name="no_perkara_mhn_eksekusi" value="" class="standard-input" style="width:320px;"  readonly>
                            </td>
                        </tr>
                         <tr id="tr_amar">                            
                            <td bgcolor='#5FB85C' ><font color='#fff'>Amar Putusan Yang di Eksekusi<font color="red">*</font></td>
                        </tr>
                        <tr>
                            <td bgcolor='#5FB85C'><font color='#fff'>Tanggal Permohonan Eksekusi<font color="red">*</font></td>
                            <td style="padding:0px;padding-left:5px;">
                                <input id="tgl_permohonan_eksekusi" name="tgl_permohonan_eksekusi" value="" class="datepicker" maxlength="10" placeholder="tgl/bln/tahun">

                            </td>
                        </tr>
                         <tr>                            
                            <td bgcolor='#5FB85C'><font color='#fff'>Nama Pemohon<font color="red">*</font></td>
                            <td style="padding:0px;padding-left:5px;">
                                <input type="hidden" id='enc_pemohon' name='enc_pemohon'>
                                <input type="text" id='nama_pemohon' name='nama_pemohon' class="standard-input" maxlength="200">
                                <input type="button" onClick="popup_form('<?php echo base_url('pihak_list_up');?>')" class="btn" style="padding: 5px 15px;" value="Cari">
                            </td>
                        </tr>
                         <tr>                            
                            <td bgcolor='#5FB85C'><font color='#fff'>Pekerjaan Pemohon</td>
                            <td style="padding:0px;padding-left:5px;">
                                    <input type="text" id='pekerjaan_pemohon' name='pekerjaan_pemohon' class="standard-input" style="width:30%" maxlength="200" readonly>
                            </td>
                        </tr>
                         <tr>                            
                            <td bgcolor='#5FB85C'><font color='#fff'>Alamat Pemohon</td>
                            <td style="padding:0px;padding-left:5px;">
                                <textarea type="text" id='alamat_pemohon' name='alamat_pemohon' class="standard-input" style="width:99%; resize: none" readonly></textarea>
                            </td>
                        </tr>

                        <tr>
                            <td bgcolor='#5FB85C'><font color='#fff'>Tanggal Surat Kuasa</td>
                            <td style="padding:0px;padding-left:5px;">
                                <input id="tgl_surat_kuasa" name="tgl_surat_kuasa" value="" class="datepicker" maxlength="10" placeholder="tgl/bln/tahun">
                            </td>
                        </tr>
                         <tr>                            
                            <td bgcolor='#5FB85C'><font color='#fff'>Nomor Surat Kuasa</td>
                            <td style="padding:0px;padding-left:5px;">
								<input type="text" id="no_surat_kuasa" name="no_surat_kuasa" value="" class="standard-input" style="width:320px;">
                            </td>
                        </tr>
              <?php if($this->session->userdata('jenis_pengadilan')!=3){ ?>  
                    <tr><td colspan="2" class="divider"><strong>Nomor Perkara Eksekusi</td></tr>
                    <tr id="rw_generate">
                        <td >Generate Nomor</td>
                        <td style="padding:0px;padding-left:5px;">
                            <span class="custom-dropdown custom-dropdown--emerald" style='width:80px;'>
                                <select name="generate" id="generate" style='width:80px;' class="custom-dropdown__select custom-dropdown__select--white">
                                    <option value="1">Ya</option>
                                    <option value="0">Tidak</option>
                                </select>
                            </span>
                        </td>
                    </tr>
                    <tr>
                        <td>Nomor Urut <font color="red">*</font></td>
                        <td style="padding:0px;padding-left:5px;">
                            <input type="text" id='no_urut_eksekusi' name='no_urut_eksekusi' value="<?php echo $no_urut;?>" class="standard-input" maxlength="10" readonly="readonly" style="width:50px;">
                        </td>
                    </tr>
                    <tr id="rw_no_perkara_auto">
                        <td>Nomor Perkara Eksekusi<font color="red">*</font></td>
                        <td style="padding:0px;padding-left:5px;">
                            <input type="text" id='no_perkara_eksekusi_auto' name='no_perkara_eksekusi_auto' value="<?php echo $no_perkara_eksekusi_auto;?>" style="width:180px;"class="standard-input" maxlength="255" readonly="readonly">
                            <input type="hidden" id="urutan" value="<?php //echo $no_perkara;?>">
                        </td>
                    </tr>
                    <tr id="rw_no_perkara_manual" disabled>
                        <td>Nomor Perkara Eksekusi<font color="red">*</font></td>
                        <td style="padding:0px;padding-left:5px;">
                            <input type="text" id='no_urut_perkara_eks_manual' name='no_urut_perkara_eks_manual' value="<?php echo $no_urut_perkara;?>" class="standard-input" maxlength="10" style="width:50px;">
                            <input type="text" id='no_perkara_eksekusi_man' name='no_perkara_eksekusi_man' value="<?php echo $no_perkara_eksekusi_man;?>" class="standard-input" maxlength="100" style="width:192px;">
                        </td>
                    </tr>
              <?php } ?>
                        <tr><td colspan="2" class="divider"><strong>Pihak Yang dimohonkan Eksekusi</td></tr>
                        <tr id="tr_penggugat">
                            <td bgcolor='#5FB85C'><font color='#fff'>Penggugat</td>                        
						</tr>
                        <tr id="tr_tergugat">
                            <td bgcolor='#5FB85C'><font color='#fff'>Tergugat</td>                        
						</tr>
                        <tr class="eks_hide"><td colspan="2" style="background-color:#A3DBA8;padding:5px;">Biaya Perkara</td></tr>
                        <tr class="eks_hide">
                            <td bgcolor='#5FB85C'><font color='#fff'>Panjar Perkara Eksekusi<font color="red">*</font></td>
                            <td style="padding:0px;padding-left:5px;">
                                <input data-a-sep="." data-a-dec="," type="text" id="panjar" name="panjar" value="" class="standard-input" style="width:220px; text-align:right">

                            </td>
                        </tr >
                        <tr class="eks_hide">
                            <td bgcolor='#5FB85C'><font color='#fff'>Biaya Pendaftaran</td>
                            <td style="padding:0px;padding-left:5px;">
                                <input readonly="readonly" data-a-sep="." data-a-dec="," type="text" id="pendaftaran" name="pendaftaran" value="<?php echo (!empty($pendaftaran) ? $pendaftaran : '');?>" class="standard-input" style="width:220px; text-align:right">
                            </td>
                        </tr>
                        <tr class="eks_hide">
                            <td bgcolor='#5FB85C'><font color='#fff'>Alat Tulis Kantor</td>
                            <td style="padding:0px;padding-left:5px;">
                                <input readonly="readonly" data-a-sep="." data-a-dec="," type="text" id="atk" name="atk" value="<?php echo (!empty($atk) ? $atk : '');?>" class="standard-input" style="width:220px; text-align:right">

                            </td>
                        </tr>

                        <tr>
                            <td colspan="2" style="background:white;" align="center">
                            <?php
                            
                            ?>
                            <input type="hidden" id="idperkara" name="idperkara" value="">
                            <input type="hidden" id="amar_yg_dieksekusi" name="amar_yg_dieksekusi" value=''>
                            <input type="hidden" id="alurperkaraid" name="alurperkaraid" value="<?php echo $alur_perkara_id;?>">
                            <input type="hidden" id="curr_date" name="curr_date" value="<?php echo $tgl_sekarang;?>">
                            <input type="button" id="kembali" value="Kembali" class="btn">
                            <?php
                            //if($this->authorization->isAuthorized('hakim_pn_edit',$AuthorizationForm)){
                            ?>
                            
                                <input type="submit" id="simpan" value="Simpan" class="btn">
                            <?php
                            //}
                            ?>
                        </td>
                        </tr>

				</tbody>
			</table>
		</form>
	</div>

<script type="text/javascript">
    var site = "<?php echo base_url();?>";
    var alur_perkara = "<?php echo $idalurperkara; ?>";
    $(function(){
        $('.autocomplete').autocomplete({
            serviceUrl: site+'cari_komplit/cari/'+alur_perkara,
            onSelect: function (suggestion) {
               $('#search-btn1').click();
            }
        });
    });
</script>
<script type="text/javascript">

$('#generate').change(function(e){
    get_nomor_eksekusi();
});

function get_nomor_eksekusi(){

    openLoadingDialog()
    var val = $('#generate').val()
    var enc = $('#alurperkaraid').val()
    $.post('<?php echo base_url()?>add_perdata_eksekusi/get_nomor_perkara_eksekusi', {
        val:val,
        enc: enc
    }, function(response){
        var json = jQuery.parseJSON(response);
        if(json.st==1){
            $('#no_perkara_eksekusi_auto').val(json.msg)
            $('#no_urut_eksekusi').val(json.nourutregister)
        }
        closeLoading()
    });
}



$('#rw_no_perkara_manual').hide();

$('#generate').change(function(e){
    if($('#generate').val()==1){
        $('#rw_no_perkara_manual').hide();
        $('#rw_no_perkara_auto').show();
        $('#no_urut_eksekusi').attr('readonly', true);
        get_nomor_eksekusi();
    }else{
        $('#rw_no_perkara_auto').hide();
        $('#rw_no_perkara_manual').show();
        $('#no_urut_eksekusi').attr('readonly', false);
    }
});



$(".ref_pihak #refresh").change(function(){
    refreshPihakList()
});
function refreshPihakList(){
    $("#popup_form").remove();
    popup_form('<?php echo base_url("pihak_list_up");?>');
}

$("#frm_add_perdata_eksekusi").on("click",'.c_penggugat', function(){
    if($(this).is(':checked')){
       $('.c_tergugat').prop('checked', false);
    }
}); 
$("#frm_add_perdata_eksekusi").on("click",'.c_tergugat', function(){
    if($(this).is(':checked')){
       $('.c_penggugat').prop('checked', false);
    }
});

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

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

$('#tgl_permohonan_eksekusi').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_parent(message);
                    $(this).css("background-color", "red");
                }else{
                    $(this).css("background-color", "#dedbdb");
                }
                error = 0;
            }
        });

$('#tgl_surat_kuasa').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_parent(message);
                    $(this).css("background-color", "red");
                }else{
                    $(this).css("background-color", "#dedbdb");
                }
                error = 0;
            }
        });

var amar_putusan_pn ='';
var amar_putusan_banding ='';
var amar_putusan_kasasi ='';
var amar_putusan_pk ='';

$('#listdataput').change(function(e){  
    if($('#listdataput').val()=='0'){
        $('#td_amar').remove();  
        $('#tr_amar').append('');  
        $('#no_perkara_mhn_eksekusi').val('')
    }else if($('#listdataput').val()==10){
        $('#td_amar').remove();  
        $('#tr_amar').append("<td id='td_amar'>"+amar_putusan_pn+"</td>");  
        $('#no_perkara_mhn_eksekusi').val($('#nomor_perkara_pn').val());
        $('#amar_yg_dieksekusi').val(amar_putusan_pn);
    }else if($('#listdataput').val()==20){
        $('#td_amar').remove();  
        $('#tr_amar').append("<td id='td_amar'>"+amar_putusan_banding+"</td>");
        $('#no_perkara_mhn_eksekusi').val($('#nomor_perkara_banding').val());
        $('#amar_yg_dieksekusi').val(amar_putusan_banding);
    }else if($('#listdataput').val()==30){
        $('#td_amar').remove();  
        $('#tr_amar').append("<td id='td_amar'>"+amar_putusan_kasasi+"</td>");
        $('#no_perkara_mhn_eksekusi').val($('#nomor_perkara_kasasi').val());
        $('#amar_yg_dieksekusi').val(amar_putusan_kasasi);
    }else if($('#listdataput').val()==40){
        $('#td_amar').remove();  
        $('#tr_amar').append("<td id='td_amar'>"+amar_putusan_pk+"</td>");
        $('#no_perkara_mhn_eksekusi').val($('#nomor_perkara_pk').val());
        $('#amar_yg_dieksekusi').val(amar_putusan_pk);
    }
});


$('.eks_hide').hide();
$('.banding_hide').hide();
$('.kasasi_hide').hide();
$('.pk_hide').hide();

function pencarianPerkara(){
    $('.eks_hide').hide();
    $('.banding_hide').hide();
    $('.kasasi_hide').hide();
    $('.pk_hide').hide();
    var val = $('#nomor_perkara_pn').val();
    var enc_alur=$('#alurperkaraid').val();
    openLoadingDialog()
    $.post('<?php echo base_url()?>add_perdata_eksekusi/show_cari_eksekusi', {
        val:val,
        enc_alur:enc_alur
    }, function(response){
        var json = jQuery.parseJSON(response);
        closeLoading()
        if(json.st==1){
            $('.eks_hide').show();
            $('#listdataput').val('0');
            $('#td_penggugat').remove();
            $('#td_tergugat').remove();
            $('#td_amar').remove();
            $('#nama_pemohon').val('');
            $('#pekerjaan_pemohon').val('');
            $('#alamat_pemohon').val('');
            $('#td_amar').remove();
            $('#no_perkara_mhn_eksekusi').val('');
            $('#idperkara').val(json.perkara_id);
            $('#alurperkaraid').val(json.alur_perkara_id);
            if(json.tgl_putusan_pn!=''){
                $('#tgl_putusan_pn').val(json.tgl_putusan_pn);
                amar_putusan_pn = json.amarpnHtml;
                if(json.amar_putusan_pn==''){
                    $('#put_1').hide();
                }            
            }else{
                $('#put_1').hide();
            }         
            if(json.tgl_putusan_banding!=''){
                $('.banding_hide').show();
                $('#nomor_perkara_banding').val(json.nomor_perkara_banding);                
                $('#tgl_putusan_banding').val(json.tgl_putusan_banding);
                amar_putusan_banding = json.amarbandingHtml;
                if(json.amar_putusan_banding==''){
                    $('#put_2').hide();
                }             
            }else{
                $('#put_2').hide();
            }
            if(json.tgl_putusan_kasasi!=''){
                $('.kasasi_hide').show();
                $('#nomor_perkara_kasasi').val(json.nomor_perkara_kasasi);
                $('#tgl_putusan_kasasi').val(json.tgl_putusan_kasasi); 
                amar_putusan_kasasi = json.amarkasasiHtml;
                if(json.amar_putusan_kasasi==''){
                    $('#put_3').hide();
                }                                            
            }else{
                $('#put_3').hide();
            }
            if(json.tgl_putusan_pk!=''){
                $('.pk_hide').show();
                $('#nomor_perkara_pk').val(json.nomor_perkara_pk);
                $('#tgl_putusan_pk').val(json.tgl_putusan_pk);
               amar_putusan_pk = json.amarpkHtml;
               if(json.amar_putusan_pk==''){
                    $('#put_4').hide();
                }              
            }else{
                 $('#put_4').hide();
            }
            $('#tr_penggugat').append(json.penggugatHtml);
            $('#tr_tergugat').append(json.tergugatHtml);
        }else if(json.st==0){
            message_error_show_parent(json.msg);
        }
    });
}

$('.datepicker').ValidateDateInput();
$('#frm_add_perdata_eksekusi').SubmitHandling({
        refresh:'1',
        setRefresh:1,
        divRef:'#frm_add_perdata_eksekusi',
        clicked:1,
        btnClicked:'#kembali',
        whenStatus:1
    });
</script>