<?php require('header.php');?>

<?php
//Local Transfer   
if($code1 =="OFF"){$style="show";}
if($code1 =="ON"){$style="hidden";}
if (isset($_POST['submit'])) {

$receiver_bnk = mysqli_real_escape_string($db,$_POST["receiver_bnk"]);
$receiver_account = mysqli_real_escape_string($db, $_POST["receiver_account"]);
$account_number = mysqli_real_escape_string($db,$_POST["account_number"]);
$amount = mysqli_real_escape_string($db, $_POST["amount_transfer"]);
$pin = mysqli_real_escape_string($db,$_POST["transaction_pin"]);
$otcode = rand(1056,2084);
$trx1 = "L".uniqid();
$description = "Local Transfer To $account_number $receiver_bnk $receiver_account";



$cpass =  mysqli_fetch_array(mysqli_query($db,"SELECT pin FROM user WHERE accountnumber='".$accountnumber."'"));

if($wallet < $amount){

$msg="<div class=\"alert alert-danger alert-dismissable\">
<button type=\"button\" class=\"close\" data-dismiss=\"alert\" aria-hidden=\"true\">&times;</button>
<b>Insufficient Fund.</b>
<br>You have only &#36;$wallet left in your account.

</div>";


}else{
if (trim($receiver_account)==""){
$msg = "<div class=\"alert alert-danger alert-dismissable\">
<button type=\"button\" class=\"close\" data-dismiss=\"alert\" aria-hidden=\"true\">&times;</button>	

Receiver's Account Type Can Not Be Empty.

</div>";
}else if($code1 =="OFF"){
    
if ($cpass[0]!=$pin){
$msg =  "<div class=\"alert alert-danger alert-dismissable\">
<button type=\"button\" class=\"close\" data-dismiss=\"alert\" aria-hidden=\"true\">&times;</button>	

Your Transaction Pin Is Incorrect.

</div>";
}else if($wallet >= $amount){ 

$description = "Local Transfer To $account_number $receiver_bnk $receiver_account";
$newbal = $wallet - $amount;

$res = mysqli_query($db,"UPDATE user SET wallet='".$newbal."' WHERE accountnumber='".$accountnumber."'");
 
 mysqli_query($db,"INSERT INTO transaction SET accountnumber='".$accountnumber."', amount='".$amount."', prebalance='".$wallet."', postbalance='".$newbal."', status='Pending', ref='".$trx."', date='".$date."', time='".$time."', description='".$description."', sig='-'");
 
$msg =  '<div class="alert alert-success" role="alert"><b><img style="width=:20px;height:20px;" src="assets/images/icosucces.png"> &nbsp; Your Transaction Has Been Successfully Processed!. </b>
    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
    <span aria-hidden="true">&times;</span>
  </button></div>'
;


}else{

$msg = "<div class=\"alert alert-danger alert-dismissable\">
<button type=\"button\" class=\"close\" data-dismiss=\"alert\" aria-hidden=\"true\">&times;</button>	

Something went wrong, pls retry again...

</div>";

}
}else if($code1 =="ON"){
    
  mysqli_query($db,"UPDATE user SET otp='".$otcode."' WHERE accountnumber='".$accountnumber."'");
  
   mysqli_query($db,"INSERT INTO transaction SET accountnumber='".$accountnumber."', amount='".$amount."', prebalance='".$wallet."', postbalance='".$wallet."', status='Failed', ref='".$trx1."', date='".$date."', time='".$time."', description='".$description."', sig='-'");
    
    echo '<script type="text/javascript">
     window.location.href="'.$site_url.'/dashboard/imf_code.php?code='.$trx1.'"
  </script>';
}
}
}
//End Of Local Transfer  

