<?php

include('php/database.php');
include('php/security.php');
session_start();
if(logged_in())
{
	header('location:../login.php');
}
$id= $_SESSION['id'];
$results= mysqli_query($connection, "SELECT `date`, `id`, `name`, `email`, `number`, `password`, `phone`, `address`, `country`, `gender`, `image`, `vcode`, `verified`, `verify`, `balance`, `totalbalance`, `investbalance`, `profit`, `totaldeposit`, `totalwithdrawal`, `loanlimit`, `availableloan`, `ongoingloan`, `savings`, `idcard`, `idcardback`, `accountstatus`, `pina`, `pinb`, `pinc`, `pind` FROM users WHERE id ='$id'");
$retrive= mysqli_fetch_array($results);
$date = $retrive['date'];
$id = $retrive['id'];
$name = $retrive['name'];
$email = $retrive['email'];
$number = $retrive['number'];
$password = $retrive['password'];
$phone = $retrive['phone'];
$address = $retrive['address'];
$country = $retrive['country'];
$gender = $retrive['gender'];
$image = $retrive['image'];
$vcode = $retrive['vcode'];
$verified = $retrive['verified'];
$verify = $retrive['verify'];
$balance = $retrive['balance'];
$totalbalance = $retrive['totalbalance'];
$investbalance = $retrive['investbalance'];
$profit = $retrive['profit'];
$totaldeposit = $retrive['totaldeposit'];
$totalwithdrawal = $retrive['totalwithdrawal'];
$loanlimit = $retrive['loanlimit'];
$availableloan = $retrive['availableloan'];
$ongoingloan = $retrive['ongoingloan'];
$savings = $retrive['savings'];
$idcard = $retrive['idcard'];
$idcardback = $retrive['idcardback'];
$accountstatus = $retrive['accountstatus'];
$pina = $retrive['pina'];
$pinb = $retrive['pinb'];
$pinc = $retrive['pinc'];
$pind = $retrive['pind'];

$usernumber = mysqli_real_escape_string($connection, $_GET['number']);
$amount = mysqli_real_escape_string($connection, $_GET['amount']);
$message = mysqli_real_escape_string($connection, $_GET['message']);
   $verify_query = "SELECT id, name, number, image, balance  FROM users WHERE number='$usernumber' LIMIT 1";
   $verify_query_run = mysqli_query($connection, $verify_query);

   if(mysqli_num_rows($verify_query_run) > 0)
   {
      $row = mysqli_fetch_array($verify_query_run);
	  
          $userid= $row['id'];
         $username= $row['name'];
     $userimage= $row['image'];
   }
   else
   {
    $_SESSION['status'] = "<h5 style='padding:8px; background: #fe8b8e; border-radius: 10px; color: #fff; text-align: center;'>Wrong Account Number</h5>";
    header("location: transfer.php");
    exit(0);
   }


?>


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


<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!-- Mobile Specific Metas -->
    <meta name="viewport" content="width=device-width, initial-scale=0.7, viewport-fit=cover">
    <title>transfer confirm</title>
    <!-- Favicon and Touch Icons  -->
    <link rel="shortcut icon" href="images/logo.png" />
    <link rel="apple-touch-icon-precomposed" href="images/logo.png" />
    <!-- Font -->
    <link rel="stylesheet" href="fonts/fonts.css" />
    <!-- Icons -->
    <link rel="stylesheet" href="fonts/icons-alipay.css">
    <link rel="stylesheet" href="styles/bootstrap.css">
    <link rel="stylesheet" type="text/css" href="styles/styles.css" />
    <link rel="manifest" href="_manifest.json" data-pwa-version="set_in_manifest_and_pwa_js">
    <link rel="apple-touch-icon" sizes="192x192" href="app/icons/icon-192x192.png">
</head>

