<?php
$id_status_delegasi='xxx';
$diterima_oleh='xxx';
if ($p_tgl_penunjukan_jurusita !='' || $p_jurusita_nama!='') {
        $id_jurusita=$p_enc_jurusita;
        $tgl_jurusita=$p_tgl_penunjukan_jurusita;
        $jurusita_nama='Jurusita : '.$p_jurusita_nama;
}else{
        $tgl_jurusita='';
        $jurusita_nama='';  
        $id_jurusita='';
}
if ($idalur==1) {
	$sumber="Asal";
	$namaDelegasi="MASUK";
	$namapn=$pn_asal_text;
}else{
	$sumber="Tujuan";
	$namaDelegasi="KELUAR";
	$namapn=$pn_tujuan_text;
}
?>
<script src="<?php echo base_url();?>resources/js/jquery.idTabs.min.js"></script>
<hr class="thick-line" style="clear:both;">
<div style="clear:both;"></div>
<div id="left" class="detil" style="font-size:14px;margin-top:2px;width: 40%;margin-left:30px;border:1px solid #eee;padding:5px 0px 5px 5px">
<table id="tableDetilPerkara">
		<col  width="30%" />
        <col  width="60%" />
        <tbody>
			<tr>
				<th colspan="2" style="border-bottom:1px solid #eee;color:#fff;background:#5fb85c;">DATA PEMOHON DELEGASI</th>
			</tr>
			<tr>
				<td class="first-chlid">Pengadilan Negeri Asal/Pemohon</td>
				<td><?php echo $pn_asal_text;?> </td>
			</tr>
			<tr>
				<td  class="first-chlid">Nomor Perkara</td>
				<td><?php echo $nomor_perkara;?></td>
			</tr>
			<tr>
				<td  class="first-chlid">Nama Pihak</td>
				<td><?php echo $pihak;?></td>
			</tr>
			<tr>
				<td>Jenis Delegasi</td>
				<td><?php echo $jenis_delegasi_text;?></td>
			</tr>
			<tr>
				<td>Tanggal Sidang</td>
				<td><?php echo $tgl_sidang;?> </td>
			</tr>
			<tr>
				<th colspan="2" style="border-bottom:1px solid #eee;color:#fff;background:#5fb85c;">PENGIRIMAN BERKAS</th>
			</tr>
			<tr>
				<td  class="first-chlid">Tanggal Permohonan</td>
				<td><?php echo $tgl_delegasi;?> </td>
			</tr>
			<tr>
				<td>Tanggal Surat Pengantar</td>
				<td><?php echo $tgl_surat;?> </td>
			</tr>
			<tr>
				<td>Tanggal Pengiriman Relaas Asli</td>
				<td><?php echo $tgl_pengiriman;?> </td>
			</tr>
			<tr>
				<td>Nomor Surat Pengantar</td>
				<td><?php echo $nomor_surat;?> </td>
			</tr>
			<tr>
				<td>Nomor Resi Biaya</td>
				<td><?php echo $nomor_resi;?> </td>
			</tr>
			<tr>
				<td>Tgl Resi Biaya</td>
				<td><?php echo $tgl_resi;?> </td>
			</tr>
			<tr>
				<?php if (intval($biaya)!=0) {
						$biaya=number_format(strval($biaya),2,",",".");
					}else{
						$biaya=0;
					}
				?>
				<td>Jumlah Biaya yang dikirimkan</td>
				<td><?php echo $biaya;?> </td>
			</tr>
		</tbody>
	</table>
