<?php 
$aksi=$this->encrypt->decode(base64_decode($act));
$urutan=$this->encrypt->decode(base64_decode($urutan_pts));
$enc_alur=$enc_a;
if ($aksi=="add"){
	$tglPutusanSela="";
	$keberatan="";
	$amar_sela="";
	$namadokumen="";
	$pemberitahuanPenggugat="";
	$pemberitahuanTergugat="";
	$pemberitahuanIntervensi="";
}
?>
<div class="centering" style="width:1024px;margin-top: 1%;z-index:-100">
	<div id='edit_sela' style="border: 1px solid #ffffff;">
		<div class="detil" style="padding: 2px;background-color: white;">
			<form id="frm_sela" style="background:white;margin:0;" method="post" enctype="multipart/form-data" action="<?php echo base_url().'managePutusanSela/validateInput';?>">
				<table id="tableDetilPerkara" style="font-size:14px;">
					<col width="40%">
					<col width="60%">
					<tbody>
						<tr>
							<td colspan="2" style="background:white;border:0px;font-size: 20px;color: #648C03;" align="center"><?php echo $title;?></td>
						</tr>
						<tr>
							<td id="first-child">Tanggal Putusan Sela</td>
							<td><input id="tgl_sela" name="tgl_sela" value="<?php echo (!empty($tglPutusanSela) ? $tglPutusanSela : date('d/m/Y'));?>" class="datepicker" maxlength="10" placeholder="tgl/bln/tahun"></td>
						</tr>
						<?php if($enc_a==111 OR $enc_a==112 OR  $enc_a==115 OR $enc_a==118 OR $enc_a==120){ ?>
						<tr>
							<td id="first-child">Hasil Putusan Sela </td>
							<td>								
								<span class="custom-dropdown custom-dropdown--emerald" style="160px">
			                        <select style="width:160px" name="is_keberatan" id="is_keberatan" class="custom-dropdown__select custom-dropdown__select--white" >                       
			                        <option value='1' <?php echo ($keberatan=='1')? 'selected':'' ?>  >Keberatan Diterima</option>
			                        <option value='2' <?php echo ($keberatan=='2')? 'selected':'' ?>  >Keberatan Ditolak</option>                        
			                        </select>
			                    </span>
							</td>
						</tr>
						<?php } ?>
						<tr>
							<td id="first-child" style="vertical-align:top;">Amar Putusan Sela</td>
							<td style="background:white;" id="amar_text">
								<span class="custom-dropdown custom-dropdown--emerald">
									<select style='width:130px;' id="template_amar_Sela"  class="custom-dropdown__select custom-dropdown__select--white">
	                                	<option value=''>Pilih amar</option>
	                                	<?php
	                                	if(!empty($list_amar)){
	                                		foreach ($list_amar as $key => $value) {
	                                			echo "<option value='".$value->id."'>".$value->nama."</option>";
	                                		}
	                                	}
	                                	?>
	                            	</select>
	                        	</span>
								<?php echo $this->ckeditor->editor("amar",$amar_sela);?>
							</td>
						</tr>
						<tr>
							<td id="first-child">Pemberitahuan Putusan Sela Kepada <?php echo $this->nativesession->getStatusPihak(10,$enc_alur,1,$jenis_perkara_id);?></td>
							<td>
								<input id="tgl_pihak1" name="tgl_pihak1" value="<?php echo (!empty($pemberitahuanPenggugat) ? $pemberitahuanPenggugat : '');?>" class="datepicker" maxlength="10" placeholder="tgl/bln/tahun">
							</td>
						</tr>
						<tr>
							<td id="first-child">Pemberitahuan Putusan Sela Kepada <?php echo $this->nativesession->getStatusPihak(10,$enc_alur,2,$jenis_perkara_id);?></td>
							<td>
								<input id="tgl_pihak2" name="tgl_pihak2" value="<?php echo (!empty($pemberitahuanTergugat) ? $pemberitahuanTergugat : '');?>" class="datepicker" maxlength="10" placeholder="tgl/bln/tahun">
							</td>
						</tr>
						<?php 
							if($enc_alur<100 && $enc_alur!=2 && $enc_alur!=8 && $enc_alur!=9 && $enc_alur!=10 && $enc_alur!=11 &&$enc_alur!=17){?>
						<tr>
							<td id="first-child">Pemberitahuan Putusan Sela Kepada <?php echo $this->nativesession->getStatusPihak(10,$enc_alur,3,$jenis_perkara_id);?></td>
							<td>
								<input id="tgl_pihak3" name="tgl_pihak3" value="<?php echo (!empty($pemberitahuanIntervensi) ? $pemberitahuanIntervensi : '');?>" class="datepicker" maxlength="10" placeholder="tgl/bln/tahun">
							</td>
						</tr>
						<?php } 
							if($enc_alur<8 OR $enc_alur==17 && $enc_alur!=2){?>
						<tr>
							<td id="first-child">Pemberitahuan Putusan Sela Kepada <?php echo $this->nativesession->getStatusPihak(10,$enc_alur,4,$jenis_perkara_id);?></td>
							<td>
								<input id="tgl_pihak4" name="tgl_pihak4" value="<?php echo (!empty($pemberitahuanTuruttergugat) ? $pemberitahuanTuruttergugat : '');?>" class="datepicker" maxlength="10" placeholder="tgl/bln/tahun">
							</td>
						</tr>
						<?php } ?>
						
							<input type="hidden" id="curr_date" value="<?php echo $current_date;?>">
							<input type="hidden" id="tglpendaftaran" value="<?php echo $tglpendaftaran;?>">
							<input type="hidden" id="tglsidangpertama" value="<?php echo $tglsidangpertama;?>">
						<?php if ($jumdata>0 && $urutan>1){?>
							<input type="hidden" id="tgl_putsela_sebelum" value="<?php echo $tgl_putsela_sebelum;?>">
						<?php } ?>
							<input type="hidden" id="enc" name="enc" value="<?php echo $enc;?>">
							<input type="hidden" id="act" name="act" value="<?php echo $act;?>">
							<input type="hidden" id="enc_alur" name="enc_alur" value="<?php echo $enc_alur;?>">
							<?php
							if ($aksi=="edit"){
								?>
								<input type="hidden" id="encputsela" name="encputsela" value="<?php echo $encputsela;?>">
								<?php
							}
							?>
						</tr>
						<tr>
						<td colspan="2" style="background:white;border:0px;" align="center">
							<input type="button" id='close_form_sela' value="Kembali" class="btn">
							<?php
							if($aksi=="edit"){
							if ($prosesid<210 || $urutan>1){
								echo '<input type="submit" id="hapus" value="Hapus" class="btn btn-danger" onclick="return false;">';
								}
							}

							?>
							<input type="hidden" id="urutan" name="urutan" value="<?php echo $urutan_pts;?>">
							<input type="hidden" id='close_form_refresh' value="">
							<input type="submit" id="simpan" value="Simpan" class="btn">
							<?php if (!empty($prosesid) and $prosesid>=210){echo "<br><br><span style='color:red'>Tombol Hapus Terkunci Dikarenakan Perkara Sudah Tahap Putusan Akhir</span>";} ?>
						</td>
					</tr>
					</tbody>
				</table>
			</form>
		</div>
	</div>
