<?php
if($this->session->userdata('is_logged_in')){
	if($this->session->userdata('idgroup')>2 AND $this->session->userdata('idgroup')!=900){
		redirect('login');
	}
}else{
	redirect('login');
}
?>
<hr class="thick-line" style="clear:both;">
<div id="left">
	<?php
	echo form_open(base_url().$page_url.'/search');
	$attributes = array('name' => 'search', 'id' => 'search-box', 'type' => 'text','size' => '50','placeholder'=>"  Ketik kata kunci  ");
	echo form_input($attributes);
	echo "<span>  </span>";
	$attributes = array('value' => 'Search', 'id' => 'search-btn1','class' => 'btn', 'type' => 'submit', 'onClick' => 'load()');
	echo form_submit($attributes);
	echo form_close('');
	?>
</div>
<div id="left">
<input type="submit" onClick='searchDetilShow()' value="Search Detil" id="search-btn1" class="btn">
</div>
<div id="left" style="margin-left:50px;">
	<input type="submit" value="Excel" class="btn"></input>
</div>
<div id="left" style="margin-left:50px;">
	<input type="submit" value="UPDATE" class="btn" onclick="">
</div>
<div id="pages">
    <div id="selector"></div>
</div>
<div class="cssTable">
	<table id="tablePerkaraAll">
		<col  width="3%" />
        <col  width="17%" />
        <col  width="75%" />
        <col  width="5%" />
		<tbody>
			<tr>
				<td>No</td>
				<td onclick="sorting(1)">Tanggal</td>
				<td>Keterangan</td>
				<td>Link</td>
			</tr>
			<?php
				if($hari_libur_list!=''){
					if($hari_libur_list->num_rows>0){
						if($page_active<1){
							$con = 1;
						}else{
							$con = $page_active+1;
						}
						$modelClass =& get_instance();
						
						# set history URL REQUESTED, this will be used to back on previous page.
						# 
						$this->nativesession->set_flash_session('history', current_url());
		    			foreach ($hari_libur_list->result() as $row) {
		    				echo "<tr>";
			    				echo '<td>'.$con.'</td>';
			    				echo '<td>'.$row->tanggal.'</td>';
			    				echo '<td>'.$row->keterangan.'</td>';
			    				echo '<td style="cursor:pointer;" align="center" onclick="show_edit(\''.base64_encode($modelClass->encrypt->encode($row->tanggal)).'\')">[<a href="#">edit</a>]</td>';
		    				echo "</tr>";
		    				$con++;
		    			}
			    	}else{
		    			echo "<tr><td colspan='4' align='center'>Data Tidak diTemukan</td></tr>";
		    		}
				}else{
		    		echo "<tr><td colspan='4' align='center'>Data Tidak diTemukan</td></tr>";
		    	}
			?>
		</tbody>
	</table>
</div>
<div id="pages_bottom" style="width:100%;padding-left:5px;padding-top:5px;">
    <div id="selector_bottom"></div>
</div>
<div id="popup_hari_libur" class="popup">
	<div style="margin: 0 auto;top: 50%;margin-top: 10%;margin-bottom: 25px;">
		<div class="detil" style="background-color:white;border-color: white;font-size:14px;margin-top:25px;width: 50%;margin: 0 auto;">
			<div id="sub_title" style="padding:10px;color:#5FB85C;text-align:center;">INFO DATA HARI LIBUR</div>
				<table id="tableDetilPerkara">
					<col width="40%">
					<col width="60%">
					<tbody>
						<tr>
							<td>Tanggal</td>
							<td style="padding:0px;padding-left:5px;">
								<input type="text" id='tanggal' name='tanggal' class="standard-input" maxlength="10" readonly="readonly">
							</td>
						</tr>
						<tr>
							<td>Keterangan</td>
							<td style="padding:0px;padding-left:5px;">
								<textarea id="keterangan" name="keterangan" class="standard-input" style="resize: none;margin: 0px; width: 350px; height: 100px;" readonly="readonly"></textarea>
							</td>
						</tr>
						<tr>
							<td colspan="2" style="background:white;" align="center">
								<input type="button" onClick='kembali_ruang_sidang();' value="Kembali" class="btn">
							</td>
						</tr>
					</tbody>
				</table>
		</div>
	</div>
</div>
<?php
$url = base_url().$page_url.'/sort/';
$keyword = (!empty($keyword))?'/'.$keyword : '';
?>
<script type="text/javascript">
function sorting(col){
	window.open('<?php echo $url;?>'+col+'/<?php echo $enc; ?><?php echo $keyword; ?>','_self')
}
<?php $enc = (!empty($enc)) ? "/".$enc : $enc;?>
function searchDetilShow(){
	window.open('<?php echo base_url();?>search','_self')
}


function show_edit(enc){
	if(enc!=''){
		$.post( "<?php echo base_url()?>hari_libur/info",{
	        enc:enc
	    }).done(function( response ){
	    	var json = jQuery.parseJSON(response);
	        if(json.st==1){
	        	$('#tanggal').val(json.tanggal);
	        	$('#keterangan').val(json.ket);
	        	$('#popup_hari_libur').fadeIn();
	        	$("body").css({overflow: 'hidden'});
	        }else{
	        	message_show(json.msg);
	        	return;
	        }
	    },'json');
	}else{
		message_show('Invalid Argument. Please refresh your browser and clear the cache');
	}
    
}

function kembali_ruang_sidang(){
	$('#popup_hari_libur').fadeOut();
	$("body").css({ overflow: 'inherit' })
}

</script>
