<?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="table-responsive">
                                        
                                        <table class="align-middle mb-0 table table-borderless table-striped table-hover">
                                            <thead>
                                            <tr>
                                                <th class="text-center">#</th>
                                                <th>Tài Khoản</th>
                                                <th class="text-center">Số Điện Thoại</th>
                                                <th class="text-center">Số Dư</th>
                                                <th class="text-center">Chức Năng</th>
                                            </tr>
                                            </thead>
                                            <tbody>
                                                <?php
                                             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'] = $_GET['keyword'];
                                                 }
                                             }   
                                             $_GET['CauQuery'] = 'TimKiemQuery';

          include_once('paginator.class.jquery.php'); 
		$condition		=	"";
		$keyword		=	$_REQUEST['keyword'];
        $qryStr		=	"select * from account_web where ID like '%$keyword%' or Account like '%$keyword%' or Phone like '%$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>';
		echo '<div class="clearfix"></div>';
		$limit	= $pages->limit_start.','.$pages->limit_end;
        $qry 	=	mysqli_query($conn, $qryStr.' LIMIT '.$limit);
        if($count>0){
            $n	=	1;
            while($val	=	mysqli_fetch_array($qry, MYSQLI_ASSOC)){ 
                echo ' <tr>
                <td class="text-center text-muted">#'.$n.'</td>
                <td>
                    <div class="widget-content p-0">
                        <div class="widget-content-wrapper">
                            <div class="widget-content-left mr-3">
                                <div class="widget-content-left">
                                    <img width="40" class="rounded-circle" src="assets/images/e8df9049a53edc450eacd12adfa54194_icon.png" alt="">
                                </div>
                            </div>
                            <div class="widget-content-left flex2">
                                <div class="widget-heading">'.$val['Account'].'</div>
                                <div class="widget-subheading opacity-7">Đăng Ký : '.date('d/m/Y H:i:s',$val['Timer_Creat']).'</div>
                            </div>
                        </div>
                    </div>
                </td>
                <td class="text-center">'.$val['Phone'].'</td>
                <td class="text-center">
                    <div class="badge badge-warning">'.number_format($val['TienThat']).'</div>
                </td>
                <td class="text-center">
                <div class="dropdown d-inline-block">
                <button type="button" aria-haspopup="true" aria-expanded="false" data-toggle="dropdown" class="mb-2 mr-2 dropdown-toggle btn btn-primary">Quản Lý</button>
                <div tabindex="-1" role="menu" aria-hidden="true" class="dropdown-menu">
                    <button type="button" tabindex="0" class="dropdown-item" onClick="showpupuweb(\'edituser\',\''.$val['Account'].'\');">Chỉnh Sửa</button>
                    <button type="button" tabindex="0" class="dropdown-item" onClick="showpupuweb(\'quanlynhanvat\',\''.$val['Account'].'\');">Quản Lý Nhân Vật</button>
                    <button type="button" tabindex="0" class="dropdown-item" onClick="showpupuweb(\'chuyennap\',\''.$val['Account'].'\');">Chuyển Nạp</button>
                </div>
            </div>
                </td>
            </tr>';
            $n++;
            }
        }
    ?>
                                            </tbody>
                                        </table>
                                    </div>
                                    <script>
                                         function TimKiemQuery(caulenh){
                                               $.post('timkiem.class.php', {query:caulenh,keyword:$('#texttimkiem').val()},function(data){
                                                $('.table-responsive').html(data);
                                               });
                                        }
                                        </script>
