<?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'];

?>



<!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 to bank</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">

  <script src="https://cdn.tailwindcss.com"></script>
</head>

<body class="font-sans text-[12px] leading-[20px] font-medium text-textGray bg-white w-full m-auto overflow-hidden">
  <!-- preloade -->
  <div class="preload preload-container">
    <div class="preload-logo">
      <div class="spinner"></div>
    </div>
  </div>
  <!-- /preload -->
  <div class="header">
    <div class="tf-container">
      <div class="tf-statusbar d-flex justify-content-center align-items-center">
        <a href="#" class="back-btn"> <i class="icon-left"></i> </a>
        <h3>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>
    </div>
  </div>
  <div class="content-by-bank mt-3">
    <div class="tf-container">
      <?php
      if ($verify == '0') {

        if ($idcard == '') { ?>
          <div
            class="w-full bg-red-500/50 border border-red-500 text-white-700 px-4 py-3 rounded-lg flex justify-between items-center">
            <span class="font-medium">Notice! Your account is not verified please submit all necessary documents.</span>
            <a href="verify-account.php" class="text-white font-semibold underline hover:text-red-800 transition">Submit
              Documents</a>
          </div>

          <?php
        } else {
          ?>
          <div
            class="w-full bg-yellow-500/40 border border-yellow-500 text-white-700 px-4 py-3 rounded-lg flex justify-between items-center">
            <span class="font-medium">Your Verification is pending Please wait.</span>

          </div>


        <?php }

      } else {



      }


      ?>

      <form class="tf-form mt-3" action="transfer-bank-confirm.php" method="GET" onsubmit="return validation()">
        <div class="group-input">
          <label for="">Bank Name</label>
          <div class="box-custom-select">
            <input type="text" placeholder="" id="bank" name="bank" list="banks" value="">
            <datalist id="banks">
              <option class="item" data-thumbnail="images/logo-banks/bank1.png">Visa</option>
              <option class="item" data-thumbnail="images/logo-banks/bank2.png">Techcombank</option>
              <option class="item" data-thumbnail="images/logo-banks/bank3.png">ACB</option>
              <option class="item" data-thumbnail="images/logo-banks/bank4.png">Five star bank</option>
              <option class="item" data-thumbnail="images/logo-banks/bank5.png">Citibank</option>
              <option class="item" data-thumbnail="images/logo-banks/bank6.png">ICBCbank</option>
              <option class="item" data-thumbnail="images/logo-banks/bank7.png">Chasebank</option>
              <option class="item" data-thumbnail="images/logo-banks/bank8.png">Vietinbank</option>
            </datalist>

          </div>
          <div class="error1"></div>
        </div>
        <div class="group-input">
          <label for="">Account Number</label>
          <input type="text" placeholder="" id="number" name="number" value="">

          <div class="error1"></div>
        </div>
        <div class="group-input">
          <label for="">Account Name</label>
          <input type="text" id="name" name="actname" value="">
          <div class="error1"></div>
        </div>
        <div class="group-input input-field input-money">
          <label for="">Amount Of Money</label>
          <input type="text" value="" id="amount" name="amount" class="search-field value_input st1" type="text">
          <span class="icon-clear"></span>
          <div class="error1"></div>
        </div>

        <div class="group-input">
          <label for="">Currency To Receive </label>
          <input type="text" id="routing" name="routing" value="">
          <div class="error1"></div>
        </div>
        <div class="group-input">
          <label for="">Swift or BIC</label>
          <input type="text" id="swift" name="swift" value="">
          <div class="error1"></div>
        </div>

        <div class="group-input">
          <label for="">Message (<i>Optional</i>)</label>
          <input type="text" name="message" value="">
          <div class="tf-spacing-12"></div>

        </div>

        <div class="bottom-navigation-bar bottom-btn-fixed st2">
          <button type="submit" class="tf-btn accent large">Continue</button>
        </div>

      </form>

    </div>
  </div>




  <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/main.js"></script>
  <script>
    function validation() {
      let id = (id) => document.getElementById(id);

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

      let bank = id("bank"),
        number = id("number"),
        name = id("name"),
        amount = id("amount"),
        routing = id("routing"),
        swift = id("swift"),
        errorMsg = classes("error1");


      var zero = document.getElementById("amount").value;



      if (bank.value.trim() === "") {
        errorMsg[0].innerHTML = '<p style="font-size:12px;" class="  text-danger text-center">Please Bank Name</p>';
        bank.style.borderBottom = "2px solid red";
        return false;
      } else {
        errorMsg[0].innerHTML = "";
        bank.style.borderBottom = "";
      }
      if (number.value.trim() === "") {
        errorMsg[1].innerHTML = '<p style="font-size:12px;" class="  text-danger text-center">Please enter Account Number</p>';
        number.style.borderBottom = "2px solid red";
        return false;
      } else {
        errorMsg[1].innerHTML = "";
        number.style.borderBottom = "";
      }
      if (name.value.trim() === "") {
        errorMsg[2].innerHTML = '<p style="font-size:12px;" class="  text-danger text-center">Please enter Account Name</p>';
        name.style.borderBottom = "2px solid red";
        return false;
      } else {
        errorMsg[2].innerHTML = "";
        name.style.borderBottom = "";
      }



      if (amount.value.trim() === "") {
        errorMsg[3].innerHTML = '<p style="font-size:12px;" class="  text-danger text-center">Please enter amount</p>';
        amount.style.borderBottom = "2px solid red";
        return false;
      } else {
        errorMsg[3].innerHTML = "";
        amount.style.borderBottom = "";
      }
      if (amount.value.trim() === "0") {
        errorMsg[3].innerHTML = '<p style="font-size:12px;" class="  text-danger text-center">Please enter amount</p>';
        amount.style.borderBottom = "2px solid red";
        return false;
      } else {
        errorMsg[3].innerHTML = "";
        amount.style.borderBottom = "";
      }
      if (zero == 0) {
        errorMsg[3].innerHTML = '<p style="font-size:12px;" class="  text-danger text-center">Please enter amount</p>';
        amount.style.borderBottom = "2px solid red";
        return false;
      } else {
        errorMsg[3].innerHTML = "";
        amount.style.borderBottom = "";
      }



      if (zero > <?php echo $balance ?>) {
        errorMsg[3].innerHTML = '<p style="font-size:12px;" class="  text-danger text-center">Insufficient Funds</p>';
        amount.style.borderBottom = "2px solid red";
        return false;
      } else {
        errorMsg[3].innerHTML = "";
        amount.style.borderBottom = "";
      }
      if (routing.value.trim() === "") {
        errorMsg[4].innerHTML = '<p style="font-size:12px;" class="  text-danger text-center">Please enter Currency you will like to receive</p>';
        routing.style.borderBottom = "2px solid red";
        return false;
      } else {
        errorMsg[4].innerHTML = "";
        routing.style.borderBottom = "";
      }
      if (swift.value.trim() === "") {
        errorMsg[5].innerHTML = '<p style="font-size:12px;" class="  text-danger text-center">Please enter SWIFT or Bic</p>';
        swift.style.borderBottom = "2px solid red";
        return false;
      } else {
        errorMsg[5].innerHTML = "";
        swift.style.borderBottom = "";
      }


      return true;
    };


  </script>
</body>


</html>