<?php
foreach ($tanggalPendaftaran->result() as $row){
    $tanggalPendaftaran =  $row->tanggal_pendaftaran;
}
?>
<div class="centering" style="width:500px;margin-top: 1%;z-index:-100">
<div id='pemeriksaan_persiapan' style="border: 1px solid #ffffff;">
	<div class="detil" style="padding: 2px;background-color: white;">
		<form id="show_pemeriksaan_persiapan" style="background:white;margin:0;" method="post" action="<?php echo base_url().'perbaikan_gugatan/validatePerbaikan';?>">
			<table id="tableDetilPerkara" style="font-size:14px;">
				<col width="50%">
				<col width="50%">
				<tbody>
					<tr>
						<td colspan="2" style='text-align:center;background:#fff;color:#5fb85c;border:2px solid #fff;margin-bottom:10px;font-size: 20px;'>Tambah Data Saran Perbaikan</td>
					</tr>
					
					<!--<tr>
						<td>Perbaikan Gugatan <font color="red">*</font></td>
						 <td>                                													                       
                                <span class="custom-dropdown custom-dropdown--emerald">
		                            <select style='width:130px;'  name="perbaikan" id="perbaikan"  class="custom-dropdown__select custom-dropdown__select--white">                                
		                                <option value=''>Pilih</option>			                                
		                                <option value='1'>Diperbaiki dan dinyatakan Lengkap</option>
		                                <option value='2'>Dinyatakan Lengkap</option>
		                            </select>
		                        </span>			                                                       		
                            </td>
					</tr>
					-->
					<tr>
						<td>Tanggal Saran Perbaikan Gugatan<font color="red">*</font></td>
						<td style="padding:0px;padding-left:5px;">							
							<input id="tgl_saran_perbaikan_gugatan" name="tgl_saran_perbaikan_gugatan"  class="datepicker" maxlength="10" placeholder="tgl/bln/tahun">
						</td>
					</tr>
					<input id="enc" name="enc" type="hidden" value="<?php echo $enc; ?>">
					<input type="hidden" id="curr_date" value="<?php echo $curr_date;?>">
					<input type="hidden" name="tanggalPendaftaran" value="<?php echo $tanggalPendaftaran;?>">
					<tr>
						<td colspan="2" style="background:white;border:0px;" align="center">
							<input type="button" id='close_form_pemeriksaan_persiapan' value="Kembali" class="btn">
							<input type="submit" id="simpan" value="Simpan" class="btn">
						</td>
					</tr>
				</tbody>
			</table>
		</form>
	</div>
</div>
<script type="text/javascript">
$('#close_form_pemeriksaan_persiapan').click(function(){
        window.open("<?php echo base_url('perkara_detil_tun/'.$enc.'/100');?>","_self");    
    });
$('#show_pemeriksaan_persiapan').SubmitHandling({
	refresh:'1',
	setRefresh:1,
	divRef:'#konten',
	clicked:1,
	btnClicked:'#close_form_pemeriksaan_persiapan',
	whenStatus:1,
	next_step:1
 });

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

		dob = new Date(tmp[2]+"-"+tmp[1]+"-"+tmp[0]+"T00:00:00");
		var tglDaftar = new Date($('#tanggalPendaftaran').val());
		var age = Math.floor((tglDaftar-dob) / (365.25 * 24 * 60 * 60 * 1000));
		if(age >1){
			message = 'Tanggal Tidak Valid. Silahkan Periksa Kembali';
			error = 1
		}
		if(error==1){
			message_error_show(message);
			$(this).css("background-color", "red");
		}else{
			$(this).css("background-color", "#dedbdb");
		}
		error = 0;
 	}
});

$('.datepicker').ValidateDateInput();
</script>