<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', 'type' => 'submit');
	echo form_submit($attributes);
	echo form_close('');
	?>
</div>

<?php
$page_name = "users_list";
$action = base64_encode($this->encrypt->encode("add"));
if($this->session->userdata('is_logged_in')){
	$AuthorizationForm = $this->nativesession->get('AuthorizationForm');
	if(empty($AuthorizationForm)){
		redirect('logout');
	}
	if($this->authorization->isAuthorized($page_name,$AuthorizationForm)){
?>
			<div id="left" style="margin-left:50px;">
			<form action="<?php echo base_url('user');?>" method="post">
				<input type="hidden" value="<?php echo $action;?>" id='action' name="action">
				<input type="submit" value="Tambah User" class="btn">
			</form>
			</div>
<?php
	}else{
		redirect('login');
	}
}else{
	redirect('login');
}
?>
<div id="pages">
    <div id="selector"></div>
</div>
<div class="cssTable">
	<table id="tablePerkaraAll">
		<col  width="3%" />
        <col  width="18%" />
        <col  width="15%" />
        <col  width="15%" />
        <col  width="18%" />
        <col  width="19%" />
        <col  width="5%" />
        <col  width="5%" />
		<tbody>
			<tr>
				<td>No</td>
				<td onclick="sorting(1)">Nama</td>
				<td onclick="sorting(2)">Username</td>
				<td onclick="sorting(3)">Email</td>
				<td onclick="sorting(4)">Hak Akses</td>
				<td>Keterangan</td>
				<td>Block</td>
				<td>Link</td>
			</tr>
			<?php
				if($users_list!=''){
					if($users_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 ($users_list->result() as $row) {
		    				echo "<tr>";
			    				echo '<td>'.$con.'</td>';
			    				echo '<td>'.$row->fullname.'</td>';
			    				echo '<td>'.$row->username.'</td>';
			    				echo '<td>'.$row->email.'</td>';
			    				echo '<td>'.$row->alternative_email.'</td>';
			    				echo '<td>'.$row->keterangan.'</td>';
			    				echo '<td>'.$row->block.'</td>';
			    				echo '<td align="center">[<a href="'.base_url('user/'.base64_encode($this->encrypt->encode($row->userid))).'">detil</a>]</td>';
		    				echo "</tr>";
		    				$con++;
		    			}
			    	}else{
		    			echo "<tr><td colspan='8' align='center'>Data Tidak diTemukan</td></tr>";
		    		}
				}else{
		    		echo "<tr><td colspan='8' 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>
<?php
$url = base_url().$page_url.'/sort/';
$keyword = (!empty($keyword))?'/enc/'.$keyword : '';
?>
<script type="text/javascript">
	function sorting(col){
		window.open('<?php echo $url;?>'+col+'<?php echo $keyword; ?>','_self')
	}
</script>