<body class="bg_surface_color">
     <!-- preloade -->
     <div class="preload preload-container">
        <div class="preload-logo">
          <div class="spinner"></div>
        </div>
      </div>
    <!-- /preload -->
    <div class="app-header st1">
        <div class="tf-container">
            <div class="tf-topbar d-flex justify-content-center align-items-center">
                <a href="#" class="back-btn"> <i class="icon-left text-white"></i></a>
                <h3 class="text-white">Transfer </h3>&nbsp; &nbsp; <div  class="gtranslate_wrapper"></div>
<script>window.gtranslateSettings = {"default_language":"en","detect_browser_language":true,"wrapper_selector":".gtranslate_wrapper"}</script>
<script src="https://cdn.gtranslate.net/widgets/latest/dropdown.js" defer></script>
            </div>
            <h4 class="text-center text-white fw_4 mt-5">Transfer amount</h4>
            <h1 class="text-center text-white mt-2">$  <?php echo $amount?></h1>
        </div>
    </div>
    <div class="card-secton transfer-section">
        <div class="tf-container">
            <div class="tf-balance-box transfer-confirm">
                <div class="top">
                    <p>From</p>
                    <div class="tf-card-block d-flex align-items-center">
                        <div class="logo-img">
                            <img src="images/user/<?php echo $image?>" alt="images">
                        </div>
                        <div class="info">
                            <h4><a href="#"><?php echo $name?></a></h4>
                            <p><?php echo $number?></p>
                        </div>
                    </div>
                </div>
                <div class="line"></div>
                <div class="bottom">
                    <p>To</p>
                    <div class="tf-card-block d-flex align-items-center">
                        <img src="images/user/<?php echo $userimage?>" alt="images">
                        <div class="info">
                            <h4><a href="#"><?php echo $username?></a></h4>
                            <p><?php echo $usernumber?></p>
                        </div>
                    </div>
                </div>
                
            </div>
           
        </div>
    </div>
    <div class="transfer-list mt-5">
        <div class="tf-container">
            <ul class="list-view">
                <li>
                    Transaction fee
                    <span>$0.00</span>
                </li>
               
                <li>
                    Transfer from 
                    <span>In wallet</span>
                </li>
                <li>
                    Message
                    <span><?php echo $message?> </span>
                </li>
    
            </ul>
       
            
        </div>
    </div>
    <div class="bottom-navigation-bar st1 bottom-btn-fixed">
        <div class="tf-container">
            <a href="#" id="btn-popup-down" class="tf-btn accent large">Confirm</a>
        </div>
    </div>
    
    <div class="tf-panel down">
        <div class="panel_overlay"></div>
        <div class="panel-box panel-down">
            <div class="header">
                <div class="tf-container">
                    <div class="tf-statusbar br-none d-flex justify-content-center align-items-center">
                        <a href="#" class="clear-panel"> <i class="icon-close1"></i> </a>
                        <h3>Enter pin</h3>
                    </div>
                    
                </div>
            </div>
            
            <div class="mt-5">
                <div class="tf-container">
                    <form class="tf-form tf-form-verify" action="php/transfer.php" method="POST" onsubmit="return validation()">
                        <div class="d-flex group-input-verify">
                                <input type="tel" maxlength="1" name="pina" id="pina" pattern="[0-9]" onkeypress="return isNumberKey(event,this.id)" class="input-verify" value="">
                                <input type="tel" maxlength="1" name="pinb" id="pinb" pattern="[0-9]" onkeypress="return isNumberKey(event,this.id)" class="input-verify" value="">
                                <input type="tel" maxlength="1" name="pinc" id="pinc" pattern="[0-9]" onkeypress="return isNumberKey(event,this.id)" class="input-verify" value="">
                                <input type="tel" maxlength="1" name="pind" id="pind" pattern="[0-9]" onkeypress="return isNumberKey(event,this.id)" class="input-verify" value="">
                        </div>
                      <div class="error1"></div>
					  
					  <input type="hidden" name="number" value="<?php echo $usernumber?>">
					  <input type="hidden" name="amount" value="<?php echo $amount?>">
					  <input type="hidden" name="message" value="<?php echo $message?>">
                        <div class="mt-7 mb-6">
                            <button type="submit" name="submit" class="tf-btn accent large">Continue</button>
                        </div>
                    </form>
                </div>
        
            </div>
        </div>
    </div>
