<?php
$errmsg='';
$sucmsg='';
$myID = $applicant_idgder;

if(isset($_POST['update'])){
    extract($_POST);
	$errmsg='';
    $sucmsg='';
    
    
}

//GET DETAILS FROM DB

	$q = "Select * from gder_application where id=$applicant_idgder limit 1";
    $qry=mysqli_query($con, $q);
    $row=mysqli_fetch_assoc($qry);
    extract($row);
	//print_r($row);
	$myAppID = $id;
    $applicant_no = $memberNo;

	switch($memberGrade)
	{
		case 1: $memberGrade="Fellow";
		break;
		
		case 2: $memberGrade="Member";
		break;
		
		case 3: $memberGrade="Probationer";
		break;
		
		case 4: $memberGrade="Technician";
		break;
		
		case 5: $memberGrade="Student";
		break;
		
		case 6: $memberGrade="Practicing Firm";
		break;
		
		case 7: $memberGrade="Graduate";
		break;
		
		case 8: $memberGrade="State Chapter";
		break;
		
		case 9: $memberGrade="Past President";
		break;
		
	}
	
?>



<div class="graph-visual tables-main" name='myarea' id='myarea'>
<?php
//header
echo "<table width='100%' cellspacing='0'>";




echo "<tr><td><img src='images/logo.png' width='100px' height='150px'></td><th><h2><center>THE NIGERIAN INSTITUTE OF QUANTITY SURVEYORS </h2></center><center><h3>
 APPLICATION FOR GRADUATE EXAMINATION <br>
(GDE REFERRAL CANDIDATE - $regSet)</center></h3>   </th> <td>"; 
		$mypassport = "passport/".$applicant_no."_".$applicant_idgder.".jpg";
		 if(file_exists($mypassport))
		 {
			 echo "<img src='".$mypassport."' width='120px' height='150px'> <font color='black'> GR ".$uniqueId." </font> <br><br>";
		 }

echo "</td></tr>";

echo "</table>";
echo "<table width='100%' cellspacing='0'>";

//1.0
echo "<tr><td colspan='3' bgcolor='black'><font color='white' size='4'>  <b>1.0 PERSONAL DETAILS</b> </font></td></tr>";
echo "<tr><td colspan='3'><br>";

	echo "<table width='100%' border='1' cellspacing='0'>";
	echo "<tr><td width='40%' height='30px'> &nbsp; <b> NIQS MEMBERSHIP NUMBER: </b></td> 	<td colspan='2'> &nbsp;  ".strtoupper($memberNo)." </td></tr>";
	echo "<tr><td> &nbsp; <b> SURNAME: </b></td> 					<td colspan='2'> &nbsp;  ".strtoupper($memberSurname)." </td></tr>";
	echo "<tr><td> &nbsp; <b> OTHER NAMES: </b></td> 				<td colspan='2'> &nbsp;  ".strtoupper($memberOthernames)." </td></tr>";
	echo "<tr><td> &nbsp; <b> TITLE/GENDER: </b></td> 				<td colspan='2'> &nbsp;  ".strtoupper($memberTitle)." </td></tr>";
	echo "<tr><td> &nbsp; <b> DATE OF BIRTH: </b></td> 				<td colspan='2'> &nbsp;  ".strtoupper($memberDOB)." </td></tr>";
	echo "<tr><td> &nbsp; <b> CHAPTER: </b></td> 					<td colspan='2'> &nbsp;  ".strtoupper($memberChapter)." </td></tr>";
	echo "<tr><td> &nbsp; <b> PHONE NUMBER:  </b></td> 				<td colspan='2'> &nbsp;  $memberPhone1, $memberPhone2 </td></tr>";
	echo "<tr><td> &nbsp; <b> EMAIL ADDRESS: </b></td> 				<td colspan='2'> &nbsp;  ".$memberEmail." </td></tr>";
	echo "<tr><td> &nbsp; <b> POSTAL ADDRESS: </b></td> 			<td colspan='2'> &nbsp;  ".strtoupper($memberAddress)." </td></tr>";
	echo "<tr><td> &nbsp; <b> CURRENT MEMBERSHIP GRADE: </b></td> 	<td colspan='2'> &nbsp;  ".strtoupper($memberGrade)." </td></tr>";
	echo "<tr><td> &nbsp; <b> DATE OF REGISTRATION: </b></td> 		<td colspan='2'> &nbsp;  ".strtoupper($memberRegDate)." </td></tr>";
	echo "<tr><td> &nbsp; <b> DIET:  </b></td> 						<td colspan='2'> &nbsp;  ".strtoupper($regSet)." </td></tr>";
	echo "</table>";
	
