<?php
session_start();
include_once('../config/#Config.php');
if(!$_SESSION['UserName']){
die('<script>window.location.href=\''.$config['site']['url'].'index.php\';</script>');
}
$get_AD = mysqli_query($conn, "Select * From config_admin WHERE Account = '".$_SESSION['UserName']."'");
if(!mysqli_num_rows($get_AD)){
	die('Không đủ quyền.');
}

$condition		=	"";
if($_REQUEST['query']){
$phantich = explode('&',$_REQUEST['query']);
for($i=0;$i<=count($phantich);$i++){
     $phantichnew = explode('=',$phantich[$i]);
     $_GET[''.$phantichnew[0].''] = $phantichnew[1];
}
}  
$_GET['CauQuery'] = 'TimKiemQueryLogsLichSu';
include_once('paginator.class.jquery.php'); 
$qryStr		=	"SELECT * FROM logs_user WHERE UserName = '".$_REQUEST['keyword']."' ORDER BY ID ASC";     		   
$country	=	mysqli_query($conn,$qryStr);
$count		=	mysqli_num_rows($country);

$pages = new Paginator($count,9);
echo '<nav class="" aria-label="Page navigation example"> <ul class="pagination">';
echo $pages->display_pages();
echo '</ul></nav>';
echo '<div class="col-sm-6 text-right">';
echo "<span class=\"form-inline\">".$pages->display_jump_menu().$pages->display_items_per_page()."</span>";
echo '</div>';
echo '<div class="clearfix"></div>';
$limit	= $pages->limit_start.','.$pages->limit_end;
$qry 	=	mysqli_query($conn, $qryStr.' LIMIT '.$limit);
?>
                             <table class="mb-0 table">
<thead>
<tr>
<th scope="col" style=" font-size: 13px; ">#</th>
<th scope="col" style=" font-size: 13px; "><center>Máy Chủ</center></th>
<th scope="col" style=" font-size: 13px; "><center>Nhân Vật</center></th>
<th scope="col" style=" font-size: 13px; "><center>Nội Dung</center></th>
<th scope="col" style=" font-size: 13px; "><center>Số Dư Sau Trừ</center></th>
<th scope="col" style=" font-size: 13px; "><center>Thời Gian</center></th>
 </tr>
</thead>
<tbody>
<?php 
if($count>0){
 $b	=	1;
 while($val	=	mysqli_fetch_array($qry, MYSQLI_ASSOC)){ 
?>
<tr>
 <td><center><?php echo $b++; ?></center></td>
 <td><center><?php echo getServerName($val['Server']); ?></center></td>
 <td><center><?php echo getNameChar($val['Server'],$val['PlayerID']); ?></center></td>
 <td><center><label class="mb-2 mr-2 badge badge-info"><?php echo $val['Messager']; ?></label></center></td>
 <td><center><label class="mb-2 mr-2 badge badge-success"><?php echo number_format($val['SoDuHC']); ?></label></center></td>                
 <td><center><?php echo date('d/m/Y H:i:s',$val['Timer']); ?></center></td>
</tr>
<?php 
 }
}else{?>
<tr>
 <td colspan="6">No Record(s) Found!</td>
</tr>
<?php } ?>
</tbody>
</table>       
