<?php 
if ((isset($detjmediasi)) and (!empty($detjmediasi)) and ($detjmediasi!='')){
$jnsmed=$this->encrypt->decode(base64_decode($encmed));
	foreach ($detjmediasi as $row){
?>
<script src="<?php echo base_url();?>resources/js/jquery.ui.timepicker.js"></script>
		<div class="centering" style="width:800px;margin-top: 1%;">
		<div id='edit_jadwal_mediasi' style="border: 1px solid #ffffff;">
			<div class="detil" style="padding: 2px;background-color: white;">
				<form id="frm_edit_jadwal_mediasi" class="removeformbottomspace" method="post" action="<?php echo base_url().'jadwal_mediasi_c/validateEdit';?>">
					<table id="tableDetilPerkara" style="font-size:14px;">
						<col width="20%">
						<col width="80%">
						<tbody>
							<tr>
								<td colspan="2" style="padding:4px;background:white;font-size:16px;color:#111;" align="center"><strong>Edit Data Jadwal <?php echo $jnsmed;?></strong></td>
							</tr>
							<tr>
								<td>Tanggal<span style="color:red">*</span></td>
								<td><?php 
										$tanggalnya=$this->tanggalhelper->convertToInputDate($row->tanggal_mediasi);
										if ($row->urutan=='1'){ 
											echo $this->tanggalhelper->convertDayDate($row->tanggal_mediasi); 
											echo "<input type='hidden' name='tgl_mediasi' id='tgl_mediasi' value='$tanggalnya'>";
										}else{ 
											echo "<input type='text' id='tgl_mediasi' name='tgl_mediasi' class='datepicker' maxlength='10' placeholder='tgl/bln/tahun' value='$tanggalnya')";
										}
									?>
								</td>
							</tr>
							<tr>
								<td>Jam Pelaksanaan<span style="color:red">*</span></td>
								<td>
		                       		<input id="jammulai" name="jammulai" value="<?php echo substr($row->jam_mediasi,0,5); ?>" class="timepicker" maxlength="4" placeholder="HH:mm">&nbsp;s/d&nbsp;<input id="jamselesai" name="jamselesai" value="<?php echo substr($row->sampai_jam,0,5); ?>" class="timepicker" maxlength="4" placeholder="HH:mm">
								</td>
							</tr>
							<tr>
								<td>Dihadiri Oleh</td>
								<td>
									<span class="custom-dropdown custom-dropdown--emerald" style="width:200px">
										<select name="dihadiri_oleh" id="dihadiri_oleh" style="width:200px" class="custom-dropdown__select custom-dropdown__select--white">
											<option value="1" <?php echo ($row->dihadiri_oleh==1)? 'selected':''; ?>>Semua Pihak</option>
											<option value="2" <?php echo ($row->dihadiri_oleh==2)? 'selected':''; ?>>Penggugat Saja</option>											
											<option value="3" <?php echo ($row->dihadiri_oleh==3)? 'selected':''; ?>>Tergugat Saja</option>
											<option value="4" <?php echo ($row->dihadiri_oleh==4)? 'selected':''; ?>>Semua Pihak Tidak Hadir</option>
										</select>
									</span>
								</td>
							</tr>
							<tr>
								<td>Tempat<span style="color:red">*</span></td>
								<td style="padding:0px;padding-left:5px;">
									<textarea name="tempat" id="tempat" maxlength="500" class="standard-input" style="margin: 0px; width: 610px; height: 175px;resize: none;"><?php echo "$row->tempat";?></textarea>
								</td>
							</tr>
							<tr>
								<td colspan="2" class="buttongroup">
									<input type="hidden" id='curr_date' value="<?php echo $curr_date;?>">
									<input type="hidden" name="enc" id="enc" value="<?php echo $enc; ?>">
									<input type="hidden" name="encmediasi" id="enc" value="<?php echo $encmediasi; ?>">
									<input type="hidden" name="encjadwalmediasi" id="enc" value="<?php echo $encjadwalmediasi; ?>">
									<?php
									if ($row->urutan!='1'){ 
									?>
									<input type="hidden" name="tgljadwalmediasisblm" id="tgljadwalmediasisblm" value="<?php echo $detjmediasisblm; ?>">
									<?php } ?>
									<input type="button" id='close_edit_jadwal_mediasi' value="Kembali" class="btn">
									<?php
									if ($row->urutan!=1)
									{ ?>
										<input type="button" id="hapus" value="Hapus" style="text-decoration:none" class="btn btn-danger">
									<?php }	?>
									<input type="submit" id="simpan" value="Simpan" class="btn">
								</td>
							</tr>
						</tbody>
					</table>
				</form>
			</div>
		</div>
	</div>
<?php }
} ?>
<script type="text/javascript">
$('#hapus').ButtonClickHandling({
	refresh:'1',
	setRefresh:1,
	divRef:'#konten',
	clicked:1,
	btnClicked:'#close_edit_jadwal_mediasi',
	whenStatus:1,
	actions:'<?php echo base_url()?>jadwal_mediasi_c/hapus_jadwal_mediasi/',
	formName:'#frm_edit_jadwal_mediasi',
	actionName:'Hapus Data'
});
$('#frm_edit_jadwal_mediasi').SubmitHandling({
	refresh:'1',
	setRefresh:1,
	divRef:'#konten',
	clicked:1,
	btnClicked:'#close_edit_jadwal_mediasi',
	whenStatus:1
});
$('#close_edit_jadwal_mediasi').closingFormWin();
$('#tgl_mediasi').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(message);
					$(this).css("background-color", "red");
				}else{
					$(this).css("background-color", "#dedbdb");
				}
				error = 0;
        	}
      	});
$('#jammulai').timepicker({
    onSelect: function(){ 
	var jammulai1=$('#jammulai').val()
	var jamselesai1=$('#jamselesai').val()
		if(jamselesai1!=''){
			if (jamselesai1 <= jammulai1) {
	        	alert ("Jam Selesai Sidang Tidak Boleh Sama Atau Kurang Dari Jam Mulai Sidang");
	        	$('#jammulai').val('');	        	
			}
		}        
    }
});

$('#jamselesai').timepicker({
    onSelect: function(){ 
	var jammulai2=$('#jammulai').val()
	var jamselesai2=$('#jamselesai').val()
		if(jamselesai2!=''){
			if (jamselesai2 <= jammulai2) {
	        	alert ("Jam Selesai Sidang Tidak Boleh Sama Atau Kurang Dari Jam Mulai Sidang");
	        	$('#jamselesai').val('');
			}
		}        
    }
});
$('.datepicker').ValidateDateInput();
</script>