<?php

$errmsg='';
$sucmsg='';

//delete
if(isset($_GET['r'])){
	extract($_GET);
	//print_r($_GET);
	
	$q_delete = "delete from prob_education where applicant_id='$applicant_idgdef' AND id='$r' LIMIT 1";
	$qry_delete = mysqli_query($con, $q_delete);
	if($qry) { $sucmsg='Record deleted successfully'; }
}//end of delete


if(isset($_POST['addInstituttion'])){
    extract($_POST);
    $errmsg='';
    $sucmsg='';
    
	//print_r($_POST);
		
	//insert record
	$qry2=mysqli_query($con, "insert into prob_education values('', '$applicant_idgdef', '$institution', '$startYear', '$endYear', '$degree', '$course', '$eduCat')");
	if($qry2){
		$sucmsg='Add another record below';
		
		?>
		<script>
		if (window.alert("Record Saved Successfully.")) { 
		   //window.location ="http://niqs.org.ng/onlineapplication/gdefull/index.php?page=body";
		}
		</script>
		
		<?php
		
	}else{
		//echo mysqli_error($con);
		$errmsg='Not Successful!';
	}
	
    
}



?>

<div class="graph-visual tables-main">
<h2 class="inner-tittle">EDUCATION (SECONDARY SCHOOL / TERTIARY)</h2>
	 Please list all academic qualification(s). 
	<div class="graph-form">
    		<div class="form-body">
		
    		<?php
				//GET DETAILS FROM DB
	
				$q = "Select * from prob_education where applicant_id='$applicant_idgdef'";
				$qry=mysqli_query($con, $q);
				if($qry){
					
					if(mysqli_num_rows($qry) >0){
						$myallow = 1;  //allow next button to display
						$yyy = 1;
						echo "<table width='100%' border='0'>";
						echo "<tr><td colspan='5'>";
						echo "<table width='100%' border='1'>";
						echo "<tr><td><b>SN</b></td> <td><b>Institution </b></td>  <td><b>Year of Entry </b></td>  <td><b>Year of Leaving </b></td>  <td><b>Degree/Certificate Obtained </b></td>  <td><b> Action </b></td>  </tr> ";
						
						while($row=mysqli_fetch_assoc($qry))
						{
							extract($row);
							echo "<tr><td>$yyy</td> <td>$institution <a href='?page=education&r=$id&i=".$_GET['i']."'><font color='red'>delete</font></a> </td> <td>$startYear </td> <td>$endYear </td> <td>".strtoupper($degree)."  $course	 </td> <td> <form method='post' action='index.php?page=educationeditor&i=".$_GET['i']."'><input type='hidden' value='$id' name='editID'><input type='submit' value='Edit'></form> </td></tr>";
							$yyy++;
						}
						
						echo "</tables></td></tr>";
						echo "</tables> ";
						
					}else{ $errmsg=''; $myallow = 0; }
							
				}else{
					$errmsg=''; 
					$myallow = 0;
				}
				
				?>
			
			
			
			
    			<form method="post" name="educationform" action="index.php?page=education&i=<?php echo $_GET['i']; ?>"> 
                <?php 
                if($errmsg!=''){
                    echo '<div class="alert alert-danger">'.$errmsg.'</div>';
                }elseif($sucmsg!=''){
                    echo '<div class="alert alert-success">'.$sucmsg.'</div>';
                }
                
                ?>
                    <div class="form-group"> 
                        <label>Name of School</label> 
                        <script>
 function mysch() {
   var sch = document.getElementById("institution").value;
   var sch2= document.getElementById("institution2");
   
   
   if(sch == "Others"){
     sch2.value = "";
     sch2.type = "text";

   } else {
     sch2.value = sch;
     sch2.type = "hidden";
   }

 }
