<style type="text/css">
.autocomplete-suggestions { border: 1px solid #999; background: #FFF; overflow: auto; }
.autocomplete-suggestion { padding: 2px 5px; white-space: nowrap; overflow: hidden; }
.autocomplete-selected { background: #BCFCA0;font-size: 12px; }
.autocomplete-suggestions strong { font-weight: normal;font-size: 14px; color: #525050;background-color:#BEECFF }
</style>
<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: 50%;margin: 0 auto;border-color: #FFFFFF;">
		<form id="frm_add_register12tahun" style="background:white;margin:0;" method="post" action="<?php echo base_url().'add_register_blm_12tahun/validateInput';?>">
			<table id="tableDetilPerkara" style="font-size:14px;" width="750px" >
				<col width="45%">
				<col width="55%">
				<tbody >
                        <tr>
                            <td bgcolor='#5FB85C'><font color='#fff'>Generate Nomor</font></td>
                            <td style="padding:0px;padding-left:5px;">
                                <span class="custom-dropdown custom-dropdown--emerald" style="width:100px">
                                    <select name="generate" id="generate" style='width:100px;' class="custom-dropdown__select custom-dropdown__select--white">
                                        <option value="1" selected>Ya</option>
                                        <option value="2">Tidak</option>
                                    </select>
                                </span>                             
                            </td>
                         </tr>
                        <tr>                            
                            <td bgcolor='#5FB85C'><font color='#fff'>Nomor Urut</font></td>
                            <td style="padding:0px;padding-left:5px;">
                                <input type="text" id="no_urut" name="no_urut" value="<?php echo !empty($data['no_urut']) ? $data['no_urut'] :'';?>" class="standard-input" style="width:60px;" readonly="true">
                            </td>
                        </tr>                         
                        <tr>                            
                            <td bgcolor='#5FB85C'><font color='#fff'>Nomor Penetapan<font color="red">*</font></td>
                            <td style="padding:0px;padding-left:5px;">
                                <input type="text" id="nomor_penetapan" name="nomor_penetapan" value="<?php echo !empty($data['nomor_penetapan']) ? $data['nomor_penetapan'] :'';?>" class="standard-input" style="width:320px;">
                            </td>
                        </tr>
                         <tr>
                            <td bgcolor='#5FB85C'><font color='#fff'>Tanggal Penetapan<font color="red">*</font></td>
                            <td style="padding:0px;padding-left:5px;">
                                <input id="tgl_penetapan" name="tgl_penetapan" value="<?php echo !empty($data['tgl_penetapan']) ? $data['tgl_penetapan'] :'';?>" class="datepicker" maxlength="10" placeholder="tgl/bln/tahun">
                            </td>
                        </tr> 
                         <tr>                            
                            <td bgcolor='#5FB85C'><font color='#fff'>Nomor Permohonan<font color="red">*</font></td>
                            <td style="padding:0px;padding-left:5px;">
                                <input type="text" id="nomor_permohonan" name="nomor_permohonan" value="<?php echo !empty($data['nomor_permohonan']) ? $data['nomor_permohonan'] :'';?>" class="standard-input" style="width:320px;">
                            </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" name="tgl_permohonan" value="<?php echo !empty($data['tgl_permohonan']) ? $data['tgl_permohonan'] :'';?>" class="datepicker" maxlength="10" placeholder="tgl/bln/tahun">
                            </td>
                        </tr>                          
                        <tr>
                            <td bgcolor='#5FB85C'><font color='#fff'>Tanggal Dilakukan Tindak Pidana<font color="red">*</font></td>
                            <td style="padding:0px;padding-left:5px;">
                                <input id="tgl_tindak_pidana" name="tgl_tindak_pidana" value="<?php echo !empty($data['tgl_tindak_pidana']) ? $data['tgl_tindak_pidana'] :'';?>" class="datepicker" maxlength="10" placeholder="tgl/bln/tahun">
                            </td>
                        </tr>
                        <tr>                            
                            <td bgcolor='#5FB85C'><font color='#fff'>Isi Tindak Pidana<font color="red">*</font></td>
                            <td style="padding:0px;padding-left:5px;">
                                <textarea type="text" id="uraian_tindak_pidana" name="uraian_tindak_pidana" style="width:320px;"><?php echo !empty($data['uraian_tindak_pidana']) ? $data['uraian_tindak_pidana'] :'';?></textarea>
                            </td>
                        </tr> 
                        <tr>                            
                            <td bgcolor='#5FB85C'><font color='#fff'>Nomor Laporan Kemasyarakatan<font color="red">*</font></td>
                            <td style="padding:0px;padding-left:5px;">
                                <input type="text" id="nomor_lap_kemasyarakatan" name="nomor_lap_kemasyarakatan" value="<?php echo !empty($data['nomor_lap_kemasyarakatan']) ? $data['nomor_lap_kemasyarakatan'] :'';?>" class="standard-input" style="width:320px;">
                            </td>
                        </tr>
                         <tr>
                            <td bgcolor='#5FB85C'><font color='#fff'>Tanggal Laporan Kemasyarakatan<font color="red">*</font></td>
                            <td style="padding:0px;padding-left:5px;">
                                <input id="tgl_lap_kemasyarakatan" name="tgl_lap_kemasyarakatan" value="<?php echo !empty($data['tgl_lap_kemasyarakatan']) ? $data['tgl_lap_kemasyarakatan'] :'';?>" class="datepicker" maxlength="10" placeholder="tgl/bln/tahun">
                            </td>
                        </tr> 
                        <tr>                            
                        <td bgcolor='#5FB85C'><font color='#fff'>Nomor Keputusan Penyidik, Pembimbing Kemasyarakatan dan Pekerja Sosial Profesional <font color="red">*</font></td>
                            <td style="padding:0px;padding-left:5px;">
                                <input type="text" id="nomor_kep_penyidik" name="nomor_kep_penyidik" value="<?php echo !empty($data['nomor_kep_penyidik']) ? $data['nomor_kep_penyidik'] :'';?>" class="standard-input" style="width:320px;">
                            </td>
                        </tr>
                         <tr>
                            <td bgcolor='#5FB85C'><font color='#fff'>Tanggal Keputusan Penyidik, Pembimbing Kemasyarakatan dan Pekerja Sosial Profesional <font color="red">*</font></td>
                            <td style="padding:0px;padding-left:5px;">
                                <input id="tgl_kep_penyidik" name="tgl_kep_penyidik" value="<?php echo !empty($data['tgl_kep_penyidik']) ? $data['tgl_kep_penyidik'] :'';?>" class="datepicker" maxlength="10" placeholder="tgl/bln/tahun">
                            </td>
                        </tr>
                        <tr>                            
                            <td bgcolor='#5FB85C'><font color='#fff'>Isi Keputusan Penyidik<font color="red">*</font></td>
                            <td style="padding:0px;padding-left:5px;">
                                <textarea type="text" id="isi_kep_penyidik" name="isi_kep_penyidik" style="width:320px;"><?php echo !empty($data['isi_kep_penyidik']) ? $data['isi_kep_penyidik'] :'';?></textarea>
                            </td>
                        </tr>  
                        <tr>
                            <td colspan="2" style="background:white;" align="center">
                            <input type="hidden" id="curr_date" name="curr_date" value="<?php echo $tgl_sekarang;?>">
                            <input type="hidden" id="act" name="act" value="<?php echo $act;?>">
                            <input type="button" id="kembali" value="Kembali" class="btn">
                            <input type="submit" id="simpan" value="Simpan" class="btn">
                        </td>
                        </tr>

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

<script type='text/javascript' src='<?php echo base_url();?>resources/js/jquery.autocomplete.js'></script>

<script type="text/javascript">
$( document ).ready(function() {
    var act="<?php echo $act ?>";
    if (act=='add'){
        $('#no_urut').attr('readonly', true);
        $('#nomor_penetapan').attr('readonly', true);
        get_nomor_register();
    }
})
$('#generate').change(function(e){
    if($('#generate').val()==1){
        $('#no_urut').attr('readonly', true);
        $('#nomor_penetapan').attr('readonly', true);
        get_nomor_register();
    }else{
        $('#no_urut').attr('readonly', false);
        $('#nomor_penetapan').attr('readonly', false);
    }        
});

function get_nomor_register(){
    openLoadingDialog()
    var val = $('#generate').val()
    $.post('<?php echo base_url()?>add_register_blm_12tahun/get_nomor_register', {
        val:val,
    }, function(response){
        var json = jQuery.parseJSON(response);
        if(json.st==1){
            $('#no_urut').val(json.no_urut)
            $('#nomor_penetapan').val(json.new_nomor)
        }
        closeLoading()
    });
}


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

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

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