</div>
<script type="text/javascript">	
$('#template_amar_Sela').change(function(){
	$.post( "<?php echo base_url('managePutusanAkhir/getAmar');?>", { selected: $(this).val(), enc: "<?php echo $enc;?>" })
	.done(function( data ) {
	   	CKEDITOR.instances['amar'].setData(data); 
	});
})

$('#frm_sela').SubmitHandling({
	refresh:'1',
	setRefresh:1,
	divRef:'#konten',
	clicked:1,
	btnClicked:'#close_form_sela',
	whenStatus:1,
	isCKEdit:1,
	tdID:'amar_text',
	textID:'amar',
	next_step:1
});
$('#close_form_refresh').closingFormWin();
<?php 
if($this->session->userdata('jenis_pengadilan')==1){
?>
    $('#close_form_sela').click(function(){
        window.open("<?php echo base_url('perkara_detil/'.$enc.'/9');?>","_self");    
    });
<?php
}else if($this->session->userdata('jenis_pengadilan')==2){
?>
    $('#close_form_sela').click(function(){
        window.open("<?php echo base_url('perkara_detil_mil/'.$enc.'/9');?>","_self");    
    });    
<?php
}else if($this->session->userdata('jenis_pengadilan')==3){
?>
    $('#close_form_sela').click(function(){
        window.open("<?php echo base_url('perkara_detil_tun/'.$enc.'/9');?>","_self");    
    });
<?php
}else if($this->session->userdata('jenis_pengadilan')==4){
?>
    $('#close_form_sela').click(function(){
        window.open("<?php echo base_url('perkara_detil_agama/'.$enc.'/9');?>","_self");    
    });        
<?php
}else{
?>
    $('#close_form_sela').closingFormWin();
<?php
}
?> 
$('#tgl_sela').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;
				};
				
				var tmp3 = $('#tglpendaftaran').val().split("-");
				if((new Date(tmp[2]+"-"+tmp[1]+"-"+tmp[0]+"T00:00:00").getTime() <= new Date(tmp3[0]+"-"+tmp3[1]+"-"+tmp3[2]+"T00:00:00").getTime())){
					message = 'Tidak Dapat Memilih Sebelum Atau Tepat Pada Tanggal Pendaftaran Perkara';
					error = 1;
				};
				
				<?php if ($jumdata>0 && $urutan>1){ ?>
				var tmp4 = $('#tgl_putsela_sebelum').val().split("-");
				if((new Date(tmp[2]+"-"+tmp[1]+"-"+tmp[0]+"T00:00:00").getTime() <= new Date(tmp4[0],tmp4[1],tmp4[2]).getTime())){
					message = 'Tidak Dapat Memilih Sebelum Atau Tepat Pada Tanggal Putusan Sela Sebelumnya';
					error = 1;
				};
				<?php } ?>
				<?php if ($this->session->userdata('jenis_pengadilan')!=3){ ?>
				var tmp5 = $('#tglsidangpertama').val().split("-");
				if((new Date(tmp[2]+"-"+tmp[1]+"-"+tmp[0]+"T00:00:00").getTime() < new Date(tmp5[0],tmp5[1],tmp5[2]).getTime())){
					message = 'Tidak Dapat Memilih Sebelum Tanggal Sidang Pertama';
					error = 1;
				};
				<?php } ?>
				
				if(error==1){
					message_error_show(message);
					$(this).css("background-color", "red");
				}else{
					$(this).css("background-color", "#dedbdb");
				}
				error = 0;
        	}
      	});
