<?php

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

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

		//Admin info
		$stmt=$pdo->prepare("SELECT * FROM users WHERE userid = :userid");
		$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 ID from URL
		if(isset($_GET["getUser"])){
			$UserStatID = intval($_GET["getUser"]);
		}else{
			header("location: users.php");
		}
		
		
		//get user info
		$stmt=$pdo->prepare("SELECT * FROM users WHERE userid = :UserStatID");
		$stmt->bindParam(":UserStatID", $UserStatID, PDO::PARAM_STR);
		$stmt->execute();
		$userInfo=$stmt->fetch();
		$siteUserImg = (!empty($userInfo["profilepix"]) ? "../img/users/".$userInfo["profilepix"]: "../img/avatar.png");
		
		
		//get users Acct Bal
		$stmt=$pdo->prepare("SELECT * FROM account WHERE userid = :UserStatID");
		$stmt->bindParam(":UserStatID", $UserStatID, PDO::PARAM_STR);
		$stmt->execute();
		$Act = $stmt->fetch();
		
		
		//get users Due Date Info
		$stmt=$pdo->prepare("SELECT * FROM duedate WHERE userid = :UserStatID");
		$stmt->bindParam(":UserStatID", $UserStatID, PDO::PARAM_STR);
		$stmt->execute();
		$duedate = $stmt->fetch();
		
	
?>

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




#btcCon, #ethCon, #usdtCon{
	height:0px;
	overflow:hidden;
	transition:1s;
}


input[type='radio']:after {
	width: 20px;
    height: 20px;
    border-radius: 15px;
    top: -2px;
    left: -1px;
    position: relative;
    background-color: #fbfbfb;
    content: '';
    display: inline-block;
    visibility: visible;
    border: 2px solid #6aa8cb;
}

    input[type='radio']:checked:after {
	width: 20px;
    height: 20px;
    border-radius: 15px;
    top: -2px;
    left: -1px;
    position: relative;
    box-shadow: 0em 0.1em 0.1em #bbb;
    background-color: #6aa8cb;
    content: '';
    display: inline-block;
    visibility: visible;
    border: 2px solid #ffffff;
 }
 
 .cancelMenu{
transition:1s;
background: #fff;
width: 100%;
position: fixed;
height: 0px;
overflow:hidden;
bottom: 0;
left: 0;
z-index: 200;
border-top: 3px solid #8c969d;
box-shadow: 2em 2em 8em #000;
 }
 .closeCn:hover{
	 background:#d52727;
 }
 .closeCn{
	 background:#f23535;
	 font-weight:550;
	 cursor:pointer;
	 float:right;
	 padding:10px;
	 border-radius:5px;
	 color:#fff;
	 margin:-10px auto 5px auto;
 }
</style>


<!DOCTYPE html>

<html lang="en">

