<?php 
require 'database.php';
?>                  
                  <h2 class="inner-tittle"> Offline Payment PIN Generation </H2>
                  
                  <?php 
	if(isset($_POST["createpin"]))
	{
	 extract($_POST);
	  
	  //check existence
	  $rpaylistc = mysqli_query($con, "select * from offlinepay where receiptno='$receiptno'");
	  $rpaylistcounter = mysqli_num_rows($rpaylistc);
	  
	  
	  //add record to paylist
	  //check existence b4 adding
	  if($rpaylistcounter > 0)
	  {
	      echo "<b> <font color='red'> This payment has been treated, verify the receipt number </font></b> <br><br>";
	      
	  }else{
	       $rpaylist = mysqli_query($con, "insert into offlinepay values('', '$memberNo', '$amount', '$receiptno', '$paydate', '$exam', '$regSet', '$username')");
	       if($rpaylist)
		  {   
		     //create link
		     if($exam == "pci") {
		        $successurl = "https://register.niqs.org.ng/admin/pingenerator/pci_payment.php";
		        
		     }elseif($exam == "tpcfull") {
		        $successurl = "https://register.niqs.org.ng/admin/pingenerator/tpcfull_payment.php";
		        
		     }elseif($exam == "tpcref") {
		        $successurl = "https://register.niqs.org.ng/admin/pingenerator/tpcref_payment.php";
		     
		     }elseif($exam == "gdefull") {
		        $successurl = "https://register.niqs.org.ng/admin/pingenerator/gdefull_payment.php";
		     
		     }elseif($exam == "gderef") {
		        $successurl = "https://register.niqs.org.ng/admin/pingenerator/gderef_payment.php";
		    
			 }elseif($exam == "epci") {
		        $successurl = "https://register.niqs.org.ng/admin/pingenerator/epci_payment.php";
		    
			 }elseif($exam == "prob") {
		        $successurl = "https://register.niqs.org.ng/admin/pingenerator/prob_payment.php";
		     }
		     
		     
		     $successurl = $successurl."?memberNumber=".$memberNo."&regSet=".$regSet."&examCentre=".$examCentre."&amount=".$amount;
		     
		    //call link
		    echo '<script>window.location = "'.$successurl.'";</script>';
            
		  }
	  }	  
	  
	  
	}
	
	?>
                    <div class="form-group"> 
                       <form method="post" name="offlinepayform" action=<?php echo "index.php?page=offlinepay&i=".$_GET['i']; ?>> 
                    
		   
                    
					<div class="form-group"> 
                        <label>Membership Number</label> 
                        <input type="text" class="form-control" name="memberNo" placeholder="e.g P00123A" required="" /> 
                    </div> 
					
		   
					
		<div class="form-group"> 
                        <label>Examination</label> 
                        <select class="form-control" name="exam" required="" style="height:auto"/>
				<option value="prob">Probation</option>
				<option value="epci">EPCI</option>
				<option value="pci">PCI</option>
				<option value="tpcfull">TPC Full</option>
				<option value="tpcref">TPC Referred</option>
				<option value="gdefull">GDE Full</option>
				<option value="gderef">GDE Referred</option>
			</select>
                    </div> 
                   
                    <div class="form-group"> 
                        <label>Amount</label> 
                        <input type="text" class="form-control" name="amount" placeholder="Amount Paid" /> 
                    </div> 
                    
                    <div class="form-group"> 
                        <label>Receipt Number</label> 
                        <input type="text" class="form-control" name="receiptno" placeholder="Receipt Number" /> 
                    </div> 
                    
                    
                    
                     <div class="form-group"> 
                        <label>Payment Date</label> 
                        <input type="date" class="form-control" name="paydate" /> 
                    </div> 
			 
			 
                   <div class="form-group">
		<label for="take" class="text-uppercase">Diet</label>
   		 <select class="form-control" name="regSet" required="" style="height:auto">  
		<?php
		  $qset = "select * from gdef_set";
		  $rset = mysqli_query($con2, $qset);
		  
		  while($rowset = mysqli_fetch_array($rset))
		  {
			echo "<option>".$rowset['setMonth'].", ".$rowset['setYear']."</option>"; 
		  }
		  
		  $qset = "select * from pci_set";
		  $rset = mysqli_query($con2, $qset);
		  
		  while($rowset = mysqli_fetch_array($rset))
		  {
			echo "<option>".$rowset['setMonth'].", ".$rowset['setYear']."</option>"; 
		  }

		  $qset = "select * from epci_set";
		  $rset = mysqli_query($con2, $qset);
		  
		  while($rowset = mysqli_fetch_array($rset))
		  {
			echo "<option>".$rowset['setMonth'].", ".$rowset['setYear']."</option>"; 
		  }
		?>
	</select>
  </div>
                   <div class="form-group">
			<label>Preferred Centre</label>
			<select class="form-control" name="examCentre" required="" style="width:auto; height:auto">
				<option>ABUJA</option><option>LAGOS</option>
				<option>AKURE</option><option>GOMBE</option>
				<option>ENUGU</option><option>PORTHARCOURT</option>
				<option>KADUNA</option><option>KANO</option>
			</select>	
		   </div>	
                    
                    <input name="createpin" type="submit" class="btn btn-default" value="Create PIN" /> 
                    
                </form> 
                
    		</div>
    		
    
    </div>
    
    
  </div>  