<?php
session_start();
require("php_con.php");
require("check_user.php");
require("function.php");

if(isset($_GET['remove'])){
	$cs_id=mysqli_real_escape_string($connation,$_GET['remove']);
	mysqli_query($connation,"DELETE FROM customer_details WHERE cs_id='$cs_id'");
}
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" href="favicon.ico">
<title><?php echo $system_name; ?></title>
<link rel="stylesheet" href="main_css.css">
	
<script src="data_table/js/jquery-3.5.1.js"></script>
<script src="data_table/js/jquery.dataTables.min.js"></script>
<script src="data_table/js/dataTables.bootstrap4.min.js"></script>
<link rel="stylesheet" href="data_table/css/bootstrap.css">
<link rel="stylesheet" href="data_table/css/dataTables.bootstrap4.min.css">
	
<link rel="stylesheet" href="icon/css/font-awesome.css">
<link rel="stylesheet" href="icon/css/font-awesome.min.css">
	
<link rel="stylesheet" href="alert/sweetalert2.min.css">
<script src="alert/sweetalert2.min.js"></script>
</head>
<style>
	.table tr td{
		font-size: 14px;
		padding: 5px;
	}
	.table tr th{
		font-size: 14px;
		padding: 5px;
	}
</style>
<body>
<script>
window.addEventListener("load",function(){
	var load_screen=document.getElementById('load_screen');
	document.body.removeChild(load_screen);
});
</script>

<div id="load_screen"><div id="loading"><img src="image/loading.gif" width="80px;"></div></div>
	
<?php require("header.php"); ?>
	
<div class="contaner">

	
<strong>User Details</strong>
	
<div style="text-align: right; margin-bottom: 10px;">
<a href="add-user" class="btn btn-dark btn-sm"><i class="fa fa-plus"></i> Add New User</a>
<a href="profile" class="btn btn-dark btn-sm"><i class="fa fa-plus"></i> My Profile</a>
</div>
	<div class="row">
<div class="table-responsive">
<table id="example" class="table list-table" style="width:100%; font-size: 14px; text-transform: capitalize;">
        <thead>
            <tr>
                <th>No.</th>
				<th>&nbsp;</th>
                <th>Name</th>
                <th>User Name</th>
                <th>Account Type</th>
				<th>Reg. Time</th>
            </tr>
        </thead>
        <tbody>
			<?php
			$count_no=0;
			$list_qury=mysqli_query($connation,"SELECT *
			FROM user_details
			WHERE user_id!=1 AND user_type!=0 AND user_id!='$_COOKIE[user_id]'");
			while($list_resalt=mysqli_fetch_assoc($list_qury)){
			$count_no++;
			?>
            <tr>
                <td><?php echo number_format($count_no,0); ?></td>
				<td style="white-space: nowrap; text-align: center">
				<a href="edit-user?user_id=<?php echo $list_resalt['user_id']; ?>" class="badge badge-primary" title="Edit Product"><i class="fa fa-edit"></i></a>
				<?php /*?><a href="customer?remove=<?php echo $list_resalt['user_id']; ?>" class="badge badge-danger" title="Remove Customer" onClick="JavaScript:return confirm('Are your sure remove this customer?');"><i class="fa fa-trash"></i></a><?php */?>
				</td>
                <td><?php echo $list_resalt['user_fname']." ".$list_resalt['user_lname']; ?></td>
                <td><?php echo $list_resalt['user_username']; ?></td>
                <td>
				<?php if($list_resalt['user_type']==1){echo "Admin";} ?>
				<?php if($list_resalt['user_type']==2){echo "Cashier";} ?>
				</td>
				<td><?php echo date("Y-m-d h:i:s A",strtotime($list_resalt['user_reg_time'])); ?></td>
          </tr>
            <?php } ?>
        </tbody>
    </table>
</div>
	
	
<script>
$(document).ready(function() {
    $('#example').DataTable();
} );	
</script>
</div>
</div>	
	

	
</body>
</html>
<?php @mysqli_close($connation); ?>