<?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.');
}
?>        
 <div class="main-card mb-3 card">
 <div role="group" class="btn-group-sm nav btn-group">
                                                        <a data-toggle="tab" href="#tab-eg1-0" class="btn-shadow btn btn-primary show">Lịch Sử Nạp</a>
                                                        <a data-toggle="tab" href="#tab-eg1-1" class="btn-shadow btn btn-primary show active">Lịch Sử Web</a>
                                                        <a data-toggle="tab" href="#tab-eg1-2" class="btn-shadow btn btn-primary show active">Lịch Sử ADMIN Can Thiệp</a>
                                                    </div>
                                            <div class="card-body">
                                                <div class="tab-content">
                                                    <div class="tab-pane show active" id="tab-eg1-0" role="tabpanel">
                                                    <div class="table-responsive" id="lichsunapform">

               <?php
        $condition		=	"";
        if($_REQUEST['query']){
            $phantich = explode('&',$_REQUEST['query']);
            for($i=0;$i<=count($phantich);$i++){
                    $phantichnew = explode('=',$phantich[$i]);
                    $_GET[''.$phantichnew[0].''] = $phantichnew[1];
            }
            if($_GET['keyword']){
               $_REQUEST['keyword'] = $_POST['keyword'];
            }
        }  
        $_GET['CauQuery'] = 'TimKiemQuerylogscard';
        include_once('../paginator.class.jquery.php'); 
        $qryStr		=	"SELECT * FROM logscard WHERE UserName = '".$_POST['user']."' and Server = '".$_POST['sv']."' ORDER BY Timer DESC";     		   
		$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>Loại Nạp</center></th>
      <th scope="col" style=" font-size: 13px; "><center>Mệnh Giá</center></th>
      <th scope="col" style=" font-size: 13px; "><center>Seri</center></th>
      <th scope="col" style=" font-size: 13px; "><center>Tình Trạng</center></th>
      <th scope="col" style=" font-size: 13px; "><center>Thời Gian</center></th>
    			</tr>
		</thead>
		<tbody>
			<?php 
			if($count>0){
				$n	=	1;
				while($val	=	mysqli_fetch_array($qry, MYSQLI_ASSOC)){ 
 			if($val['Active'] == 0){
				$TinhTrang = '<label class="mb-2 mr-2 badge badge-info">Đang chờ</label>';
			}
			if($val['Active'] == 1){
				$TinhTrang = '<label class="mb-2 mr-2 badge badge-success">Thành công</label>';
			}			
			if($val['Active'] == 2){
				$TinhTrang = '<label class="mb-2 mr-2 badge badge-danger">Bị hủy</label>';
			}
			if($val['Active'] == 3){
				$TinhTrang = '<label class="mb-2 mr-2 badge badge-warning">Sai Mệnh giá</label>';
			}		
$NoiDungSeri = $val['transaction_id'];
if($val['Seri']){
$NoiDungSeri = $val['Seri'];
}	
if($val['Hash'] == 'VCB' or $val['Hash'] == 'MoMo'){
$LoaiThanhToan = $val['Hash'];
$MaNap =  $config['site']['KeyNap']."-".$val['UserName'];
}	 else {
$LoaiThanhToan = $val['TypeCard'];
$MaNap = $val['PassCard'];
}
			?>
			<tr>
				<td><center><?php echo $n++; ?></center></td>
                <td><center><?php echo nameCardType($LoaiThanhToan); ?></center></td>
				<td><center><?php echo number_format($val['Money']); ?></center></td>
				<td><center><?php echo $NoiDungSeri; ?></center></td>
                <td><center><?php echo $TinhTrang; ?></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>       
                                        </div>    

                                                    </div>
													<!----------------- TAB 1 ----------------------------->
                                                    <div class="tab-pane show" id="tab-eg1-1" role="tabpanel">
                                                    <div class="table-responsive" id="lichsuingameform">

<?php
$condition		=	"";
if($_REQUEST['query']){
$phantich = explode('&',$_REQUEST['query']);
for($i=0;$i<=count($phantich);$i++){
     $phantichnew = explode('=',$phantich[$i]);
     $_GET[''.$phantichnew[0].''] = $phantichnew[1];
}
if($_GET['keyword']){
$_REQUEST['keyword'] = $_POST['keyword'];
}
}  
$_GET['CauQuery'] = 'TimKiemQueryLogsLichSu';
$qryStr		=	"SELECT * FROM logs_user WHERE UserName = '".$_POST['user']."' ORDER BY Timer DESC";     		   
$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 $val['Server']; ?></center></td>
 <td><center><?php echo $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>       
                         </div>                                                          

                                                    </div>
													<!------ TAB 2 ---->
                                                    <div class="tab-pane show" id="tab-eg1-2" role="tabpanel">
                                                    <div class="table-responsive" id="lichsuingameform">

<?php
$condition		=	"";
if($_REQUEST['query']){
$phantich = explode('&',$_REQUEST['query']);
for($i=0;$i<=count($phantich);$i++){
     $phantichnew = explode('=',$phantich[$i]);
     $_GET[''.$phantichnew[0].''] = $phantichnew[1];
}
if($_GET['keyword']){
$_REQUEST['keyword'] = $_POST['keyword'];
}
}  
$_GET['CauQuery'] = 'TimKiemQueryLogsLichSu';
$qryStr		=	"SELECT * FROM logs_admin WHERE Messager Like '%".$_REQUEST['user']."%' ORDER BY Timer DESC";     		   
$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>Can Thiệp</center></th>
<th scope="col" style=" font-size: 13px; "><center>Nội Dung</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 $val['UserName']; ?></center></td>
 <td><center><label class="mb-2 mr-2 badge badge-info"><?php echo $val['Messager']; ?></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>       
                         </div>                                                          

                                                    </div>													
                                                </div>
                                            </div>
                                        </div>
                                        <script>
                                         function TimKiemQuerylogscard(caulenh){
                                               $.post('paginator.logscard.php', {query:caulenh,keyword:'<?=$_REQUEST['user']?>'},function(data){
                                                $('#lichsunapform').html(data);
                                               });
                                        }
                                        function TimKiemQueryLogsLichSu(caulenh){
                                               $.post('paginator.logsingame.php', {query:caulenh,keyword:'<?=$_REQUEST['user']?>'},function(data){
                                                $('#lichsuingameform').html(data);
                                               });
                                        }
                                        </script>