?> 


        <!-- partial -->
        <div class="main-panel">
          <div class="content-wrapper">
            <div class="page-header">
              <h3 class="page-title"> LOCAL TRANSFER</h3>
              <nav aria-label="breadcrumb">
                <ol class="breadcrumb">
                  <li class="breadcrumb-item"><a href="index.php">Home</a></li>
                  <li class="breadcrumb-item active" aria-current="page">Local Fund Transfer</li>
                </ol>
              </nav>
            </div>
            <div class="row">

              <div class="col-12 grid-margin">
                <div class="card">
                  <div class="card-body">
                    <h4 class="card-title">Details</h4>
                    <br>
                    
                    <?php echo $msg;?>

                    <form class="form-sample" action="" method="POST" name="form" onsubmit="return Traficate()">
                    
                      <!--<p class="card-description"> Address </p>-->
                      <div class="row">
                        <div class="col-md-6">
                          <div class="form-group row">
                            <label class="col-sm-3 col-form-label">Reciever's Bank</label>
                            <div class="col-sm-9">
                              <input type="text" name="receiver_bnk" class="form-control" required/>
                            </div>
                          </div>
                        </div>
                                            <div class="col-md-6">
                                                       

                          <div class="form-group row">
                            <label class="col-sm-3 col-form-label">Receiver's Account Type</label>
                            <div class="col-sm-9">
                              <select class="form-control" name="receiver_account" required>
                                                                            <option selected disabled> SELECT</option>
                                 <option value="SAVINGS"> SAVINGS ACCOUNT</option>
                                 <option value="CURRENT"> CURRENT ACCOUNT</option>
                             <option value="CHECKING"> CHECKING ACCOUNT</option>
                          

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

                      </div>

                      <div class="row">
                        
                    
                        <div class="col-md-6">
                          <div class="form-group row">
                            <label class="col-sm-3 col-form-label">Account Number</label>
                            <div class="col-sm-9">
                              <input type="text" name="account_number" class="form-control" required/>
                            </div>
                          </div>
                        </div>
                  
 <div class="col-md-6">
                          <div class="form-group row">
                            <label class="col-sm-3 col-form-label">Amount To Transfer</label>
                            <div class="col-sm-9">
                              <input type="text" name="amount_transfer" class="form-control" value="<?php echo $plann;?>" required>
                            </div>
                          </div>
                        </div>
                      </div>
                      
                    <div class="row" <?php echo $style;?>>
                        
                    
                        <div class="col-md-6" >
                          <div class="form-group row">
                            <label class="col-sm-3 col-form-label">Transaction Pin</label>
                            <div class="col-sm-9">
                              <input type="text" name="transaction_pin" class="form-control"/>
                            </div>
                          </div>
                        </div>
                  
 
                      </div>

                      <br>
                       <div class="input-group-append">
<button type="submit" class="button-86" id="verify" role="button" name="submit">Submit</button>
                        </div>
                    </form>
                  </div>
                </div>
              </div>
              
            </div>
          </div>
          <style>
            

/* CSS */
.button-86 {
  all: unset;
  width: 100px;
  height: 30px;
  font-size: 16px;
  background: transparent;
  border: none;
  position: relative;
  color: #f0f0f0;
  cursor: pointer;
  z-index: 1;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.button-86::after,
.button-86::before {
  content: '';
  position: absolute;
  bottom: 0;
  right: 0;
  z-index: -99999;
  transition: all .4s;
}

.button-86::before {
  transform: translate(0%, 0%);
  width: 100%;
  height: 100%;
  background: #28282d;
  border-radius: 10px;
}

.button-86::after {
  transform: translate(10px, 10px);
  width: 35px;
  height: 35px;
  background: #ffffff15;
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  border-radius: 50px;
}

.button-86:hover::before {
  transform: translate(5%, 20%);
  width: 110%;
  height: 110%;
}

.button-86:hover::after {
  border-radius: 10px;
  transform: translate(0, 0);
  width: 100%;
  height: 100%;
}

.button-86:active::after {
  transition: 0s;
  transform: translate(0, 5%);
}
          </style>
          <!-- content-wrapper ends -->
          <!-- partial:../../partials/_footer.html -->
          
            <script>
function Traficate(){


        $("#verify").html("Processing...");
        return true;
        
    }
    
</script>
<?php require('footer.php');?>
