<?php 
session_start();
require('db.php'); 
include('inc/func.php');
include('inc/gravatar.php');
include('inc/logo.php');
include('inc/coinpayments.inc.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-wifi"></li> Smile Internet Payment </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['disco'])){
										
										$username = $_SESSION['user'];
										$amount = $_POST['amount'];
										$service = $_POST['service'];
										$plan = $_POST['plan'];
										$phone = $_POST['tel'];
										$iucs = $_POST['iuc'];
										$variation_code = $_POST['variation_code'];
										$type = $_POST['transType'];


$username = filter_var($username, FILTER_SANITIZE_STRING);
$amount = filter_var($amount, FILTER_SANITIZE_STRING);
$service = filter_var($service, FILTER_SANITIZE_STRING);
$plan = filter_var($plan, FILTER_SANITIZE_STRING);
$variation = filter_var($variation, FILTER_SANITIZE_STRING);
$iuc = filter_var($iuc, FILTER_SANITIZE_STRING);
$phone = filter_var($phone, FILTER_SANITIZE_STRING);
$type = filter_var($type, FILTER_SANITIZE_STRING);


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

										
										
						if(!empty($amount) && !empty($service)  && !empty($iuc) ){
										$uid = substr(str_shuffle("0123456789678901"), 0, 16);
										
										// replace comma
		$str1 = $amount;
        $xamount = str_replace( ',', '', $str1);	
												
										
										
										$_SESSION['amt'] = $xamount;
										$_SESSION['carier'] = $service;
										$_SESSION['phone'] = $phone;
										//$_SESSION['iuc'] = $iuc;
										$_SESSION['transid'] = $uid;
										$_SESSION['plan'] = $plan;
										$_SESSION['variation_code'] = $variation_code;
										$_SESSION['type'] = $type;
									
											$dat = date("d/m/Y");
											
											$token = uniqid();
											$stat = "pending";
											
										
										
										$pnt = " Smile ".
if($type === 'voice'){	
$countryCode = '234';
$iuc = preg_replace('/^0/', $countryCode, $iucs);
}else{	
$iuc = $iucs;
}
	
$_SESSION['iuc'] = $iuc;							
						
										
include('inc/smile-verify.php');


					
		if(is_null($result->description->Customer)){
			
			echo'<div class="alert alert-warning">
		<button type="button" class="close" data-dismiss="alert">×</button>
		<strong>Invalid Smile Account Number</strong>  
									</div>'; 
			
		}else{		
					
									
$qsel = "INSERT INTO transactions(network,serviceid,vcode,meterno,phone,ref,refer,amount,email,status,token)VALUES('$pnt','$service','$variation','$iuc','$phone','$uid','$token','$amount','$username','$stat','$token')";	
								
								$sav = $conn->query($qsel);
								
			?>
        <script>						
       window.location="transaction-view/smile/index.php?<?php echo $uid; ?>#transPreview";
          </script>
         <?php 
											

			
$_SESSION['customer'] = $result->description->Customer;

$_SESSION['service']=$service;


$customer = $_SESSION['customer'];
$_SESSION['address'] = $result->description->Address;

								
                                }	

}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 Smile Service</label><br>
                                            <label class="custom-control custom-radio custom-control-inline">
                                                <input type="radio" name="carier"  class="custom-control-input" value="SmileData" onclick="javascript:showTv();" id="smiledata" ><span class="custom-control-label"><img src="assets/images/smiledata.png" ></span>
                                            </label>
                                            
                                            
                                            <label class="custom-control custom-radio custom-control-inline">
                                                <input type="radio" name="carier" class="custom-control-input"value="voice" onclick="javascript:showTv();" id="voice"><span class="custom-control-label" ><img src="assets/images/smilevoice.png" ></span>
                                            </label>
                                           
                                            
                                       
                                           
                                        <p></p>
                                        <div class="float-center">
                                        <img style="display:none;" id="bigpic" src="bigpic" />     
                                                   
                                    </div>
                                    
                                   
                                 
                                  <!-- Start SmileData hidden -->       
                              <div class="float-center" id="ifData" style="display:none;">                 
                                       <div class="form-group" >
                                          
		 
        <label>Smile Internet Bundles</label>
		
		<select class="form-control" id="IsData" required="required" ><option value = "" selected="selected" required="required">Select Data Bundle</option>
                
  <option data-plan="2GB MidNite for 7days - 1,020 Naira" data-variation_code="413" data-amount="1020" data-service="smile-direct" >2GB MidNite for 7days - &#x20A6;1020</option>
  
  <option data-plan="3GB MidNite for 7days - 1,530 Naira" data-variation_code="414" data-amount="1530" data-service="smile-direct" >3GB MidNite for 7days - &#x20A6;1,530 </option>
  
  
  <option data-plan="3GB Weekend ONLY for 3days - 1,530 Naira" data-variation_code="415" data-amount="1530" data-service="smile-direct" >3GB Weekend ONLY for 3days - &#x20A6;1,530 </option>
  
			
                
 <option data-plan="1GB Flexi for 1days - 300 Naira" data-variation_code="624" data-amount="300" data-service="smile-direct" >1GB Flexi for 1days - &#x20A6;300</option>	
         
  
        <option data-plan="2.5GB Flexi for 2days - 500 Naira" data-variation_code="625" data-amount="500" data-service="smile-direct" >2.5GB Flexi for 2days - &#x20A6;500 </option> 
         
         <option data-plan="1GB Flexi-Weekly for 7days - 500 Naira" data-variation_code="626" data-amount="500" data-service="smile-direct" >1GB Flexi-Weekly for 7days - &#x20A6;500</option>
         
         
        <option data-plan="1.5GB Bigga for 30days - 1,000 Naira" data-variation_code="606" data-amount="1000" data-service="smile-direct" >1.5GB Bigga for 30days - &#x20A6;1,000 </option> 
        
        
        <option data-plan="2GB Flexi-Weekly  for 7days - 1,000 Naira" data-variation_code="627" data-amount="1000" data-service="smile-direct" >2GB Flexi-Weekly  for 7days - &#x20A6;1,000 </option>
        
        <option data-plan="2GB Bigga for 30days - 1,200 Naira" data-variation_code="607" data-amount="1200" data-service="smile-direct" >2GB Bigga for 30days - &#x20A6;1,200 </option> 
        
        <option data-plan="3GB Bigga for 30days - 1,500 Naira" data-variation_code="608" data-amount="1500" data-service="smile-direct" >3GB Bigga for 30days - &#x20A6;1,500</option>
         
         <option data-plan="6GB Flexi-Weekly  for 7days - 1,500 Naira" data-variation_code="628" data-amount="1500" data-service="smile-direct" >6GB Flexi-Weekly  for 7days - &#x20A6;1,500 </option>
         
     <option data-plan="5GB Bigga for 30days - 2,000 Naira" data-variation_code="620" data-amount="2000" data-service="smile-direct" >5GB Bigga for 30days - &#x20A6;2,000 </option>    

         <option data-plan="6.5GB Bigga for 30days - 2,500 Naira" data-variation_code="609" data-amount="2500" data-service="smile-direct" >6.5GB Bigga for 30days - &#x20A6;2,500 </option>  
         
          <option data-plan="8GB Bigga for 30days - 3,000 Naira" data-variation_code="610" data-amount="3000" data-service="smile-direct" >8GB Bigga for 30days - &#x20A6;3,000 </option>  
                
          <option data-plan="10GB Bigga for 30days - 3,500 Naira" data-variation_code="611" data-amount="3500" data-service="smile-direct" >10GB Bigga for 30days - &#x20A6;3,500 </option>         
                
                <option data-plan="12GB Bigga for 30days - 4,000 Naira" data-variation_code="612" data-amount="4000" data-service="smile-direct" >12GB Bigga for 30days - &#x20A6;4,000 </option>    
                
  <option data-plan="15GB Bigga for 30days - 5,000 Naira" data-variation_code="613" data-amount="5000" data-service="smile-direct" >15GB Bigga for 30days - &#x20A6;5,000 </option>
  
  
  <option data-plan="20GB Bigga for 30days - 6,000 Naira" data-variation_code="614" data-amount="6000" data-service="smile-direct" >20GB Bigga for 30days - &#x20A6;6,000 </option>
  
  
<option data-plan="30GB Bigga for 30days - 8,000 Naira" data-variation_code="615" data-amount="8000" data-service="smile-direct" >30GB Bigga for 30days - &#x20A6;8,000 </option>                  
  
   <option data-plan="40GB Bigga for 30days - 10,000 Naira" data-variation_code="616" data-amount="10000" data-service="smile-direct" >40GB Bigga for 30days - &#x20A6;10,000 </option>              
   
   <option data-plan="Unlimited-Lite for 30days - 10,000 Naira" data-variation_code="629" data-amount="10000" data-service="smile-direct" >Unlimited-Lite for 30days - &#x20A6;10,000 </option>
   
<option data-plan="60GB Bigga for 30days - 13,500 Naira" data-variation_code="617" data-amount="13500" data-service="smile-direct" >60GB Bigga for 30days - &#x20A6;13,500 </option>
    
    
     <option data-plan="75GB Bigga for 30days - 15,000 Naira" data-variation_code="618" data-amount="15000" data-service="smile-direct" >75GB Bigga for 30days - &#x20A6;15,000 </option>
     
 <option data-plan="Unlimited-Essential for 30days - 15,000 Naira" data-variation_code="630" data-amount="15000" data-service="smile-direct" >Unlimited-Essential for 30days - &#x20A6;15,000 </option>


<option data-plan="100GB Bigga for 30days - 18,000 Naira" data-variation_code="619" data-amount="18000" data-service="smile-direct" >100GB Bigga for 30days - &#x20A6;18,000 </option>


<option data-plan="200GB-Anytime   for 365days - 70,000 Naira" data-variation_code="604" data-amount="70000" data-service="smile-direct" >200GB-Anytime   for 365days - &#x20A6;70,000 </option>


                
                </select>
		
      </div>


      
      <div class="form-group">
          <label for="inputText3" class="col-form-label">Smile Account Number</label>
    <input id="accno" type="text" class="form-control" name="smartno" onKeyUp="javacript:document.getElementById('iuc').value = document.getElementById('accno').value;" onSelect="javacript:document.getElementById('iuc').value = document.getElementById('accno').value;">
                                            </div>
                                            
                                         
                                            
          <!-- <div class="form-group">
          <label for="inputText3" class="col-form-label">Phone Number</label>
    <input id="mobile" type="phone" class="form-control" name="phone" onKeyUp="javascript:document.getElementById('tele').value = document.getElementById('mobile').value;" onSelect="javascript:document.getElementById('tele').value = document.getElementById('mobile').value;">
                                            </div> -->           
                             
                                            
                </div>
                <!-- End SmileData hidden -->   
                
               
                <!-- Start SmileVoice hidden -->       
                              <div class="float-center" id="ifVoice" style="display:none;">                 
                                       <div class="form-group" >
                                                 
		 
        <label>Smile Voice Package</label>
		
		<select class="form-control" id="IsVoice" required="required" ><option value = "" selected="selected" required="required">Select Voice Package</option>
                 
<option data-plan="Smile Voice - 65mins" data-variation_code="516" data-amount="510" data-service="smile-direct" data-trans="voice" >Smile Voice - 65mins - &#x20A6;500 </option>
  
  
  <option data-plan="Voice 135mins" data-variation_code="517" data-amount="1020" data-service="smile-direct" data-trans="voice" >Voice 135mins for 30days - &#x20A6;1,020</option>                  
  
   <option data-plan="Voice 430mins" data-variation_code="518" data-amount="3070" data-service="smile-direct" data-trans="voice" >Voice 430mins - &#x20A6;3,070 - 30 days</option>  


<option data-plan="SmileVoice ONLY 150 for 60days" data-variation_code="698" data-amount="1500" data-service="smile-direct" data-trans="voice" >SmileVoice ONLY 150 for 60days -  - &#x20A6;1500 </option>
  
  
  <option data-plan="SmileVoice ONLY 175 for 90days" data-variation_code="700" data-amount="2000" data-service="smile-direct" data-trans="voice" >SmileVoice ONLY 175 for 90days - &#x20A6;2,000</option>                  
  
   <option data-plan="SmileVoice ONLY 450 for 60days" data-variation_code="699" data-amount="4000" data-service="smile-direct" data-trans="voice" >SmileVoice ONLY 450 for 60days - &#x20A6;4,000 - 30 days</option>  


  <option data-plan="Smile Voice ONLY 500 for 90days" data-variation_code="701" data-amount="5000" data-service="smile-direct" data-trans="voice" >Smile Voice ONLY 500 for 90days - &#x20A6;5,000 - 30 days</option> 


   
                
                </select>
	
      </div>


                                            
                                          
                                            
              <div class="form-group">
          <label for="inputText3" class="col-form-label">Smile Voice Number</label>
    <input id="phone" type="phone" class="form-control" name="phone" onKeyUp="javascript:document.getElementById('tele').value = document.getElementById('phone').value; document.getElementById('iuc').value = document.getElementById('phone').value" onSelect="javascript:document.getElementById('tele').value = document.getElementById('phone').value; document.getElementById('iuc').value = document.getElementById('phone').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="tel" id="tele">
         
         <input type="hidden" value="" name="iuc" id="iuc">
         
         <input type="hidden" value="" name="transType" id="transType">
                                            
                     <div class="col-sm-6 pl-0">
                           <p class="text-center">
                                                    <button type="submit" name="disco" class="btn btn-rounded btn-primary" onClick="alert('We will validate your smile account ID to be sure everything looks good')" >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/smile-data.jpg";
  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 amount = selected.data('amount');
	  var service = selected.data('service');
	  var plan = selected.data('plan');
	  var variation_code = selected.data('variation_code');
	  
	  $('#amount').val(amount);
	  $('#service').val(service);
	  $('#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/smile-voice.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  -->
                            <!-- ============================================================== -->
                            <div class="col-xl-3 col-lg-6 col-md-6 col-sm-12 col-12">
                                <div class="card">
                                    <h5 class="card-header">Account Status</h5>
                                    <div class="card-body">
                                   <div class="d-inline-block">
                                        <h5 class="text-muted">Current Balance</h5>
                                        <h2 class="mb-0"> &#x20A6;<?php echo number_format($bal,2,'.',',');?></h2>
                                    </div>
                                    <div class="float-right icon-circle-medium  icon-box-lg  bg-brand-light mt-1">
                                        <i class="fa fa-money-bill-alt fa-fw fa-sm text-brand"></i>
                                    </div>
                                   
                                    </div>
                                </div>
                                
                                <div class="card">
                                <div class="card-body">
                                    <div class="d-inline-block">
                                        <h5 class="text-muted">Affiliate Link:</h5>
                                        <p class="mb-0"> <?php echo $data['reflink'];echo $data['refid'];?></p>
                                        
                                    </div>
                                    <div class="float-left"><p class="text-muted"><strong>Total Referred:</strong> <?php echo $data['refcount']; ?> <br> 
                                    
                                   <strong> Earning:</strong> &#x20A6;<?php echo number_format($data['refwallet'],2,'.',','); ?>
                                    </p> </div>
                                    
                                    
                                    <div class="float-right icon-circle-medium  icon-box-lg  bg-primary-light mt-1">
                                        
                                        <i class="fa fa-users fa-fw fa-sm text-primary"></i>
                                    </div>
                                </div>
                            </div>
                            </div>
                            <!-- ============================================================== -->
                            
                            
                            
                            <!-- end customer acquistion  -->
                      <div class="col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12">
                        <div class="card">
                            <h5 class="card-header">Transaction History</h5>
                            <div class="card-body">
                                <div class="table-responsive">
                                    <table class="table table-striped table-bordered first">
                                        <thead>
                                            <tr>
                                                <th>Transaction ID</th>
                                                
                                                <th>Amount</th>
                                                <th>Status</th>
                                                <th>Date</th>
                                               
                                            </tr>
                                        </thead>
                                        <tbody>
                                         <?php 
										
										while($row = $resu->fetch_assoc())
											
											{
										
											?>
                                            <tr>
                                           
                                                <td><?php echo $row['orderno']; ?></td>
                                                
                                                <td><?php echo '&#x20A6;'.$row['amount'].' ';?></td>
                                                 <td><?php echo $row['status'];?></td>
                                                <td><?php echo $row['date'];?></td>
                                                
                                            </tr>
                                           
                                           <?php } ?>
                                          
                                           
                                        </tbody>
                                        <tfoot>
                                            <tr>
                                                <th>Transaction ID</th>
                                                
                                                <th>Amount</th>
                                                <th>Status</th>
                                                <th>Date</th>
                                                
                                            </tr>
                                        </tfoot>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>      
                          
                            <!-- ============================================================== -->
                        </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');?>