</div>
	<div id="left" class="detil" style="font-size:14px;margin-top:2px;width: 55%;margin: 0 auto;border-color: #FFFFFF">
		<form id="frm_proses_delegasi_masuk" style="background:white;margin-left:20px;border:1px solid #ddd;padding:5px 0px 5px 5px" method="post" enctype="multipart/form-data" action="<?php echo base_url().'manage_delegasi_perkara/simpan_pelaksanaan';?>">
			<input type="hidden" value="<?php echo $edit;?>" id="edit" name="edit">
			<table id="tableDetilPerkara" style="font-size:14px">
				<col width="40%">
				<col width="60%">
				<tbody>
					<tr>
						<th colspan="2" style="border-bottom:1px solid #eee;color:#fff;background:#5fb85c;">PELAKSANAAN DELEGASI</th>
					</tr>
					<tr>
						<td>Tanggal Berkas Relaas Diterima<font color="red">*</font></td>
						<td style="padding:0px;padding-left:5px;">
							<input id="tgl_surat_diterima" name="tgl_surat_diterima" value="<?php echo $p_tgl_surat_diterima;?>" class="datepicker" maxlength="10" placeholder="tgl/bln/tahun">
						</td>
					</tr>
					<tr>
						<td >Nomor Relaas <font color="red">*</font></td>
						<td>
							<input type="text" id='nomor_relaas' name='nomor_relaas' placeholder="Nomor Perkara PN Pengaju" value="<?php echo $nomor_perkara;?>" class="standard-input" maxlength="50"  style="width:300px;">
						</td>
					</tr>
					<tr>
						<td>Tanggal Penunjukkan Jurusita<font color="red">*</font></td>
						<td><?php echo $p_tgl_penunjukan_jurusita; ?></td>						
					</tr>
					<tr>
						<td>Jurusita / Jurusita Pengganti<font color="red">*</font></td>
						<td style="padding:0px;padding-left:5px;">
							<span class="custom-dropdown custom-dropdown--emerald" style='width:300px;'>
								<select style='width:300px;' name="cmb-jurusita" id="cmb-jurusita" class="custom-dropdown__select custom-dropdown__select--white" disabled>
									<option id="main-jurusita" value="-1" selected>-- Pilih Jurusita  -- </option>
									<?php
										if($data_jurusita!=''){
											if($data_jurusita->num_rows>0){
												$id = 'xxx';
								    			foreach ($data_jurusita->result() as $row) {
								    				echo '<option value="'. $row->id.'" ';echo ($row->id == $id_jurusita) ? 'selected' : ''; echo ' >'.$row->nama_gelar.'</option>';
								    			}
								    		}
								    	}
									?>
								</select>
							</span>
						</td>
					</tr>
					<tr>
					<td>Tanggal Pelaksanaan Delegasi<font color="red">*</font></td>
						<td style="padding:0px;padding-left:5px;">
							<input id="tgl_relaas" name="tgl_relaas" value="<?php echo $p_tgl_relaas;?>" class="datepicker" maxlength="10" placeholder="tgl/bln/tahun">
						</td>
					</tr>
					<tr>
						<td>Status Pelaksanaan Delegasi<font color="red">*</font></td>
						<td style="padding:0px;padding-left:5px;">
							<span class="custom-dropdown custom-dropdown--emerald" style='width:300px;'>
								<select style='width:300px;' name="status_delegasi" id="status_delegasi" class="custom-dropdown__select custom-dropdown__select--white">
									<option id="main-status" value="-1" selected>-- Pilih status pelaksanaan  -- </option>
									<option value="1" <?php echo ($p_id_status_delegasi)=="1" ? 'selected' : '' ?>>Bertemu (ditandatangani)</option>
									<option value="2" <?php echo ($p_id_status_delegasi)=="2" ? 'selected' : '' ?>>Bertemu (tidak bersedia tanda tangan)</option>
									<option value="3" <?php echo ($p_id_status_delegasi)=="3" ? 'selected' : '' ?>>Tidak Bertemu (Diterima oleh Lurah / Kepala Desa)</option>
									<option value="4" <?php echo ($p_id_status_delegasi)=="4" ? 'selected' : '' ?>>Tidak Bertemu (Alamat tidak ada)</option>
									
								</select>
							</span>
						</td>

					</tr>
					<tr id="tr_catatan" <?php echo ($p_catatan=='') ? 'hidden' : '' ?>>
						<td style="vertical-align:top;">Catatan Pelaksanaan</td>
						<td>
							<textarea rows="4" class="standard-input" cols="38" style="width: 301px; height: 104px;resize: none;" id="catatan_proses"  name="catatan_proses"><?php echo $p_catatan;?></textarea>
						</td>
					</tr>
					<tr>
						<th colspan="2" style="border-bottom:1px solid #eee;color:#fff;background:#5fb85c;">PENGIRIMAN KEMBALI</th>
					</tr>
					<tr>
						<td>Tanggal Surat Pengantar <font color="red">*</td>
						<td><input id="tgl_pengiriman_relaas" name="tgl_pengiriman_relaas" value="<?php echo $p_tgl_pengiriman_relaas;?>" class="datepicker" maxlength="10" placeholder="tgl/bln/tahun"></td>
					</tr>
					<tr>
						<td>Nomor Surat Pengantar <font color="red">*</font></td>
						<td>
							<input type="text" id='nomor_surat_pengantar_relaas' placeholder="Nomor Surat Pengiriman Relaas Asli" name='nomor_surat_pengantar_relaas' value="<?php echo $p_nomor_surat_pengantar_relaas;?>" class="standard-input" maxlength="50"  style="width:300px;">
						</td>
					</tr>
					<tr>
						<td>Tanggal Resi Pengiriman </td>
						<td><input id="p_tgl_resi" name="p_tgl_resi" value="<?php echo $p_tgl_resi;?>" class="datepicker" maxlength="10" placeholder="tgl/bln/tahun"></td>
					</tr>
					<tr>
						<td>Nomor Resi Pengiriman</td>
						<td>
							<input type="text" id='nomor_resi' placeholder="" name='nomor_resi' value="<?php echo $p_nomor_resi;?>" class="standard-input" maxlength="50"  style="width:300px;">
						</td>
					</tr>
					<tr>
						<td>Biaya Panggilan<font color="red">*</font></td>
						<td>
							Rp. <input type="text" id='biaya' name='biaya' value="<?php echo $p_biaya;?>" class="standard-input" maxlength="50"  style="width:250px;">
						</td>
					</tr>
					<tr>

					
					<tr>
						<td colspan="3" style="background:white;" align="center">
							<input type="button" class="btn" id="kembali" value="Kembali">
							<input type="submit" id="simpan_proses_delegasi" value="Simpan" class="btn">
						</td>
					</tr>
						<input type="hidden" id="idalur" name="idalur" value="<?php echo base64_encode($this->encrypt->encode($idalur));?>">
						<input type="hidden" id="perkara_id" name="perkara_id" value="<?php echo $perkara_id;?>">	
						<input type="hidden" id="delegasi_id" name="delegasi_id" value="<?php echo $delegasi_id;?>">
						<input type="hidden" id="id_pn_asal_txt"  name="id_pn_asal_txt" value="<?php echo $id_pn_asal;?>">
						<input type="hidden" id="id_pn_tujuan_txt" name="id_pn_tujuan_txt" value="<?php echo $id_pn_tujuan;?>">
						<input type="hidden" id="jurusita_nama_txt" name="jurusita_nama_txt" value="<?php echo $p_jurusita_nama;?>">
						<input type="hidden" id="id_jurusita_txt" name="id_jurusita_txt" value="<?php echo $id_jurusita;?>">
						<input type="hidden" id="id_status_delegasi_txt" name="id_status_delegasi_txt" value="<?php echo  $p_id_status_delegasi;?>">
						<input type="hidden" id="status_delegasi_txt" name="status_delegasi_txt" value="<?php echo  $p_status_delegasi;?>">
						<input type="hidden" id="tgl_surat_relaas" name="tgl_surat_relaas" value="<?php echo  $tgl_surat_relaas;?>">
						<input type="hidden" id="curr_date" value="<?php echo $current_date;?>">
						<input type="hidden" id="tgl_penunjukan_jsp" name="tgl_penunjukan_jsp" value="<?php echo $tgl_penunjukan_jurusita;?>">
				</tbody>
			</table>
		</form>
	</div>
