<?php
require_once '../includes/core.php';
require '../includes/connect.php';


$count = @current(@mysql_fetch_assoc(@mysql_query("SELECT count('user_id') FROM users")));


if (loggedinadmin()){


$adminname = getfield1('name','admin','admin-id');
$admin_id = getfield1('admin-id','admin','admin-id');
$password = getfield1('password','admin','admin-id');

}else{ 
	header('Location:../loginexec.php');
}



?>






<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Admin - Dashboard</title>

<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/datepicker3.css" rel="stylesheet">
<link href="css/styles.css" rel="stylesheet">
<link rel="icon" type="image/png" href="../assets/img/favicon.png">

<!--Icons-->
<script src="js/lumino.glyphs.js"></script>

<!--[if lt IE 9]>
<script src="js/html5shiv.js"></script>
<script src="js/respond.min.js"></script>
<![endif]-->

</head>

<body>

    <?php include ('includes/header.php')  ?>

    <?php include ('includes/leftnav.php')  ?>
	
	
		
	<div class="col-sm-9 col-sm-offset-3 col-lg-10 col-lg-offset-2 main" style="margin-top: 20px">			
		<div class="row">
			<ol class="breadcrumb">
				<li><a href="#"><svg class="glyph stroked home"><use xlink:href="#stroked-home"></use></svg></a></li>
				<li class="active">home</li>
			</ol>
		</div><!--/.row-->
		
		<div class="row">
			<div class="col-lg-12">
				<h1 class="page-header">Members List</h1>
			</div>
		</div><!--/.row-->
		
		<div class="row">
			
			<div class="col-md-12">
				<div class="panel panel-primary">
					<div class="panel-heading" style="display: block">
						

						
					</div>
					</div>
					<div class="panel-body">




<?php
error_reporting('E_ALL ^ E_NOTICE');


$page=mysql_real_escape_string($_REQUEST['p']);
$limit=10;
if($page=='')
{
 $page=1;
 $start=0;
}
else
{
 $start=$limit*($page-1);
}



$query=mysql_query("SELECT * FROM users order by user_id DESC limit $start, $limit")or die(mysql_error());
$tot=mysql_query("SELECT * FROM users order by user_id DESC")or die(mysql_error());
$total=mysql_num_rows($tot);
$num_page=ceil($total/$limit);


echo'                  <table class="table table-bordered">
    <thead>
      <tr>
         <th>user_id</th>
        <th>Firstname</th>
        <th>Lastname</th>
         <th>Email</th>
       
        <th>Phone</th>

       
        

          
    
       
        <th>Date</th>

         <th>Ban</th>

      
        
        
        
        
        <th>Delete</th>
      
      </tr>
    </thead>
    <tbody>
     ';





while($res=mysql_fetch_array($query))
{

$id = mysql_real_escape_string($res['user_id']);	

				$value = mysql_real_escape_string($test['suspend']);	
			

				echo "<tr align='center'>";	
				
				echo"<td bgcolor=\"#E6E6E6\"><font color='#1c1c1c'>" .$res['user_id']."</font></td>";
				echo"<td bgcolor=\"#E6E6E6\"><font color='#1c1c1c'>" .$res['firstname']."</font></td>";
				echo"<td bgcolor=\"#E6E6E6\"><font color='black'>" .$res['lastname']."</font></td>";
				echo"<td bgcolor=\"#E6E6E6\"><font color='black'>" .$res['email']."</font></td>";
				
				echo"<td bgcolor=\"#E6E6E6\"><font color='black'>" .$res['phone']."</font></td>";

				
				
				echo"<td bgcolor=\"#E6E6E6\"><font color='black'>". $res['date']. "</font></td>";

             	echo"<td ><font>";
				
				if ($res['ban'] === '0') {
				echo "<span class='badge badge-success' style='background-color:green'><a href='unbanuser.php?id=$id' onclick=\"return confirm('Confirm you want to UnBan this user')\"' style='text-decoration:none;color:#fff'>Unban User</a></span>";
			}elseif ($res['ban'] === '1') {
				echo "<span class='badge badge-danger' style='background-color:red'><a href='banuser.php?id=$id' onclick=\"return confirm('Confirm you want to Ban this user')\"' style='text-decoration:none;color:#fff'>Ban User</a></span>";
			}


				echo"</font></td>";


			

               

				echo"<td > <a class='badge badge-danger' style='background-color:red' href ='admindel.php?id=$id' onclick=\"return confirm('Confirm you want to Delete this user')\">Delete</a>";



				
									
				echo "</tr>";


}
echo'</table>


 </tbody>';


function pagination($page,$num_page)
{
  echo'<ul style="list-style-type:none;">';
  for($i=1;$i<=$num_page;$i++)
  {
     if($i==$page)
{
 echo'<li style="float:left;padding:5px;">'.$i.'</li>';
}
else
{
 echo'<li style="float:left;padding:5px;"><a href="users.php?p='.$i.'">'.$i.'</a></li>';
}
  }
  echo'</ul>';
}
if($num_page>1)
{
 pagination($page,$num_page);
}
?> 






























					</div>
				</div>
			</div>





			
			
			

		</div><!--/.row-->




		
		
		
	
								
	
	</div>	<!--/.main-->

	<script src="js/jquery-1.11.1.min.js"></script>
	<script src="js/bootstrap.min.js"></script>
	<script src="js/chart.min.js"></script>
	<script src="js/chart-data.js"></script>
	<script src="js/easypiechart.js"></script>
	<script src="js/easypiechart-data.js"></script>
	<script src="js/bootstrap-datepicker.js"></script>
	<script>
		$('#calendar').datepicker({
		});

		!function ($) {
		    $(document).on("click","ul.nav li.parent > a > span.icon", function(){          
		        $(this).find('em:first').toggleClass("glyphicon-minus");      
		    }); 
		    $(".sidebar span.icon").find('em:first').addClass("glyphicon-plus");
		}(window.jQuery);

		$(window).on('resize', function () {
		  if ($(window).width() > 768) $('#sidebar-collapse').collapse('show')
		})
		$(window).on('resize', function () {
		  if ($(window).width() <= 767) $('#sidebar-collapse').collapse('hide')
		})
	</script>	
</body>

</html>