<head>

        <meta charset="utf-8" />

        <title> User Statistics </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:0">

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



                    <!-- Start Content-->

                    <div class="container-fluid" >

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

                         <div class="row" style="justify-content: center;">

                            <div class="col-md-8" 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.3),#fbfbfb), url(../img/split.jpg); background-repeat:no-repeat; background-position:center; padding:15px;height:auto">
				
				<h2 align="center" style='color:#767e80' id="wlcm">User Stats</h2><br>
				<div class="dropdown-divider" style="border-color:#e9eff5;margin-top:0px;"></div>
		
	
		
		
		
				<section style="display:flex; padding:0px;">
				<div><img src="<?php echo $siteUserImg;?>" class="avatars"></div>
				
				<div style="margin:8px 10px; font-size:18px; color:#405972; font-weight:500;text-align:left;">
				<?php echo htmlspecialchars($userInfo["fullName"]);?><br>
				<div style="color:#7c8a99; font-size:13px; margin-top:4px;"><?php echo htmlspecialchars($userInfo["email"]);?></div>
				<br>
				<div style="color:#405972; font-size:15px; margin-top:-8px; ;text-align:center">
				<b>Registered</b> &nbsp; <?php echo date("jS F, Y", strtotime($userInfo["created"]));?></div>
				
				</div>
				
				</section>
				<div class="dropdown-divider" style="border-color:#e9eff5;margin-top:10px;"></div>
				<br>
		
		
		
		
				<div style="color:#405972; font-size:16px; margin-top:4px;text-align:center">
				<b>Account Balance</b>
				<br><h2>$ <?php echo number_format(intval($Act["balance"]))?>.00</h2></div>
				<div class="dropdown-divider" style="border-color:#e9eff5;"></div>
				<div class="dropdown-divider" style="border-color:#e9eff5;"></div>
				
				
		
				<div style="color:#405972; font-size:16px; margin-top:4px;text-align:center">
				<b>Active Reading Deposit</b>
				<br><h2><?php echo "$ ".number_format(intval($Act["deposit"]));?>.00</h2></div>
				
				
		
		
		
				<center>
				<!--Display Reaing Plan if user invested-->
				<?php 
				if(!empty($duedate["deposit_date"])){
				
				echo '<div class="dropdown-divider" style="border-color:#e9eff5;"></div>
					  <div class="dropdown-divider" style="border-color:#e9eff5;"></div>';
					  
				if($duedate["plan"] == "Bronze"){?>
				
				<span class="badge badge-primary" style="font-size:15px;font-weight:500;
				margin-top:5px;background:#087495;box-shadow:#bbb 0.1em 0.1em 0.2em;"><i class="flaticon-wallet"></i> Bronze Plan</span>
				<?php }?>
				
				<?php if($duedate["plan"] == "Silver"){?>
				<span class="badge badge-primary" style="font-size:15px;font-weight:500;
				margin-top:5px;background:#1cb366;box-shadow:#bbb 0.1em 0.1em 0.2em;"><i class="flaticon-wallet"></i> Silver Plan</span>
				<?php }?>
				
				<?php if($duedate["plan"] == "Gold"){?>
				<span class="badge badge-primary" style="font-size:15px;font-weight:500;
				margin-top:5px;background:#ff8a45;box-shadow:#bbb 0.1em 0.1em 0.2em;"><i class="fa  fa-star"></i> Gold Plan</span>
				<?php }?>
				
				<?php if($duedate["plan"] == "Platinum"){?>
				<span class="badge badge-primary" style="font-size:15px;font-weight:500;
				margin-top:5px;background:#ff8a45;box-shadow:#bbb 0.1em 0.1em 0.2em;"><i class="fa  fa-star"></i> Platinum Plan</span>
				<?php }?>
				
				<?php if($duedate["plan"] == "Vip"){?>
				<span class="badge badge-primary" style="font-size:15px;font-weight:500;
				margin-top:5px;background:#f5226a;box-shadow:#bbb 0.1em 0.1em 0.2em;"><i class="fa fa-bolt"></i> Vip Plan</span>
				<?php } ?>
		
	
		<div style="color:#396f89; margin:10px 0px;font-size:15px">
		<b>Deposited</b> &nbsp; <?php echo date("jS F Y - H:i A", strtotime($duedate["deposit_date"]));?></div>
		
		<div style="color:#396f89; margin:10px 0px;font-size:15px">
		<b>Due Date</b> &nbsp; <?php echo date("jS F Y - H:i A", strtotime($duedate["due_date"]));?></div>
		
		
		<br>
		
		<div style="color:#396f89; margin:10px 0px;font-size:15px">
		<b>Reading Completes In</b></div>
		<div align="center" style="font-size:15px;color:#dd243e; margin-top:6px;">
		<?php
		//Get difference btwn deposit time and duedate
		
		$timers = (!empty($duedate["alterTime"]) ? $duedate["alterTime"] : "+0 days");
			
		$curdate = date("Y-m-d H:i:s", strtotime($timers));
		$dDate = date("Y-m-d H:i:s", strtotime($duedate["due_date"]));
		
		$timeZ = new DateTimeZone('UTC');
		$curDate = new DateTime($curdate, $timeZ);
		$due_date = new DateTime($dDate, $timeZ);
		
		//('%r%y years, %m Months, %d days, %h hours, %i minutes, %s seconds');
		
		//for days plans
		if($duedate["plan"] == "Bronze" || $duedate["plan"] == "Silver"){
			echo $curDate->diff($due_date)->format('%h hour(s), %i minute(s)');
		}else{
			echo $curDate->diff($due_date)->format('%d day(s), %h hour(s), %i minute(s)');
		}
		
		?>
		</div>
		
		
		
		
		
		
		
		
		<br>
		
		<button class="btnss btn btn-primary" id="cancelReading">Cancel Active Deposit</button><br><br>
		<a href="alterReading.php?user=<?php echo $UserStatID;?>" class="btnss btn btn-primary" id="alterReading">Alter Active Reading
		<i class="fas fa-clock"></i></button></a>
		
		
		
		
	<div class="cancelMenu">
		
		<div class="form-group col-md-5 text-left" id="cancelForm">
        <p>
		<h3 align="center" style="margin:10px;">Cancel Active Deposit</h3>
		<div align="center" style="font-size:17px;color: #0b5e77;"><b>Supposed Profit</b> 
		&nbsp;$<?php echo number_format($duedate["percentage_profit"]);?></div>
		<div class="dropdown-divider"></div><br>
			
		<label for="earning" style="font-size:17px;">Enter Custom Profit Earning</label>
		<span class="closeCn">Close</span>
		<br><input type="number" name="earning" placeholder="$ 0.00" step="0.01" id="earning" class="form-control">
		<div style="color:#7b7979; margin:5px 0px">Leave field blank to credit user with the supposed profit or enter custom amount</div>
		<p>
		<br><button class="btnss btn-primary btn btn-block" id="process">Proceed to cancel&nbsp; <i class="fa fa-angle-right"></i></button>
		</div>
		
		
		
	<section id="success" class="display-none">
	<div style="color:#2ecc71;font-size:23px;display:flex;font-weight:550; justify-content:center;place-items:center; text-align:center;
	margin:100px auto 10px auto;"><span>Successfully Cancelled</span> &nbsp; <span><img src="../img/tick.png" width="25"></span></div>
	<br>
	<center><div class="btn btnss" id="refresh">Refresh Now &nbsp; <i class="fa fa-history"></i></div></center>
	</section>
		
	</div>
		
		
		
		<?php } ?>
		
		
		
		
		
		
		
		
		
		
		<br><br>
		<div class="dropdown-divider" style="border-color:#d7e1f0"></div> 
		
		
		
		<!--Disable | Enable ACCOUNT-->
		<div style="color:#396f89; margin:15px 0px 5px 0px;font-size:14px"> 
		Once Disabled, user can no longer access their account but can message admin</div>
		
		<?php if($userInfo["disable"] !== "disabled"){?>
		<div class="btn btn-primary btnss btn-block" id="suspend">
		<i class="far fas fa-power-off "></i> &nbsp;Disable <?php echo htmlspecialchars($userInfo["fullName"]);?></div>
		
		<!--for Ajax-->
		<div class="btn btn-danger btnssD btn-block display-none" id="enable">
		<i class="fas fa-exclamation-triangle"></i> &nbsp;Enable <?php echo htmlspecialchars($userInfo["fullName"]);?></div>
		
		<?php }else{?>
		
		<div class="btn btn-danger btnssD btn-block" id="enable">
		<i class="fas fa-exclamation-triangle"></i> &nbsp;Enable <?php echo htmlspecialchars($userInfo["fullName"]);?></div>
		
		<!--for Ajax-->
		<div class="btn btn-primary btnss btn-block display-none" id="suspend">
		<i class="far fas fa-power-off "></i> &nbsp;Disable <?php echo htmlspecialchars($userInfo["fullName"]);?></div>
		
		<?php }?>
		<div class="dropdown-divider" style="border-color:#d7e1f0"></div> 
		
		
		
		
		
		
		<!--SUSPEND | Enable Withdrawal-->
		<div style="color:#396f89; margin:20px 0px 5px 0px;font-size:14px"> 
		Once Suspended, user can no longer Withdraw</div>
		
		<?php if($userInfo["suspendWithdrawal"] !== "suspended"){?>
		<div class="btn btn-primary btnss btn-block" id="noWithdraw">
		<i class="far fas fa-key "></i> &nbsp;Suspend Withdrawal</div>
		
		<!--for Ajax-->
		<div class="btn btn-danger btnssD btn-block display-none" id="enableWithdraw">
		<i class="fas fa-exclamation-triangle"></i> &nbsp;Enable Withdrawal</div>
		
		<?php }else{?>
		
		<div class="btn btn-danger btnssD btn-block" id="enableWithdraw">
		<i class="fas fa-exclamation-triangle"></i> &nbsp;Enable Withdrawal</div>
		
		<!--for Ajax-->
		<div class="btn btn-primary btnss btn-block display-none" id="noWithdraw">
		<i class="far fas fa-key"></i> &nbsp;Suspend Withdrawal </div>
		
		<?php }?>
		
		
		
		<!--Withdrawal e-code Lock -->
		<br><a href="e-codeWithdrawal.php?user=<?php echo intval($userInfo["userid"]);?>">
		<div class="btn btn-primary btnss" id="noWithdraw"><i class="far fas fa-lock "></i> &nbsp; Activate e-Code Withdrawal</div>
		</a>
		
		
		
		
		<div class="dropdown-divider" style="border-color:#d7e1f0"></div> 
		<br>
		
		
		
		<div class="btn btn-danger btnssD btn-block" id="del">
		<i class="fas fa-trash"></i> &nbsp;Delete <?php echo htmlspecialchars($userInfo["fullName"]);?></div>
		
		
		<div class="dropdown-divider" style="border-color:#d7e1f0"></div>
		

		<style>
		.btn-primary {
		background-color: #4477a9!important;
		border-color: #4587c7!important;
		}
		.btt{
			margin:4px;
		}
		</style>

		<!-- Management -->
		<div style="color:#396f89; margin:40px 0px -0px;font-size:16px"><b>Managements</b></div>
		<div class="dropdown-divider"></div><br>
		
		<div class="row">
		<div class="col-md-12">
		
		<a href="user-management.php?user=<?php echo intval($userInfo["userid"]);?>"><button class="btn btn-primary btt">
		<i class="fa fa-plus"></i>&nbsp;Manage funds</button></a>
		
		<a href="editUser.php?user=<?php echo intval($userInfo["userid"]);?>"><button class="btn btn-primary btt">
		<i class="fas fa-user-cog"></i> &nbsp;Edit user</button></a>
		
		<a href="changeUserPassword.php?user=<?php echo intval($userInfo["userid"]);?>"><button class="btn btn-primary btt">
		<i class="fas fa-key"></i> &nbsp;Change Password</button></a>
		
		<a href="mailUser.php?user=<?php echo intval($userInfo["userid"]);?>"><button class="btn btn-primary btt">
		<i class="fas fa-envelope"></i> &nbsp;Mail user</button></a>
		
		</div>
		</div>


















		
		
		<!-- PAYMENTS HISTORY TABLE -->
		<div style="color:#396f89; margin:40px 0px -0px;font-size:16px"><b>TRANSACTION HISTORY</b></div>
		<div class="dropdown-divider"></div><br>
		</center>
		
		
		
		<?php	
		//Get Total Approved Investments
		$stmt=$pdo->prepare("SELECT SUM(amount) AS total FROM transactions WHERE type='investment' AND status='approved' AND userid = :userid");
		$stmt->bindParam(":userid",$UserStatID, PDO::PARAM_STR);
		$stmt->execute();
		$sumInv = $stmt->fetch();
		
		
		//Get Total Approved Withdrawals
		$stmt=$pdo->prepare("SELECT SUM(amount) AS total FROM transactions WHERE type='withdrawal' AND status='approved' AND userid = :userid");
		$stmt->bindParam(":userid",$UserStatID, PDO::PARAM_STR);
		$stmt->execute();
		$sumWith = $stmt->fetch();
		?>
		
		
		<div style="color:#405972; font-size:15px; margin-top:4px;text-align:left">
		<b>Total Approved Investments</b><br>
		<div style="color:#2aab00;font-size:14px;margin-top:4px;">$ <?php echo number_format(intval($sumInv["total"]))?>.00</div>
		</div>
		<div class="dropdown-divider" style="border-color:#e9eff5;"></div>
		
		
		<div class="dropdown-divider" style="border-color:#e9eff5;"></div>
		<div style="color:#405972; font-size:15px; margin-top:4px;text-align:left">
		<b>Total Approved Withdrawals</b><br>
		<div style="color:#e13131;font-size:14px;margin-top:4px;">$ <?php echo number_format(intval($sumWith["total"]))?>.00</div>
		</div>
		<div class="dropdown-divider" style="border-color:#e9eff5;"></div>
		
		
		
		
		
		
		
		
		
        <h3 style="text-align: center;">User Transactions</h3>	
		<?php	
		$stmt=$pdo->prepare("SELECT * FROM transactions WHERE userid = :userid");
		$stmt->bindParam("userid",$userInfo["userid"] , PDO::PARAM_STR);
		$stmt->execute();
		$tran=$stmt->fetchAll();
		$count = 1;
		if($stmt->rowCount()<1){
			echo '<h4 class="title" style="text-align: center;">No recorded transaction</h4>';
		}else{
		?>
				<section class="transact-con">
				<table class="table table-bordered">
				
				<thead class="thead-dark">
				<th>S/N</th>
				<th>Status</th>
				<th>Date</th>
				<th>Transaction</th>
				<th>Plan</th>
				<th>Amount</th>
				<th>Reference ID</th>
				<th>Action</th>
				
				</thead>
					
		<?php
		foreach($tran as $trans){	
		?>
		
		<tr>
		<td><?php echo $count++;?></td>
		<td><?php echo htmlspecialchars($trans["status"]);?></td>
		<td><?php echo date("d/m/y", strtotime($trans["dateTime"]));?></td>
		<td><?php echo htmlspecialchars($trans["type"]);?></td>
		<td><?php echo htmlspecialchars($trans["plan"]);?></td>
		<td><?php echo "$". htmlspecialchars(number_format($trans["amount"]));?></td>
		<td><?php echo htmlspecialchars($trans["ref"]);?></td>
		
		<td style="display:flex;">
		
		<?php
		if($trans["status"] == "pending" || $trans["status"] == "declined"){
		//for pending
		?>
		<div id="approve_<?php echo intval($trans["id"]);?>" style="width:120px;" class="approve btn btn-sm btn-primary btnss"> 
		Approve</div>
		<!--For Ajax-->
		<div id="approved_<?php echo intval($trans["id"]);?>" style="width:120px;" class="display-none btn btn-sm btn-success">
		Approved &nbsp;<i class="fa fa-check"></i></div>
		
		<?php }else{
		//for already Approved	
		?>
		<div id="approved_<?php echo intval($trans["id"]);?>" style="width:120px;" class="btn btn-sm btn-success">
		Approved &nbsp;<i class="fa fa-check"></i></div>	
		<?php }?>
		
		
		
		&nbsp;&nbsp; 
		
		<?php
		if($trans["status"] == "pending"){
		//for pending
		?>
		<div id="decline_<?php echo intval($trans["id"]);?>" style="width:120px;" class="decline btn btn-sm btn-danger btnssD"> 
		Decline</div>
		<!--For Ajax-->
		<div id="declined_<?php echo intval($trans["id"]);?>" style="width:120px;" class="display-none btn btn-sm btn-danger btn-disabled">
		Declined &nbsp;<i class="fa fa-check"></i></div>
		
		<!--If approved-->
		<div id="cantD_<?php echo intval($trans["id"]);?>" style="width:120px;" class="display-none btn btn-sm btn-danger btn-disabled">
		<i class="fa fa-times" style="margin-top:3px;"></i></div>
		
		<?php }
		elseif($trans["status"] == "approved"){ //if transaction was approved ?>
		
		<div id="cantD_<?php echo intval($trans["id"]);?>" style="width:120px;" class="btn btn-sm btn-danger btn-disabled">
		<i class="fa fa-times" style="margin-top:3px;"></i></div>
		
		<?php }else{?>
		
		<div id="declined_<?php echo intval($trans["id"]);?>" style="width:120px;" class="btn btn-sm btn-danger btn-disabled">
		Declined &nbsp;<i class="fa fa-check"></i></div>
		<?php }?>
		
		</td>
		
	
		
		</tr>
		
			
		<?php } }?>

		  </table>
		 
		</section>
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		




