<?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">BET Account Funding </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['topup'])){
										
										$username = $_SESSION['user'];
										$amount = $_POST['amt'];
										$network = $_POST['carier'];
										$phone = $_POST['phone'];
                                        $iuc = $_POST['iuc'];
										
									
$amount = filter_var($amount, FILTER_SANITIZE_STRING);
$network = filter_var($network, FILTER_SANITIZE_STRING);
$phone = filter_var($phone, FILTER_SANITIZE_STRING);
$iuc = filter_var($iuc, FILTER_SANITIZE_STRING);



$username = mysqli_real_escape_string ($conn, $username);
$amount = mysqli_real_escape_string ($conn, $amount);
$network = mysqli_real_escape_string ($conn, $network);
$phone = mysqli_real_escape_string ($conn, $phone);
$iuc = mysqli_real_escape_string ($conn, $iuc);

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

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


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


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




									
										if(!empty($xamount) && !empty($network) && !empty($iuc) ){
								
										
if($xamount >= '100'){

if($xamount <= $bal){										
									

$variation = strtolower($network);
$plan = strtoupper($network);
$pnt = "$plan Account Funding";

									
										$_SESSION['amt'] = $xamount;
										$_SESSION['carier'] = $network;
										$_SESSION['phone'] = $phone;
                                        $_SESSION['iuc'] = $iuc;
										$_SESSION['transid'] = $uid;	
										
										


 
				
include('inc/verify-betting.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 on '.$sitephone.'</strong>  
									</div>'; 
			
			}else{		

											
											$token = uniqid();
											$stat = "Pending";
											
							
											
											
									

$qsel = "INSERT INTO transactions(network,serviceid,vcode,meterno,phone,ref,refer,amount,email,status,token,customer,balanceB,balanceA,date)VALUES('$pnt','$network','$variation','$iuc','$phone','$uid','$token','$xamount','$user','$stat','$token','$customer','$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/betpay?<?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-warning">
										<button type="button" class="close" data-dismiss="alert">×</button>
										<strong>Minimum is '.$currency.'100</strong>  
									</div>';  }   
                                        
								
                                }else{
										echo'<div class="alert alert-danger">
										<button type="button" class="close" data-dismiss="alert">×</button>
										<strong>Enter required fields</strong>  
									</div>'; }
									} 
									
									 ?>
                       
                                        <form method="post" action="" id="TransTable">
                                        

 <label><strong>Betting Platform:</strong></label>
		
 <select class="form-control" placeholder="Betting Platform" id="carier" name="carier" required="required" >
<option value = "" selected="selected" required="required">Select Betting Platform</option>
                                       
<option value="bet9ja">Bet9ja</option>
<option value="bet9ja-agent">Bet9ja Agent/Shop Funding</option>
<option value="betking">BetKing</option>
<option value="1xbet">1XBet</option>
<option value="nairabet">NairaBet</option>
<option value="merrybet">MerryBet</option>
<option value="naijabet">NaijaBet</option>
<option value="betway">Betway</option>
<option value="bangbet">BangBet</option>
<option value="Naira-Million">Naira-Million</option>
<option value="betland">Bet Land</option> 
<option value="betlion">Bet Lion</option>
<option value="hallabet">HallaBet</option>
<option value="supabet">SupaBet</option> 
<option value="msport">MSport</option> 
<option value="green-lotto">Green Lotto</option> 
<option value="western-lotto">Western Lotto</option> 
<option value="mlotto">Mylotto</option>

<option value="BetBiga">BetBiga</option>
<option value="Betano">Betano</option> 
<option value="CloudBet">CloudBet</option> 
<option value="Paripesa">Paripesa</option> 
<option value="LiveScoreBet">LiveScoreBet</option>
<option value="MelBet">MelBet</option>
<option value="SportyBet">SportyBet</option>
<option value="WAJEGAME">WajeGAME</option>

</select>

		 
       



 <label for="inputText3" class="col-form-label">Enter Amount</label>  
 
                                       
<div class="input-group mb-3">
                                                <div class="input-group-prepend"><span class="input-group-text"><?php echo $currency;?></span></div>
                                                <input type="text" class="form-control"oninput="javascript:this.value=Comma(this.value);" name="amt" >
                                                <div class="input-group-append"><span class="input-group-text">.00</span></div>
                                                
                                                
                                             </div> 
                                           
                                            
                           <div class="form-group">
          <label for="inputText3" class="col-form-label">User ID/Bet ID/Customer ID</label>
    <input id="inputText3" type="text" class="form-control" name="iuc">
                                            </div>
 

                 
                                         
                                     <div class="col-sm-6 pl-0">
                                         
                                                <p class="text-center">
                                                    <button type="submit" name="topup" class="btn btn-rounded btn-primary">Proceed</button>
                           <button class="btn btn-rounded btn-secondary">Cancel</button>                    
                                                
                                                   
                                                </p>
                                                
                                                <p align="center">
                                                    
                                                
                                                     </p>
                                               
                                           
                                        </form>    </div>                      
                                    
                                    
                                  <script>
                           
						   function show9mobile() {
  var sourceOfPicture = "assets/images/9mobile.jpg";
  var img = document.getElementById('bigpic')
  img.src = sourceOfPicture.replace('90x90', '225x225');
  img.style.display = "block";
  
} 
                   
function showMTN() {
  var sourceOfPicture = "assets/images/mtn.jpg";
  var img = document.getElementById('bigpic')
  img.src = sourceOfPicture.replace('90x90', '225x225');
  img.style.display = "block";
} 

function showAirtel() {
  var sourceOfPicture = "assets/images/airtel.jpg";
  var img = document.getElementById('bigpic')
  img.src = sourceOfPicture.replace('90x90', '225x225');
  img.style.display = "block";
} 

function showGlo() {
  var sourceOfPicture = "assets/images/glo.jpg";
  var img = document.getElementById('bigpic')
  img.src = sourceOfPicture.replace('90x90', '225x225');
  img.style.display = "block";
} 
                    
                                  </script>
                                        
                                    </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 yesnoCheck() {
    if (document.getElementById('yescard').checked) {
        document.getElementById('ifYes').style.visibility = 'visible';
    }
    
     if (document.getElementById('yescash').checked) {
        document.getElementById('ifYes').style.visibility = 'visible';
    }
    
     if (document.getElementById('yesbitcoin').checked) {
        document.getElementById('ifYes').style.visibility = 'visible';
    }
    
    

}



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

                                   <!-- product sales  -->
                            <!-- ============================================================== -->
                            <!-- ============================================================== -->
                            <!-- end product sales  -->
                            <!-- ============================================================== -->
                        </div>

                        <div class="row">
                            <!-- ============================================================== -->
                            <!-- sales  -->
                            <!-- ============================================================== -->
                         
                          
                        </div>
                        <div class="row">
                            <!-- ============================================================== -->
                            <!-- total revenue  -->
                            <!-- ============================================================== -->
  
                        </div>
                        <div class="row">
                          <!-- ============================================================== -->
                            <!-- end sales traffice source  -->
                            <!-- ============================================================== -->
                          
                        </div>
                    </div>
                </div>
            </div>
            <!-- ============================================================== -->
            <!-- footer -->
            <!-- ============================================================== -->
            <?php include('inc/footer.php');?>