</script>
                        <select class="form-control" name="institution" id="institution" onchange="mysch()" style="height:auto"  required="required">
                        <option value="">select institution</option>
			<option>Abia State Polytechnic Aba, Abia State</option>
			<option>Abubakar Tafawa Balewa University, Bauchi, Bauchi State</option>
			<option>AbubakarTatari All Polytechnic, Bauchi, Bauchi State</option>
			<option>Ahmadu Bello University, Zaria, Kaduna State</option>
			<option>Akanu Ibiam Federal Polytechnic Uwana-Afikpo, Ebonyl State</option>
			<option>Akwa lbom State Polytechnic, lkot-Osurua, Akwa Ibom State</option>
			<option>Auchi Polytechnic, Auchi, Edo State</option>
			<option>Bayero University, Kano, Kano State</option>
			<option>Bells University of Technology, Ota, Ogun State</option>
			<option>Caleb University, Imota, Lagos State</option>
			<option>Crown PolytechnicAdo Ekiti, Ekiti State</option>
			<option>Delta State Polytechnic Ozoro, Delta State</option>
			<option>Enugu State University of Science and Technology, Enugu</option>
			<option>Federal Polytechnic Ado Ekiti, Ekiti State</option>
			<option>Federal Polytechnic Bauchi, Bauchi State</option>
			<option>Federal Polytechnic Bida, Niger State </option>
			<option>Federal Polytechnic Ede, Osun State</option>
			<option>Federal Polytechnic Ilaro, Ogun State</option>
			<option>Federal Polytechnic Kaura Namoda, Zamfara State</option>
			<option>Federal Polytechnic ldah, Kogi State</option>
			<option>Federal Polytechnic Nekede, Imo State</option>
			<option>Federal Polytechnic Offa, Kwara State</option>
			<option>Federal Polytechnic Oko, Anambra State</option>
			<option>Federal Polytechnic Ukana, Ukana Ikot, Ntuen, Akwa Ibom State</option>
			<option>Federal Polytechnic, Nasarawa, Nasarawa State</option>
			<option>Federal University of Technology Minna, Niger State</option>
			<option>Federal University of Technology Owerri, Imo State</option>
			<option>Federal University of Technology, Akure, Ondo State</option>
			<option>Fidei Polytechnic Gboko, Benue State</option>
			<option>Gregory University Uturu, Abia State</option>
			<option>Hassan Usman Polytechnic, Kastina</option>
			<option>Heritage Polytechnic, Eket,Akwa lbom State</option>
			<option>Imo State University, Owerri, Imo State</option>
			<option>Institute of Management and Technology, Enugu, Enugu State</option>
			<option>Jigawa State Polytechnic, Dutse, Jigawa State</option>
			<option>Joseph Ayo Babalola University, Ikeji-Arakeji, Osun State</option>
			<option>Kaduna Polytechnic, Kaduna, Kaduna State</option>
			<option>Kaduna State U n iversity, Kaduna</option>
			<option>Kano State Polytechnic, Kano, Kano State</option>
			<option>Kwara State Polytechnic Ilorin, Kwara State</option>
			<option>Lagos State Polytechnic,lkorodu, Lagos State</option>
			<option>MoshoodAbiola Polytechnic, Abeokuta, Ogun State</option>
			<option>Niger State Polytechnic, Niger State</option>
			<option>Nigerian Army Military School of Military Engineering, Makurdi, Benue State</option>
			<option>Nnarndi Azikiwe University, Awka, Anambra State</option>
			<option>Nuhu Bamali Polytechnic, Zaria, Kaduna State</option>
			<option>Obafemi Awolowo University, Ile-Ife, Osun State</option>
			<option>Osun State College of Technology, Esa-Oke, Osun State</option>
			<option>Osun State Polytechnic, Iree, Osun State</option>
			<option>Plateau State Polytechnic, Plateau State</option>
			<option>Ramat Polytechnic, Maiduguri, Borno State</option>
			<option>Rivers State University of Science and Technology, Port-harcourt, Rivers State</option>
			<option>Rufus Giwa Polytechnic, Owo, Ondo State</option>
			<option>The Polytechnic of Sokoto State, Sokoto</option>
			<option>The Polytechnic, Ibadan, Oyo State</option>
			<option>University of Benin, Benin, Edo State</option>
			<option>University of Birnin Kebbi, Kebbi State</option>
			<option>University of Ilorin, Ilorin, Kwara State</option>
			<option>University of Jos, Plateau State</option>
			<option>University of Lagos, Lagos State</option>
			<option>University of Uyo, Akwa lbom State</option>
			<option>Waziri Umaru Federal Polytechnic, Birnin Kebbi, Kebbi State</option>
			<option>Yaba College of Technology, Yaba, Lagos State</option>
			<option>Others</option>
                        </select> <br>
<input type="hidden" class="form-control" name="institution" id="institution2" placeholder="name of institution" required="" />
  
                    </div> 
                    
					<div class="form-group"> 
                        <label>Type of School</label> 
                        <select class="form-control" name="eduCat" required="" style="height:auto"/>
							<option>Secondary School</option>
							<option>Higher Institution</option>
						</select>
                    </div> 
                    
					<div class="form-group"> 
                        <label>Degree/Certificate Obtained</label> 
                        <input type="text" class="form-control" name="degree" placeholder="e.g B.TECH, BSc, HND, SSCE" required="" /> 
                    </div> 
					
					<div class="form-group"> 
                        <label>Course</label> 
                        <input type="text" class="form-control" name="course" placeholder="Course where applicable" /> 
                    </div> 
					
					<div class="form-group"> 
                        <label>Year of Entry</label> 
                        <!--input type="text" class="form-control" name="startYear" placeholder="e.g 2013" required="" style="height:auto"/-->  
                        <select class="form-control" name="startYear" style="width:100%; height:auto">
                         <?php $y=date('Y'); for($iy=$y; $iy>1960; $iy--){ echo "<option>$iy</option>"; } ?>
                        </select>
                    </div> 
                   <div class="form-group"> 
                        <label>Year of Leaving</label> 
                        <!--input type="text" class="form-control" name="endYear" placeholder="e.g 2018"  required="" style="height:auto"/-->
                        <select class="form-control" name="endYear" style="width:100%; height:auto">
                         <?php $y=date('Y'); for($iy=$y; $iy>1960; $iy--){ echo "<option>$iy</option>"; } ?>
                        </select>
                    </div> 
                   
                    
                    <input name="addInstituttion" type="submit" class="btn btn-default" value="Add Record"/> 
                    
                </form> 
                
    		</div>
    		
    
    </div>
    
    
  </div>  
   
   

<?php

 echo "<div>";
 echo "  <a href='?page=disability&i=".$_GET['i']."'><button class='btn'>Back</button></a>"; 
 
if($myallow != 0){ echo "  <a href='?page=body&i=".$_GET['i']."'><button class='btn'>Next</button></a>"; }
 echo "</div>";

?>