<?php 
	require("database.php");	
	$errmsg='';
	$sucmsg='';
	$memberGrade='';
	
 	
   //open/close registration
 $q_close = "select * from close_reg where reg='exam'";
 $r_close = mysqli_query($con, $q_close);

 if(mysqli_num_rows($r_close)==1){
	 $row_close = mysqli_fetch_assoc($r_close);
	 extract($row_close);
	
    if($status == 'close'){
        echo '<script>alert("Registration closed!");</script>';
        echo '<script>window.location = "https://niqs.org.ng/examinations/";</script>';
        exit();   
    }
     
 }
 
?>
<html>
<head>
<title> Probation Registration </title>

<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; height:auto">
			<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">Verify your membership to proceed with your application</h3>
		</div>	
 
    <div class="form-check">
    
		<center>
		<div class="form-group" style="width:100%; padding-left:10%; padding-right:10%;"> 
			<form method="post">
					<label>Membership Number</label> 
					<input type="text" class="form-control" name="memberNo" placeholder="e.g P00234Z, T00123Z, G00456E, P03243T" required="" style="width:50%" /> 
					<input name="verify" type="submit" class="btn btn-default" value="Verify My Membership" style="width:50%"/> 
			  
			</form> 
		</div> 
		</center>
		
		<?php
		
		if(isset($_POST["verify"]))
		{
			$memberNo = $_POST["memberNo"];
			$q = "Select * from members where memberNo='$memberNo' limit 1";
			$qry=mysqli_query($con, $q);
			if($qry){
				
				if(mysqli_num_rows($qry) >0){
					$row=mysqli_fetch_assoc($qry);
					extract($row);
					
					
					$sucmsg='Select preferred interview centre, diet and click <b>Continue</b>';
					
					//check dues
					if($errmsg=='')
					{
					   $q_dues = "select * from dues where memberNo='$memberNo'";
					   $r_dues = mysqli_query($con, $q_dues);
					   $rowdues = mysqli_fetch_array($r_dues);
					   extract($rowdues);
					   
					   $amount_owing = $outstanding + $annualSub + $advance + $upgradeCharge + $annualSub2017 + $annualSub2018 + $annualSub2019 + $annualSub2020 + $annualSub2021 + $annualSub2022 + $annualSub2023 + $annualSub2024;
					   
					   if($amount_owing>=1000){ $errmsg='You are not financially up-to-date. Only financially up-to-date members can apply!'; $sucmsg=''; }
					   
					}//dues check ends here
					
					
				}else{ $errmsg='Your membership can not be verified, please enter a valid membership number!!'; }
						
			}else{
				$errmsg='Your membership can not be verified, please enter a valid membership number!';
			}
		}
		?>
		
		<div class="form-group" style="width:100%; padding-left:10%; padding-right:10%"> 
                    
		        <?php 
				//check membership grade
				if(($memberGrade ==1) || ($memberGrade ==2) || ($memberGrade ==9)){ $errmsg = 'Only Graduates, Technicians and Probationer members are eligible for PCI'; }
						
                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="verifydetails.php"> 
					<input type="hidden" class="form-control" name="memberNumber" value="<?php echo $memberNo; ?>" 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($memberSurname); ?>" required="" readonly/> 
                    </div> 
                    
					<div class="form-group"> 
                        <label>Othername</label> 
                        <input type="text" class="form-control" name="memberOthernames" value="<?php echo strtoupper($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="memberSex" 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 $memberState; ?>" 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><br>If your details above are not up-to-date, please <a href='https://portal.niqs.org.ng/membership'>click here</a> to update your personal details and restart registration.<br><br>Preferred Examination Centre</label>
						<select class="form-control" name="examCentre" required="">

                        <?php
                            //get exam centres
                            $qcentre = "SELECT * FROM examcentre where status=1";
                            $rcentre = mysqli_query($con, $qcentre);

                            if($rcentre){
                                while($c_row = mysqli_fetch_array($rcentre)){
                                    echo "<option>".$c_row["centre"]."</option>";
                                }

                            }else{ }
                        ?>
							
						</select>
					</div>	
						
					 <div class="form-group">
						<label>Diet</label>
						<select class="form-control" name="gdeset" required="">
							<?php
							  $qset = "select * from prob_set";
							  $rset = mysqli_query($con, $qset);
							  
							  while($rowset = mysqli_fetch_array($rset))
							  {
								echo "<option>".$rowset['setMonth'].", ".$rowset['setYear']."</option>"; 
							  }
							  
							?>
						</select>
						
						<br>
						
						<?php
						
							if(($memberGrade =='1') || ($memberGrade =='2') ||($memberGrade =='9'))
							{
								echo "<font color='red'><b>You are not eligible to register for this interview</b></font>";
							}else{
								//allow application
							 echo '<input name="makepayment" type="submit" class="btn btn-default" value="Continue" style="width:100%"/> ';
							}
						?>
					  </div>
					  
					  
        </div>
		
<script>alert("KINDLY ENSURE THAT YOUR EMAIL ADDRESS IS CORRECT BEFORE YOU PROCEED. YOUR PIN WILL BE SENT TO YOUR MAIL.");</script>

				<?php
                }
                ?>
		
		
	</div>
  
  
  
</form>
		</div>
		
</div>
<br><br><br><br><br><br><br><br><br><br>

</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>