echo "</td></tr>";
echo "<tr><td><b> <br><br> </b></td> 						<td colspan='2'> </td></tr>";
	
//2.0 centre
echo "<tr><td colspan='3' bgcolor='black'><font color='white' size='4'> <b>2.0 PREFERRED EXAMINATION CENTRE</b> </font></td></tr>";
echo "<tr><td colspan='3'> ".strtoupper($examCentre)." </td></tr>";
echo "<tr><td><b> <br><br> </b></td> 						<td colspan='2'> </td></tr>";

//3.0 olevel
/*
$q = "Select * from gder_olevel where applicant_id='$applicant_idgder'";
$qry2=mysqli_query($con, $q);

echo "<tr><td colspan='3' bgcolor='black'><font color='white' size='4'> <b>3.0 O' LEVEL SUBJECTS RESULT (5 CREDITS FROM WAEC/NECO/NABTEB):</b> </font></td></tr>";
echo "<tr><td colspan='3'> <br>";
	echo "<table width='50%' border='1' cellspacing='0'>";
	echo "<tr bgcolor='skyblue'><td> &nbsp; <b> SUBJECTS </b></td> 	<td align='center'><b> GRADE </b></td></tr>";

	while($row2=mysqli_fetch_array($qry2)){
		extract($row2);
		echo "<tr><td><b> &nbsp; ".$subject."</b></td> 	<td align='center'> ".strtoupper($grade)." </td></tr>";
	}
	echo "</table>";
	
echo "</td></tr>";
echo "<tr><td><b> <br><br> </b></td> 						<td colspan='2'> </td></tr>";
*/


//6.0 entries
echo "<tr><td colspan='3' bgcolor='black'><font color='white' size='4'>  <b>3.0 DETAILS OF REFERENCE </b> </font></td></tr>";
echo "<tr><td colspan='3'><font color='black' size='4'>  <b> &nbsp;  </b> </font></td></tr>";

echo "<tr><td colspan='3' bgcolor='black'><font color='white' size='4'>  <b>3.1 DETAILS OF EXAMINATION WHERE THE CANDIDATE FIRST RECORDED THE REFERENCE(S) </b> </font></td></tr>";


echo "<tr><td colspan='3'> <br>";
	echo "<table width='100%' border='1' cellspacing='0'>";
	echo "<tr><td align='left'> &nbsp; <b> EXAMINATION  NUMBER </b></td> <td align='left'> <b> &nbsp; YEAR </b></td> <td align='left'> <b> &nbsp; EXAMINATION CENTRE</b></td> <td align='left'> <b> &nbsp; SUBJECTS </b></td> </tr>";
	
	
		$q = "select * from exemptioncourse where exam='GDE'";
		$r = mysqli_query($con, $q);
		$cx = 6;
		 
		//check old option
		$q2 = "select * from gder_firstreg where applicant_id=$applicant_idgder";
		$r2 = mysqli_query($con, $q2);
		$row2 = mysqli_fetch_array($r2);
		extract($row2);
		//echo print_r($row2);
		echo "<tr><td align='left'> &nbsp; $examNo </td> <td align='left'> &nbsp; $examYear </td> <td align='left'> &nbsp; $examCentre </td>   <td align='left'> ";
		
			echo "<table width='100%' border='1' cellspacing='0'>";
		while($row=mysqli_fetch_assoc($r))
		{
			$gname = "ex".$cx;
			extract($row);
			$mycell = "course".$cx;

			if($row2[$mycell]=="1"){ echo '<tr><td> &nbsp; '.strtoupper($course).'</td></tr>'; }
			
			$cx++;
		}	
		
		echo "</table>";
		echo "</table>";
		
		
	echo " </td>  </tr>";
	
	
