<div id="konten">
	<div id="pageTitle">
		<?php echo $page_title;?>
	</div>
    <br>
<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);
	$data = array(
		'enc' => $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>
<?php
$actionName = "audittrail_list";
if($this->session->userdata('is_logged_in')){
	$AuthorizationForm = $this->nativesession->get('AuthorizationForm');
	if($this->authorization->isAuthorized($actionName,$AuthorizationForm)==FALSE){
		
		redirect('login');
	}
}else{
	redirect('login');
}
?>
<div id="pages">
    <div id="selector"></div>
</div>
<div class="cssTable">
	<table id="tablePerkaraAll">
		<col  width="3%" />
        <col  width="12%" />
        <col  width="8%" />
        <col  width="10%" />
        <col  width="12%" />
        <col  width="8%" />
        <col  width="42%" />
        <col  width="5%" />
		<tbody>
			<tr>
				<td>No</td>
				<td onclick="sorting(1)">Date Time</td>
				<td onclick="sorting(2)">IP Address</td>
				<td onclick="sorting(3)">Username</td>
				<td onclick="sorting(4)">Table Name</td>
				<td onclick="sorting(5)">Action</td>
				<td onclick="sorting(6)">Keterangan</td>
				<td>Link</td>
			</tr>
			<?php
				if($list_audittrail!=''){
					if($list_audittrail->num_rows>0){
						if($page_active<1){
							$con = 1;
						}else{
							$con = $page_active+1;
						}
		    			foreach ($list_audittrail->result() as $row) {
		    				$date = new DateTime(str_replace("-","",$row->datetime));
		    				echo "<tr>";
			    				echo '<td>'.$con.'</td>';
			    				echo '<td align="center">'.$date->format('d M Y H:i:s').'</td>';
			    				echo '<td>'.$row->ipaddress.'</td>';
			    				echo '<td>'.$row->username.'</td>';
			    				echo '<td>'.$row->tablename.'</td>';
			    				echo '<td>'.$row->action.'</td>';
			    				echo '<td>'.$row->title.'</td>';
			    				echo '<td align="center">[<a href="#" onClick="show_detail('.$row->id.')">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>

<script type="text/javascript" src="<?php echo base_url();?>resources/js/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="<?php echo base_url();?>resources/js/jquery.simplePagination.js"></script>
<?php
$url = base_url().$page_url.'/sort/';
?>
<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<?php echo $enc; ?>','_self')
	}

	function show_detail(val){
		$('#popup-message').load('<?php echo base_url();?>popup_message/audittrail/'+val);
		$("body").css({ overflow: 'hidden' })
		$('#popup_message').fadeIn('slow');
	}

	function close_msg(){
    $("body").css({ overflow: 'inherit' })
    $('#popup').hide();
    $('#msg-container').html('');
    $('#popup_message').hide();
    $('#popup-message').html('');
}
</script>
<?php
$url = base_url().$page_url.'/page/';
?>
<script language="javascript">
$(function() {
    var totalPage = '<?php echo $total_rows; ?>';
    var page = '<?php echo $page_number;?>';
    $('#selector').pagination({
        items: totalPage,
        itemsOnPage: 50,
        displayedPages: 3,
        cssStyle: 'light-theme',
        currentPage:page,
        onPageClick: function(pageNumber){
            window.open('<?php echo $url;?>'+pageNumber+'/<?php echo $enc; ?>/<?php echo $keyword; ?>/col=<?php echo $column_sorted; ?>','_self')
        	}
        });
    $('#selector_bottom').pagination({
        items: totalPage,
        itemsOnPage: 50,
        displayedPages: 3,
        cssStyle: 'light-theme',
        currentPage:page,
        onPageClick: function(pageNumber){
            window.open('<?php echo $url;?>'+pageNumber+'/<?php echo $enc; ?>/<?php echo $keyword; ?>/col=<?php echo $column_sorted; ?>','_self')
        	}
        });
    });
</script>
</div>

<?php $this->load->view('footer'); ?>
<div id="popup_message" class="popup">
	<div class="centering">
		<div id="popup-message" style="width:600px;"></div>
	</div>
</div>