<script src="<?php echo base_url();?>resources/js/autoNumeric.js"></script>
<script type="text/javascript">
$(document).ready(function() {
    $('#biaya').ForceNumericOnly();
    $('#biaya').autoNumeric('init', {mDec: '0'});

});
$( document ).ready(function() {
	
    $( function() {        
    	$('#tgl_surat_diterima').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("/");
				var tgl_surat_relaas = $('#tgl_surat_relaas').val();
                var tmp3 = tgl_surat_relaas.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((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 Tanggal Sebelum Tanggal Surat Pengantar Pengiriman Berkas';
                    error = 1
                }

                if(error==1){
                    message_error_show_parent(message);
                    $(this).css("background-color", "red");
                }else{
                    $(this).css("background-color", "#dedbdb");
                }               
			}
        });
	});
    $( function() {
        $('#tgl_relaas').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("/");
				var tgl_penunjukan_jsp = $('#tgl_penunjukan_jsp').val();
                var tmp3 = tgl_penunjukan_jsp.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((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 Tanggal Sebelum Tanggal Penunjukan Jurusita/Jurusita Pengganti';
                    error = 1
                }

                if(error==1){
                    message_error_show_parent(message);
                    $(this).css("background-color", "red");
                }else{
                    $(this).css("background-color", "#dedbdb");
                }               
			}
        });      
    });
    $( function() {
        $('#p_tgl_resi').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("/");
				var tgl_penunjukan_jsp = $('#tgl_penunjukan_jsp').val();
                var tmp3 = tgl_penunjukan_jsp.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((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 Tanggal Sebelum Tanggal Penunjukan Jurusita/Jurusita Pengganti';
                    error = 1
                }

                if(error==1){
                    message_error_show_parent(message);
                    $(this).css("background-color", "red");
                }else{
                    $(this).css("background-color", "#dedbdb");
                }               
			}
        });      
    });

	$( function() {
        $('#tgl_pengiriman_relaas').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("/");
				var tgl_penunjukan_jsp = $('#tgl_penunjukan_jsp').val();
                var tmp3 = tgl_penunjukan_jsp.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((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 Tanggal Sebelum Tanggal Penunjukan Jurusita/Jurusita Pengganti';
                    error = 1
                }

                if(error==1){
                    message_error_show_parent(message);
                    $(this).css("background-color", "red");
                }else{
                    $(this).css("background-color", "#dedbdb");
                }               
			}
        });      
    });
        
});