echo "<tr><td><b> <br> </b></td> 						<td colspan='2'> </td></tr>";

echo "<tr><td colspan='3' bgcolor='black'><font color='white' size='4'>  <b>3.2 DETAILS OF EXAMINATION WHERE THE CANDIDATE LAST ATTEMPTED THE REFERENCE(S) </b> </font></td></tr>";


echo "<tr><td colspan='3'> <br>";
	echo "<table width='100%' border='1' cellspacing='0'>";
	echo "<tr><td align='left'> &nbsp; <b> EXAMINATION  NUMBER </b></td> <td align='left'> <b> &nbsp; YEAR </b></td> <td align='left'> <b> &nbsp; EXAMINATION CENTRE</b></td> <td align='left'> <b> &nbsp; SUBJECTS </b></td> </tr>";
	
	
		$q = "select * from exemptioncourse where exam='GDE'";
		$r = mysqli_query($con, $q);
		$cx = 6;
		 
		//check old option
		$q2 = "select * from gder_lastreg where applicant_id=$applicant_idgder";
		$r2 = mysqli_query($con, $q2);
		$row2 = mysqli_fetch_array($r2);
		extract($row2);
		//echo print_r($row2);
		echo "<tr><td align='left'> &nbsp; $examNo </td> <td align='left'> &nbsp; $examYear </td> <td align='left'> &nbsp; $examCentre </td>   <td align='left'> ";
		
			echo "<table width='100%' border='1' cellspacing='0'>";
		while($row=mysqli_fetch_assoc($r))
		{
			$gname = "ex".$cx;
			extract($row);
			$mycell = "course".$cx;

			if($row2[$mycell]=="1"){ echo '<tr><td> &nbsp; '.strtoupper($course).'</td></tr>'; }
			
			$cx++;
		}	
		
		echo "</table>";
		echo "</table>";
		
		
	echo " </td>  </tr>";
	
	
echo "<tr><td><b> <br> </b></td> 						<td colspan='2'> </td></tr>";

echo "<tr><td><b> <br> </b></td> 						<td colspan='2'> </td></tr>";

echo "<tr><td colspan='3' bgcolor='black'><font color='white' size='4'>  <b>3.3 ENTRY FOR CURRENT EXAMINATION </b> </font></td></tr>";


echo "<tr><td colspan='3'> <br>";
	
		$q = "select * from exemptioncourse where exam='GDE'";
		$r = mysqli_query($con, $q);
		$cx = 6;
		 
		//check old option
		$q2 = "select * from gder_currentreg where applicant_id=$applicant_idgder";
		$r2 = mysqli_query($con, $q2);
		$row2 = mysqli_fetch_array($r2);
		extract($row2);
		//echo print_r($row2);
		
			echo "<table width='100%' border='1' cellspacing='0'>";
			echo "<tr><td align='center'> &nbsp; <b> S/N </b></td> <td align='left'> <b> &nbsp; SUBJECTS </b></td></tr>";
			$sn=1;
		while($row=mysqli_fetch_assoc($r))
		{
			$gname = "ex".$cx;
			extract($row);
			$mycell = "course".$cx;

			if($row2[$mycell]=="1"){ echo '<tr><td align="center"> '.$sn.' </td> <td> &nbsp; '.strtoupper($course).'</td></tr>'; $sn++; }
			
			$cx++;
		}	
		
		echo "</table>";
		
		
	echo " </td>  </tr>";
	
	
echo "<tr><td><b> <br><br> </b></td> 						<td colspan='2'> </td></tr>";


