<?php

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

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

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

<style>

	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 #0e405c;
}

    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: #064b72;
    content: '';
    display: inline-block;
    visibility: visible;
    border: 2px solid #ffffff;
 }
 
 
  .cancelMenu{
background: #fff;
width: 100%;
position: fixed;
bottom: 0;
left: 0;
z-index: 200;
border-top: 3px solid #8c969d;
box-shadow: 2em 2em 8em #000;
 }

</style>


<!DOCTYPE html>

<html lang="en">

<head>

        <meta charset="utf-8" />

        <title> Alter Percentage Reading | Six Digital Assets</title>

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

        <meta name="keywords" content="trade, trading, forex, investing, invest, investment, investor, money, chart, bitcoin, ethereum, USDT, coins, cryptocurrencies, crypto, profit, market, online money, money online,">
    <meta name="description" content="Six Digital Assets provides a full investment service focused on the Bitcoin and cryptocurrency trading market. A certified legal investment company incorporated and headquartered in Australia.">
    <meta name="author" content="Six Digital Assets">

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

                <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">
                            
						
						<span id="result"></span>
						
				<div class="col-md-7" style="margin-top:20px!important;margin: auto;">
				
        
		
		<div class="card-box" style="background-image:radial-gradient(ellipse closest-side, rgba(225, 225, 225, 0),#e9f3fb);">
				
		<center><img src="<?php echo $userimg;?>" class="avatars"></center><br>
		<div style="color:#405972; font-size:16px; margin-bottom:10px;text-align:center"><b><?php echo htmlspecialchars($userInfo["fullName"]);?>
		</b></div>

	
		<center>
		<h3 align="center" style='color:#767e80;margin-bottom:20px;border:1px solid #d3d3d3;padding:5px;width:250px;border-radius:10px'>
		Alter Timing
		</h3>
		</center>
			
		<p>

		<div style="max-width:600px;margin:auto">
		<div style="color:#405972; font-size:16px; margin-top:4px;text-align:center">
		<b>Account Balance &nbsp; $<?php echo number_format(intval($Act["balance"]))?>.00</b></div>
				
				
		<br><div class="dropdown-divider" style="border-color:#e9eff5;"></div>
				<!--Display Reaing Plan if user invested-->
				<center>
				<?php 
				if(!empty($duedate["deposit_date"])){
					  
				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 } }?>
				</center><br>
		
		
		
				<div style="color:#405972; font-size:16px; margin-top:4px;text-align:center">
				<b>Active Reading Deposit</b>
				<br><h3><?php echo "$ ".number_format(intval($Act["deposit"]));?>.00</h3></div>
				<div class="dropdown-divider" style="border-color:#e9eff5;"></div><br>
				
				
		
		<div align="center" style="font-size:16px;color: #0b5e77;"><b>Supposed Profit</b> 
		&nbsp;$<?php echo number_format($duedate["percentage_profit"]);?></div>
		<p><br>
		
		<label for="earning" style="font-size:14px;margin-bottom:1px;"><b>Enter Custom Profit</b></label>
		<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>
		<div class="dropdown-divider" style="border-color:#e9eff5;"></div>
		
		
		
		
		
		<br><br><p>
		
		<div align="center" style="font-size:16px;color:#0b5e77;"><b>Profit 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>
		<div class="dropdown-divider" style="border-color:#e9eff5;"></div><br>
		
		
		<div style="color:#7b7979; margin:5px 0px">Select time formatting below to either delay or speed up profit reading</div>
		
		<div style="margin-top:15px; display:flex">
		<input type="radio" name="formatting" value="day" id="days">&nbsp; &nbsp; 
		<label for="days" style="color:#3d658d!important;font-size:17px;">Speed or delay in Days</label>
		</div>
		
		<div style="margin-top:10px; display:flex">
		<input type="radio" name="formatting" value="hour" id="hours">&nbsp; &nbsp; 
		<label for="hours" style="color:#3d658d!important;font-size:17px;">Speed or delay in Hours</label>
		</div>
		
		<div style="margin-top:10px; display:flex">
		<input type="radio" name="formatting" value="minute" id="minutes">&nbsp; &nbsp; 
		<label for="minutes" style="color:#3d658d!important;font-size:17px;">Speed or delay in Minutes</label>
		</div>
		
		
		
		<br><div class="dropdown-divider" style="border-color:#e9eff5;"></div>
		<div style="color:#7b7979; margin:5px 0px">Select Action</div>
		
		<div style="margin-top:15px; display:flex">
		<input type="radio" name="action" value="speed" id="speed">&nbsp; &nbsp; 
		<label for="speed" style="color:#3d658d!important;font-size:17px;">Speed Up Profit Reading</label>
		</div>
		
		<div style="margin-top:10px; display:flex">
		<input type="radio" name="action" value="delay" id="delay">&nbsp; &nbsp; 
		<label for="delay" style="color:#3d658d!important;font-size:17px;">Delay Profit Reading</label>
		</div>
		
		
		<br>
		<div class="dropdown-divider" style="border-color:#e9eff5;"></div>
		<div style="color:#7b7979; margin:5px 0px">
		Enter timing value <span id="theTime"></span>
		</div>
		<input type="number" name="timing" disabled="disabled" placeholder="Enter timing" step="1" id="timing" class="form-control">
		
		<p>
		<br><button class="btnss btn-primary btn btn-block" id="process">Update Reading&nbsp; <i class="fa fa-angle-right"></i></button>
		
		
		</div>



	<!--Success Function, show slideUp-->
	<div class="cancelMenu display-none" id="success">

	<div style="color:#2ecc71;font-size:19px;display:flex; justify-content:center;place-items:center; text-align:center;
	margin:20px auto 10px auto;"><span>Percentage Reading Updated</span> &nbsp; <span><img src="../img/tick.png" width="25"></span></div>
	<br>
	
	<center>
	<div style="color:#5e6b6e;font-size:16px; font-weight:550;" id="updateText"></div><br>
	
	<a class="btn btnss" href="userStats.php?getUser=<?php echo intval($theUser);?>"><i class="fa fa-angle-left"></i> &nbsp; User Stats</a>
	<div class="btn btnss closeCn">Close &nbsp;<i class="fa fa-times"></i></div>
	
	</center>
	<p><br>
	</div>







		
			 
			  
	<br><br>	  
	<div class="dropdown-divider" style="border-color: #c5d3ea;"></div>	    
	<a href="userStats.php?getUser=<?php echo intval($theUser);?>">
	<div class="btn btnss" style="width:100%; margin-top:4px;"><i class="fa fa-caret-left"></i> &nbsp;Go back </div>
	</a>	
              
				 
						</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>



        <!-- App js -->

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

   
   
   
   
   
   
   
   
   
   <script>
   
   $(document).ready(function(){
		
	
	$('.coversoverlay').hide();
		 
		 
		 		//close success overlay
				$(".closeCn").click(function(){
				$(".cancelMenu").addClass("display-none")
				});
		 
		 
		 
	//Timing format and placeholder text swap
	$("#days,#hours,#minutes").click(function(){
		
		if($("#days").is(":checked")){
			$("#timing").prop("placeholder", "Enter time in days");				//placeholder text
			$("#timing").attr("disabled", false);								//remove disabled attr from input timing
			$("#theTime").html("in <span style='color:#f90e0e;font-weight:600'>DAYS</span> (e.g 1)");			//timing value text
			
		}else
		
		if($("#hours").is(":checked")){
			$("#timing").prop("placeholder", "Enter time in hours");			//placeholder text
			$("#timing").attr("disabled", false);								//remove disabled attr from input timing
			$("#theTime").html("in <span style='color:#f90e0e;font-weight:600'>HOURS</span> (e.g 6)");			//timing value text
		}else
		
		if($("#minutes").is(":checked")){
			$("#timing").prop("placeholder", "Enter time in minutes");			//placeholder text
			$("#timing").attr("disabled", false);								//remove disabled attr from input timing
			$("#theTime").html("in <span style='color:#f90e0e;font-weight:600'>MINUTES</span> (e.g 45)");		//timing value text
		}
	});
 
 
 
 
 
 
 
 
	//Alter Readings
 
	$("#process").click(function(){
	 
	 
	 //Determine the Time Formatting (day, hours || minutes)
		if($("#days").is(":checked")){
			var formatting = $("#days").val();
		}
		else if($("#hours").is(":checked")){
			var formatting = $("#hours").val();
		}
		else if($("#minutes").is(":checked")){
			var formatting = $("#minutes").val();
		}
		else{
		
		alert("Select time formatting");
			return false;
		}
		
		
		
		
		//Determine the Action (Speed or Delay)
		if($("#speed").is(":checked")){
			var action = $("#speed").val();
		}
		else if($("#delay").is(":checked")){
			var action = $("#delay").val();
		}
		else{
		
		alert("Select ACTION to either speed or delay profit reading");
			return false;
		}
		
		
		//Validate Input
		if($("#timing").val() == ""){
			alert("Enter a timing value");
			return false;
		}else{
		
		let timing = $("#timing").val();			//timing value
		let earning = $("#earning").val();			//Custome earning
		let user = <?php echo $theUser; ?>;			//user
		
		
		
		$.ajax({
			url:'function.php',
			method:'POST',
			data:{formatting:formatting, action:action, timing:timing, earning:earning, user:user},
			beforeSend:function(){$(".coversoverlay").show()},
			success:function(data){
				
				if(data == 1){
					
					//show overlay
					$(".cancelMenu").removeClass("display-none")
					
					
					$("#updateText").html("Reading set to " + action + " by " + timing + " " + formatting + "(s)" );
		
				}
				
				//refresh btn
				$("#refresh").click(function(){ location.reload(); });
				
				
				console.log(data);
				
				//console.log(data);
				$(".coversoverlay").hide();
				
			}
		});
		
		}
		});

 
 
				
 
 
 
 
 
	 
   });
   
   
   
   
   </script>
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
    </body>

</html>