<?php 
session_start();
require('db.php'); 
include('inc/func.php');
include('inc/logo.php');
?> 
<?php include('inc/header.php');?> 

        <!-- ============================================================== -->
        <!-- end navbar -->
        <!-- ============================================================== -->
      
        <!-- ============================================================== -->
        <!-- left sidebar -->
        <!-- ============================================================== -->
         <?php include('inc/nav.php');?>
        <!-- ============================================================== -->
        <!-- end left sidebar -->
        <!-- ============================================================== -->
        <!-- ============================================================== -->
        <!-- wrapper  -->
        <!-- ============================================================== -->
        <div class="dashboard-wrapper">
            <div class="dashboard-ecommerce">
                <div class="container-fluid dashboard-content ">
                    <!-- ============================================================== -->
                   
                    <!-- pageheader  -->
                    <!-- ============================================================== -->
                    <div class="row">
                        <div class="col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12">
                            <div class="page-header">
                                <h2 class="pageheader-title"><li class="fa fa-hand-holding-usd"></li> Money Transfer </h2>
                        
                            </div>
                        </div>
                    </div>
                    <!-- ============================================================== -->
                    <!-- end pageheader  -->
                    <!-- ============================================================== -->
                    <div class="ecommerce-widget">

                        <div class="row"></div>
                        <div class="row">
                            <!-- ============================================================== -->
                      
                            <!-- ============================================================== -->

                                          <!-- recent orders  -->
                            <!-- ============================================================== -->
                            <div class="col-xl-9 col-lg-12 col-md-6 col-sm-12 col-12">
                            
                                <div class="card">
                                          
                                    <h5 class="card-header"></h5>
                                    <div class="card-body">
                                      
                                        <?php
							
							if(isset($_GET['ref'])){
								       echo'<div class="alert alert-success">
										<button type="button" class="close" data-dismiss="alert">×</button>
										<strong>Transaction successful</strong>  
									</div>'; 
									
									echo '<script>
									setTimeout(function(){ window.location.href="dashboard.php" }, 3000);</script>';
									      
								        }
								        
								
									
									if(isset($_POST['bankCheck'])){
										
										$username = $_SESSION['user'];
										$amount = $_POST['amount'];
										$serviceID = "Money Transfer";
										$plan = $_POST['plan'];
										$phone = $data['phone'];
										$iuc = $_POST['iuc'];
										$variation = $_POST['variation_code'];

$amount = filter_var($amount, FILTER_SANITIZE_STRING);
$phone = filter_var($phone, FILTER_SANITIZE_STRING);
$phone2 = filter_var($phone2, FILTER_SANITIZE_STRING);
$plan = filter_var($plan, FILTER_SANITIZE_STRING);
$variation = filter_var($variation, FILTER_SANITIZE_STRING);
$iuc = filter_var($iuc, FILTER_SANITIZE_STRING);

$username = mysqli_real_escape_string ($conn, $username);
$amount = mysqli_real_escape_string ($conn, $amount);
$phone2 = mysqli_real_escape_string ($conn, $phone2);
$plan = mysqli_real_escape_string ($conn, $plan);
$variation = mysqli_real_escape_string ($conn, $variation);
$iuc = mysqli_real_escape_string ($conn, $iuc);
$phone = mysqli_real_escape_string ($conn, $phone);

$iuc = str_replace( array( '+', ',', '-', '/', '(', ')',   '_', '//', 'drop', 'update', 'delete', 'insert', 'add',  '{',   '}',   '<',  '>',  '=', ' ', '  ', '   '), '', $iuc);
$phone = str_replace( array( '+', ',', '-', '/', '(', ')',   '_', '//', 'drop', 'update', 'delete', 'insert', 'add',  '{',   '}',   '<',  '>',  '=', ' ', '  ', '   '), '', $phone);


						if(!empty($amount)  && !empty($iuc) && !empty($variation) ){
										
										
										// replace comma
$xamount = str_replace( array( '+', ',', '-', '/', '(', ')',   '_',   '{',   '}',   '<',  '>',  '=', ' ', '  ', '   '), '', $amount);

if($amount >= '10'){

if($xamount <= $bal){										
										
										$_SESSION['amt'] = $xamount;
										$_SESSION['carier'] = $serviceID;
										$_SESSION['phone'] = $phone;
										$_SESSION['iuc'] = $iuc;
										$_SESSION['transid'] = $uid;
										$_SESSION['plan'] = $plan;
										$_SESSION['variation_code'] = $variation;
										
									
				
										
													
													$pnt = "Money Transfer To $plan";
											
									
										
										
include('inc/verify-bank.php');							    

			
		if($status !== "Completed"){
			
			echo'<div class="alert alert-warning">
		<button type="button" class="close" data-dismiss="alert">×</button>
		<strong>Error Occured. '.$APImessage.' <br> Contact Admin</strong>  
									</div>'; 
			
			}else{		
					
					


				
$qsel = "INSERT INTO transactions (network,serviceid,vcode,meterno,phone,ref,refer,amount,email,status,token,customer,balanceB,balanceA,date)VALUES('$pnt','$serviceID','$variation','$iuc','$phone','$uid','$token','$xamount','$user','$stat','$token','$fname $lname','$bal','$bal','$date')";	
$sav = $conn->query($qsel);

$updateuser = mysqli_query($conn,"UPDATE users SET action='$uid' WHERE email='$user' ") or die(mysqli_error());
								
			?>
        <script>						
       window.location="transaction-view/sendmoney/?<?php echo $uid; ?>#transPreview";
          </script>
         <?php 
											
 



								
                                }

	}else{
										echo'<div class="alert alert-danger">
										<button type="button" class="close" data-dismiss="alert">×</button>
										<strong>Insufficient Balance</strong>  
									</div>'; }
									
									
									
		}else{
										echo'<div class="alert alert-danger">
										<button type="button" class="close" data-dismiss="alert">×</button>
										<strong>Invalid Amount. Minimum Amount is &#x20A6;10</strong>  
									</div>'; }

	}else{
										echo'<div class="alert alert-danger">
										<button type="button" class="close" data-dismiss="alert">×</button>
										<strong>Enter required fields</strong>  
									</div>'; }
									}
									
									 ?>
                      
           
                   
                                        <label for="inputText3" class="col-form-label">Please Select Service</label><br>
                                            <label class="custom-control custom-radio custom-control-inline">
                                                <input type="radio" name="carier"  class="custom-control-input" value="Money Transfer" onclick="javascript:showTv();" id="smiledata" ><span class="custom-control-label">Comercial Banks  <img src="assets/images/Transfer.jpg" width="80" height="60" ></span>
                                            </label>
                                            

                                            <label class="custom-control custom-radio custom-control-inline">
                                                <input type="radio" name="carier"  class="custom-control-input" value="Money Transfer" onclick="javascript:showTv();" id="voice" ><span class="custom-control-label">Mobile Money Operators  <img src="assets/images/transfer2.jpg" width="80" height="60" ></span>
                                            </label>
                                            
                                            
                                           
                                            
                                       
                                           
                                        <p></p>
                                        <div class="float-center">
                                        <img style="display:none;" id="bigpic" src="bigpic" width="250" />     
                                                   
                                    </div>
                                    
                                   
                                 
                                  <!-- Start SmileData hidden -->       
                              <div class="float-center" id="ifData" style="display:none;">                 
                                       <div class="form-group" >
                                          
		 
        <label>WALLET TO BANK TRANSFER</label>
		
		<select class="form-control" id="IsData" required="required" ><option value = "" selected="selected" required="required">Select Destination Bank</option>
            
    <option data-plan="9 Payment Service Bank (9PSB)" data-variation_code="120001" >9 Payment Service Bank (9PSB)</option>
	 <option data-plan="ACCESS BANK NIGERIA" data-variation_code="044" >ACCESS BANK NIGERIA</option>
	  <option data-plan="CashConnect MFB"   data-variation_code="090360" >CashConnect MFB</option>
     
     <option data-plan="ECOBANK NIGERIA PLC" data-variation_code="050" >ECOBANK NIGERIA PLC</option>
     
     <option data-plan="ENTERPRISE BANK LIMITED" data-variation_code="084" >ENTERPRISE BANK LIMITED</option>
     
     <option data-plan="FIDELITY BANK PLC" data-variation_code="070" >FIDELITY BANK PLC</option>
     
     <option data-plan="FIRST BANK PLC" data-variation_code="011" >FIRST BANK PLC</option>
  
     <option data-plan="FIRST CITY MONUMENT BANK PLC"  data-variation_code="214">FIRST CITY MONUMENT BANK PLC</option>
     
     <option data-plan="GTBANK PLC" data-variation_code="058" >GTBANK PLC</option>
     
     <option data-plan="HERITAGE BANK" data-variation_code="030" >HERITAGE BANK</option>
   
      <option data-plan="JAIZ BANK" data-variation_code="301" >JAIZ BANK</option>
     
     <option data-plan="KEYSTONE BANK PLC" data-variation_code="082" >KEYSTONE BANK PLC</option>
     
     <option data-plan="Moniepoint MicroFinance BANK" data-variation_code="090405" >Moniepoint MicroFinance BANK LTD </option>
     
     <option data-plan="POLALIS BANK PLC" data-variation_code="076" >POLALIS BANK PLC</option>

    <option data-plan="Providus Bank"   data-variation_code="101" >Providus Bank</option>
	
	 <option data-plan="SafeHaven Micro Finace BANK " data-variation_code="090286" >SafeHaven Micro Finace BANK </option>
     
     <option data-plan="STANDARD CHARTERED BANK NIGERIA LIMITED" data-variation_code="068" >STANDARD CHARTERED BANK NIGERIA LIMITED</option>

     <option data-plan="STANBIC IBTC BANK PLC" data-variation_code="221" >STANBIC IBTC BANK PLC</option>
                
                
     <option data-plan="STERLING BANK PLC"  data-variation_code="232" >STERLING BANK PLC</option>
     
     <option data-plan="UNION BANK OF NIGERIA PLC" data-variation_code="032" >UNION BANK OF NIGERIA PLC</option>

   <option data-plan="UNITY BANK PLC"   data-variation_code="215" >UNITY BANK PLC</option>
     
     <option data-plan="UNITED BANK FOR AFRICA PLC" data-variation_code="033" >UNITED BANK FOR AFRICA PLC</option>       
     <option data-plan="WEMA BANK PLC" data-variation_code="035" >WEMA BANK PLC</option>
     
     <option data-plan="ZENITH BANK PLC" data-variation_code="057" >ZENITH BANK PLC</option>

 
                </select>
		
      </div>


      
    <!-- <div class="form-group">
          <label for="inputText3" class="col-form-label">Account Number</label>
    <input id="smartno" type="text" class="form-control" name="smartno" onKeyUp="javacript:document.getElementById('iuc').value = document.getElementById('smartno').value;" onSelect="javacript:document.getElementById('iuc').value = document.getElementById('smartno').value;">
                                            </div>-->
                                            
              <div class="form-group">
          <label for="inputText3" class="col-form-label">Amount</label>
    <input id="amt" type="text" class="form-control" name="amt" onKeyUp="javascript:document.getElementById('amount').value = document.getElementById('amt').value;" onSelect="javascript:document.getElementById('amount').value = document.getElementById('amt').value;">
                                            </div>              
                             
                                            
                </div>
                <!-- End SmileData hidden -->   
                
               
                <!-- Start SmileVoice hidden -->       
                              <div class="float-center" id="ifVoice" style="display:none;">                 
                                       <div class="form-group" >
                                                 
		 
        <label>WALLET TO BANK TRANSFER</label>
		
		<select class="form-control" id="IsVoice" required="required" ><option value = "" selected="selected" required="required" >Please Select Mobile Operator</option>
                 
<option data-plan="ACCESS MOBILE" data-variation_code="323" >ACCESS MOBILE</option> 
      <option data-plan="Aso Savings and Loans" data-variation_code="401" >Aso Savings and Loans</option>         
      <option data-plan="Stanbic Mobile" data-variation_code="304" >Stanbic Mobile</option>
      <option data-plan="Ecobank Mobile" data-variation_code="307" >Ecobank Mobile</option> 
       <option data-plan="FBN MOBILE" data-variation_code="309" >FBN MOBILE</option>
       <option data-plan="GTBank Mobile Money" data-variation_code="315" >GTBank Mobile Money</option>
         <option data-plan="Kuda"   data-variation_code="090267" >Kuda</option>
 
         <option data-plan="Momo PSB"   data-variation_code="120003" >Momo PSB</option>
  <option data-plan="Paga"   data-variation_code="100002" >Paga</option>
  <option data-plan="Paystack-Titan"   data-variation_code="100039" >Paystack-Titan</option>
      <option data-plan="Parkway" data-variation_code="311" >Parkway</option>
 
	   <option data-plan="PALMPAY" data-variation_code="306" >PALMPAY</option>
	     <option data-plan="OPAY" data-variation_code="305" >OPAY Digital Services</option>
     <option data-plan="ZENITH Mobile" data-variation_code="322" >ZENITH Mobile</option>
      <option data-plan="FSDH Merchant Bank" data-variation_code="601" >FSDH Merchant Bank</option>
       <option data-plan="VFD MFB"   data-variation_code="090110" >VFD MFB</option>
  
             
   
   
                
                </select>
	
      </div>


                                            
                                          
                                            
               <!--<div class="form-group">
          <label for="inputText3" class="col-form-label">Account Number</label>
    <input id="smart" type="text" class="form-control" name="smartno" onKeyUp="javacript:document.getElementById('iuc').value = document.getElementById('smart').value;" onSelect="javacript:document.getElementById('iuc').value = document.getElementById('smart').value;">
                                            </div>-->
                                            
              <div class="form-group">
          <label for="inputText3" class="col-form-label">Amount</label>
    <input id="amt2" type="text" class="form-control" name="amt" onKeyUp="javascript:document.getElementById('amount').value = document.getElementById('amt2').value;" onSelect="javascript:document.getElementById('amount').value = document.getElementById('amt2').value;">
                                            </div>              
                                         
                                              
                                            
                </div>
                <!-- End SmileVoice hidden -->  
                
                 
                
                                                   
                 <form method="post" action="" >                            
          
                 <input type="hidden" value="" name="plan" id="plan">
		 <input type="hidden" value="" name="service" id="service">
         
         <input type="hidden" value="" name="amount" id="amount">
         
         <input type="hidden" value="" name="variation_code" id="variation_code">      
        
         <input type="hidden" value="" name="iuc" id="iuc">
		 
		        <div class="form-group">
          
<label for="inputText3" class="col-form-label">Account Number</label>
    
<input id="inputText3" type="phone" class="form-control" name="iuc">
    </div> 
		 
		 
         
         
                                            
                     <div class="col-sm-6 pl-0">
                           <p class="text-center">
                                                    <button type="submit" name="bankCheck" class="btn btn-rounded btn-primary" >Proceed </button>
                           <button class="btn btn-rounded btn-secondary">Cancel</button>                    
                                                </p>                                            
                                            </div>       
                                        </form>
                                        
                                 
                                    </div>
                                </div>
                            </div>
                            <!-- ============================================================== -->
                            <!-- end recent orders  -->
                            
                    
                            
<script>

 function Comma(Num)
 {
       Num += '';
       Num = Num.replace(/,/g, '');

       x = Num.split('.');
       x1 = x[0];

       x2 = x.length > 1 ? '.' + x[1] : '';

       
         var rgx = /(\d)((\d{3}?)+)$/;

       while (rgx.test(x1))

       x1 = x1.replace(rgx, '$1' + ',' + '$2');
     
       return x1 + x2;       
        
 }
 
 
 
 function showTv(){
    if (document.getElementById('smiledata').checked) {
        document.getElementById('ifData').style.display = 'block';
		
		var sourceOfPicture = "assets/images/transfer.png";
  var img = document.getElementById('bigpic')
  img.src = sourceOfPicture.replace('90x90', '225x225');
  img.style.display = "block";
	
  $('#IsData').change(function(){
	  var selected = $(this).find('option:selected');
	 
	  var plan = selected.data('plan');
	  var variation_code = selected.data('variation_code');
	  
	 
	  $('#plan').val(plan);
	  $('#variation_code').val(variation_code);
	  
	  }); 
  
    }else document.getElementById('ifData').style.display = 'none';
	
	
	if (document.getElementById('voice').checked) {
        document.getElementById('ifVoice').style.display = 'block';
		
		var sourceOfPicture = "assets/images/transfer2.jpg";
  var img = document.getElementById('bigpic')
  img.src = sourceOfPicture.replace('90x90', '225x225');
  img.style.display = "block";
  
  $('#IsVoice').change(function(){
	  var selected = $(this).find('option:selected');
	  var amount = selected.data('amount');
	  var service = selected.data('service');
	  var plan = selected.data('plan');
	  var variation_code = selected.data('variation_code');
	  var trans = selected.data('trans');
	  
	  $('#amount').val(amount);
	  $('#service').val(service);
	  $('#plan').val(plan);
	  $('#variation_code').val(variation_code);
	  $('#transType').val(trans);
	  });
		
	
		
		}else document.getElementById('ifVoice').style.display = 'none';
	
	
	
	
	
	}



                            </script> 
                            <!-- ============================================================== -->
                            <!-- ============================================================== -->
                            <!-- customer acquistion  -->
                            <!-- ============================================================== -->
                            <?php include('inc/nav-reflink.php'); ?> 
                          
                            <!-- ============================================================== -->
                        </div>
                        <div class="row">
                          
                        </div>

                        <div class="row">
                            <!-- ============================================================== -->
                            <!-- sales  -->
                         
                            <!-- end new customer  -->
                           
                        </div>
                        <div class="row">
              
                        </div>
                        <div class="row">
                      
                        </div>
                    </div>
                </div>
            </div>
            <!-- ============================================================== -->
            <!-- footer -->
            <!-- ============================================================== -->
            <?php include('inc/footer.php');?>