//8.0 Employer 
$q = "Select * from gder_employer where applicant_id='$applicant_idgder'";
$qry2=mysqli_query($con, $q);
$row2=mysqli_fetch_array($qry2);
extract($row2);
echo "<tr><td colspan='3' bgcolor='black'><font color='white' size='4'>  <b>4.0 EMPLOYER DETAILS</b> </font></td></tr>";
	
echo "<tr><td colspan='3'><br>";

	echo "<table width='100%' border='1' cellspacing='0'>";

	echo "<tr><td width='40%'><b> &nbsp;  a)   NAME OF EMPLOYER: </b></td> 	<td colspan='2'> &nbsp;  ".strtoupper($employer)." </td></tr>";
	echo "<tr><td><b> &nbsp;  b) EMPLOYER'S BUSINESS ADDRESS: </b></td> 			<td colspan='2'> &nbsp;  ".strtoupper($address)." </td></tr>";
	echo "<tr><td><b> &nbsp;  c)  NATURE OF EMPLOYER'S BUSINESS: </b></td> 			<td colspan='2'> &nbsp;  ".strtoupper($nature)." </td></tr>";
	echo "<tr><td><b> &nbsp;  d)  POSITION OF APPLICANT: </b></td> 				<td colspan='2'> &nbsp;  ".strtoupper($position)." </td></tr>";
	echo "<tr><td><b> &nbsp;  e)  DATE OF EMPLOYMENT: </b></td> 				<td colspan='2'> &nbsp;  ".strtoupper($employmentDate)." </td></tr>";
	
	echo "</table>";

echo "</td></td>";
echo "<tr><td><b> <br> </b></td> 					<td colspan='2'>  </td></tr>";
	echo "<tr><td colspan='2'><b> f)  I hereby attest that to the best of my knowledge, the particulars given by me and the applicant here are true and correct.   </b></td> 	</tr>";
	echo "<tr><td><b>  </b></td> 				<td colspan='2' align='center'> <br><br><br><img src='images/line.jpg' width='70%'><br><b> EMPLOYER'S SIGNATURE & DATE </b>	 </td></tr>";
echo "<tr><td><b> <br><br> </b></td> 						<td colspan='2'> </td></tr>";




//9.0 sponsor
$q = "Select * from gder_sponsor where applicant_id='$applicant_idgder'";
$qry2=mysqli_query($con, $q);
$row2=mysqli_fetch_array($qry2);
extract($row2);

echo "<tr><td colspan='3' bgcolor='black'><font color='white' size='4'> <b>5.0 SPONSOR DETAILS</b> </font></td></tr>";
echo "<tr><td colspan='3'><br>";

	echo "<table width='100%' border='1' cellspacing='0'>";
	echo "<tr><td width='40%'><b> &nbsp;  a) NIQS MEMBERSHIP NUMBER: </b></td> 	<td colspan='2'> &nbsp;  ".strtoupper($memberNo)." </td></tr>";
	echo "<tr><td><b> &nbsp;  b)  FULL NAME: </b></td> 				<td colspan='2'> &nbsp;  ".strtoupper($memberSurname)." ".strtoupper($memberOthernames)." </td></tr>";
	echo "<tr><td><b> &nbsp;  c)  EMAIL ADDRESS: </b></td> 			<td colspan='2'> &nbsp;  ".strtoupper($memberEmail)." </td></tr>";
	echo "<tr><td><b> &nbsp;  d)  CONTACT ADDRESS: </b></td> 			<td colspan='2'> &nbsp;  ".strtoupper($memberAddress)." </td></tr>";
	echo "<tr><td><b> &nbsp;  e)  MEMBERSHIP GRADE: </b></td> 			<td colspan='2'> &nbsp;  ".strtoupper($memberGrade)." </td></tr>";
	echo "<tr><td><b> &nbsp;  f)  RESGISTRATION DATE:: </b></td> 			<td colspan='2'> &nbsp;  ".strtoupper($memberRegDate)." </td></tr>";
	
	echo "</table>";

