<hr class="thick-line" style="clear:both;">
<div id="left">
	<?php
	echo form_open(base_url().'penahanan_list/search');
	$attributes = array('name' => 'search', 'id' => 'search-box', 'type' => 'text','size' => '50','placeholder'=>"  Ketik kata kunci  ");
	echo form_input($attributes);
	$data = array(
		'enc' => $enc
	);
	echo form_hidden($data);
	echo "<span>  </span>";
	$attributes = array('value' => 'Search', 'id' => 'search-btn1', 'type' => 'submit', 'onClick' => 'load()');
	echo form_submit($attributes);
	echo form_close('');
	?>
</div>
<div id="left">
<input type="hidden" onClick='searchDetilShow()' value="Search Detil" id="search-btn1"></input>
</div>
<div id="left" style="margin-left:50px;"><input id="cetak_perkara_list" type="submit" value="Excel" class="btn"></input></div>&nbsp;
<?php if($idalurperkara=='118'){ ?>
<input type="submit" onClick="popup_form('<?php echo base_url();?>register_penahanan/<?php echo $idalurperkara; ?>');" value="Cetak Register" id="cetak_reg" class="btn btn-warning"></input>
<?php } ?>
<?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 type="submit" onClick='tambahDataPenahanan()' value="Tambah Penahanan" class="btn"></input>
			</div>
<?php
	}
}
?>
<div id="pages">
    <div id="selector"></div>
</div>
<div class="cssTable">
	<table id="tablePerkaraAll">
		<col  width="3%" />
        <col  width="15%" />
        <col  width="9%" />
        <col  width="9%" />
        <col  width="9%" />
        <col  width="4%" />
        <col  width="7%" />
        <col  width="14%" />
        <col  width="9%" />
        <col  width="8%" />
        <col  width="8%" />
        <col  width="5%" />
		<tbody>
			<tr>
				<td>No</td>
				<td onclick="sorting(1)">Nomor Perkara</td>
				<td onclick="sorting(2)">Nama</td>
				<td onclick="sorting(3)">Tempat Lahir</td>
				<td onclick="sorting(4)">Tanggal Lahir</td>
				<td onclick="sorting(5)">Umur</td>
				<td onclick="sorting(6)">Jenis Kelamin</td>
				<td onclick="sorting(7)">Alamat</td>
				<td onclick="sorting(8)">Ditahan Oleh</td>
				<td onclick="sorting(9)">Mulai</td>
				<td onclick="sorting(10)">Sampai</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) {
		    				echo "<tr>";
			    				echo '<td>'.$con.'</td>';
			    				echo '<td>'.$row->nomor_perkara.'</td>';
			    				echo '<td>'.$row->nama.'</td>';
			    				echo '<td>'.$row->tempat_lahir.'</td>';
			    				echo '<td>'.$this->tanggalhelper->convertDate($row->tanggal_lahir).'</td>';
			    				echo '<td>'.$row->umur.'</td>';
			    				$row->jenis_kelamin = $row->jenis_kelamin=='L'?'Laki-Laki':'Perempuan';
			    				echo '<td>'.$row->jenis_kelamin.'</td>';
			    				echo '<td>'.$row->alamat.'</td>';
			    				echo '<td>'.$row->jenis_penahanan_nama.'</td>';
			    				echo '<td>'.$this->tanggalhelper->convertDate($row->mulai).'</td>';
			    				echo '<td>'.$this->tanggalhelper->convertDate($row->sampai).'</td>';
			    				echo '<td align="center">[<a href="'.base_url('tampil_detail_penahanan/'.base64_encode($this->encrypt->encode($row->pihak_id)).'/'.base64_encode($this->encrypt->encode($row->perkara_id))).'">detil</a>]</td>';
		    				echo "</tr>";
		    				$con++;
		    			}
			    	}else{
		    			echo "<tr><td colspan='12' align='center'>Data Tidak diTemukan</td></tr>";
		    		}
				}else{
		    		echo "<tr><td colspan='12' align='center'>Data Tidak diTemukan</td></tr>";
		    	}
			?>
		</tbody>
	</table>
</div>
<?php
if($keyword!==''){
	$keyword=$keyword;
} else {
	$keyword="0";
}
?>
<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();?>penahanan_list/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')
	}
	function tambahDataPenahanan(){
		window.open('<?php echo base_url();?>tambah_penahanan<?php echo $enc; ?>','_self');
	}
	$('#cetak_perkara_list').click(function(){
		window.open('<?php echo base_url(); echo "perkara_list_cetak/cetak/7".$enc."/".$keyword; ?>','_self')
	});
</script>
