<div style="padding:10px;"></div>
<?php
	if($infopihak!=''){
		if($infopihak->num_rows>0){
			foreach ($infopihak->result() as $row) {
				$diwakili = ($row->pihak_diwakili=='Y')? 'YA':'TIDAK';
				$namapihak = $row->pihak_nama;
				$statusasal = $row->pihak_asal_text;
				$statuskasasi = $row->status_pihak_text.' Ke-'.$row->urutan_kasasi;
				$noperkarapn = $row->nomor_perkara_pn;
				$tglpermohonan = $this->tanggalhelper->convertToInputDate($row->permohonan_kasasi);
				$tglputusan = $this->tanggalhelper->convertToInputDate($row->putusan_pn);
				$idpihak = base64_encode($this->encrypt->encode($row->pihak_id));
				$pemohon = $row->pemohon_nama;
				$pemohonalamat = $row->pemohon_alamat;
				$pemohonpekerjaan = $row->pemohon_pekerjaan;
				$pihak_id = $row->pihak_id;
				$noSurat = $row->pemohon_nomor_surat;
				$tglSurat = $this->tanggalhelper->convertDayDate($row->pemohon_tanggal_surat);
				$idperkara = base64_encode($this->encrypt->encode($row->perkara_id));
			}
		}
	}else{
		show_404();
	}
?>
<div class="detil" style="padding: 4px;font-size:14px;margin-top:25px;width: 45%;margin: 0 auto;border-color: #FFFFFF;">
	<form id="frm_permohonan" style="padding: 4px;background:white;margin:0;" method="post" action="<?php echo base_url().'savepermohonankasasi';?>">
		<table id="tableDetilPerkara" style="font-size:14px;">
			<col width="40%">
			<col width="60%">
			<tbody>
				<?php
					if($this->session->userdata('jenis_pengadilan')==2){
							$nop="Nomor Perkara Dilmil";		
							$nops="Tanggal Putusan Dilmil";
					}
					elseif($this->session->userdata('jenis_pengadilan')==3){
							$nop="Tanggal Permohonan";		
							$nops="Nomor Perkara PTUN";
						}
					else {
							$nop="Tanggal Putusan PN";
							$nops="Nomor Perkara PN";				
					}
				?>
				<tr>
					<td colspan="2" class="divider">DATA PERKARA</td>
				</tr>		
				<tr>
					<td><?php echo $nop;?><font color="red">*</font></td>
					<td style="padding:0px;padding-left:5px;">
						<input id="tgl_pendaftaran" name="tgl_pendaftaran" value="<?php echo (!empty($tglpermohonan) ? $tglpermohonan : '');?>" class="datepicker" maxlength="10" placeholder="tgl/bln/tahun">
					</td>
				</tr>
				<tr>
					<td><?php echo $nops;?><font color="red">*</font></td>
					<td style="padding:0px;padding-left:5px;"><?php echo (!empty($noperkarapn) ? $noperkarapn : '');?></td>
				</tr>
				<tr id="tr_pihak">
					<td colspan="2" class="divider">PIHAK PEMOHON KASASI</td>
					<input type="hidden" id="date_put" value="<?php echo (!empty($tglputusan))? $tglputusan:'';?>">
					<input type="hidden" id="enc" name="enc" value="<?php echo (!empty($idperkara))? $idperkara:'';?>">
					<input type="hidden" id="enc_id" name="enc_id" value="<?php echo (!empty($enc_id))? $enc_id:'';?>">
				</tr>
				<tr>
					<td>Status Pihak<font color="red">*</font></td>
					<td style="padding:0px;padding-left:5px;"><?php echo (!empty($statuskasasi) ? $statuskasasi : '');?></td>
				</tr>
				<tr>
					<td>Status Asal<font color="red">*</font></td>
					<td style="padding:0px;padding-left:5px;"><?php echo (!empty($statusasal) ? $statusasal : '');?></td>
				</tr>
				<tr>
					<td>Nama Pihak<font color="red">*</font></td>
					<td style="padding:0px;padding-left:5px;"><?php echo (!empty($namapihak) ? $namapihak : '');?></td>
				</tr>
				<tr>
					<td >Pihak Diwakili<font color="red">*</font></td>
					<td style="padding:0px;padding-left:5px;"><?php echo (!empty($diwakili) ? $diwakili : '');?></td>
				</tr>
				<tr class ="tr_pemohon">
					<td colspan="2" class="divider">PEMOHON KASASI</td>
				</tr>
				<tr class ="tr_pemohon">
					<td>Nama Pemohon<font color="red">*</font></td>
					<td style="padding:0px;padding-left:5px;"><?php echo (!empty($pemohon) ? $pemohon : '');?></td>
				</tr>
				<tr class ="tr_pemohon">
					<td>Pekerjaan Pemohon</td>
					<td style="padding:0px;padding-left:5px;"><?php echo (!empty($pemohonpekerjaan) ? $pemohonpekerjaan : '');?></td>
				</tr>
				<tr class ="tr_pemohon">
					<td>Alamat Pemohon</td>
					<td style="padding:0px;padding-left:5px;"><?php echo (!empty($pemohonalamat) ? $pemohonalamat : '');?></td>
				</tr>
				<tr id="tr_tgl_kuasa" class ="tr_pemohon">
					<td>Tanggal Surat Kuasa</td>
					<td style="padding:0px;padding-left:5px;"><?php echo (!empty($tglSurat) ? $tglSurat : '');?></td>
				</tr>
				<tr class ="tr_pemohon">
					<td>Nomor Surat Kuasa</td>
					<td style="padding:0px;padding-left:5px;"><?php echo (!empty($noSurat) ? $noSurat : '');?></td>
				</tr>
				<input type="hidden" id="curr_date" value="<?php echo $current_date;?>">
				<tr>
					<td colspan="2" style="background:white;" align="center">
						<input type="button" value="Kembali" id="kembali" class="btn">
						<input type="submit" id="simpan" value="Simpan" class="btn">
					</td>
				</tr>
			</tbody>
		</table>
	</form>
</div>
<script type="text/javascript">
$('#kembali').closingFormWin();
$( document ).ready(function() {
    $('#frm_permohonan').SubmitHandling({
		refresh:'1',
		setRefresh:1,
		divRef:'#frm_permohonan',
		clicked:1,
		btnClicked:'.close_form',
		whenStatus:1
	});
	$('.datepicker').ValidateDateInput();
    $( function() {
        $('#tgl_pendaftaran').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 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.';
            		message_error_show_parent(message);
            		return;
            	}
				
				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();
					message_error_show_parent(message);
					$(this).css("background-color", "red");
				}else{
					$(this).css("background-color", "#dedbdb");
				}

				if($('#date_put').val()!=''){
					var date = new Date(tmp[2]+"-"+tmp[1]+"-"+tmp[0]+"T00:00:00");
					var tmp2 = $('#date_put').val().split("/");
					var today = new Date(tmp2[2]+"-"+tmp2[1]+"-"+tmp2[0]+"T00:00:00");
					var dayDiff = Math.ceil((date-today) / (1000 * 60 * 60 * 24));
					if(dayDiff>14){
						message_error_show_parent('Permohonan kasasi Telah Melebihi 14 Hari. Mohon Untuk Melihat kembali permohonan yang diajukan untuk menjadi catatan.');
					}
				}
			}
        });
    });
});
</script>
