<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: 60%;margin: 0 auto;border-color: #FFFFFF;">
		<form id="frm_add_eksekusi_ht" style="background:white;margin:0;" method="post" action="<?php echo base_url().'add_eksekusi_hak_tanggungan/validateInput';?>">
			<table id="tableDetilPerkara" dotted style="font-size:14px;" width="550px" >
				<col width="25%">
				<col width="75%">
				<tbody >
                        <tr><td colspan="2" class="divider"><strong>Permohonan Eksekusi Hak Tanggungan</td></tr>
                        <tr>
                            <td bgcolor='#5FB85C'><font color='#fff'>Tanggal Permohonan<font color="red">*</font></td>
                            <td style="padding:0px;padding-left:5px;">
                                <input id="tgl_permohonan_ht" name="tgl_permohonan_ht" value="" class="datepicker" maxlength="10" placeholder="tgl/bln/tahun">
                            </td>
                        </tr>
                        <tr id="rw_generate">
                                <td ><font color='#fff'>Generate Nomor</font></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><font color='#fff'>Nomor Urut </font><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><font color='#fff'>Nomor Perkara Eksekusi</font><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">                                
                            </td>
                        </tr>
                        <tr id="rw_no_perkara_manual" disabled>
                            <td><font color='#fff'>Nomor Perkara Eksekusi</font><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>

                        <tr >
                            <td bgcolor='#5FB85C'><font color='#fff'>Jenis Eksekusi Hak Tanggungan<font color="red">*</font></td>
                            <td style="padding:0px;padding-left:5px;">
                                <span class="custom-dropdown custom-dropdown--emerald" style="width:200px">
                                    <select name="jenis_ht" id="jenis_ht" style='width:200px;' class="custom-dropdown__select custom-dropdown__select--white">
                                        <option value="">- Pilih - </option>
                                        <option value="1">Hak Tanggungan</option>
                                        <option value="2">Hipotek</option>
                                        <option value="3">Fidusia</option>
                                        <option value="4">Lelang</option>
                                    </select>
                                </span>                             
                            </td>
                         </tr>
                        <tr>
                            <td bgcolor='#5FB85C'><font color='#fff'>Tanggal Sertifikat<font color="red">*</font></td>
                            <td style="padding:0px;padding-left:5px;">
                                <input id="tgl_sertifikat" name="tgl_sertifikat" value="" class="datepicker" maxlength="10" placeholder="tgl/bln/tahun">
                            </td>
                        </tr>

                        <tr>
                            <td bgcolor='#5FB85C'><font color='#fff'>Nomor Sertifikat<font color="red">*</font></td>
                            <td style="padding:0px;padding-left:5px;">
                                <input type="text" id="nomor_sertifikat" name="nomor_sertifikat" value="" class="standard-input" style="width:220px;">
                            </td>
                         </tr>

                        <tr><td colspan="2" class="divider">Biaya Perkara</td></tr>
                        <tr>
                            <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>
                            <td bgcolor='#5FB85C'><font color='#fff'>Biaya Pendaftaran<font color="red">*</font></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>
                            <td bgcolor='#5FB85C'><font color='#fff'>Alat Tulis Kantor<font color="red">*</font></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="alurperkaraid" name="alurperkaraid" value="<?php echo $idalurperkara?>">
                            <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">

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

function get_nomor_eksekusi(){

    openLoadingDialog()
    var val = $('#generate').val()
    $.post('<?php echo base_url()?>add_eksekusi_hak_tanggungan/get_nomor_perkara_eksekusi', {
        val:val
    }, 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);
    }
});




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

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

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

$('#tgl_sertifikat').datepicker({
            inline: true,
            showOtherMonths: true,
            dateFormat: 'dd/mm/yy',
            dayNamesMin: ['Ming', 'Sen', 'Sel', 'Rab', 'Kam', 'Jum', 'Sab'],
            
            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_eksekusi_ht').SubmitHandling({
        refresh:'1',
        setRefresh:1,
        divRef:'#frm_add_eksekusi_ht',
        clicked:1,
        btnClicked:'#kembali',
        whenStatus:1
    });


</script>