<?php
//echo $this->session->userdata('jenis_pengadilan');
?>
<hr class="thick-line" style="clear:both;">
<div id="left">
	<?php
	echo form_open(base_url().'perkara_dashboard/search');
	$attributes = array('name' => 'search', 'id' => 'search-box', 'type' => 'text','size' => '50','placeholder'=>"  Ketik kata kunci  ");
	echo form_input($attributes);
	$data = array(
		'enc' => $enc,
		'name' => 'enc'
	);
	echo form_hidden($data);
	echo "<span>  </span>";
	$attributes = array('value' => 'Search', 'id' => 'search-btn1', 'type' => 'submit');
	echo form_submit($attributes);
	echo form_close('');
	?>
</div>
<div id="left" style="margin-left:5px;">
	<input type="submit" value="Excel" class="btn"></input>
</div>
<?php
if($this->session->userdata('is_logged_in')){
	$AuthorizationAction = $this->nativesession->get('getAuthorizationAction');
	if($this->authorization->hasAuthorizationAddPerkara($idalurperkara,$AuthorizationAction)){
?>
			<div id="left" style="margin-left:50px;">
				<input id="tambah_pidana" type="submit" value="Tambah Perkara" class="btn"></input>
				<script type="text/javascript">
					$('#tambah_pidana').click(function(event){
						window.open('<?php echo base_url();echo "new_pidana/".$enc; ?>/','_self')
					});
				</script>
			</div>
<?php
	}
}
?>
<div id="pages">
    <div id="selector"></div>
</div>
<div class="cssTable">
	<table id="tablePerkaraAll">
		<col  width="3%" />
        <col  width="15%" />
        <col  width="7%" />
        <col  width="15%" />
        <col  width="17%" />
        <col  width="11%" />
        <col  width="13%" />
        <col  width="5%" />
        <col  width="4%" />
		<tbody>
			<tr>
				<td>No</td>
				<td onclick="sorting(1)">Nomor Perkara</td>
				<td onclick="sorting(2)">Tanggal Register</td>
				<td onclick="sorting(3)">Klasifikasi Perkara</td>
				<td onclick="sorting(4)">Para Pihak</td>
				<td onclick="sorting(5)">Tahapan</td>
				<td onclick="sorting(6)">Status Perkara</td>
				<td onclick="sorting(7)">Lama Proses</td>
				<td>Link</td>
			</tr>
			<?php
				if($list_perkara!=''){
					if($list_perkara->num_rows>0){
						if($page_active<1){
							$con = 1;
						}else{
							$con = $page_active+1;
						}
		    			foreach ($list_perkara->result() as $row) {
		    				$date = new DateTime(str_replace("-","",$row->tanggal_pendaftaran));
		    				echo "<tr>";
			    				echo '<td>'.$con.'</td>';
			    				echo '<td>'.$row->nomor_perkara.'</td>';
			    				echo '<td align="center">'.$date->format('d M Y').'</td>';
			    				echo '<td>'.$row->jenis_perkara_nama.'</td>';
			    				echo '<td>'.$row->para_pihak.'</td>';
			    				echo '<td>'.$row->tahapan_terakhir_text.'</td>';
			    				echo '<td>'.$row->proses_terakhir_text.'</td>';
			    				echo '<td>'.$row->lama_proses.'</td>';
			    				//echo '<td align="center">[<a href="'.base_url('perkara_detil/'.base64_encode($this->encrypt->encode($row->perkara_id))).'">detil</a>]</td>';
			    				if($this->session->userdata('jenis_pengadilan')==1){
			    					echo '<td align="center">[<a href="'.base_url('perkara_detil/'.base64_encode($this->encrypt->encode($row->perkara_id))).'">detil</a>]</td>';
		    					} else if ($this->session->userdata('jenis_pengadilan')==2){
		    						echo '<td align="center">[<a href="'.base_url('perkara_detil_mil/'.base64_encode($this->encrypt->encode($row->perkara_id))).'">detil</a>]</td>';
		    					} else if ($this->session->userdata('jenis_pengadilan')==3){
		    						echo '<td align="center">[<a href="'.base_url('perkara_detil_tun/'.base64_encode($this->encrypt->encode($row->perkara_id))).'">detil</a>]</td>';
		    					} else {
		    						echo '<td align="center">[<a href="'.base_url('perkara_detil_agama/'.base64_encode($this->encrypt->encode($row->perkara_id))).'">detil</a>]</td>';
		    					}
		    				echo "</tr>";
		    				$con++;
		    			}
			    	}else{
		    			echo "<tr><td colspan='9' align='center'>Data Tidak diTemukan</td></tr>";
		    		}
				}else{
		    		echo "<tr><td colspan='9' 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>
<script type="text/javascript">
	function sorting(col){
		window.open('<?php echo base_url();?>perkara_dashboard/sort/'+col+'/<?php echo $enc; ?>/<?php echo $keyword; ?>','_self')
	}
	<?php $enc = (!empty($enc)) ? "/".$enc : $enc;?>
	function searchDetilShow(){
		window.open('<?php echo base_url();?>search<?php echo $enc; ?>','_self')
	}
</script>
