<?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 ">
                    <!-- ============================================================== -->
                     <?php 
                                  
                       
                         include('inc/coinpayments.inc.php');
                         
                       	
										 ?>
                    <!-- 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-tv"></li> JAMB e-PIN 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['tvCheck'])){
										
										$username = $_SESSION['user'];
										$amount = $_POST['amount'];
										$serviceID = $_POST['service'];
										$plan = $_POST['plan'];
										$phone = $_POST['tel'];
										$iuc = $_POST['iuc'];
										$variation = $_POST['variation_code'];

$amount = filter_var($amount, FILTER_SANITIZE_STRING);
$serviceID = filter_var($serviceID, FILTER_SANITIZE_STRING);
$phone = filter_var($phone, 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 = filter_var($username, FILTER_SANITIZE_STRING);

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

$phone = str_replace( ' ', '', $phone);
$iuc = str_replace( ' ', '', $iuc);

						if(!empty($amount) && !empty($service)&& !empty($phone) && !empty($iuc) && !empty($variation) ){
										
										
										// replace comma
$xamount = str_replace( array( '+', ',', '-', '/', '(', ')',   '_', '//', 'drop', 'update', 'delete', 'insert', 'add',  '{',   '}',   '<',  '>',  '=', ' ', '  ', '   '), '', $amount);

if($xamount >= '4500'){

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 = $plan;
										
									              
										
											
											  
include('inc/verify-jamb.php');										
										
										
										
$qsel= "INSERT INTO transactions(network,serviceid,meterno,phone,ref,refer,amount,email,customer,status,token,balanceB,balanceA,date)VALUES('$pnt','$serviceID','$iuc','$phone','$uid','$token','$xamount','$username','$fname $lname','$stat','$token','$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/exampin/?<?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;5000</strong>  
									</div>'; }


}
                                
                       
                                else{
										echo'<div class="alert alert-danger">
										<button type="button" class="close" data-dismiss="alert">×</button>
										<strong>Enter required fields</strong>  
									</div>'; }
									} ?>

  <?php  
$query_rec = mysqli_query($conn,"SELECT * FROM exam_billing");
$waecA = mysqli_fetch_array($query_rec);	



$query_rec2 = mysqli_query($conn,"SELECT * FROM exam_billing_regular");
$waecR = mysqli_fetch_array($query_rec2);




		


if($level == $Reseller ){
$waec = $waecA['waec'];
$waec2 = $waecA['waecGCE'];
$nysc = $waecA['nysc'];
$neco = $waecA['neco'];
$neco2 = $waecA['necoGCE'];
$nabteb = $waecA['nabteb'];
$nabteb2 = $waecA['nabtebGCE'];
$jambutme = $waecA['jambutme'];
$jambde = $waecA['jambde'];
		

	
					
				
}elseif($level == $free){
		
$waec = $waecR['waec'];
$waec2 = $waecR['waecGCE'];
$nysc = $waecR['nysc'];
$neco = $waecR['neco'];
$neco2 = $waecR['necoGCE'];
$nabteb = $waecR['nabteb'];
$nabteb2 = $waecR['nabtebGCE'];
$jambutme = $waecR['jambutme'];
$jambde = $waecR['jambde'];
                                         

}else{
$waec = 2100000000;
$waec2 = 160000000;
$nysc = 200000000;
$neco = 70000000;
$neco2 = 1500000000;
$nabteb = 1200000000;
$nabteb2 = 1600000000;
$jambutme = 420000000;
$jambde = 420000000; 

}  ?>
                      
           
                   <font color="red"><b>1. SMS ‘NIN’ space your 11-digit NIN number to 55019 e.g NIN 00123456789. Note that there should be a space between the word ‘NIN’ and your 11-digit NIN.<br>

2. You’ll receive an SMS with your 10-digit profile code and your registered NIN name.<br>
3. Enter the ProfileCode below and make payment. <br>
4. The JAMB e-pin will be delivered to your phone number once payment is confirmed.</b></font> <br>
                                        <label for="inputText3" class="col-form-label">Please Select Service Below:</label><br>
                                            <label class="custom-control custom-radio custom-control-inline">
                                                <input type="radio" name="carier"  class="custom-control-input" value="gotv" onclick="javascript:showTv();" id="gotv" ><span class="custom-control-label">JAMB Registration PIN<img src="assets/images/jamb.jpg" width="100" height="80"></span>
                                            </label>
                                            
                                            
                                           <!-- <label class="custom-control custom-radio custom-control-inline">
                                                <input type="radio" name="carier" class="custom-control-input"value="dstv" onclick="javascript:showTv();" id="dstv"><span class="custom-control-label" ><img src="assets/images/Pay-DSTV-Subscription.jpg" width="35" height="30"></span>
                                            </label>
                                            
                                            <label class="custom-control custom-radio custom-control-inline">
                                                <input type="radio" name="carier" class="custom-control-input"value="startimes" onclick="javascript:showTv();" id="startimes"><span class="custom-control-label" ><img src="assets/images/Startimes-Subscription.jpg" width="35" height="30"></span>
                                            </label>-->
                                            
                                       
                                           
                                        <p></p>
                                        <div class="float-center">
                                        <img style="display:none;" id="bigpic" src="bigpic"  width="150" height="100"/>     
                                                   
                                    </div>
                                    
                                   
                                 
                                  <!-- Start GOTV hidden -->       
                              <div class="float-center" id="ifGotv" style="display:none;">                 
                                       <div class="form-group" >
                                          
		 
        <label>JAMB e-PIN:</label>
		
		<select class="form-control" id="IsGotv" required="required" ><option value = "" selected="selected" required="required">Select PIN Type</option>
               

<option data-plan="JAMB UTME Registration PIN" data-amount="<?php echo $jambutme;?>"  data-service="jamb" data-variation_code="1" >JAMB UTME Registration PIN (N<?php echo $jambutme;?>)</option>
			
<option data-plan="Direct Entry Registration PIN" data-amount="<?php echo $jambde;?>"  data-service="jamb" data-variation_code="2" >JAMB Direct Entry Registration PIN (N<?php echo $jambde;?>)</option>
            
                
                
                </select>
		
		
      </div>


      
     <!-- <div class="form-group">
          <label for="inputText3" class="col-form-label">Profile Code:</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">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 GOTV hidden -->   
                
               
                <!-- Start DSTV hidden -->       
                              <div class="float-center" id="ifDstv" style="display:none;">                 
                                       <div class="form-group" >
                                                 
		 
        <label>Bouquet:</label>
		
		<select class="form-control" id="IsDstv" required="required" ><option value = "" selected="selected" required="required">Select DSTV Banquet</option>
                
			
			 <?php                    $query_apiS = mysqli_query($conn,"SELECT * FROM api_setting");
			
			$apiSet = mysqli_fetch_array($query_apiS);
				
			
			
				if($apiSet['tvactive'] == 'vtuafrica') {
				
				include('tv-select/epin-dstv.php');
				
			}elseif($apiSet['tvactive'] =='smartrecharge'){
			
				include('tv-select/smart-dstv.php');

			}elseif($apiSet['tvactive'] =='mobileng'){
			
				include('tv-select/mobileng-dstv.php');
        
                              }elseif($apiSet['tvactive'] =='clubkonnect'){
			
				include('tv-select/club-dstv.php');
          
                               }elseif($apiSet['tvactive'] == 'vtpass'){
			
	                          include('tv-select/vtpass-dstv.php');
			}
?>
			
			
                </select>
	
	
      </div>


      
      
      <div class="form-group">
          <label for="inputText3" class="col-form-label">Smartcard Number</label>
    <input id="smartcard" type="text" class="form-control" name="smartno" onKeyUp="javascript:document.getElementById('iuc').value = document.getElementById('smartcard').value;" onSelect="javascript:document.getElementById('iuc').value = document.getElementById('smartcard').value;">
                                            </div>
                                            
              <div class="form-group">
          <label for="inputText3" class="col-form-label">Phone Number</label>
    <input id="phone" type="phone" class="form-control" name="phone" onKeyUp="javascript:document.getElementById('tele').value = document.getElementById('phone').value;" onSelect="javascript:document.getElementById('tele').value = document.getElementById('phone').value;">
                                            </div>                
                                              
                                            
                </div>
                <!-- End DSTV hidden -->  
                
          <!-- Start STARTTIMES hidden -->       
                              <div class="float-center" id="ifStar" style="display:none;">                 
                                       <div class="form-group" >
                                                 
		 
        <label>Bouquet:</label>
		
		<select class="form-control" id="IsStar" required="required" ><option value = "" selected="selected" required="required">Select Startimes Banquet</option>
               
              <?php                    $query_apiS = mysqli_query($conn,"SELECT * FROM api_setting");
			
			$apiSet = mysqli_fetch_array($query_apiS);
				
			
			
				if($apiSet['tvactive'] == 'vtuafrica') {
				
				include('tv-select/epin-startimes.php');
				
			}elseif($apiSet['tvactive'] =='smartrecharge'){
			
				include('tv-select/smart-startimes.php');

			}elseif($apiSet['tvactive'] =='mobileng'){
			
				include('tv-select/mobileng-startimes.php');
        
                              }elseif($apiSet['tvactive'] =='clubkonnect'){
			
				include('tv-select/club-startimes.php');
          
                               }elseif($apiSet['tvactive'] == 'vtpass'){
			
	                          include('tv-select/vtpass-startimes.php');
			}
?>               
                
                </select>
	
      </div>


      
       
      <div class="form-group">
          <label for="inputText3" class="col-form-label">Smartcard Number</label>
    <input id="smart" type="text" class="form-control" name="smartno" onKeyUp="javascript:document.getElementById('iuc').value = document.getElementById('smart').value;" onSelect="javascript:document.getElementById('iuc').value = document.getElementById('smart').value;">
                                            </div>
                                            
              <div class="form-group">
          <label for="inputText3" class="col-form-label">Phone Number</label>
    <input id="mobil" type="phone" class="form-control" name="phone" onKeyUp="javascript:document.getElementById('tele').value = document.getElementById('mobil').value;" onSelect="javascript:document.getElementById('tele').value = document.getElementById('mobil').value;">
                                            </div>                   
                                            
                </div>
                <!-- End STARTIMES 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="iuc2" id="iuc">         
         <input type="hidden" value="" name="tel2" id="tele">
		 
         <input type="hidden" value="" name="variation_code" id="variation_code">
		 
		        <div class="form-group">
          
<label for="inputText3" class="col-form-label">Profile Code:</label>
    
<input id="inputText3" type="phone" class="form-control" name="iuc">
    </div> 
	
	 <div class="form-group">
          <label for="inputText3" class="col-form-label">Candidate Phone Number</label>
    <input id="inputText3" type="phone" class="form-control" name="tel">
                                            </div> 
                                            
                     <div class="col-sm-6 pl-0">
                           <p class="text-center">
                                                    <button type="submit" name="tvCheck" 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('gotv').checked) {
        document.getElementById('ifGotv').style.display = 'block';
		
		var sourceOfPicture = "assets/images/jamb.jpg";
  var img = document.getElementById('bigpic')
  img.src = sourceOfPicture.replace('150x100', '225x225');
  img.style.display = "block";
	
  $('#IsGotv').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('ifGotv').style.display = 'none';
	
	
	if (document.getElementById('dstv').checked) {
        document.getElementById('ifDstv').style.display = 'block';
		
		var sourceOfPicture = "assets/images/Pay-DSTV-Subscription.jpg";
  var img = document.getElementById('bigpic')
  img.src = sourceOfPicture.replace('90x90', '225x225');
  img.style.display = "block";
  
  $('#IsDstv').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('ifDstv').style.display = 'none';
	
	if (document.getElementById('startimes').checked) {
        document.getElementById('ifStar').style.display = 'block';
		
		var sourceOfPicture = "assets/images/Startimes-Subscription.jpg";
  var img = document.getElementById('bigpic')
  img.src = sourceOfPicture.replace('90x90', '225x225');
  img.style.display = "block";
		
		
		$('#IsStar').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('ifStar').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');?>