<?php 
	require("database.php");	
	$errmsg='';
	$sucmsg='';
	
	if(isset($_POST["makepayment"]))
	{
	   	extract($_POST);
	   	
	   	//check existing application
		$q = "Select * from prob_application where memberNo='$memberNumber' AND regSet='$gdeset' limit 1";
		$qry=mysqli_query($con, $q);
		$counter = mysqli_num_rows($qry);
		//echo $q; echo $counter;
		if($counter==1){
		   $errmsg='Multiple application is not allowed, you have made payment for '.$gdeset.' application.<br>Check your registered email for your application PIN and <a href="login.php">Login to continue</a> with your application';
		}else{$sucmsg='Click <b>Proceed to payment</b> to continue!';}
			
					
	}else{
		echo '<script>alert("Invalid Token"); history.back();</script>';
		
		header("location: index.php");
	}
	?>

<html>
<head>

<link href="css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"/>
<script src="js/bootstrap.min.js"></script>
<script src="js/jquery-1.11.1.min.js"></script>
<link href="login.css" rel="stylesheet"/>
<!------ Include the above in your HEAD tag ---------->
</head>

<body bgcolor="black">
		
<section class="login-block" style="padding-top:0px; background-color:eeeeee;">
			<h2 class="text-center"> <font color="blue">NIGERIAN INSTITUTE OF QUANTITY SURVEYORS<BR>Probation Examination</font></h2>

    <div class="container" style="width:80%"> 
	<div class="row">
		<div class="col-md-12 login-sec">
		    <h3 class="text-center">Confirmation</h3>
		</div>	
		</div>
 
    <div class="form-check">
    			
		<div class="form-group" style="width:100%; padding-left:10%; padding-right:10%"> 
                    
		<?php			
                if($errmsg!=''){
                    echo '<div class="alert alert-danger">'.$errmsg.'</div>';
                }elseif($sucmsg!=''){
                    echo '<div class="alert alert-success">'.$sucmsg.'</div>';
				
				?>
				<!--form method="post" name="regform" action="payment.php"--> 
					<input type="hidden" class="form-control" name="memberNumber" value="<?php echo $memberNumber; ?>" required="" /> 
					<input type="hidden" class="form-control" name="memberID" value="<?php echo $memberID; ?>" required="" /> 
						
					<div class="form-group"> 
                        <label>Surname</label> 
                        <input type="text" class="form-control" name="memberSurname" value="<?php echo strtoupper(str_replace("'", "", $memberSurname)); ?>" required="" readonly/> 
                    </div> 
                    
					<div class="form-group"> 
                        <label>Othername</label> 
                        <input type="text" class="form-control" name="memberOthernames" value="<?php echo strtoupper(str_replace("'", "", $memberOthernames)); ?>" required="" readonly/> 
                    </div> 
                    
					<div class="form-group"> 
                        <label>Email Address</label> 
                        <input type="text" class="form-control" name="memberEmail" value="<?php echo $memberEmail; ?>" required="" readonly/> 
                    </div> 
                    
					<div class="form-group"> 
                        <label>Phone Number 1</label> 
                        <input type="text" class="form-control" name="memberPhone" value="<?php echo $memberPhone; ?>" required="" readonly/> 
                    </div> 
					
                    <div class="form-group"> 
                        <label>Phone Number 2</label> 
                        <input type="text" class="form-control" name="memberPhone2" value="<?php echo $memberPhone2; ?>" required="" readonly/> 
                    </div> 
                    
					<div class="form-group"> 
                        <label style="align:left">Date of Birth</label> 
                        <input type="text" class="form-control" name="memberDOB" value="<?php echo strtoupper($memberDOB); ?>" required="" readonly/> 
                    </div> 		
				
				
					<div class="form-group"> 
                        <label>Gender</label> 
                        <input type="text" class="form-control" name="sex" value="<?php echo $memberSex; ?>" required="" readonly/> 
                    </div> 	
					
					<div class="form-group"> 
                        <label>State Chapter</label> 
                        <input type="text" class="form-control" name="chapter" value="<?php echo $chapter; ?>" required="" readonly/> 
                    </div> 
                    
					<div class="form-group"> 
                        <label style="align:left">Contact Address</label> 
                        <input type="text" class="form-control" name="memberAddress" value="<?php echo strtoupper($memberAddress); ?>" required="" readonly/> 
                    </div> 
					<div class="form-group"> 
                        <label style="align:left">Preferred Examination Centre</label> 
                        <input type="text" class="form-control" name="examCentre" value="<?php echo strtoupper($examCentre); ?>" required="" readonly/> 
                    </div> 
                    
                    <div class="form-group"> 
                        <label style="align:left">Diet</label> 
                        <input type="text" class="form-control" name="gdeset" value="<?php echo strtoupper($gdeset); ?>" required="" readonly/> 
                    </div> 
                    
                    <?php
			   $qt = "Select * from examTransactions";
		           $rt =mysqli_query($con, $qt);
		           while($rowt = mysqli_fetch_array($rt))
		           {
		             $lastTransID = $rowt["transID"];
		           }
		           
		           $transID = $lastTransID + $memberID + time();
		           $amount = "60000.00";
		           
		           //insert new transID
		           if(mysqli_query($con, "insert into examTransactions(transID, memberNo, exam, status, successurl, regSet, amount, examCentre)values('$transID', '$memberNumber', 'GDE Full', 'Pending', 'https://register.niqs.org.ng/gdefull/payment.php', '$gdeset', '$amount', '$examCentre')")){}else{echo mysqli_error($con);}
		           
		           //echo "Last TransID : $lastTransID";
		          // echo "<br>TransID : $transID";
		          
		           
		           
		           //echo '<form method="POST" id="OnePay_form" name="OnePay_form" action="https://www.onepay.com.ng/api/live/main">';
                   //echo '<form method="POST" id="OnePay_form" name="OnePay_form" action="https://www.onepay.com.ng/mod/live/main.php">';
				   echo '<form method="POST" id="OnePay_form" name="OnePay_form" action="https://vuvaa.com/ONEPAY/mod/live/main">';
				   
                             echo '<input type="hidden" name="merchant_reg_id" value="ACC-OPMHT000000190">'; 
                           echo '<input type="hidden" name="amt_paid" value="'.$amount.'">  ';
                           echo '<input type="hidden" name="merch_trans_id" value="'.$transID.'"> ';
                           echo '<input type="hidden" name="client_phone" value="'.$memberPhone.'">  ';
                           echo '<input type="hidden" name="product_desc" value="Probation Examination Full"> '; 
                           echo '<input type="hidden" name="client_email" value="'.$memberEmail.'">  ';
			   echo '<input type="hidden" name="client_name" value="'.str_replace("'", "", $memberSurname).' '.str_replace("'", "", $memberOthernames).'"> ';
			   //echo '<input type="submit" name="submit" value="Pay">  ';
			   
		           
			
			?>
					
				
						
					 <div class="form-group">
						<input name="makepayment" type="submit" class="btn btn-default" value="Proceed to Payment" style="width:100%"/> 
					  </div>
					  
					  
        </div>
		
				<?php
                }
                ?>
		
		
	</div>
  
  
  
</form>
		</div>
		
</div>
</section>
<div class="copy-text"> <center>&COPY;<?php echo date('Y'); ?>  All right reserved. &nbsp; &nbsp; The Nigerian Institute of Quantity Surveyors</center></div>

</body>
</html>

