<?php

$db_academic = new MySQLDatabase();
$session = new Session();
$sql_high_insti = "SELECT * FROM higher_institutions WHERE applicant_id=" . $session->applicant_id;
$result_high_insti = HigherInstitutions::find_by_sql($sql_high_insti);
$applicant_details = User::find_by_sql("SELECT student_status FROM personal_details WHERE applicant_id='" . $session->applicant_id . "'");
foreach ($applicant_details as $applicant) {
    $applicant->student_status;
}
?>
<h3 align="center">Academic Qualification</h3>
<hr>

<form action="" method="POST" class="academic_qualification" >
<input type="hidden" name="applicant_status" value="<?php 
echo $applicant->student_status;
?>
" />
	<!-- Beginning of Tertiary Institution -->
    
    <?php 
if ($applicant->student_status == "PGA") {
    ?>
    
	<table class="table table-hover">
		<caption><h4>Tertiary Institution</h4></caption>
		<thead>
			<tr>
			  	<th>Institution Name</th>
			  	<th>Degree Earned</th>
if ($personal_details['student_status'] == 'PGA') {
    ?>
            <h4 align="center">A-Level</h4>
            <table class="table table-bordered table-hover">
            	<thead>
                	<th>S/N</th>
                    <th>Institution Name</th>
                    <th>Class of Degree</th>
                    <th>From</th>
                    <th>To</th>
                    <th>Degree Earned</th>
                    <th>CGPA</th>
                    <th>Course of Study</th>
                </thead>
            <?php 
    $tertiary_institution = HigherInstitutions::find_by_sql("SELECT * FROM higher_institutions WHERE applicant_id='" . $applicant_id . "'");
    $index = 1;
    echo '<tbody>';
    foreach ($tertiary_institution as $higher_institution) {
        echo '
					<tr>
						<td width="4%">' . $index . '</td>
						<td width="30%">' . $higher_institution->institution_name . '</td>
						<td width="15%">' . $higher_institution->class_of_degree . '</td>
						<td width="5%">' . $higher_institution->year_of_attendance . '</td>
						<td width="5%">' . $higher_institution->graduation_year . '</td>
						<td width="8%">' . $higher_institution->degree_earned . '</td>
						<td width="5%">' . $higher_institution->cgpa . '</td>
						<td>' . $higher_institution->course_of_study . '</td>
					</tr>';
        $index++;
<?php

require_once '../inc/initialize.php';
$error_higher_institution = false;
$error_other_relevant_qualification = false;
$error_secondary_school = false;
$error_olevel = false;
$error_academic_prizes = false;
/*Update Higher Institution*/
$high_inst = new HigherInstitutions();
$high_inst->db_fields = array('high_id', 'applicant_id', 'institution_name', 'class_of_degree', 'year_of_attendance', 'graduation_year', 'degree_earned', 'cgpa', 'course_of_study');
/*loop for number of higher institution rows*/
for ($i = 1; $i < $_POST['num_of_high_insti_rows']; $i++) {
    $high_inst_key = 'tetiary_institution_name_' . $i;
    $class = 'tetiary_institution_class_' . $i;
    $from = 'tetiary_institution_from_' . $i;
    $to = 'tetiary_institution_to_' . $i;
    $degree = 'tetiary_institution_degree_' . $i;
    $cpga = 'tetiary_institution_cgpa_' . $i;
    $course = 'tetiary_institution_course_' . $i;
    $high_id = "high_id_" . $i;
    /*set properties for higher institution details*/
    $high_inst->institution_name = $_POST[$high_inst_key];
    $high_inst->class_of_degree = $_POST[$class];
    $high_inst->year_of_attendance = $_POST[$from];
    $high_inst->graduation_year = $_POST[$to];
    $high_inst->degree_earned = $_POST[$degree];
    $high_inst->cgpa = $_POST[$cpga];
    $high_inst->course_of_study = $_POST[$course];
    if ($high_inst->institution_name == '') {
        continue;
$sql = "select * from admission_status where applicant_id='" . $session->applicant_id . "'";
$admissions = Admission::find_by_sql($sql);
foreach ($admissions as $admission) {
    $time = $admission->time_completed_application;
    $academic_session = $admission->academic_session;
    $status = $admission->status;
}
if ($status < 5) {
    redirect_to('confirmation.php');
}
$student_status = $user->get_student_status();
$database = new MySQLDatabase();
?>

<?php 
$higher_institutions = new HigherInstitutions();
$query = "SELECT * FROM higher_institutions\r\n          WHERE applicant_id='" . $session->applicant_id . "'";
$myschool = $higher_institutions->find_by_sql($query);
$myschool = array_shift($myschool);
?>



<?php 
$personal_details = $database->query("SELECT * FROM personal_details p, title t, lga l, state s, religion r, nationality n, department d, faculty f, next_of_kin next, marital mar, photographs photo WHERE p.applicant_id='" . $session->applicant_id . "' AND p.title_id=t.title_id AND p.lga_id=l.lga_id AND l.state_id=s.state_id AND p.religion_id=r.religion_id AND p.country_id=n.country_id AND p.programme_applied_id=d.department_id AND d.faculty_id=f.faculty_id AND p.applicant_id=next.applicant_id AND p.applicant_id=photo.applicant_id AND p.marital_status=mar.marital_status_id");
$personal_details = $database->fetch_array($personal_details);
$admission = $database->query("SELECT * FROM `admission_letter_date` WHERE visible = 1");
$admission = $database->fetch_array($admission);
// $programme = $database->query("SELECT * FROM `department` WHERE `department_id` = ");
?>
<!DOCTYPE HTML>