<p><br><br>
			   
              
				
               
		<center>
		<div class="dropdown-divider" style="border-color: #c8d2e5;"></div>
		<div style="color:#396f89; font-size:18px;"><b>Referral History (Auto)</b></div>
		<div class="dropdown-divider" style="border-color: #c8d2e5;"></div>
		<br></center>



			<div class="col-md-10" style="margin:auto">
				
				
				<?php
				
				//Get referred users
				$stmt=$pdo->prepare("SELECT * FROM referral WHERE userid = :userid ORDER BY id DESC");
				$stmt->bindParam(":userid", $UserStatID, PDO::PARAM_STR);
				$stmt->execute();
				if($stmt->rowCount()>0){
				$referees = $stmt->fetchAll();
				
				foreach($referees as $referee){
				
				//get Referee info
				$stmt=$pdo->prepare("SELECT * FROM users WHERE userid = :userid");
				$stmt->bindParam(":userid", $referee["referee"], PDO::PARAM_STR);
				$stmt->execute();
				$refInfo = $stmt->fetch();
				
				$refereeImg = (!empty($refInfo["profilepix"]) ? "../img/users/".$refInfo["profilepix"]: "../img/avatar.png");
				
				?>
				
				<div class="card-box" style="background-image: radial-gradient(ellipse closest-side, rgba(255, 255, 255, 0),#f1f6fb), url(../img/active.jpg); background-repeat:no-repeat; background-position:center; padding:12px;">
				
				
				<section style="display:flex">
				<div><img src="<?php echo $refereeImg;?>" class="avatars"></div>
				<div style="margin:8px 7px; font-size:18px; color:#405972; font-weight:500;">
				<?php if(!empty($refInfo["fullName"])){echo htmlspecialchars($refInfo["fullName"]);}else{echo "Site User";}?><br>
				<div style="color:#405972; font-size:14px; margin-top:4px; margin-bottom:8px;">
				<?php if(!empty($refInfo["email"])){echo htmlspecialchars($refInfo["email"]);}?>
				</div>
				
				<div style="color:#396f89; font-size:14px; font-weight:500">
				<b>Registered </b> &nbsp; 
				<?php echo date("jS F, Y", strtotime($referee["refDate"]));?></div>
				
				</div>
				</section>
				
				<div class="dropdown-divider" style="border-color: #c8d2e5;"></div>
				
				<div style="color:#396f89; font-size:15px; margin-bottom:15px;margin-left:10px; font-weight:500;text-transform:capitalize;">
				<b>Status </b> &nbsp; 
				<?php echo htmlspecialchars($referee["status"]); if($referee["status"]=="paid"){echo " <i class='fa fa-check'></i>";}?></div>
				
				
				<?php if($referee["status"] == "paid"){?>
				<div style="color:#396f89; font-size:13px; margin:-8px 10px 5px 10px; font-weight:500">
				A Ref bonus of $3 was paid</div>
				<?php }?>
				
				
				</div>
				
				<?php }}else{?>
				
				<div style="color:#818ba1; font-size:20px; margin-bottom:10px; font-weight:500">
				<center>Record is empty </center></div>
				
				
				<?php }?>

