<?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.');
}


if(!$_REQUEST['tb1']){
                     $_REQUEST['tb1'] = 0;
}
        $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'] = 'TimKiemQuerylogscard';
        include_once('paginator.class.jquery.php'); 
		if($_REQUEST['tb1'] == 0){
        $qryStr		=	"SELECT * FROM logscard WHERE UserName = '".$_REQUEST['keyword']."' ORDER BY Timer ASC"; 
        }
        if($_REQUEST['tb1'] == 1){
            $qryStr		=	"SELECT * FROM logscard WHERE UserName = '".$_REQUEST['keyword']."' and (Hash = N'VCB' or Hash = N'MoMo') ORDER BY Timer ASC"; 
         }
            if($_REQUEST['tb1'] == 2){
                $qryStr		=	"SELECT * FROM logscard WHERE UserName = '".$_REQUEST['keyword']."' and Hash = 'GameBank' ORDER BY Timer ASC"; 
           }
            if($_REQUEST['tb1'] == 3){
                $qryStr		=	"SELECT * FROM logscard WHERE UserName = '".$_REQUEST['keyword']."' and Active = 1 ORDER BY Timer ASC"; 
           }       
            if($_REQUEST['tb1'] == 4){
                $qryStr		=	"SELECT * FROM logscard WHERE UserName = '".$_REQUEST['keyword']."' and Active = 2 ORDER BY Timer ASC"; 
           }       
            if($_REQUEST['tb1'] == 5){
                $qryStr		=	"SELECT * FROM logscard WHERE UserName = '".$_REQUEST['keyword']."' and Active = 3 ORDER BY Timer 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>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>       