$('#tgl_pihak1').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
				};
				
				var tmp3 = $('#tgl_sela').val().split("/");
				if((new Date(tmp[2]+"-"+tmp[1]+"-"+tmp[0]+"T00:00:00").getTime() < new Date(tmp3[2]+"-"+tmp3[1]+"-"+tmp3[0]+"T00:00:00").getTime())){
					message = 'Tidak Dapat Memilih Sebelum Tanggal Putusan Sela';
					error = 1
				};

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

				var tmp3 = $('#tgl_sela').val().split("/");
				if((new Date(tmp[2]+"-"+tmp[1]+"-"+tmp[0]+"T00:00:00").getTime() < new Date(tmp3[2]+"-"+tmp3[1]+"-"+tmp3[0]+"T00:00:00").getTime())){
					message = 'Tidak Dapat Memilih Sebelum Tanggal Putusan Sela';
					error = 1
				};
				
				if(error==1){
					message_error_show(message);
					$(this).css("background-color", "red");
				}else{
					$(this).css("background-color", "#dedbdb");
				}
				error = 0;
        	}
      	});
$('#tgl_pihak3').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
				}

				var tmp3 = $('#tgl_sela').val().split("/");
				if((new Date(tmp[2]+"-"+tmp[1]+"-"+tmp[0]+"T00:00:00").getTime() < new Date(tmp3[2]+"-"+tmp3[1]+"-"+tmp3[0]+"T00:00:00").getTime())){
					message = 'Tidak Dapat Memilih Sebelum Tanggal Putusan Sela';
					error = 1
				};
				
				if(error==1){
					message_error_show(message);
					$(this).css("background-color", "red");
				}else{
					$(this).css("background-color", "#dedbdb");
				}
				error = 0;
        	}
      	});
$('#hapus').ButtonClickHandling({
	refresh:'1',
	setRefresh:1,
	divRef:'#konten',
	clicked:1,
	btnClicked:'#close_form_refresh',
	whenStatus:1,
	actions:'<?php echo base_url()?>managePutusanSela/validateDelete',
	formName:'#frm_sela',
	actionName:'Hapus Data'
});
$('.datepicker').ValidateDateInput();
</script>