<?php

echo " we are still working on the courses, please check back on the 20th for course registration and exam card printing";

exit();

 ?>



<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




$level = get_user_level($user_id); //get user level



//block special edu for 200 level
/*$prog_id_arr = [1,4,8,13,14,17,36,43,52,54,63,65,86,89,93,98,99,102,121,129,138,140,151,153,177,182,196,197,198,211,212];

    for ($i = 0; $i < count($prog_id_arr) ; $i++) {

		if (in_array($programme_id, $prog_id_arr )) {
			$level = 'NOT';

		}

	}

if ($level == 'NOT') {

	echo

			   '<div class="alert alert-danger in" >
			                 <button class="close" data-dismiss="alert" type="button">
			                    X

			                 </button>
			                    <i class="glyphicon glyphicon-info-sign"></i>&nbsp;&nbsp;Course Registration will be active soon.
			            </div>';


	exit();
}


*/

?>

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

    <ul class="breadcrumb">

        <li><a href="">Course registration</a> <span class="divider"></span> </li>

    </ul>

<div class="well">

   <?php if(has_paid_school_fee($user_id, $current_session, $current_semester )) //check if the user has paid this session fee
   { ?>

    	<?php


			if(get_user_sign($user_id) !='' ) //check if user done registration before
			{
				if(!has_done_registration($user_id, $current_session, $current_semester)) //check if user done registration before
				{

					?>

			            <div class="alert alert-info in" >
			                 <button class="close" data-dismiss="alert" type="button">
			                    X

			                 </button>
			                    <i class="glyphicon glyphicon-info-sign"></i>&nbsp;&nbsp;Please click on the green-plus-sign below to register your new courses.
			        	</div>
			    		<a href="dashboard.php?act=course_registration&qlk=<?php echo md5(3); ?>"  class="pull-right"><img src="images/add_icon.png" data-toggle="tooltip" data-placement="top"  title="Click here to register new courses" />   </a> <br/><br/>

			     <?php
					 }
				  ?>


			 <?php

			   }
			   else
			   {


				   echo

			   '<div class="alert alert-danger in" >
			                 <button class="close" data-dismiss="alert" type="button">
			                    X

			                 </button>
			                    <i class="glyphicon glyphicon-info-sign"></i>&nbsp;&nbsp;Please Upload ID Signature First.
			            </div>';

			   }
			}else{

				   echo

			   '<div class="alert alert-danger in" >
			                 <button class="close" data-dismiss="alert" type="button">
			                    X

			                 </button>
			                    <i class="glyphicon glyphicon-info-sign"></i>&nbsp;&nbsp;Please make registration payments before you can be able to do course registration.
			            </div>';

			}
			  ?>


   <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;COURSE 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">





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

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

                                        <?php $q = "SELECT * FROM sessions  WHERE status = '0' ORDER BY title DESC";
                                                    $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
																								   FROM  students_courses_nce
																								   WHERE semester = '1'
																								   AND student_id ='$user_id'
																								   AND session_id = '$session'
																								   ORDER BY date_added";

																								$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:12px;">
																										<thead>
																													<th>S/N</th>
																													<th>Code</th>
																													<th>Title</th>
																													<th>Credit Unit</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>".get_course_unit($row['course_id'])."</td>";
																										$output .= "</tr>";

																										////add total unit carried
//																										$total_units = 0;
//																										$total_unit = $total_units + get_course_unit($row['course_id']);
//																										$t +=  $total_unit;



																										$t = get_total_course_unit_registered_per_semester($student_id, $session, $semester = '1');

																									}
																										$output .= "<tr>";
																										$output .= "<td colspan='2'></td>";
																									    $output .= "<td>Sub Total </td>";
																										$output .= "<td>".$t."</td>";
																										$output .= "</tr>";
																								}
																								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>';


																								}



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





																								echo $output;










																							//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
																								   FROM  students_courses_nce
																								   WHERE semester = '2'
																								   AND student_id ='$user_id'
																								   AND session_id = '$session'
																								   ORDER BY date_added";

																								$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:12px;">
																										<thead>
																													<th>S/N</th>
																													<th>Code</th>
																													<th>Title</th>
																													<th>Credit Unit</th>
																													</thead>
																										<tbody>';

																									while($row4 = mysqli_fetch_array($r4, MYSQLI_ASSOC))
																									{
																										//add total unit carried
																										//$total_units4 = 0;
//																										$total_unit4 = $total_units4 + get_course_unit($row4['course_id']);
//																										$t4[$row4['íd']] += $total_unit4;
																										$t4 = get_total_course_unit_registered_per_semester($student_id, $session, $semester = '2');




																										$output4 .= "<tr>";
																										$output4 .= "<td>".$sn4 = $sn4 +1 ."</td>";
																										$output4 .= "<td> ".get_course_code($row4['course_id'])."</td>";
																										$output4 .= "<td> ".get_course_name($row4['course_id'])."</td>";
																										$output4 .= "<td>".get_course_unit($row4['course_id'])."</td>";
																										$output4 .= "</tr>";

																									}
																										$output4 .= "<tr>";
																										$output4 .= "<td colspan='2'></td>";
																										$output4 .= "<td>Sub Total </td>";
																										$output4 .= "<td>".$t4."</td>";
																										$output4 .= "</tr>";
																								}
																								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>';


																								}



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





																								echo $output4;


																								//add the total of the course
																								$total = $t + $t4;


																							if(($sn >0) || ($sn4  >0))//to sho button check if sn is greater than 0
																							{	//now show total tcu taken
																								echo '<span class="btn btn-default pull-right" >TOTAL CREDIT LOAD - <span  class="text-success" style="font-size:20px;font-wight:bold">'.$total.'</span></span>';



																								echo '<div style="height:25px;display:block;clear:both;"></div>';


																								//play with edit button if its not current session dont show


																								if($current_session == $session)
																								{

																									 if(has_paid_school_fee($user_id, $current_session, $current_semester )) //check if the user has paid this session fee
																									 {

																										 if(has_done_registration($user_id, $current_session, $current_semester)) //check if user done registration before
																										 {


																											echo '<input type="hidden" value="'.md5(3).'" name="qlk" />';
																											echo '<input type="hidden" value="edit_rc" name="act" />';

																											//check if has paid school fee for the curent semster and allow him to edi
																								//comment edit
																								////// this is commented because there was a compalint that some people were editing there courses

																											echo '<input type="submit" name="submit" class="btn btn-success" value="Edit" id="submit" data-toggle="tooltip" data-placement="top" title="Click here to edit"/>';
																										 }//end of if has done registration
																									 }//end of if has paid school fee edit

																								}//end of check if current session



																								//for now we are providing temporary measure to print for the particular system u are viewing

																								//echo '&nbsp;&nbsp;&nbsp;<a class="btn btn-primary"  onclick="printMe()" target="_blank" data-toggle="tooltip" data-placement="top" title="Print">Click here to print</a>';
																								echo '&nbsp;&nbsp;&nbsp;<a class="btn btn-success"  href="create_course_slip.php?u='.$user_id.'&s='.$session.'&se='.$current_semester.'&me='.sha1(md5('fucku')).'" target="_blank" data-toggle="tooltip" data-placement="top" title="Click here to Print">Print</a>';

																							}



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

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

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