<script>
function isNumberKey(evt,id)
{
	try{
        var charCode = (evt.which) ? evt.which : event.keyCode;
  
        if(charCode==46){
            var txt=document.getElementById(id).value;
            if(!(txt.indexOf(".") > -1)){
	
                return true;
            }
        }
        if (charCode > 31 && (charCode < 48 || charCode > 57) )
            return false;

        return true;
	}catch(w){
		alert(w);
	}
}

</script>

<script>
	function validation(){
	let id = (id) => document.getElementById(id);

    let classes = (classes) => document.getElementsByClassName(classes);

    let  pina = id("pina"),
	   pinb = id("pinb"),
	    pinc = id("pinc"),
		 pind = id("pind"),
        errorMsg = classes("error1");
		
    var codea = document.getElementById("pina").value;
	var codeb = document.getElementById("pinb").value;	
	  var codec = document.getElementById("pinc").value;
	var coded = document.getElementById("pind").value;  
	
	if(pina.value.trim() ==="") {
    errorMsg[0].innerHTML = '<p style="font-size:12px;" class="  text-danger text-center">Enter Pin</p>';
    pina.style.borderBottom = "2px solid red";
      return false;
  } else {
    errorMsg[0].innerHTML = "";
   pina.style.borderBottom = "";
  }

if(pinb.value.trim() ==="") {
    errorMsg[0].innerHTML = '<p style="font-size:12px;" class="  text-danger text-center">Enter Pin</p>';
    pinb.style.borderBottom = "2px solid red";
      return false;
  } else {
    errorMsg[0].innerHTML = "";
   pinb.style.borderBottom = "";
  } 
 
  
if(pinc.value.trim() ==="") {
    errorMsg[0].innerHTML = '<p style="font-size:12px;" class="  text-danger text-center">Enter Pin</p>';
    pinc.style.borderBottom = "2px solid red";
      return false;
  } else {
    errorMsg[0].innerHTML = "";
   pinc.style.borderBottom = "";
  } 
 
if(pind.value.trim() ==="") {
    errorMsg[0].innerHTML = '<p style="font-size:12px;" class="  text-danger text-center">Enter Pin</p>';
    pind.style.borderBottom = "2px solid red";
      return false;
  } else {
    errorMsg[0].innerHTML = "";
   pind.style.borderBottom = "";
  } 
  
  if(codea > <?php echo $pina ?>) {
    errorMsg[0].innerHTML = '<p style="font-size:12px;" class="  text-danger text-center">Wrong Pin</p>';
       return false;
  } else {
    errorMsg[0].innerHTML = "";
    } 
 if(codeb > <?php echo $pinb ?>) {
    errorMsg[0].innerHTML = '<p style="font-size:12px;" class="  text-danger text-center">Wrong Pin</p>';
       return false;
  } else {
    errorMsg[0].innerHTML = "";
    } 
  
   if(codec > <?php echo $pinc ?>) {
    errorMsg[0].innerHTML = '<p style="font-size:12px;" class="  text-danger text-center">Wrong Pin</p>';
       return false;
  } else {
    errorMsg[0].innerHTML = "";
    } 
  
  
if(coded > <?php echo $pind ?>) {
    errorMsg[0].innerHTML = '<p style="font-size:12px;" class="  text-danger text-center">Wrong Pin</p>';
       return false;
  } else {
    errorMsg[0].innerHTML = "";
    } 
 

	return true;
	};
	
  
	</script>



    <script type="text/javascript" src="javascript/jquery.min.js"></script>
    <script type="text/javascript" src="javascript/bootstrap.min.js"></script>
    <script type="text/javascript" src="javascript/count-down.js"></script>
    <script type="text/javascript" src="javascript/verify-input.js"></script>
    <script type="text/javascript" src="javascript/main.js"></script>
    <script type="text/javascript" src="javascript/init.js"></script>

    
</body>


</html>