echo "</td></td>";
echo "<tr><td><b> <br> </b></td> 					<td colspan='2'>  </td></tr>";
	echo "<tr><td colspan='2'><b> g) I hereby declare that to the best of my knowledge, the particulars given by me and the applicant here are true and correct.   </b></td> 	</tr>";	
echo "<tr><td><b>  </b></td> 				<td colspan='2' align='center' width='50%'> <br><br><br><img src='images/line.jpg' width='70%'><br><b> SPONSOR'S SIGNATURE & DATE </b>	 </td></tr>";
echo "<tr><td><b> <br><br> </b></td> 						<td colspan='2'> </td></tr>";

//10.0
echo "<tr><td colspan='3' bgcolor='black'><font color='white' size='4'> &nbsp; <b>6.0 DECLARATION</b> </font></td></tr>";
echo "<tr><td colspan='2' align='justify'><br>I declare that the particulars given on this form are true and correct and that I will abide by the Rules and Regulations governing the Institute’s Examinations.   <br><br><br></td> 	</tr>";
echo "<tr><td colspan='2'><b>Applicant's Signature...................................................... Date..............................................    </b></td> 	</tr>";
echo "<tr><td><b> <br><br> </b></td> 						<td colspan='2'> </td></tr>";
//

//11.0
echo "<tr><td colspan='3' bgcolor='black'><font color='white' size='4'> &nbsp; <b>7.0 STATE CHAPTER CHAIRMAN/SECRETARY (COMPULSORY) TO BE COMPLETED MANUALLY</b> </font></td></tr>";
echo "<tr><td colspan='3'><br>";

	echo "<table width='100%' border='1' cellspacing='0'>";
	echo "<tr><td height='40px' width='30%'> &nbsp; <b> CHAPTER: </b></td> 	<td colspan='2' > &nbsp; &nbsp;  ".strtoupper($memberChapter)." <br> </td></tr>";
	echo "<tr><td> &nbsp;<b> NAME: </b></td> 	<td colspan='2'> <br><br> </td></tr>";
	echo "<tr><td> &nbsp;<b> NIQS MEMBERSHIP NUMBER: </b></td> 	<td colspan='2'> <br><br> </td></tr>";
	echo "<tr><td> &nbsp;<b> DESIGNATION: </b></td> 	<td colspan='2'> <br><br> </td></tr>";
	echo "<tr><td> &nbsp;<b> PHONE NUMBER: </b></td> 	<td colspan='2'> <br><br> </td></tr>";
	echo "<tr><td> &nbsp;<b> DATE: </b></td> 	<td colspan='2'> <br><br> </td></tr>";
	echo "<tr><td> &nbsp;<b> EMAIL: </b></td> 	<td colspan='2'> <br><br> </td></tr>";
	echo "<tr><td> &nbsp;<b> SIGNATURE: </b></td> 	<td colspan='2'> <br><br><br><br> </td></tr>";
	echo "</table>";

echo "<br><br>";
echo "<p align='justify'>By completing and submitting this application form, you agree to be bound by all existing NIQS Examination Policies, Rules and Guidelines and the rules guiding the ".substr($regSet, 4)." professional examination in particular.</p>";
echo "</td><tr>";

echo "</table>";
?>
</div>

<div>


<?php 
if($status == "Pending"){ echo "<b><font color='red'>NOTE: Please ensure that all information on this form is correct. You will not be able to edit this form once submitted.</font></b> <br><br> <a href='?page=sponsor'><button class='btn'>Back</button></a> <a href='submitform.php?i=".$myAppID."'><button name='btnsubmit' id='btnsubmit'  class='btn'>Submit</button></a>";}else{echo "<a href='printform.php?i=$myAppID'><button name='btn' id='btn' class='btn'>Print</button></a>";}
 ?>  
</div>

	
<script>
function printform(){    
   var originalContents = document.body.innerHTML;
   document.getElementById('btn').style.display="none";
     var printContents = document.getElementById('myarea').innerHTML;      
   document.body.innerHTML = printContents;   
   window.print();     
   document.body.innerHTML = originalContents;
}
</script>