</div>

<p><br><br>











		
		
		
		
		
		
		
		
		
		
		
		
		
		<div class="dropdown-divider" style="border-color: #c8d2e5;"></div><br>
		
		<div style="padding:12px;max-width:700px; margin:20px auto">
				  
				  
		<?php	
		//Check user withrawal adress method if BTC,ETH,USDT
		$stmt=$pdo->prepare("SELECT * FROM transactions WHERE type='withdrawal' AND userid = :userid");
		$stmt->bindParam(":userid",$UserStatID, PDO::PARAM_STR);
		$stmt->execute();
		$Withtype=$stmt->fetch();
		
		//If user have withdrawal history
		if($stmt->rowCount() >0){?>
				  
		
		<center>
		<div style="color:#396f89; margin:10px 0px;font-size:17px">
		Withdrawal Method &nbsp; - &nbsp; <b><?php echo htmlspecialchars($Withtype["walletType"]);?></b>
		</div>
					
		<div class="dropdown-divider" style="border-color:#d7e1f0"></div>
		</center><br>
				  
		
		<?php 
		//Display withdrawal wallet link based on the wallet user used
		
		//for Btc
		if($Withtype["walletType"] == "Bitcoin"){?>  
		
		<div class="form-group">
		<label for="myInput" style="margin-left:10px; font-weight:500"><i class="fas fa-link"></i> Bitcoin Address
		<span style="color:#32ac32" id="copied" class="display-none">&nbsp; Copied!</span></label>
        <div class="col-sm-12">
        <input type="text" readonly class="form-control" id="myInput" 
		value="<?php if(!empty($userInfo["btc"])){echo htmlspecialchars($userInfo["btc"]);}else{echo "Not available";}?>">
        </div></div>
		<div onclick="copyAddress()" id="copyAddress" class="btn btnss btn-block copyAddress">Click to Copy 
		&nbsp;<i class="fas fa-copy"></i></div>

				 
		<?php }elseif($Withtype["walletType"] == "Ethereum Bep20"){ //for Ethereum?>	  
				  
		<div class="form-group">
        <label for="myInputE" style="margin-left:10px;font-weight:500"><i class="fas fa-link"></i> Ethereum Bep20
		<span style="color:#32ac32" id="copied" class="display-none">&nbsp; Copied!</span></label>
        <div class="col-sm-12">
        <input type="text" readonly class="form-control" id="myInputE" 
		value="<?php if(!empty($userInfo["ethereum"])){echo htmlspecialchars($userInfo["ethereum"]);}else{echo "Not available";}?>">
        </div></div>
        <div onclick="copyAddressE()" id="copyAddressE" class="btn btnss btn-block copyAddress">Click to Copy 
		&nbsp;<i class="fas fa-copy"></i></div>
  
		
		<?php }else{ //for USDT ?>		  
		
		<div class="form-group">
        <label for="myInputT" style="margin-left:10px; font-weight:500"><i class="fas fa-link"></i> Tether USDT(TRC20)
		<span style="color:#32ac32" id="copied" class="display-none">&nbsp; Copied!</span></label>
        <div class="col-sm-12">
        <input type="text" readonly class="form-control" id="myInputT" 
		value="<?php if(!empty($userInfo["usdt"])){echo htmlspecialchars($userInfo["usdt"]);}else{echo "Not available";}?>">
        </div></div>
		<div onclick="copyAddressT()" id="copyAddressT" class="btn btnss btn-block copyAddress">Click to Copy 
		&nbsp;<i class="fas fa-copy"></i></div>		
		
		<?php }?>
		
		
		</div>
		<br><p>
		
		<?php } ?>
				  
				  
				  



			
				  
		<!-- User Wallet Address-->	 
		
		<center>	  
		<div style="max-width:700px;">		  
		<div class="dropdown-divider" style="border-color:#d7e1f0"></div>
		<div style="color:#396f89; margin:10px 0px;font-size:17px">
		Wallet addresses
		</div>
		<div class="dropdown-divider" style="border-color:#d7e1f0"></div>		
		</center>
		<br>  
				  
				  

		
				  <!--BTC Withdrawal-->
				  <div style="margin-left:10px; display:flex">
				  <input type="radio" name="walletAdress" id="btcs">&nbsp; &nbsp; 
				  <label for="btcs" style="color:#3d658d!important;font-size:17px;">Bitcoin</label>
				  </div>
				  
				   <div class="form-group" id="btcCon"><br>
                    <label for="btc" style="margin-left:10px"><i class="fas fa-wallet"></i> Bitcoin wallet address</label>
                    <div class="col-sm-12">
                    <input type="text" readonly class="form-control" id="myInputT" 
					value="<?php if(!empty($userInfo["btc"])){echo htmlspecialchars($userInfo["btc"]);}else{echo "Not available";}?>">
                    </div>
					</div>
				  
				  
				  <!--Ethereum Withdrawal-->
				  <div style="margin-left:10px; display:flex">
				  <input type="radio" name="walletAdress" id="eth">&nbsp; &nbsp; 
				  <label for="eth" style="color:#3d658d!important;font-size:17px;">Ethereum Bep20</label>
				  </div>
				  
				   <div class="form-group" id="ethCon"><br>
                    <label for="ethereum" style="margin-left:10px"><i class="fas fa-wallet"></i> Ethereum wallet</label>
                    <div class="col-sm-12">
                     <input type="text" readonly class="form-control" id="myInputT" 
					value="<?php if(!empty($userInfo["ethereum"])){echo htmlspecialchars($userInfo["ethereum"]);}else{echo "Not available";}?>">
                    </div>
					</div>
				  
				  
				  
				  <!--USDT Withdrawal-->
				  <div style="margin-left:10px; display:flex">
				  <input type="radio" name="walletAdress" id="usdts">&nbsp; &nbsp; 
				  <label for="usdts" style="color:#3d658d!important;font-size:17px;"> Tether USDT(TRC20)</label>
				  </div>
				  
				   <div class="form-group" id="usdtCon"><br>
                    <label for="usdt" style="margin-left:10px"><i class="fas fa-wallet"></i> Tether USDT wallet</label>
                    <div class="col-sm-12">
                    <input type="text" readonly class="form-control" id="myInputT" 
					value="<?php if(!empty($userInfo["usdt"])){echo htmlspecialchars($userInfo["usdt"]);}else{echo "Not available";}?>">
                    </div>
					</div>








		
		



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

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



                </div> <!-- content -->
                </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>
   
   
   
   //Copy BTC address
   function copyAddress() {
  var copyText = document.getElementById("myInput");
  copyText.select();
  copyText.setSelectionRange(0, 99999)
  document.execCommand("copy");
  $("#copied").removeClass("display-none");
}  
  
 //Copy Ethereum address
   function copyAddressE() {
  var copyText = document.getElementById("myInputE");
  copyText.select();
  copyText.setSelectionRange(0, 99999)
  document.execCommand("copy");
  $("#copied").removeClass("display-none");
}
 
 //Copy Tether USDT address
   function copyAddressT() {
  var copyText = document.getElementById("myInputT");
  copyText.select();
  copyText.setSelectionRange(0, 99999)
  document.execCommand("copy");
  $("#copied").removeClass("display-none");
}
 
 
 
   
   
   
   
   
   
   
   
   
   
   $(document).ready(function(){
	
	$('.coversoverlay').hide();
		 
	
	
	
	
	//Drop address link container
	
	$("#btcs").click(function(){
		$("#btcCon").css({"height":"120","transition":"1s"});
		$("#ethCon").css({"height":"0","transition":"1s"});
		$("#usdtCon").css({"height":"0","transition":"1s"});
	});
	
	$("#eth").click(function(){
		$("#ethCon").css({"height":"120","transition":"1s"});
		$("#btcCon").css({"height":"0","transition":"1s"});
		$("#usdtCon").css({"height":"0","transition":"1s"});
	});
	
	$("#usdts").click(function(){
		$("#usdtCon").css({"height":"120","transition":"1s"});
		$("#ethCon").css({"height":"0","transition":"1s"});
		$("#btcCon").css({"height":"0","transition":"1s"});
	});
 
	
	
	
	
	
	
	
	
	
	
 //APPROVE TRANSACTIONS
 
 $(".approve").click(function(){
	 
		
		//get transaction ID from btn
		let id = this.id;
		let splitId = id.split("_");
		
		let transactID = splitId[1];
		let approved = "approved";
			
			if(confirm("Proceed to approve transaction. \Once approved can\'t be declined")){

		$.ajax({
			url:'function.php',
			method:'POST',
			data:{transactID:transactID, approved:approved},
			beforeSend:function(){$(".coversoverlay").show()},
			success:function(data){
				$(".transact-con").append(data);
				
				console.log(data);
				$(".coversoverlay").hide();
				
			}
		}); 
		
			}
		
		});	
 
 
 
 
 
 //Deline TRANSACTIONS
 
 $(".decline").click(function(){
	 
		
		//get transaction ID from btn
		let id = this.id;
		let splitId = id.split("_");
		
		let transactID = splitId[1];
		let declined = "declined";
			

		$.ajax({
			url:'function.php',
			method:'POST',
			data:{transactID:transactID, declined:declined},
			beforeSend:function(){$(".coversoverlay").show()},
			success:function(data){
				$(".transact-con").append(data);
				
				console.log(data);
				$(".coversoverlay").hide();
				
			}
		}); 
		
		});
		
		
		
		
		
		
		
		
		
		
		
		
 //Disable user from accessing account
 
 $("#suspend").click(function(){
	 
		//get transaction ID from btn
		let userid = <?php echo $UserStatID; ?>;
		let disableStatus = "disabled";
			

		$.ajax({
			url:'function.php',
			method:'POST',
			data:{userid:userid, disableStatus:disableStatus},
			beforeSend:function(){$(".coversoverlay").show()},
			success:function(data){
				
				if(data == "disabled"){
				//Swap suspend btns
				$("#suspend").addClass("display-none");
				$("#enable").removeClass("display-none");
				}
				
				
				//console.log(data);
				$(".coversoverlay").hide();
				
			}
		}); 
		
		});






		
 //Enable user
 
 $("#enable").click(function(){
	 
		//get transaction ID from btn
		let userid = <?php echo $UserStatID; ?>;
		let disableStatus = "enable";
			

		$.ajax({
			url:'function.php',
			method:'POST',
			data:{userid:userid, disableStatus:disableStatus},
			beforeSend:function(){$(".coversoverlay").show()},
			success:function(data){
				
				if(data == "enabeled"){
				//Swap suspend btns
				$("#enable").addClass("display-none");
				$("#suspend").removeClass("display-none");
				}
				
				//console.log(data);
				$(".coversoverlay").hide();
				
			}
		}); 
		
		});
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
			
		
		
		
 //Suspend user from Withdrawing
 
 $("#noWithdraw").click(function(){
	 
		//get transaction ID from btn
		let userid = <?php echo $UserStatID; ?>;
		let withdrawStatus = "suspended";
			

		$.ajax({
			url:'function.php',
			method:'POST',
			data:{userid:userid, withdrawStatus:withdrawStatus},
			beforeSend:function(){$(".coversoverlay").show()},
			success:function(data){
				
				if(data == "suspended"){
				//Swap suspend btns
				$("#noWithdraw").addClass("display-none");
				$("#enableWithdraw").removeClass("display-none");
				}
				
				
				//console.log(data);
				$(".coversoverlay").hide();
				
			}
		}); 
		
		});






		
 //Enable user to withdraw
 
 $("#enableWithdraw").click(function(){
	 
		//get transaction ID from btn
		let userid = <?php echo $UserStatID; ?>;
		let withdrawStatus = "enableWithdraw";
			

		$.ajax({
			url:'function.php',
			method:'POST',
			data:{userid:userid, withdrawStatus:withdrawStatus},
			beforeSend:function(){$(".coversoverlay").show()},
			success:function(data){
				
				if(data == "enabeled"){
				//Swap suspend btns
				$("#enableWithdraw").addClass("display-none");
				$("#noWithdraw").removeClass("display-none");
			
				}
				
				//console.log(data);
				$(".coversoverlay").hide();
				
			}
		}); 
		
		});
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
 //Delete user
 
 $("#del").click(function(){
	 
			let delid = <?php echo intval($userInfo["userid"]); ?>;
	 
			if(confirm("Are you sure you want to delete this user?")){

		$.ajax({
			url:'function.php',
			method:'POST',
			data:{delid:delid},
			beforeSend:function(){$(".coversoverlay").show()},
			success:function(data){
				
				if(data == 1){
					alert("User deleted successfully");
					location.href="users.php";
				}
				
				console.log(data);
				$(".coversoverlay").hide();
				
			}
		}); 
		
			}
		
		});	
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
		//CANCEL ACTIVE DEPOSIT READING
		
		$("#cancelReading").click(function(){
			$(".cancelMenu").css({"height":"300px"});
		});
		
		$(".closeCn").click(function(){
			$(".cancelMenu").css({"height":"0px"});
		});
		
		
		
		//Process Cancellation
		
		 $("#process").click(function(){
	 
			let earning = $("#earning").val();
			let cancelDeposit = "cancelDeposit";
			let user = <?php echo $UserStatID; ?>;
	 

		$.ajax({
			url:'function.php',
			method:'POST',
			data:{earning:earning,cancelDeposit:cancelDeposit,user:user},
			beforeSend:function(){$(".coversoverlay").show()},
			success:function(data){
				
				if(data == 1){
					$("#cancelForm").addClass("display-none");
					$("#success").removeClass("display-none");
				}
				//refresh btn
				$("#refresh").click(function(){ location.reload(); });
				
				//console.log(data);
				$(".coversoverlay").hide();
				
			}
		}); 
		
		
		});	
 
 
     
 
	 
   });
   
 
 
   
   
   </script>
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
    </body>

</html>