<?php
require_once("../app/config.php");
$title="Transfer funds";
require_once('include/user_header.php');
require_once('include/user_navbar.php');
require_once('include/user_sidebar.php');
?>
<div class="content-wrapper">

      <!-- Page header -->
      <div class="page-header page-header-light">
        <div class="page-header-content header-elements-md-inline">
        </div>
      </div>
      <!-- /page header -->

  <div class="content">
  <?php if(!empty($_SESSION['offshore_trans'])){?>
    <div class="row">
        <div class="col-lg-12">
          <div class="alert <?php if($_SESSION['offshore_trans']=='success') {echo 'bg-success-800';}else{echo 'bg-danger';}?> text-white alert-styled-left alert-dismissible">
            <button type="button" class="close" data-dismiss="alert"><span>&times;</span></button>
      <?php if($_SESSION['offshore_trans']=='success') {
        echo'Transaction was successful.';
      } else if($_SESSION['offshore_trans']=='thesame') {
        echo"You cannot transfer money to the same account.";
      } else if($_SESSION['offshore_trans']=='invalid') {
        echo"Invalid account number.";
      } else if($_SESSION['offshore_trans']=='insufficient') {
        echo'Account balance is insufficient.';
      }
      unset($_SESSION['offshore_trans']);?>                 
            </div>
          </div>
      </div>
  <?php }?>
    <div class="row">
      <div class="col-lg-12">
        <div class="alert bg-white alert-dismissible">
          <button type="button" class="close" data-dismiss="alert"><span>&times;</span></button>
            Transfer charges is <?php echo $scan2['currency'].$set['transfer_charge'];?> per transaction.
          </div>
        </div>
    </div>
    <div class="row">
      <div class="col-md-12">
        <!-- Basic layout-->
        <div class="card">
          <div class="card-header header-elements-inline">
            <h6 class="card-title font-weight-semibold">Transfer Funds</h6>
                <div class="header-elements">
                  <div class="list-icons">
                </div>
              </div>
          </div>
          <div class="card-body">
            <form action="../app/user/sendfund" method="post">
                <div class="form-group row">
                  <label class="col-form-label col-lg-2">Account number</label>
                  <div class="col-lg-10">
                    <div class="input-group">
                      <span class="input-group-prepend">
                        <span class="input-group-text">#</span>
                      </span>
                      <input type="number" name="acct_no" maxlength="10" class="form-control" required>
                    </div>
                  </div>
                </div>
                <div class="form-group row">
                  <label class="col-form-label col-lg-2">Amount</label>
                  <div class="col-lg-10">
                    <div class="input-group">
                      <span class="input-group-prepend">
                        <span class="input-group-text"><?php echo $scan2['currency'];?></span>
                      </span>
                      <input type="number" class="form-control" name="amount" id="amount" required>
                      <input type="hidden" name="user_id" value="<?php echo $row['id'];?>">
                      <span class="input-group-append">
                        <span class="input-group-text">.00</span>
                      </span>
                      <input type="hidden" id="transfer" value="<?php echo $set['transfer_charge'];?>">
                    </div>
                  </div>
                </div>
                <div class="form-group row">
                 <div class="col-lg-12 text-center center-col">
                  <span>You will send <?php echo $scan2['currency'];?><span id="gain">0.00</span></span><br>
                  </div> 
                </div>                     
                <div class="text-center">
                  <button type="submit" class="btn bg-info">Submit</button>
                </div>
            </form>
          </div>
        </div>
        <!-- /basic layout -->
      </div>
    </div>
  </div>
<?php require_once('include/user_footer.php');?>
<script type="text/javascript">
  function sellVals(){
    var amount = $("#amount").val();
    var transfer = $("#transfer").val();
    var rate = parseFloat(transfer)+parseFloat(amount);
    $("#gain").text(rate);
  }
  $("#amount").change(sellVals);
  sellVals();
</script>