$("#cmb-jurusita").change(function() {
	var IDJurusita = $("#cmb-jurusita option:selected").val();
	var p_jurusita_nama=$("#cmb-jurusita option:selected").text();
	if ($('#cmb-jurusita').val()==-1) {
		$('#id_jurusita_txt').val('');
		$('#p_jurusita_nama_txt').val('');
	}else{
		$('#id_jurusita_txt').val(IDJurusita);
		$('#p_jurusita_nama_txt').val(p_jurusita_nama);
	}
});

$("#status_delegasi").change(function() {
	var IDStatusDelegasi = $("#status_delegasi option:selected").val();
	var delegasiText=$("#status_delegasi option:selected").text();
	if ($('#status_delegasi').val()==-1) {
		$('#tr_catatan').hide();	
		$('#id_status_delegasi_txt').val('');
		$('#status_delegasi_txt').val('');
	} else {
		$('#tr_catatan').show();
		$('#id_status_delegasi_txt').val(IDStatusDelegasi);
		$('#status_delegasi_txt').val(delegasiText);
	}

});

$('#frm_proses_delegasi_masuk').SubmitHandling({
	refresh:'1',
	setRefresh:1,
	divRef:'#konten',
	clicked:1,
	btnClicked:'#kembali',
	whenStatus:1,
});

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