<script src="<?php echo base_url();?>resources/js/jquery.ui.timepicker.js"></script>
<div class="centering" style="width:650px;margin-top: 1%;z-index:-100">
<div id='form_penetapan_sidang_pertama' style="border: 1px solid #ffffff;">
    <div class="detil" style="padding: 2px;background-color: white;">
        <div style="font-size:14px;">
            <form id="frm_sidang_pertama" class="removeformbottomspace" method="post" action="<?php echo base_url().'addSidangPertama_c/f_validate_input_add';?>">
            <table id='tableDetilPerkara' style="font-size:14px; width:100%" border="0">
            <tr><td colspan='2' style="padding:4px;background:white;font-size:16px;color:#111;" align="center"><strong>
			<?php
			echo $namahalaman;

            if($this->session->userdata('jenis_pengadilan')==2){
                $namanyapanitera2="Panitera";
        }else{
                $namanyapanitera2="Panitera/Panitera Pengganti";
                }
            ?></strong>
            </td></tr>
                <col width="280px">
                <col>
                <tbody>
                	<tr>
                    	<td id="first-child">Nomor Perkara</td>
                        <td>
                        	<span>
							    <?php
                                echo($nomor_perkara);
							    ?>
							    <input type="hidden" name='enc' id='enc' value='<?php echo $enc;?>'>
							</span>
						</td>
                    </tr>
                    <tr>
                    <?php
                        if ($alur_perkara_id>100){
						echo "<td id='first-child'>Tanggal Pelimpahan</td>";
					    }else{
						echo "<td id='first-child'>Tanggal Pendaftaran</td>";
					    }
					?>
                    	<td>
                        	<span>
						    <?php
                            echo $this->tanggalhelper->convertDayDate($tanggal_pendaftaran);
						    ?>
							</span>
                        </td>
                    </tr>
                    <tr>
                    	<td id="first-child">Tanggal Penetapan Majelis Hakim</td>
                        <td>
                        	<span>
						    <?php
                            echo $this->tanggalhelper->convertDayDate($tgl_penetapan_majelis_hakim);
						    ?>
							</span>
                        </td>
                    </tr>
                    <tr>
                    	<td id="first-child">Majelis Hakim/Hakim</td>
                        <td>
                        <?php
                            if (trim($nama_majelis_hakim)==''){
							echo 'Belum Penetapan Majelis Hakim';
						    }else{
							echo $nama_majelis_hakim;
						    }
						?>
                        </td>
                    </tr>
                    <tr>
                    	<td id="first-child">Tanggal Penunjukan <?php echo $namanyapanitera2 ?></td>
                        <td>
                        	<span>
						    <?php
                            echo $this->tanggalhelper->convertDayDate($tgl_penetapan_panitera_pengganti);
						    ?>
							</span>
                        </td>
                    </tr>
                    <tr>
                    	<td id="first-child"><?php echo $namanyapanitera2 ?></td>
                        <td>
                        <?php
                            echo $nama_panitera_pengganti;
						?>
                        </td>
                    </tr>
                <?php
                if($this->session->userdata('jenis_pengadilan')!=2){
                    ?>
                    <tr>
                    	<td id="first-child">Tanggal Penunjukan Jurusita</td>
                        <td>
                        	<span>
						    <?php
                            echo $this->tanggalhelper->convertDayDate($tgl_penetapan_jurusita);
						    ?>
							</span>
                        </td>
                    </tr>
                    <tr>
                    	<td id="first-child">Jurusita</td>
                        <td>
                        <?php
                            echo $nama_jurusita_text;
						?>
                        </td>
                    </tr>
                <?php
                       }
                    ?>
                    <tr>
						<td colspan="2" class="divider">Penetapan Hari Sidang Pertama</td>
				    </tr>
				    <tr>
                        <td id="first-child">Tanggal Penetapan Hari Sidang Pertama<span style="color:red">*</span></td>
                        <td>
                        	<input id="tgl_penetapan_sidang_pertama" name="tgl_penetapan_sidang_pertama" value="<?php echo (!empty($penetapan_hari_sidang) ? $this->tanggalhelper->convertToInputDate($penetapan_hari_sidang) : '');?>" class="datepicker" maxlength="10" placeholder="tgl/bln/tahun" required>
                       	</td>
                    </tr>
                    <tr>
                        <td id="first-child">Tanggal Hari Sidang Pertama<span style="color:red">*</span></td>
                        <td>
                        	<input id="tgl_sidang_pertama" name="tgl_sidang_pertama" value="<?php echo (!empty($tgl_sidang_pertama) ? $this->tanggalhelper->convertToInputDate($tgl_sidang_pertama) : '');?>" class="datepicker" maxlength="10" placeholder="tgl/bln/tahun" required>
                       	</td>
                    </tr>
                    <tr>
                        <td id="first-child">Jam Sidang Pertama<span style="color:red">*</span></td>
                        <td>
                        	<input id="jam_sidang_pertama" name="jam_sidang_pertama" value="<?php echo (!empty($jam_sidang_pertama) ? substr($jam_sidang_pertama,0,5) : '');?>" class="datepicker" maxlength="5" placeholder="HH:mm" required>
                       	</td>
                    </tr>
					<tr>
                        <td id="first-child">Ruang Sidang <span style="color:red">*</span></td>
                        <td style="background:white;">

								<?php
								if (!empty($ruangansidang) || $ruangansidang!=''){
									?>
									<span class="custom-dropdown custom-dropdown--emerald" style="width:200px">
										<select name="ruangan" id="ruangan" style="width:200px" class="custom-dropdown__select custom-dropdown__select--white">
											<?php
												foreach ($ruangansidang as $rowrs){
													$id=$rowrs->id;
													$ruangan=$rowrs->nama;
													$data_ruangan=$id."|".$ruangan;
													if ($rowrs->id==$ruangan_id){
														echo "<option selected value='$data_ruangan' >$rowrs->nama</option>";
													}
													else{
														echo "<option value='$data_ruangan'>$rowrs->nama</option>";
													}
												}
											?>
										</select>
									</span>
									<?php
									}else{
										echo "<span style='color:red;font-weight:bold'>Referensi Ruang Sidang Belum Ada</span>";
									}
									?>
								</td>
                    </tr>
                    <tr>
                    	<td colspan="2" class="buttongroup">
                            <input type="hidden" id="curr_date" value="<?php echo $current_date;?>">
                            <input type="hidden" id="tgl_penetapan_panitera_pengganti" name="tgl_penetapan_panitera_pengganti" value="<?php echo $tgl_penetapan_panitera_pengganti;?>">
                            <input type="hidden" id="tgl_penetapan_jurusita" name="tgl_penetapan_jurusita" value="<?php echo $tgl_penetapan_jurusita;?>">
                            <input type="hidden" id="action" name="action" value="<?php echo $action; ?>">
							<input type="hidden" id="namahalaman" name="namahalaman" value="<?php echo $namahalaman; ?>">
							<input type="hidden" id="enc" name="enc" value="<?php echo $enc; ?>">
                            <input type="button" id='close_form_add_sidang_pertama' value="Kembali" class="btn">
                            <?php
                            if ($action=='edit')
                            {
                                ?>
                                <input type="hidden" id="encjsidang" name="encjsidang" value="<?php echo base64_encode($this->encrypt->encode($jadwalsidang_id));?>">
								<input type="hidden" id="encphs" name="encphs" value="<?php echo $encphs; ?>">
                                <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>
                    <input type="hidden" id="refresh" class='detil_perkara_refresh' value="0">
            	</tbody>
         	</table>
     	</form>
        </div>
    </div>
</div>
</div>

<script type="text/javascript">
/*$('#close_form_add_sidang_pertama').closingFormWin();*/
<?php 
if($this->session->userdata('jenis_pengadilan')==1){
?>
    $('#close_form_add_sidang_pertama').click(function(){
        window.open("<?php echo base_url('perkara_detil/'.$enc.'/2');?>","_self");    
    });
<?php
}else if($this->session->userdata('jenis_pengadilan')==2){
?>
    $('#close_form_add_sidang_pertama').click(function(){
        window.open("<?php echo base_url('perkara_detil_mil/'.$enc.'/2');?>","_self");    
    });    
<?php
}else if($this->session->userdata('jenis_pengadilan')==3){
?>
    $('#close_form_add_sidang_pertama').click(function(){
        window.open("<?php echo base_url('perkara_detil_tun/'.$enc.'/2');?>","_self");    
    });
<?php
}else if($this->session->userdata('jenis_pengadilan')==4){
?>
    $('#close_form_add_sidang_pertama').click(function(){
        window.open("<?php echo base_url('perkara_detil_agama/'.$enc.'/2');?>","_self");    
    });        
<?php
}else{
?>
    $('#close_form_add_sidang_pertama').closingFormWin();
<?php
}
?> 
<?php
if ($action=='edit'){
?>
$('#hapus').ButtonClickHandling({
    refresh:'1',
    setRefresh:1,
    divRef:'#konten',
    clicked:1,
    btnClicked:'#close_form_add_sidang_pertama',
    whenStatus:1,
    actions:'<?php echo base_url();?>addSidangPertama_c/hapus_penetapan_sidang_pertama',
    formName:'#frm_sidang_pertama',
    actionName:'Hapus Data'
});
<?php
}
?>
$('#frm_sidang_pertama').SubmitHandling({
	refresh:'1',
	setRefresh:1,
	divRef:'#konten',
	clicked:1,
	btnClicked:'#close_form_add_sidang_pertama',
	whenStatus:1,
    next_step:1
});
$('#jam_sidang_pertama').timepicker({});
$('#tgl_penetapan_sidang_pertama').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("/");
                var tmp3 = $('#tgl_penetapan_panitera_pengganti').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;
                    $(this).val('');
				}
                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 Kurang Dari Tanggal Penetapan Panitera Pengganti';
                    error = 1;
					$(this).val('');
                }
				if(error==1){
					message_error_show(message);
					$(this).css("background-color", "red");
				}else{
					$(this).css("background-color", "#dedbdb");
				}
				error = 0;
        	}
});
$('#tgl_sidang_pertama').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 = $('#tgl_penetapan_sidang_pertama').val().split("/");  
				if(!tmp2[0] ){
                    message = 'Tanggal Penetapan Sidang Pertama Belum Diisi';
                    error = 1;
                    $(this).val('');
				}
                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 Sebelum Tanggal '+$('#tgl_penetapan_sidang_pertama').val();
                    error = 1;
                    $(this).val('');
                }
    			if(error==1){
    			    message_error_show(message);
    				$(this).css("background-color", "red");
    			}else{
    				$(this).css("background-color", "#dedbdb");
    			}
    			error = 0;
            }
});
$('.datepicker').ValidateDateInput();
</script>