
<form id="" name="" class="form-horizontal" method="post" action="dashboard.php" enctype="multipart/form-data">

<?php

$student_id = $user_id;
$dept_id = get_user_department_id($user_id);
$school_id = get_user_school_id($user_id);
$programme_id = get_user_programme_id($user_id); //get course if for a suer
$level = get_user_level($user_id); //get user level

$current_session = get_current_session_4($id = '4'); //current session is always
$current_semester = get_current_semester($id = '1'); //current session is always



$validity_status = get_user_validity_status($student_id);//get studenrt validity whther expelled or not







?>

    <div style="height:20px; displat:block;"></div>

    <ul class="breadcrumb">

        <li><a href="">Results</a> <span class="divider"></span> </li>

    </ul>

<div class="well">



   <div style="height:20px; displat:block;"></div>




     <!--First accordion panel container tat accomodates all courses -->

    <div class="panel panel-success">
        <div class="panel-heading">
            <p class="panel-title">
                <a id="Me" data-toggle="collapse" data-parent="#accordion" href="#collapseMe"> <span class="glyphicon glyphicon-plus"></span>&nbsp;&nbsp;RESULT HISTORY </a>
                 <span class="label label-primary" style="font-size:15px;float:right;"></span>
            </p>
        </div>
                <div id="collapseMe" class="panel-collapse collapse in ">
                    <div class="panel-body">
                        <ul class="list-group">


							<?php
                            //check for expulsion
                            //check for released or not
                            //
                            if($validity_status != 1 )
                            {




                            	if($validity_status == '2')
                            	{

												echo '<div class="alert alert-danger alert-dismissable">
															<button class="close" aria-hidden="true" data-dismiss="alert" type="button">x</button>
																	<img src="images/info.png" />&nbsp;&nbsp; KINDLY NOTE THAT YOU ARE SUSPENDED FOR A SEMESTER FOR MISCONDUCT DURING '.get_session_title($current_session).' ACADEMIC SESSION.
											          </div>';
                            	}




                            	if($validity_status == '3')
                            	{

												echo '<div class="alert alert-danger alert-dismissable">
															<button class="close" aria-hidden="true" data-dismiss="alert" type="button">x</button>
																	<img src="images/info.png" />&nbsp;&nbsp; KINDLY NOTE THAT YOU ARE SUSPENDED FOR TWO(2) SEMESTERS FOR MISCONDUCT DURING '.get_session_title($current_session).' ACADEMIC SESSION.
											          </div>';
                            	}



                            ?>


                                     <!-- accordion for history starts here ###############################################################-->

                                      <div id="accordion" class="panel-group">

                                        <?php $q = "SELECT * FROM sessions  WHERE status = '0' ORDER BY title DESC LIMIT 4";
                                                    $r = mysqli_query($dbc, $q);

                                                    if(mysqli_num_rows($r)>0)
                                                    {
                                                        $a=0; //initialise counter
                                                        while($row = mysqli_fetch_array($r,MYSQLI_ASSOC))
                                                        {
                                        ?>
                                                            <div class="panel panel-success">
                                                                <div class="panel-heading">
                                                                    <p class="panel-title">
                                                                        <a id="<?php echo $a + 1; ?>" data-toggle="collapse" data-parent="#accordion" href="#collapse<?php  echo $a + 1; ?>">
                                                                        <span class="glyphicon glyphicon-plus"></span>
                                                                            <?php echo $row['title']; ?>
                                                                        </a>

                                                                    <span class="label label-success" style="font-size:15px;float:right;">
                                                                    <?php //echo get_total_votes_per_post($row['id']); //parameter is post id?></span>


                                                                    </p>
                                                                </div>
                                                                        <div id="collapse<?php echo $a + 1; ?>" class="panel-collapse collapse<?php //echo $a + 1; ?>  <?php //if($a + 1 =='1'){ echo 'in';} //hide the collapse ?>">
                                                                            <div class="panel-body">
                                                                                <ul class="list-group" >
                                                                                <div class="refresh_me">
                                                                                    <?php

																					    $session = $row['id'];
                                                                                        //collect the post id


																							$output ='';//declare output
																							$output4 ='';//declare output




																							//view the temporary table and show the preview for first semester
																							$q3 = "SELECT id, student_id, programme_id, course_id, course_unit,session_id,  level, semester,total_score, seen_as_elective
																								   FROM  students_courses_nce
																								   WHERE semester = '1'
																								   AND student_id ='$user_id'
																								   AND session_id = '$session'
																								   ORDER BY course_category";

																								$r3 = mysqli_query($dbc,$q3);
																								$sn = 0 ;
																								if(mysqli_num_rows($r3) > 0)
																								{//show table


																									$output .= '<h5 id="list" class="btn btn-success">First Semester</h5> <br>';

																									$output .=
																									  '<table class="table user display table-bordered table-hover table-striped" cellspacing="0" width="100%" style="font-size:11px;">
																										<thead>
																													<th>S/N</th>
																													<th>Code</th>
																													<th>Course Name</th>
																													<th>Type</th>
																													<th>Unit</th>
																													<th>Grade</th>
																													<th>Point</th>

																										 </thead>
																										<tbody>';

																									while($row = mysqli_fetch_array($r3, MYSQLI_ASSOC))
																									{


																										$output .= "<tr>";
																										$output .= "<td>".$sn = $sn+1 ."</td>";
																										$output .= "<td> ".get_course_code($row['course_id'])."</td>";
																										$output .= "<td > ".get_course_name($row['course_id'])."</td>";
																										$output .= "<td align='center'>".
																										seen_as_elective_for_pdf($row['seen_as_elective'])."</td>";
																										$output .= "<td align='center'>".
																										get_course_unit($row['course_id'])."</td>";
																										$output .= "<td align='center' ><span class='".get_grade_color(get_student_grade_by_score($row['total_score']))."'>".
																										get_student_grade_by_score($row['total_score'])."</span></td>";

																										$output .= "<td align='center'>".
																										get_student_grade_point_score($row['total_score']) * get_course_unit($row['course_id'])."</td>";

																										$output .= "</tr>";




																									}


																								$output .=
																								'</tbody>
																								</table>';

                                                                                                $outputr = '';
																								$outputr .=
																									  '<table class="table user display table-bordered table-hover table-striped" cellspacing="0" border="0" width="100%" style="font-size:12px;">

																										<tbody>';


																										$outputr .= "<tr><td></td>";
																										$outputr .= "<td>";
																										$outputr .= "</td>";
																										$outputr .= "</tr>";

																										$outputr .= "<tr><td></td>";

																										$outputr .= "<td><b>";
																										$outputr .= "PREVIOUS";
																										$outputr .= "</b></td>";

																										$outputr .= "</tr>";

																										$outputr .= "<tr><td></td>";

																										$outputr .= "<td>";
																										$outputr .= "TOTAL CREDIT UNITS REGISTERED: ".get_total_prev_credit_unit_registered_per_semester($student_id, $session, $semester=1)." <br/>

																										TOTAL GRADE POINTS: ". get_total_prev_grade_points_per_semester($student_id, $session, $semester = 1);
																										$outputr .= "</td>";


																										$outputr .= "<td>";
																										$outputr .= "TOTAL CREDIT UNITS EARNED:  ". get_total_credit_units_earned_per_semester($student_id, $session, $semester =1)."<br/>
																										CUMMULATIVE GRADE POINTS:
																										".get_total_prev_gpa_per_semester($student_id, $session, $semester = 1);
																										$outputr .= "</td>";

																										$outputr .= "</tr>";


																										$outputr .= "<tr><td></td>";

																										$outputr .= "<td><b>";
																										$outputr .= "PRESENT";
																										$outputr .= "</b></td>";

																										$outputr .= "</tr>";


																										$outputr .= "<tr><td></td>";

																										$outputr .= "<td>";
																										$outputr .= "TOTAL CREDIT UNITS REGISTERED: ".get_total_present_credit_unit_registered_per_semester($student_id, $session, $semester =1)." <br/>

																										TOTAL GRADE POINTS: ".get_total_present_grade_points_per_semester($student_id, $session, $semester = 1);
																										$outputr .= "</td>";


																										$outputr .= "<td>";
																										$outputr .= "TOTAL CREDIT UNITS EARNED:  ". get_total_present_credit_units_earned_per_semester($student_id, $session, $semester = 1)."<br/>
																										CUMMULATIVE GRADE POINTS:
																										".get_total_present_gpa_per_semester($student_id, $session, $semester = 1);
																										$outputr .= "</td>";

																										$outputr .= "</tr>";



																										$outputr .= "<tr><td></td>";

																										$outputr .= "<td><b>";
																										$outputr .= "CUMMULATIVE";
																										$outputr .= "</b></td>";

																										$outputr .= "</tr>";


																										$outputr .= "<tr><td></td>";

																										$outputr .= "<td>";
																										$outputr .= "TOTAL CREDIT UNITS REGISTERED:  ". get_total_cummulative_credit_unit_registered_per_semester($student_id, $session, $semester = 1)."<br/>

																										TOTAL GRADE POINTS: ".get_total_cummulative_grade_points_per_semester($student_id, $session, $semester =1);
																										$outputr .= "</td>";


																										$outputr .= "<td>";
																										$outputr .= "TOTAL CREDIT UNITS EARNED:  ".get_total_cummulative_credit_units_earned_per_semester($student_id, $session, $semester = 1)."<br/>
																										CUMMULATIVE GRADE POINTS:
																										".get_total_cummulative_gpa_per_semester($student_id, $session, $semester =1);
																										$outputr .= "</td>";

																										$outputr .= "</tr>";

																										if($level == 'I')
																										{

																											$outputr .= "<tr><td></td>";

																											$outputr .= "<td colspan='2'>";
																											$outputr .= "<b>REMARK</b>: ".get_remark2_per_semester($student_id, $session, $semester = 1)." : ".get_remark1_per_semester($student_id, $session, $semester = 1);
																											$outputr .= "</td>";

																											$outputr .= "</tr>";
																										}
																										else
																										{
																											$outputr .= "<tr><td></td>";

																											$outputr .= "<td colspan='2'>";
																											$outputr .= "<b>REMARK</b>: ".get_remark2_per_semester($student_id, $session, $semester = 1)." : ".get_remark1_per_semester($student_id, $session, $semester = 1);
																											$outputr .= "</td>";

																											$outputr .= "</tr>";

																										}

																										$outputr .='</tbody>
																												  </table>';


																										$outputr .= '&nbsp;&nbsp;&nbsp;<br/> <a class="btn btn-info"  href="create_result_slip.php?u='.$user_id.'&s='.$session.'&se=1&me='.sha1(md5('fucku')).'" target="_blank" data-toggle="tooltip" data-placement="top" title="Click here to Print">PRINT FIRST SEMESTER</a><br/><br/>';


																								}
																								else
																								{//show the msg

																										$output .='<div class="alert alert-danger alert-dismissable">
																												<button class="close" aria-hidden="true" data-dismiss="alert" type="button">x</button>
																												<img src="images/info.png" />&nbsp;&nbsp; No record found.
																											   </div>';


																								}






																		//$published1 = check_results_published($student_id, $session, $semester = 1);

																		//also check for if published or not
										                            	 if(check_results_published($student_id, $session, $semester = 1))
										                            	 {//$published1 === true

																				echo $output;

																				echo $outputr;



																		 }
																		 else
						                                            	 {


																			 echo '<div class="alert alert-danger alert-dismissable">
																			  <button class="close" aria-hidden="true" data-dismiss="alert" type="button">x</button>
																			<img src="images/info.png" />&nbsp;&nbsp; RESULTS NOT AVAILABLE AT MOMENT.</div><br/>';

						                                            	 }









																							//view the temporary table and show the preview for second semester
																							$q4 = "SELECT id, student_id, programme_id, course_id, course_unit,session_id,  level, semester,total_score, seen_as_elective
																								   FROM  students_courses_nce
																								   WHERE semester = '2'
																								   AND student_id ='$user_id'
																								   AND session_id = '$session'
																								   ORDER BY course_category";

																								$r4 = mysqli_query($dbc,$q4);
																								$sn4 = 0 ;
																								if(mysqli_num_rows($r4) > 0)
																								{//show table
																									$output4 .= '<h5 id="list" class="btn btn-success">Second Semester</h5> <br>';


																									$output4 .=
																									  '<table class="table user display table-bordered table-hover table-striped" cellspacing="0" width="100%" style="font-size:11px;">
																										<thead>
																													<th>S/N</th>
																													<th>Code</th>
																													<th>Course Name</th>
																													<th>Type</th>
																													<th>Unit</th>
																													<th>Grade</th>
																													<th>Point</th>

																										 </thead>
																										<tbody>';

																									while($row4 = mysqli_fetch_array($r4, MYSQLI_ASSOC))
																									{



																										$output4 .= "<tr>";
																										$output4 .= "<td>".$sn = $sn+1 ."</td>";
																										$output4 .= "<td> ".get_course_code($row4['course_id'])."</td>";
																										$output4 .= "<td > ".get_course_name($row4['course_id'])."</td>";
																										$output4 .= "<td align='center'>".
																										seen_as_elective_for_pdf($row4['seen_as_elective'])."</td>";
																										$output4 .= "<td align='center'>".
																										get_course_unit($row4['course_id'])."</td>";
																										$output4 .= "<td align='center' ><span class='".get_grade_color(get_student_grade_by_score($row4['total_score']))."'>".
																										get_student_grade_by_score($row4['total_score'])."</span></td>";

																										$output4 .= "<td align='center'>".
																										get_student_grade_point_score($row4['total_score']) * get_course_unit($row4['course_id'])."</td>";

																										$output4 .= "</tr>";

																									}
																										$output4 .=
																								'</tbody>
																								</table>';



                                                                                                $outputr2 ='';
																								$outputr2 .=
																									  '<table class="table user display table-bordered table-hover table-striped" cellspacing="0" border="0" width="100%" style="font-size:12px;">

																										<tbody>';


																										$outputr2 .= "<tr><td></td>";
																										$outputr2 .= "<td>";
																										$outputr2 .= "</td>";
																										$outputr2 .= "</tr>";

																										$outputr2 .= "<tr><td></td>";

																										$outputr2 .= "<td><b>";
																										$outputr2 .= "PREVIOUS";
																										$outputr2 .= "</b></td>";

																										$outputr2 .= "</tr>";

																										$outputr2 .= "<tr><td></td>";

																										$outputr2 .= "<td>";
																										$outputr2 .= "TOTAL CREDIT UNITS REGISTERED: ".get_total_prev_credit_unit_registered_per_semester($student_id, $session, $semester=2)." <br/>

																										TOTAL GRADE POINTS: ". get_total_prev_grade_points_per_semester($student_id, $session, $semester=2);
																										$outputr2 .= "</td>";


																										$outputr2 .= "<td>";
																										$outputr2 .= "TOTAL CREDIT UNITS EARNED:  ". get_total_credit_units_earned_per_semester($student_id, $session, $semester =2)."<br/>
																										CUMMULATIVE GRADE POINTS:
																										".get_total_prev_gpa_per_semester($student_id, $session, $semester = 2);
																										$outputr2 .= "</td>";

																										$outputr2 .= "</tr>";


																										$outputr2 .= "<tr><td></td>";

																										$outputr2 .= "<td><b>";
																										$outputr2 .= "PRESENT";
																										$outputr2 .= "</b></td>";

																										$outputr2 .= "</tr>";


																										$outputr2 .= "<tr><td></td>";

																										$outputr2 .= "<td>";
																										$outputr2 .= "TOTAL CREDIT UNITS REGISTERED: ".get_total_present_credit_unit_registered_per_semester($student_id, $session, $semester =2)." <br/>

																										TOTAL GRADE POINTS: ".get_total_present_grade_points_per_semester($student_id, $session, $semester = 2);
																										$outputr2 .= "</td>";


																										$outputr2 .= "<td>";
																										$outputr2 .= "TOTAL CREDIT UNITS EARNED:  ". get_total_present_credit_units_earned_per_semester($student_id, $session, $semester = 2)."<br/>
																										CUMMULATIVE GRADE POINTS:
																										".get_total_present_gpa_per_semester($student_id, $session, $semester = 2);
																										$outputr2 .= "</td>";

																										$outputr2 .= "</tr>";



																										$outputr2 .= "<tr><td></td>";

																										$outputr2 .= "<td><b>";
																										$outputr2 .= "CUMMULATIVE";
																										$outputr2 .= "</b></td>";

																										$outputr2 .= "</tr>";


																										$outputr2 .= "<tr><td></td>";

																										$outputr2 .= "<td>";
																										$outputr2 .= "TOTAL CREDIT UNITS REGISTERED:  ". get_total_cummulative_credit_unit_registered_per_semester($student_id, $session, $semester = 2)."<br/>

																										TOTAL GRADE POINTS: ".get_total_cummulative_grade_points_per_semester($student_id, $session, $semester =2);
																										$outputr2 .= "</td>";


																										$outputr2 .= "<td>";
																										$outputr2 .= "TOTAL CREDIT UNITS EARNED:  ".get_total_cummulative_credit_units_earned_per_semester($student_id, $session, $semester = 2)."<br/>
																										CUMMULATIVE GRADE POINTS:
																										".get_total_cummulative_gpa_per_semester($student_id, $session, $semester =2);
																										$outputr2 .= "</td>";

																										$outputr2 .= "</tr>";


																										if($level == 'I')
																										{


																										$outputr2 .= "<tr><td></td>";

																										$outputr2 .= "<td colspan='2'>";
																										$outputr2 .= "<b>REMARK</b>: ".get_remark2_per_semester($student_id, $session, $semester = 2)." : ".get_remark1_per_semester($student_id, $session, $semester = 1).', '.get_remark1_per_semester($student_id, $session, $semester = 2);
																										$outputr2 .= "</td>";

																										$outputr2 .= "</tr>";

																									 }
																									 else
																									 {
																										  $outputr2 .= "<tr><td></td>";

	 																										$outputr2 .= "<td colspan='2'>";
	 																										$outputr2 .= "<b>REMARK</b>: ".get_remark2_per_semester($student_id, $session, $semester = 2)." : ".get_remark1_per_semester($student_id, $session, $semester = 2);
	 																										$outputr2 .= "</td>";

	 																										$outputr2 .= "</tr>";

																									 }






																										$outputr2 .='</tbody>
																												  </table>';




																										$outputr2 .= '&nbsp;&nbsp;&nbsp;<br/> <a class="btn btn-primary"  href="create_result_slip.php?u='.$user_id.'&s='.$session.'&se=2&me='.sha1(md5('fucku')).'" target="_blank" data-toggle="tooltip" data-placement="top" title="Click here to Print">PRINT SECOND SEMESTER</a><br/><br/>';

																								}
																								else
																								{//show the msg

																										$output4 .='<div class="alert alert-danger alert-dismissable">
																												<button class="close" aria-hidden="true" data-dismiss="alert" type="button">x</button>
																												<img src="images/info.png" />&nbsp;&nbsp; No record found.
																											   </div>';


																								}










																		//$published2 = check_results_published($student_id, $session, $semester = 2);

																		//also check for if published or not
										                            	 if(check_results_published($student_id, $session, $semester = 2))
										                            	 {//$published2 === true

																				echo $output4;

																				echo $outputr2;


																		 }
																		 else
						                                            	 {


																			 echo '<br/><div class="alert alert-danger alert-dismissable">
																			  <button class="close" aria-hidden="true" data-dismiss="alert" type="button">x</button>
																			<img src="images/info.png" />&nbsp;&nbsp; RESULTS NOT AVAILABLE AT MOMENT.</div>';

						                                            	 }









                                                                                     ?></div>
                                                                                    </ul>
                                                                        </div>
                                                            </div>
                                                            <!--First accordion panel container Ends here -->
                                            <?php

                                                        $a++; //increment the loop for the control
                                                        }
                                                    }
                                            ?>








                                            <?php





											}//end of brace for validty
											else
											{



												echo '<div class="alert alert-danger alert-dismissable">
																												<button class="close" aria-hidden="true" data-dismiss="alert" type="button">x</button>
																												<img src="images/info.png" />&nbsp;&nbsp; EXPELLED FOR EXAMINATION MISCONDUCT DURING '.get_session_title($current_session).' ACADEMIC SESSION.
																											   </div>';
											}

                                            ?>

                                                            </div><!-- panel --info-->




                                                            <!-- accordion for history ends here #########################################-->




                    </ul><!-- end of list group --->
                </div><!-- end o panel body -->
    </div>
    <!--First accordion panel container Ends here -->


    </div>
    <!-- payment history -->




</div><!-- /well -->

</form>
