<?php

include("../config.php");
session_start();

if(isset($_SESSION["user_login"])){
	$userid = $_SESSION["user_login"];
}else{
		header("location: ../register-login.php");
	}
	

		//get admin info
		
		$stmt="SELECT * FROM users WHERE userid = :userid";
		$stmt=$pdo->prepare($stmt);
		$stmt->bindParam("userid", $userid, PDO::PARAM_STR);
		$stmt->execute();
		$row=$stmt->fetch();
		$userimage = (!empty($row["profilepix"]) ? "../img/users/".$row["profilepix"]: "../img/avatar.png");
		
	
		
	
?>

<style>
form label{
	font-weight:500!important;
	color:#444;
	cursor:pointer;
	font-size:16px!important;
}


</style>


<!DOCTYPE html>

<html lang="en">

<head>

        <meta charset="utf-8" />

        <title>Registered Users | Six Digital Assets</title>

        <meta name="viewport" content="width=device-width, initial-scale=1.0">

        <meta content="A fully featured cryptocurrency investment platform" name="description" />

        <meta content="Coderthemes" name="author" />

        <meta http-equiv="X-UA-Compatible" content="IE=edge" />

      

            <link rel="stylesheet" type="text/css" href="w3.css">

        <!-- Bootstrap Css -->

        <link href="assets/css/bootstrap.min.css" id="bootstrap-stylesheet" rel="stylesheet" type="text/css" />

        <!-- Icons Css -->

        <link href="assets/css/icons.min.css" rel="stylesheet" type="text/css" />

        <!-- App Css-->

        <link href="assets/css/app.min.css" id="app-stylesheet" rel="stylesheet" type="text/css" />

		<link href="../css/style7eda3860.css" rel="stylesheet">

    </head>



    <body>


	<div class='coversoverlay'>
	<center><img src="../img/loader.gif" style="width:60px; margin-top:20%;"></center>
	</div>

  <!-- Begin page -->
  <div id="wrapper" style="overflow:auto!important">

    
	
	
	<!-- Topbar Start -->
	<?php
	include("header.php");
	?>
    <!-- end Topbar -->
	
	

    <!-- ========== Left Sidebar Start ========== -->
    <div class="left-side-menu">

      <div class="slimscroll-menu">

        <!-- User box -->
        <div class="user-box text-center ">

          <div class="dropdown">
            <a href="#" class="user-name dropdown-toggle h5 mt-2 mb-1 d-block" data-toggle="dropdown" aria-expanded="false"></a>
            <div class="dropdown-menu user-pro-dropdown">




            </div>
          </div>


        </div>

        <!--- Sidemenu -->
        <?php include("sidebar.php");?>
		
        <!-- End Sidebar -->
        <div class="clearfix"></div>



                </div>

                <!-- Sidebar -left -->



            </div>

            <!-- Left Sidebar End -->






            <div class="content-page" style="padding:0px;">

                <div class="content" style="width: 100%;color: white;">



                    <!-- Start Content-->

                    <div class="container-fluid" >

                        <div id="google_translate_element"></div>

                         <div class="row">

                            <div class="col-md-12" style="padding-left:0px; padding-right:0px">
                            
						  
						
				<div class="col-md-12" style="margin-top:20px!important;margin: auto;">

                <div class="card-box" style="background-image: radial-gradient(ellipse closest-side, rgba(255, 255, 255, 0.8),#d5e1ed), url(../img/users.png); background-repeat:no-repeat; background-position:center">
				
			
				<h3 align="center" style="color:#475d79" id="wlcm">Users List</h3>
				<div class="dropdown-divider" style="border-color:#d4dee7;"></div>
				
				
				<!--SearchBox-->
			 <center>
			   <div class="input-group input-group-sm" style="max-width:600px;margin-top:20px;">
                <input type="search" name="g-search" class="g-search form-control" style="height:40px" placeholder="Search User">
                 <div class="input-group-append">
                    <div class="btn btnss" style="padding:10px; width:50px;">
                      <i class="fas fa-search"></i>
                    </div>
                  </div></div>
				 <br>
				<div class="s-results"></div>
				</center>
				<!--/SearchBox-->
				
				
				<p><br>
				<div class="row" style="justify-content: space-evenly;">
				
				
				
				<?php 
		//get users info
		$stmt="SELECT * FROM users WHERE userid != :userid ORDER BY userid DESC";
		$stmt=$pdo->prepare($stmt);
		$stmt->bindParam("userid", $userid, PDO::PARAM_STR);
		$stmt->execute();
		$usersInfo=$stmt->fetchAll();
		
		if($stmt->rowCount()<1){
			
				echo '<p><h4 class="text-center" style="color:#767e80;position:absolute;">';
			 if(isset($location)){echo "No ".$location;}else{echo "No Registered user yet";}
				echo '</h4><p><br><p><br><p><br><br><p><br>';
			
		}else{
			
			
		foreach($usersInfo as $userInfo){
		$siteUserImg = (!empty($userInfo["profilepix"]) ? "../img/users/".$userInfo["profilepix"]: "../img/avatar.png");
				?>
				
				<div class="col-md-4 user-boxes">
				<div class="card-box" style="background-image: radial-gradient(ellipse closest-side, rgba(255, 255, 255, 0),#f1f6fb), url(../img/split.jpg); background-repeat:no-repeat; background-position:center; padding:12px;">
				
				<section style="display:flex">
				<div><img src="<?php echo $siteUserImg;?>" class="avatars"></div>
				<div style="margin:10px 6px; font-size:18px; color:#405972; font-weight:500;">
				<?php echo htmlspecialchars($userInfo["fullName"]);?><br>
				<div style="color:#7c8a99; font-size:13px; margin-top:4px;"><?php echo htmlspecialchars($userInfo["email"]);?></div>
				
				<?php
				//get users Acct Bal
				$stmt=$pdo->prepare("SELECT * FROM account WHERE userid = :userid");
				$stmt->bindParam("userid", $userInfo["userid"], PDO::PARAM_STR);
				$stmt->execute();
				$Act = $stmt->fetch()
				?>
				
				<div style="color:#405972; font-size:15px; margin-top:5px;">
				<b>Acct Balance</b> &nbsp; $ <?php echo number_format(intval($Act["balance"]))?></div>
				</div>
				</section>
				<div class="dropdown-divider" style="border-color:#d4dee7;margin-top:3px;"></div>
				
				
				
				
			
				<section style="display:flex; justify-content: space-around;">
				
				<a href="userStats.php?getUser=<?php echo intval($userInfo["userid"]);?>" style="color:#fff;">
				<div style="font-size:14px;margin:5px;padding:5px;" class="btn btn-sm btn-primary btnss btn-block">
				User Stats &nbsp; <i class="fa fa-caret-right"></i>
				</div></a>
				
				
				<a href="inbox.php?user=<?php echo intval($userInfo["userid"]);?>" style="color:#fff;">
				<div style="font-size:14px;margin:5px;padding:5px;" class="btn btn-sm btn-primary btnss btn-block">
				Message user &nbsp; <i class="fa fa-caret-right"></i></div></a>
				<section/>
				
				</div>
				</div>
			
		<?php } }?>
			
			
            </div>
				
				
				
				
				
				
				
				
					
					
					</div>
					</div>
					</div> <!-- container-fluid -->



                </div> <!-- content -->
                </div> 
              
					</div> 
	
					</div>
               


       

        <!-- Vendor js -->

        <script src="assets/js/vendor.min.js"></script>



        <!-- knob plugin -->

        <script src="assets/libs/jquery-knob/jquery.knob.min.js"></script>



        <!--Morris Chart-->

        <script src="assets/libs/morris-js/morris.min.js"></script>

        <script src="assets/libs/raphael/raphael.min.js"></script>



        <!-- Dashboard init js-->

        <script src="assets/js/pages/dashboard.init.js"></script>



        <!-- App js -->

        <script src="assets/js/app.min.js"></script>

   
   
   
   
   
   
   
   
   
   <script>
   
   $(document).ready(function(){
	
	$('.coversoverlay').hide();
	
	
	
	
	
	
	
	//AJAX SEARCH USERS
	
	$(".g-search").keyup(function(){
		
	let query = $(".g-search").val();
	

	$.ajax({
		url:'userSearch.php',
		type:'POST',
		data:{query:query},
		success:function(data){
			//console.log(data);
			
		if(query ==""){
		$(".s-results").css({"display":"none"});
		$(".user-boxes").css({"display":"block"});
		}else{
			$(".s-results").css({"display":"block"});
			$(".user-boxes").css({"display":"none"});
			$(".s-results").html(data);
		}
			
			
			
		}
	});
		
	});
	
	
	
	
	
	
	
	
   });
   </script>
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
    </body>

</html>