<?php 
$tgl_sekarang = date("Y-m-d");

?>

<link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>resources/css/date-css.css" />
<div class="centering" style="width:370px;margin-top: 10%;">
	<div id='popup_cetak_jadwal_sidang' style="border: 1px solid #ffffff;">
    <div class="detil" style="padding: 2px;background-color: white;">
		<form id="form_relaas" name="" class="templatepopform" target="_self" method="POST" action="<?php echo base_url().'sidang_list_cetak/cetak_jadwal_sidang_ruang';?>">
		<table id="tableDetilPerkara" style="background: #dedbdb;">
			<col width="30%">
			<col width="70%">
			<tbody>
				<tr>
					<td colspan='2' style="font-size:15px;text-align:center;"><font color="#fff">CETAK JADWAL SIDANG</font></td>
				</tr>
				<tr >
					<td >Pilih Tanggal <font color="red">*</font></td>
					<td style="padding:0px;padding-left:5px;">
						<span class="custom-dropdown custom-dropdown--emerald" style="width:100px">
						<input id="tgl_transaksi" name="tgl_transaksi" value="<?php echo (!empty($tgl_sekarang) ? $this->tanggalhelper->convertToInputDate($tgl_sekarang) : '');?>" class="datepicker" maxlength="10" placeholder="tgl/bln/tahun">
						</span>
					</td>
				</tr>
				<tr id="rw_kriteria_cetak">
					<td >Kriteria Cetak <font color="red">*</font></td>
					<td style="padding:0px;padding-left:5px;">
						<span class="custom-dropdown custom-dropdown--emerald" style='width:210px;'>
							<select name="kriteria_cetak" id="kriteria_cetak" style='width:210px;' class="custom-dropdown__select custom-dropdown__select--white">
								<option value="-1">Pilih Jenis Cetak</option>
								<option value="1">Berdasarkan Majelis</option>
								<option value="0">Berdasarkan Ruang Sidang</option>
							</select>
						</span>
					</td>
				</tr>
				<tr id="rw_pilih_majelis">
					<td >Berdasarkan Majelis <font color="red">*</font></td>
					<td style="padding:0px;padding-left:5px;">
						<span class="custom-dropdown custom-dropdown--emerald" style='width:210px;'>
							<select name="pilih_majelis" style='width:210px;' id="pilih_majelis" class="custom-dropdown__select custom-dropdown__select--white">
								<?php
								foreach ($ketuaMajelis->result() as $row) {
									
										echo '<option value='.$row->id.'>'.$row->nama_gelar.'</option>';
									
								}
							
									?>
							</select>
						</span>
					</td>
				</tr>
				<tr>
					<td style="background:white;padding:2px;"></td>
					<input type="hidden" id="enc" name="enc" value="<?php echo $enc;?>">
				</tr>
				<tr id="rw_nama_ruang">
					<td>Berdasarkan Ruang Sidang</td>
					<td style="padding:0px;padding-left:5px;">
						<span class="custom-dropdown custom-dropdown--emerald" style='width:210px;'>
							<select name="nama_ruang" style='width:210px;' id="nama_ruang" class="custom-dropdown__select custom-dropdown__select--white">
								<?php
								foreach ($ruangSidang->result() as $row) {
									
										echo '<option value='.$row->id.'>'.$row->nama_ruang.'</option>';
									
								}
								
								?>
							</select>
						</span>
					</td>
				</tr>
				
			
				</tr>
				<tr>
					<td colspan='2' style="background:white;" align="center">
					<input type="button" id='close_form_jadwal' value="Kembali" class="btn">
					 <input type="submit" id="simpan_btn" value="Cetak" class="btn btn-danger">	
					<input type="hidden" id="curr_date" name="curr_date" value="<?php echo $current_date;?>">					
					</td>
				</tr>
			</tbody>
		</table>
	</form>
	</div>
	</div>
</div>

<script type="text/javascript">
	$('#close_form_jadwal').closingFormWin();

	$('.datepicker').ValidateDateInput();
	$('#tgl_transaksi').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 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 (Sabtu & Minggu).';
                    error = 1;
                }
                
                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 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;
            }
        });
$('#rw_pilih_majelis').hide();
$('#kriteria_cetak').change(function(e){
	if($('#kriteria_cetak').val()==0){
		$('#rw_pilih_majelis').hide();
		$('#kriteria_cetak').show();
		$('#rw_nama_ruang').show();
		
	}else{
		$('#rw_pilih_majelis').show();
		$('#rw_nama_ruang').hide();

	}
});

</script>