<?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");
		
		
		
		//get user info
		$stmt="SELECT * FROM users WHERE userid != :userid";
		$stmt=$pdo->prepare($stmt);
		$stmt->bindParam("userid", $userid, PDO::PARAM_STR);
		$stmt->execute();
		$userInfo=$stmt->fetch();
		$countUsers = $stmt->rowCount();
		
		
		
		//Count User pending investment transactions
		$stmt="SELECT COUNT(*) AS invest FROM transactions WHERE type='investment' AND status='pending' ";
		$stmt=$pdo->prepare($stmt);
		$stmt->execute();
		$invest=$stmt->fetch();
		
		
		//Count User pending withdrawal requests
		$stmt="SELECT COUNT(*) AS withd FROM transactions WHERE type='withdrawal' AND status='pending' ";
		$stmt=$pdo->prepare($stmt);
		$stmt->execute();
		$withd=$stmt->fetch();
		
		
		
		//Get Account User Balance
		$stmt="SELECT * FROM account WHERE userid = :userid";
		$stmt=$pdo->prepare($stmt);
		$stmt->bindParam("userid", $userid, PDO::PARAM_STR);
		$stmt->execute();
		$actBal=$stmt->fetch();
		
		

?>




<!DOCTYPE html>
<html lang="en">


<head>
  <meta charset="utf-8" />
  <title>Admin</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" />


        <!-- 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>



<style>
body{
	background:#263140;
}

</style>



<body>
 

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

  <!-- Begin page -->
  <div id="wrapper">

   
   
   
   <!-- 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 -->

    <!-- ============================================================== -->
    <!-- Start Page Content here -->
    <!-- ============================================================== -->
    <div class="content-page">
      <div class="content">

        <!-- Start Content-->
        <div class="container-fluid">
          <div id="google_translate_element"></div>

          <div class="row" style="margin-top:20px;">



         


			<div class="col-xl-4 col-md-6">
             <div class="card-box" style="background-image: radial-gradient(ellipse closest-side, rgba(255, 255, 255, 0.9),#d5e1ed), url(../img/users.png); background-repeat:no-repeat; background-position:center">

                <h4 class="header-title mt-0 mb-3">Registered users</h4>
				<div style="color:#506b8e;font-size:15px;margin-top:-20px;margin-bottom:25px">
				<i class="fa fa-users"></i> &nbsp; Total registered users</div>
				
                <div class="widget-box-2">
                  <div class="widget-detail-2 text-right">

                    <h2 class="font-weight-normal mb-1"><?php echo $countUsers;?></h2>
					
				<a href="users.php" style="font-size:14px;margin-top:-5px; margin-bottom:-10px" class="btn btn-block btn-primary btnss">
					<i class="fa fa-users"></i> &nbsp; View all users
					</a>
				
                  </div>
                  
                </div>
              </div>
            </div><!-- end col -->


			





			<div class="col-xl-4 col-md-6">
             <div class="card-box" style="background-image: radial-gradient(ellipse closest-side, rgba(255, 255, 255, 0.9),#d5e1ed), url(../img/invest.png); background-repeat:no-repeat; background-position:center">

                <h4 class="header-title mt-0 mb-3">Pending Investments</h4>
				<div style="color:#506b8e;font-size:14px;margin-top:-20px;margin-bottom:25px">
				<i class="fa fa-dollar-sign"></i>&nbsp;  
				<?php if($invest["invest"] >0){echo ' Approve pending payments';}else{ echo " No pending investment";}?>
				</div>
				
                <div class="widget-box-2">
                  <div class="widget-detail-2 text-right">

                    <h2 class="font-weight-normal mb-1"><?php echo $invest["invest"]; ?></h2>
					
					
					<a href="pendingInvestment.php" style="font-size:15px;margin-top:-5px; margin-bottom:-10px" class="btn btn-block btn-primary btnss">
					<i class="fa fa-check"></i> &nbsp; Pending investments
					</a>
				
                  </div>
                  
                </div>
              </div>
            </div><!-- end col -->






			<div class="col-xl-4 col-md-6">
             <div class="card-box" style="background-image: radial-gradient(ellipse closest-side, rgba(255, 255, 255, 0.1),#d5e1ed), url(../img/piggy.jpg); background-repeat:no-repeat; background-position:center">

                <h4 class="header-title mt-0 mb-3">Withdrawal Requests</h4>
				<div style="color:#506b8e;font-size:15px;margin-top:-20px;margin-bottom:25px">
				<i class="fa fa-wallet"></i>&nbsp;
				<?php if($withd["withd"] >0){echo ' outstanding withdrawals';}else{ echo " No pending withdrawals";}?>
				</div>
				
                <div class="widget-box-2">
                  <div class="widget-detail-2 text-right">

                    <h2 class="font-weight-normal mb-1"><?php echo $withd["withd"]; ?></h2>
					
					
				<a href="pendingWithdrawal.php" style="font-size:14px;margin-top:-5px; margin-bottom:-10px" class="btn btn-block btn-primary btnss">
					<i class="fa fa-credit-card"></i> &nbsp; Approve pending withdrawals
					</a>
				
                  </div>
                  
                </div>
              </div>
            </div><!-- end col -->


		
		
		



          </div>
          <!-- end row -->

        </div> <!-- container-fluid -->

      </div> <!-- content -->
      </div> <!-- content page-->
      </div> <!-- wrapper-->







	    <!-- 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 type="text/javascript">
        function googleTranslateElementInit() {
          new google.translate.TranslateElement({
            pageLanguage: 'en'
          }, 'google_translate_element');
        }
      </script>
      <script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>







<script>

$(document).ready(function(){
	$(".coversoverlay").hide();





	//Redeem Cash
	$("#redeem").click(function(){
		
		let redeem = "redeem";
		
		$.ajax({
			url:'function.php',
			method:'POST',
			data:{redeem:redeem},
			beforeSend:function(){
				$("#loadR").removeClass("display-none");
				$("#noLoad").addClass("display-none");
				},
			success:function(data){
			$("#result").html(data);
				
				$("#loadR").addClass("display-none");
				$("#noLoad").removeClass("display-none");
				
				
			}
		});
		
		
		
		
	});
	









//Update notification to read when clicked - button in header.php
	$(".getMsg").click(function(){
		
		let senderID = this.id
		
		$.ajax({
			url:'../processChat.php',
			method:'POST',
			data:{senderID:senderID},
			success:function(data){ }
		});
		
	});






});

</script>





</body>

</html>