<?php

if(isset($_GET['sid'],$_GET['pid']))
{
	$sid = $_GET['sid'];
  //$did = $_GET['did'];
  $pid = $_GET['pid'];

  //get department id from programme id supplied
  //$did = get_department_using_programme_id($pid);


  $did = get_department_comb_using_programme_id($pid);

}

 $mid = get_user_department($user_id); // the main department_id


 //check if the programme is a sed programme
 //checking eiither new special edu course or old
if ($mid != 12) //12 is set for old sed structure
{

  $sed_pids = get_sed_programme_ids( '%SED%',$type_id = 2, $mode = 1,$dept_idd = '!= 12');
}
else
{
  $sed_pids = get_sed_programme_ids( '%SED%',$type_id = 2, $mode = 1,$dept_idd = '= 12');
}

//print_r($pids);

//$prog_id = get_user_programme_id($user_id);
$prog_code = get_programme_code($pid);
//$level = get_user_level($user_id);

//verify programme id presence
$sed_std = false;
if(in_array($pid, $sed_pids)){
  $sed_pro = true;
  //echo  'yes';
  //$sed_prog_id = get_user_sed_prog_id($user_id);
}

 ?>

<div class="well">

      <ul class="tabs">
      	<li><a href="#view1">Assessment</a></li>
        <!--<li><a href="gateway.php?act=view_course_assessments">Assessments</a></li>-->
      </ul>
      <div class="tabcontents">
        <div id="view1">

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




                                                    <?php 	//collect the post id
                                														$session = $row['id'];
													                         	?>


                                                                <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">



										                                                        <!-- start level III -->

										                                                        <!-- show level III starting from 2019/2020 session -->

										                                                        <?php if ($session > 4)
										                                                        {


										                                                        ?>


										                                                                 <div class="panel panel-info">
										                                                                        <div class="panel-heading" role="tab" id="level3_heading">
										                                                                          <h4 class="panel-title">
										                                                                            <a class="collapsed" data-toggle="collapse" data-parent="#accordion" href="#level3" aria-expanded="false" aria-controls="level3">Level III</a>
										                                                                          </h4>
										                                                                        </div>
										                                                                        <div id="level3" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="level3_heading">
										                                                                          <div class="panel-body">


										                                                                              <div class="col-lg-6">

										                                                                      <h4>FIRST SEMESTER</h4>
										                                        <?php


										                                                                                        if(!check_if_computatation_exist_per_semester($pid,$session,1,'III'))
										                                                                                        {
										                                                                                        echo '<a target="_blank" href="gateway.php?act=compute_by_school_nce&ses='. $session.'&sem=1&sid='.$sid.'&pid='.$pid.'&level=III&type=do" class="btn btn-warning"> COMPUTE RESULT</a>';

										                                                                                       }
										                                                                                       else
										                                                                                       {
										                                                                                          echo '<a target="_blank" href="gateway.php?act=compute_by_school_nce&ses='. $session.'&sem=1&sid='.$sid.'&pid='.$pid.'&level=III&type=redo" class="btn btn-warning"> RE-COMPUTE RESULT</a>';

										                                                                                       }



										                                                                                           echo '&nbsp&nbsp <div class="btn-group">
																													                                                    <button type="button" class="btn btn-info dropdown-toggle" data-toggle="dropdown"><i class="glyphicon glyphicon-search"></i>
																													                                                      View <span class="caret"></span>
																													                                                    </button>
																													                                                    <ul class="dropdown-menu">
																													                                                      <li><a target="_blank" href="gateway.php?act=view_students_list_form_b2&ses='. $session.'&sem=1&sid='.$sid.'&pid='.$pid.'&level=III" > Students </a></li>

																													                                                       <li><a target="_blank" href="gateway.php?act=view_students_list_enter_scores&ses='. $session.'&sem=1&sid='.$sid.'&pid='.$pid.'&level=III" > Students (Enter Scores) </a></li>


																																																								 <li><a target="_blank" href="gateway.php?act=view_students_reg&ses='. $session.'&sem=1&sid='.$sid.'&pid='.$pid.'&level=III" > Reg. Students </a></li>

																													                                                    </ul>
																													                                                  </div>';







										                                                  //work on the short code for different core courses
										                                                      $debt_comb_array =array();

										                                                      //get department comb of programme combination
										                                                      $debt_comb = get_department_comb_using_programme_id($pid);

										                                                        //get headings for the core departments


										                                                        //
										                                                        if(strpos($debt_comb, ',') !== false )
										                                                        {

										                                                          for ($i = 0; $i < count($debt_comb);$i++)
										                                                          {
										                                                             $debt_comb_array = explode(',', $debt_comb);


										                                                          }

										                                                           $first_debt = $debt_comb_array[0];

										                                                           $second_debt = $debt_comb_array[1];


										                                                           $first_debt_code = get_department_code($first_debt);

										                                                            $second_debt_code = get_department_code($second_debt);

										                                                        }
										                                                        else
										                                                        {

										                                                          //get department id using programme id
										                                                         $first_debt =  get_department_using_programme_id($pid);

										                                                         $first_debt_code = get_department_code($first_debt);
										                                                         $second_debt = '';



										                                                          //get short code for department

										                                                        }


										                                                                                           echo '&nbsp&nbsp <div class="btn-group">
										                                                    <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"> <i class="glyphicon glyphicon-print"></i>
										                                                      Print <span class="caret"></span>
										                                                    </button>
										                                                    <ul class="dropdown-menu">';



																																					if ($sed_pro && isset($sed_pids) && !empty($sed_pids)  && $level != 'I')
																																					{


																																							//geting the prog sub string since it is 3
																																							$prog_full_code = '';
																																							$prog_code_str1 = substr($prog_code,0,3);
																																							$prog_code_str2 = substr($prog_code,4);

																																							$prg_str_arr = ['SHI','SLD','SVI'];
																																							$prog_ids_arr = [];

																																							//get the Programmes for dropdown
																																							foreach ($prg_str_arr  as $ps)
																																							{
																																								if ($mid != '12')
																																								{

																																									$prog_full_code = $prog_code_str1.'-'.$ps;
																																								}
																																								else
																																								{

																																									$prog_full_code = $prog_code_str2.'-'.$ps;
																																								}

																																								$new_pid = get_programme_id_by_code($prog_full_code);
																																								//echo $prog_full_code;
																																								//validate the new ids
																																								if (strlen($new_pid) > 0)
																																								{
																																									array_push($prog_ids_arr, $new_pid);
																																								}
																																							}

																																							//print_r($prog_ids_arr);

																																							 echo list_special_sed_programme_codes_form_b2($prog_ids_arr,$pid,$session,$semester=1,$sid,$second_debt,$level='III');
																																					}
																																					else //if not sed
																																					{
																																						echo '<li><a target="_blank" href="print_form_b2_per_semester.php?mis='.md5('mis').'&ses='. $session.'&sem=1&sid='.$sid.'&pid='.$pid.'&lvl=III" > FORM B2</a> </li>';

																																					}



										                                                      echo '<li><a target="_blank" href="print_form_a2_per_semester.php?mis='.md5('mis').'&ses='. $session.'&sem=1&sid='.$sid.'&pid='.$pid.'&lvl=III" > FORM A2 </a></li>

										                                                          <li><a target="_blank" href="print_form_a2_per_semester_gse.php?mis='.md5('mis').'&ses='. $session.'&sem=1&sid='.$sid.'&pid='.$pid.'&lvl=III" > GSE FORM A </a></li>

										                                                          <li><a target="_blank" href="print_form_a2_per_semester_edu.php?mis='.md5('mis').'&ses='. $session.'&sem=1&sid='.$sid.'&pid='.$pid.'&lvl=III" > EDU FORM A </a></li>


										                                                          <li class="divider"></li>';

										                                                      echo '<li><a target="_blank" href="print_form_a2_per_semester_core.php?mis='.md5('mis').'&ses='. $session.'&sem=1&sid='.$sid.'&pid='.$pid.'&did='.$first_debt.'&lvl=III&core=1" > '.$first_debt_code.' FORM A </a></li>';

										                                                      if($second_debt !== '')
										                                                      {


																																						//if not epmty check if its SED programme or not
																																						//convert this guy to function in the next session
																																						//
																																						if ($sed_pro && isset($sed_pids) && !empty($sed_pids)  && $level != 'I')
																																						{


																																		            //geting the prog sub string since it is 3
																																		            $prog_full_code = '';
																																		            $prog_code_str1 = substr($prog_code,0,3);
																																		            $prog_code_str2 = substr($prog_code,4);

																																		            $prg_str_arr = ['SHI','SLD','SVI'];
																																		            $prog_ids_arr = [];

																																		            //get the Programmes for dropdown
																																		            foreach ($prg_str_arr  as $ps)
																																								{
																																		              if ($mid != '12')
																																									{

																																		                $prog_full_code = $prog_code_str1.'-'.$ps;
																																		              }
																																									else
																																									{

																																		                $prog_full_code = $prog_code_str2.'-'.$ps;
																																		              }

																																		              $new_pid = get_programme_id_by_code($prog_full_code);
																																		              //echo $prog_full_code;
																																		              //validate the new ids
																																		              if (strlen($new_pid) > 0)
																																									{
																																		                array_push($prog_ids_arr, $new_pid);
																																		              }
																																		            }

																																		            //print_r($prog_ids_arr);

																																								 echo list_special_sed_programme_codes($prog_ids_arr,$pid,$session,$semester=1,$sid,$second_debt,$level='III');
																																		        }
																																						else //if not sed
																																						{
																																							echo '<li><a target="_blank" href="print_form_a2_per_semester_core.php?mis='.md5('mis').'&ses='. $session.'&sem=1&sid='.$sid.'&pid='.$pid.'&did='.$second_debt.'&lvl=III&core=2" > '.$second_debt_code.' FORM A </a></li>';

																																						}

										                                                      }
																																					else //if it doesnt have second combination
																																					{
																																						echo '<li><a target="_blank" href="print_form_a2_per_semester_core.php?mis='.md5('mis').'&ses='. $session.'&sem=1&sid='.$sid.'&pid='.$pid.'&did='.$second_debt.'&lvl=III&core=2" > '.$second_debt_code.' FORM A </a></li>';

																																					}



										                                                   echo
										                                                   '</ul>
										                                                  </div>'; //end of  /.btn group


										                                                                                 ?>


										                                                                                 </div>


										                                                                                 <div class="col-lg-6">

										                                                                                <h4>SECOND SEMESTER</h4>
										                                          <?php
										                                                                                          //get second semester courses assigned to staff
										                                                                                           // echo view_courses_by_programme($session,$sid,$did, $pid,$semester = '2', $level = 'I'); //$user_id
										                                                                                           //
										                                                                                          if(!check_if_computatation_exist_per_semester($pid,$session,2,'III'))
										                                                                                          {
										                                                                                          echo '<a target="_blank" href="gateway.php?act=compute_by_school_nce&ses='. $session.'&sem=2&sid='.$sid.'&pid='.$pid.'&level=III&type=do" class="btn btn-warning"> COMPUTE RESULT</a>';

										                                                                                         }
										                                                                                         else
										                                                                                         {
										                                                                                            echo '<a target="_blank" href="gateway.php?act=compute_by_school_nce&ses='. $session.'&sem=2&sid='.$sid.'&pid='.$pid.'&level=III&type=redo" class="btn btn-warning"> RE-COMPUTE RESULT</a>';

										                                                                                         }



										                                                                                           echo '&nbsp&nbsp <div class="btn-group">
										                                                    <button type="button" class="btn btn-info dropdown-toggle" data-toggle="dropdown"><i class="glyphicon glyphicon-search"></i>
										                                                      View <span class="caret"></span>
										                                                    </button>
										                                                    <ul class="dropdown-menu">
										                                                      <li><a target="_blank" href="gateway.php?act=view_students_list_form_b2&ses='. $session.'&sem=2&sid='.$sid.'&pid='.$pid.'&level=III" > Students </a></li>


										                                                    <li><a target="_blank" href="gateway.php?act=view_students_list_enter_scores&ses='. $session.'&sem=2&sid='.$sid.'&pid='.$pid.'&level=III" > Students (Enter Scores) </a></li>


																																				<li><a target="_blank" href="gateway.php?act=view_students_reg&ses='. $session.'&sem=2&sid='.$sid.'&pid='.$pid.'&level=III" > Reg. Students </a></li>

										                                                    </ul>
										                                                  </div>';


																																			//work on the short code for different core courses
																																					$debt_comb_array =array();

																																					//get department comb of programme combination
																																					$debt_comb = get_department_comb_using_programme_id($pid);

																																						//get headings for the core departments


																																						//
																																						if(strpos($debt_comb, ',') !== false )
																																						{

																																							for ($i = 0; $i < count($debt_comb);$i++)
																																							{
																																								 $debt_comb_array = explode(',', $debt_comb);


																																							}

																																							 $first_debt = $debt_comb_array[0];

																																							 $second_debt = $debt_comb_array[1];


																																							 $first_debt_code = get_department_code($first_debt);

																																								$second_debt_code = get_department_code($second_debt);

																																						}
																																						else
																																						{

																																							//get department id using programme id
																																						 $first_debt =  get_department_using_programme_id($pid);

																																						 $first_debt_code = get_department_code($first_debt);
																																						 $second_debt = '';



																																							//get short code for department

																																						}


																																																							 echo '&nbsp&nbsp <div class="btn-group">
																																				<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"> <i class="glyphicon glyphicon-print"></i>
																																					Print <span class="caret"></span>
																																				</button>
																																				<ul class="dropdown-menu">';



																																					if ($sed_pro && isset($sed_pids) && !empty($sed_pids)  && $level != 'I')
																																					{


																																							//geting the prog sub string since it is 3
																																							$prog_full_code = '';
																																							$prog_code_str1 = substr($prog_code,0,3);
																																							$prog_code_str2 = substr($prog_code,4);

																																							$prg_str_arr = ['SHI','SLD','SVI'];
																																							$prog_ids_arr = [];

																																							//get the Programmes for dropdown
																																							foreach ($prg_str_arr  as $ps)
																																							{
																																								if ($mid != '12')
																																								{

																																									$prog_full_code = $prog_code_str1.'-'.$ps;
																																								}
																																								else
																																								{

																																									$prog_full_code = $prog_code_str2.'-'.$ps;
																																								}

																																								$new_pid = get_programme_id_by_code($prog_full_code);
																																								//echo $prog_full_code;
																																								//validate the new ids
																																								if (strlen($new_pid) > 0)
																																								{
																																									array_push($prog_ids_arr, $new_pid);
																																								}
																																							}

																																							//print_r($prog_ids_arr);

																																							 echo list_special_sed_programme_codes_form_b2($prog_ids_arr,$pid,$session,$semester=2,$sid,$second_debt,$level='III');
																																					}
																																					else //if not sed
																																					{
																																						echo '<li><a target="_blank" href="print_form_b2_per_semester.php?mis='.md5('mis').'&ses='. $session.'&sem=2&sid='.$sid.'&pid='.$pid.'&lvl=III" > FORM B2</a> </li>';

																																					}



																																					echo '<li><a target="_blank" href="print_form_a2_per_semester.php?mis='.md5('mis').'&ses='. $session.'&sem=2&sid='.$sid.'&pid='.$pid.'&lvl=III" > FORM A2 </a></li>

																																							<li><a target="_blank" href="print_form_a2_per_semester_gse.php?mis='.md5('mis').'&ses='. $session.'&sem=2&sid='.$sid.'&pid='.$pid.'&lvl=III" > GSE FORM A </a></li>

																																							<li><a target="_blank" href="print_form_a2_per_semester_edu.php?mis='.md5('mis').'&ses='. $session.'&sem=2&sid='.$sid.'&pid='.$pid.'&lvl=III" > EDU FORM A </a></li>


																																							<li class="divider"></li>';

																																					echo '<li><a target="_blank" href="print_form_a2_per_semester_core.php?mis='.md5('mis').'&ses='. $session.'&sem=2&sid='.$sid.'&pid='.$pid.'&did='.$first_debt.'&lvl=III&core=1" > '.$first_debt_code.' FORM A </a></li>';

																																					if($second_debt !== '')
																																					{


																																						//if not epmty check if its SED programme or not
																																						//convert this guy to function in the next session
																																						//
																																						if ($sed_pro && isset($sed_pids) && !empty($sed_pids)  && $level != 'I')
																																						{


																																								//geting the prog sub string since it is 3
																																								$prog_full_code = '';
																																								$prog_code_str1 = substr($prog_code,0,3);
																																								$prog_code_str2 = substr($prog_code,4);

																																								$prg_str_arr = ['SHI','SLD','SVI'];
																																								$prog_ids_arr = [];

																																								//get the Programmes for dropdown
																																								foreach ($prg_str_arr  as $ps)
																																								{
																																									if ($mid != '12')
																																									{

																																										$prog_full_code = $prog_code_str1.'-'.$ps;
																																									}
																																									else
																																									{

																																										$prog_full_code = $prog_code_str2.'-'.$ps;
																																									}

																																									$new_pid = get_programme_id_by_code($prog_full_code);
																																									//echo $prog_full_code;
																																									//validate the new ids
																																									if (strlen($new_pid) > 0)
																																									{
																																										array_push($prog_ids_arr, $new_pid);
																																									}
																																								}

																																								//print_r($prog_ids_arr);

																																								 echo list_special_sed_programme_codes($prog_ids_arr,$pid,$session,$semester=2,$sid,$second_debt,$level='III');
																																						}
																																						else //if not sed
																																						{
																																							echo '<li><a target="_blank" href="print_form_a2_per_semester_core.php?mis='.md5('mis').'&ses='. $session.'&sem=2&sid='.$sid.'&pid='.$pid.'&did='.$second_debt.'&lvl=III&core=2" > '.$second_debt_code.' FORM A </a></li>';

																																						}

																																					}
																																					else //if it doesnt have second combination
																																					{
																																						echo '<li><a target="_blank" href="print_form_a2_per_semester_core.php?mis='.md5('mis').'&ses='. $session.'&sem=2&sid='.$sid.'&pid='.$pid.'&did='.$second_debt.'&lvl=III&core=2" > '.$second_debt_code.' FORM A </a></li>';

																																					}



																																			 echo
																																			 '</ul>
																																			</div>'; //end of  /.btn group


										                                                                                   ?>

										                                                                                </div>



										                                                                          </div>
										                                                                        </div>
										                                                                      </div>








										                                              <?php


										                                            }// end of condition to show 2019/2020 session for level III and above

										                                              ?>

                                                        <!-- start level II -->

                                                        <!-- show level II starting from 2018/2019 session -->

                                                        <?php if ($session != 3)
                                                        {


                                                        ?>


                                                                 <div class="panel panel-danger">
                                                                        <div class="panel-heading" role="tab" id="level2_heading">
                                                                          <h4 class="panel-title">
                                                                            <a class="collapsed" data-toggle="collapse" data-parent="#accordion" href="#level2" aria-expanded="false" aria-controls="level2">Level II</a>
                                                                          </h4>
                                                                        </div>
                                                                        <div id="level2" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="level2_heading">
                                                                          <div class="panel-body">


                                                                              <div class="col-lg-6">

                                                                      <h4>FIRST SEMESTER</h4>
                                        <?php


                                                                                        if(!check_if_computatation_exist_per_semester($pid,$session,1,'II'))
                                                                                        {
                                                                                        echo '<a target="_blank" href="gateway.php?act=compute_by_school_nce&ses='. $session.'&sem=1&sid='.$sid.'&pid='.$pid.'&level=II&type=do" class="btn btn-warning"> COMPUTE RESULT</a>';

                                                                                       }
                                                                                       else
                                                                                       {
                                                                                          echo '<a target="_blank" href="gateway.php?act=compute_by_school_nce&ses='. $session.'&sem=1&sid='.$sid.'&pid='.$pid.'&level=II&type=redo" class="btn btn-warning"> RE-COMPUTE RESULT</a>';

                                                                                       }



                                                                                           echo '&nbsp&nbsp <div class="btn-group">
																			                                                    <button type="button" class="btn btn-info dropdown-toggle" data-toggle="dropdown"><i class="glyphicon glyphicon-search"></i>
																			                                                      View <span class="caret"></span>
																			                                                    </button>
																			                                                    <ul class="dropdown-menu">
																			                                                      <li><a target="_blank" href="gateway.php?act=view_students_list_form_b2&ses='. $session.'&sem=1&sid='.$sid.'&pid='.$pid.'&level=II" > Students </a></li>

																			                                                       <li><a target="_blank" href="gateway.php?act=view_students_list_enter_scores&ses='. $session.'&sem=1&sid='.$sid.'&pid='.$pid.'&level=II" > Students (Enter Scores) </a></li>


																																														 <li><a target="_blank" href="gateway.php?act=view_students_reg&ses='. $session.'&sem=1&sid='.$sid.'&pid='.$pid.'&level=II" > Reg. Students </a></li>

																			                                                    </ul>
																			                                                  </div>';







                                                  //work on the short code for different core courses
                                                      $debt_comb_array =array();

                                                      //get department comb of programme combination
                                                      $debt_comb = get_department_comb_using_programme_id($pid);

                                                        //get headings for the core departments


                                                        //
                                                        if(strpos($debt_comb, ',') !== false )
                                                        {

                                                          for ($i = 0; $i < count($debt_comb);$i++)
                                                          {
                                                             $debt_comb_array = explode(',', $debt_comb);


                                                          }

                                                           $first_debt = $debt_comb_array[0];

                                                           $second_debt = $debt_comb_array[1];


                                                           $first_debt_code = get_department_code($first_debt);

                                                            $second_debt_code = get_department_code($second_debt);

                                                        }
                                                        else
                                                        {

                                                          //get department id using programme id
                                                         $first_debt =  get_department_using_programme_id($pid);

                                                         $first_debt_code = get_department_code($first_debt);
                                                         $second_debt = '';



                                                          //get short code for department

                                                        }


                                                                                           echo '&nbsp&nbsp <div class="btn-group">
                                                    <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"> <i class="glyphicon glyphicon-print"></i>
                                                      Print <span class="caret"></span>
                                                    </button>
                                                    <ul class="dropdown-menu">';



																											if ($sed_pro && isset($sed_pids) && !empty($sed_pids)  && $level != 'I')
																											{


																													//geting the prog sub string since it is 3
																													$prog_full_code = '';
																													$prog_code_str1 = substr($prog_code,0,3);
																													$prog_code_str2 = substr($prog_code,4);

																													$prg_str_arr = ['SHI','SLD','SVI'];
																													$prog_ids_arr = [];

																													//get the Programmes for dropdown
																													foreach ($prg_str_arr  as $ps)
																													{
																														if ($mid != '12')
																														{

																															$prog_full_code = $prog_code_str1.'-'.$ps;
																														}
																														else
																														{

																															$prog_full_code = $prog_code_str2.'-'.$ps;
																														}

																														$new_pid = get_programme_id_by_code($prog_full_code);
																														//echo $prog_full_code;
																														//validate the new ids
																														if (strlen($new_pid) > 0)
																														{
																															array_push($prog_ids_arr, $new_pid);
																														}
																													}

																													//print_r($prog_ids_arr);

																													 echo list_special_sed_programme_codes_form_b2($prog_ids_arr,$pid,$session,$semester=1,$sid,$second_debt,$level='II');
																											}
																											else //if not sed
																											{
																												echo '<li><a target="_blank" href="print_form_b2_per_semester.php?mis='.md5('mis').'&ses='. $session.'&sem=1&sid='.$sid.'&pid='.$pid.'&lvl=II" > FORM B2</a> </li>';

																											}



                                                      echo '<li><a target="_blank" href="print_form_a2_per_semester.php?mis='.md5('mis').'&ses='. $session.'&sem=1&sid='.$sid.'&pid='.$pid.'&lvl=II" > FORM A2 </a></li>

                                                          <li><a target="_blank" href="print_form_a2_per_semester_gse.php?mis='.md5('mis').'&ses='. $session.'&sem=1&sid='.$sid.'&pid='.$pid.'&lvl=II" > GSE FORM A </a></li>

                                                          <li><a target="_blank" href="print_form_a2_per_semester_edu.php?mis='.md5('mis').'&ses='. $session.'&sem=1&sid='.$sid.'&pid='.$pid.'&lvl=II" > EDU FORM A </a></li>


                                                          <li class="divider"></li>';

                                                      echo '<li><a target="_blank" href="print_form_a2_per_semester_core.php?mis='.md5('mis').'&ses='. $session.'&sem=1&sid='.$sid.'&pid='.$pid.'&did='.$first_debt.'&lvl=II&core=1" > '.$first_debt_code.' FORM A </a></li>';

                                                      if($second_debt !== '')
                                                      {


																												//if not epmty check if its SED programme or not
																												//convert this guy to function in the next session
																												//
																												if ($sed_pro && isset($sed_pids) && !empty($sed_pids)  && $level != 'I')
																												{


																								            //geting the prog sub string since it is 3
																								            $prog_full_code = '';
																								            $prog_code_str1 = substr($prog_code,0,3);
																								            $prog_code_str2 = substr($prog_code,4);

																								            $prg_str_arr = ['SHI','SLD','SVI'];
																								            $prog_ids_arr = [];

																								            //get the Programmes for dropdown
																								            foreach ($prg_str_arr  as $ps)
																														{
																								              if ($mid != '12')
																															{

																								                $prog_full_code = $prog_code_str1.'-'.$ps;
																								              }
																															else
																															{

																								                $prog_full_code = $prog_code_str2.'-'.$ps;
																								              }

																								              $new_pid = get_programme_id_by_code($prog_full_code);
																								              //echo $prog_full_code;
																								              //validate the new ids
																								              if (strlen($new_pid) > 0)
																															{
																								                array_push($prog_ids_arr, $new_pid);
																								              }
																								            }

																								            //print_r($prog_ids_arr);

																														 echo list_special_sed_programme_codes($prog_ids_arr,$pid,$session,$semester=1,$sid,$second_debt,$level='II');
																								        }
																												else //if not sed
																												{
																													echo '<li><a target="_blank" href="print_form_a2_per_semester_core.php?mis='.md5('mis').'&ses='. $session.'&sem=1&sid='.$sid.'&pid='.$pid.'&did='.$second_debt.'&lvl=II&core=2" > '.$second_debt_code.' FORM A </a></li>';

																												}

                                                      }
																											else //if it doesnt have second combination
																											{
																												echo '<li><a target="_blank" href="print_form_a2_per_semester_core.php?mis='.md5('mis').'&ses='. $session.'&sem=1&sid='.$sid.'&pid='.$pid.'&did='.$second_debt.'&lvl=II&core=2" > '.$second_debt_code.' FORM A </a></li>';

																											}



                                                   echo
                                                   '</ul>
                                                  </div>'; //end of  /.btn group


                                                                                 ?>


                                                                                 </div>


                                                                                 <div class="col-lg-6">

                                                                                <h4>SECOND SEMESTER</h4>
                                          <?php
                                                                                          //get second semester courses assigned to staff
                                                                                           // echo view_courses_by_programme($session,$sid,$did, $pid,$semester = '2', $level = 'I'); //$user_id
                                                                                           //
                                                                                          if(!check_if_computatation_exist_per_semester($pid,$session,2,'II'))
                                                                                          {
                                                                                          echo '<a target="_blank" href="gateway.php?act=compute_by_school_nce&ses='. $session.'&sem=2&sid='.$sid.'&pid='.$pid.'&level=II&type=do" class="btn btn-warning"> COMPUTE RESULT</a>';

                                                                                         }
                                                                                         else
                                                                                         {
                                                                                            echo '<a target="_blank" href="gateway.php?act=compute_by_school_nce&ses='. $session.'&sem=2&sid='.$sid.'&pid='.$pid.'&level=II&type=redo" class="btn btn-warning"> RE-COMPUTE RESULT</a>';

                                                                                         }



                                                                                           echo '&nbsp&nbsp <div class="btn-group">
                                                    <button type="button" class="btn btn-info dropdown-toggle" data-toggle="dropdown"><i class="glyphicon glyphicon-search"></i>
                                                      View <span class="caret"></span>
                                                    </button>
                                                    <ul class="dropdown-menu">
                                                      <li><a target="_blank" href="gateway.php?act=view_students_list_form_b2&ses='. $session.'&sem=2&sid='.$sid.'&pid='.$pid.'&level=II" > Students </a></li>


                                                    <li><a target="_blank" href="gateway.php?act=view_students_list_enter_scores&ses='. $session.'&sem=2&sid='.$sid.'&pid='.$pid.'&level=II" > Students (Enter Scores) </a></li>


																										<li><a target="_blank" href="gateway.php?act=view_students_reg&ses='. $session.'&sem=2&sid='.$sid.'&pid='.$pid.'&level=II" > Reg. Students </a></li>

                                                    </ul>
                                                  </div>';


																									//work on the short code for different core courses
																											$debt_comb_array =array();

																											//get department comb of programme combination
																											$debt_comb = get_department_comb_using_programme_id($pid);

																												//get headings for the core departments


																												//
																												if(strpos($debt_comb, ',') !== false )
																												{

																													for ($i = 0; $i < count($debt_comb);$i++)
																													{
																														 $debt_comb_array = explode(',', $debt_comb);


																													}

																													 $first_debt = $debt_comb_array[0];

																													 $second_debt = $debt_comb_array[1];


																													 $first_debt_code = get_department_code($first_debt);

																														$second_debt_code = get_department_code($second_debt);

																												}
																												else
																												{

																													//get department id using programme id
																												 $first_debt =  get_department_using_programme_id($pid);

																												 $first_debt_code = get_department_code($first_debt);
																												 $second_debt = '';



																													//get short code for department

																												}


																																													 echo '&nbsp&nbsp <div class="btn-group">
																										<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"> <i class="glyphicon glyphicon-print"></i>
																											Print <span class="caret"></span>
																										</button>
																										<ul class="dropdown-menu">';



																										 if ($sed_pro && isset($sed_pids) && !empty($sed_pids)  && $level != 'I')
																										 {


																												 //geting the prog sub string since it is 3
																												 $prog_full_code = '';
																												 $prog_code_str1 = substr($prog_code,0,3);
																												 $prog_code_str2 = substr($prog_code,4);

																												 $prg_str_arr = ['SHI','SLD','SVI'];
																												 $prog_ids_arr = [];

																												 //get the Programmes for dropdown
																												 foreach ($prg_str_arr  as $ps)
																												 {
																													 if ($mid != '12')
																													 {

																														 $prog_full_code = $prog_code_str1.'-'.$ps;
																													 }
																													 else
																													 {

																														 $prog_full_code = $prog_code_str2.'-'.$ps;
																													 }

																													 $new_pid = get_programme_id_by_code($prog_full_code);
																													 //echo $prog_full_code;
																													 //validate the new ids
																													 if (strlen($new_pid) > 0)
																													 {
																														 array_push($prog_ids_arr, $new_pid);
																													 }
																												 }

																												 //print_r($prog_ids_arr);

																													echo list_special_sed_programme_codes_form_b2($prog_ids_arr,$pid,$session,$semester=2,$sid,$second_debt,$level='II');
																										 }
																										 else //if not sed
																										 {
																											 echo '<li><a target="_blank" href="print_form_b2_per_semester.php?mis='.md5('mis').'&ses='. $session.'&sem=2&sid='.$sid.'&pid='.$pid.'&lvl=II" > FORM B2</a> </li>';

																										 }



																											echo '<li><a target="_blank" href="print_form_a2_per_semester.php?mis='.md5('mis').'&ses='. $session.'&sem=2&sid='.$sid.'&pid='.$pid.'&lvl=II" > FORM A2 </a></li>

																													<li><a target="_blank" href="print_form_a2_per_semester_gse.php?mis='.md5('mis').'&ses='. $session.'&sem=2&sid='.$sid.'&pid='.$pid.'&lvl=II" > GSE FORM A </a></li>

																													<li><a target="_blank" href="print_form_a2_per_semester_edu.php?mis='.md5('mis').'&ses='. $session.'&sem=2&sid='.$sid.'&pid='.$pid.'&lvl=II" > EDU FORM A </a></li>


																													<li class="divider"></li>';

																											echo '<li><a target="_blank" href="print_form_a2_per_semester_core.php?mis='.md5('mis').'&ses='. $session.'&sem=2&sid='.$sid.'&pid='.$pid.'&did='.$first_debt.'&lvl=II&core=1" > '.$first_debt_code.' FORM A </a></li>';

																											if($second_debt !== '')
																											{


																											 //if not epmty check if its SED programme or not
																											 //convert this guy to function in the next session
																											 //
																											 if ($sed_pro && isset($sed_pids) && !empty($sed_pids)  && $level != 'I')
																											 {


																													 //geting the prog sub string since it is 3
																													 $prog_full_code = '';
																													 $prog_code_str1 = substr($prog_code,0,3);
																													 $prog_code_str2 = substr($prog_code,4);

																													 $prg_str_arr = ['SHI','SLD','SVI'];
																													 $prog_ids_arr = [];

																													 //get the Programmes for dropdown
																													 foreach ($prg_str_arr  as $ps)
																													 {
																														 if ($mid != '12')
																														 {

																															 $prog_full_code = $prog_code_str1.'-'.$ps;
																														 }
																														 else
																														 {

																															 $prog_full_code = $prog_code_str2.'-'.$ps;
																														 }

																														 $new_pid = get_programme_id_by_code($prog_full_code);
																														 //echo $prog_full_code;
																														 //validate the new ids
																														 if (strlen($new_pid) > 0)
																														 {
																															 array_push($prog_ids_arr, $new_pid);
																														 }
																													 }

																													 //print_r($prog_ids_arr);

																														echo list_special_sed_programme_codes($prog_ids_arr,$pid,$session,$semester=2,$sid,$second_debt,$level='II');
																											 }
																											 else //if not sed
																											 {
																												 echo '<li><a target="_blank" href="print_form_a2_per_semester_core.php?mis='.md5('mis').'&ses='. $session.'&sem=2&sid='.$sid.'&pid='.$pid.'&did='.$second_debt.'&lvl=II&core=2" > '.$second_debt_code.' FORM A </a></li>';

																											 }

																											}
																										 else //if it doesnt have second combination
																										 {
																											 echo '<li><a target="_blank" href="print_form_a2_per_semester_core.php?mis='.md5('mis').'&ses='. $session.'&sem=2&sid='.$sid.'&pid='.$pid.'&did='.$second_debt.'&lvl=II&core=2" > '.$second_debt_code.' FORM A </a></li>';

																										 }



																									 echo
																									 '</ul>
																									</div>'; //end of  /.btn group


                                                                                   ?>

                                                                                </div>



                                                                          </div>
                                                                        </div>
                                                                      </div>








                                              <?php


                                            }// end of condition to show 2018/2019 session for level II and above

                                              ?>




                                                                   <!-- start level I -->
                                                                      <div class="panel panel-warning">
                                                                        <div class="panel-heading" role="tab" id="level1_heading">
                                                                          <h4 class="panel-title">
                                                                            <a class="collapsed" data-toggle="collapse" data-parent="#accordion" href="#level1" aria-expanded="false" aria-controls="level1">Level I</a>
                                                                          </h4>
                                                                        </div>
                                                                        <div id="level1" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="level1_heading">
                                                                          <div class="panel-body">





                                                                          		<div class="col-lg-6">

                                                            					<h4>FIRST SEMESTER</h4>
																				<?php


                                                                                        if(!check_if_computatation_exist_per_semester($pid,$session,1,'I'))
                                                                                        {
                                                                                        echo '<a target="_blank" href="gateway.php?act=compute_by_school_nce&ses='. $session.'&sem=1&sid='.$sid.'&pid='.$pid.'&level=I&type=do" class="btn btn-warning"> COMPUTE RESULT</a>';

                                                                                       }
                                                                                       else
                                                                                       {
                                                                                          echo '<a target="_blank" href="gateway.php?act=compute_by_school_nce&ses='. $session.'&sem=1&sid='.$sid.'&pid='.$pid.'&level=I&type=redo" class="btn btn-warning"> RE-COMPUTE RESULT</a>';

                                                                                       }



                                                                                           echo '&nbsp&nbsp <div class="btn-group">
                                                    <button type="button" class="btn btn-info dropdown-toggle" data-toggle="dropdown"><i class="glyphicon glyphicon-search"></i>
                                                      View <span class="caret"></span>
                                                    </button>
                                                    <ul class="dropdown-menu">
                                                      <li><a target="_blank" href="gateway.php?act=view_students_list_form_b2&ses='. $session.'&sem=1&sid='.$sid.'&pid='.$pid.'&level=I" > Students </a></li>

                                                       <li><a target="_blank" href="gateway.php?act=view_students_list_enter_scores&ses='. $session.'&sem=1&sid='.$sid.'&pid='.$pid.'&level=I" > Students (Enter Scores) </a></li>


																											 <li><a target="_blank" href="gateway.php?act=view_students_reg&ses='. $session.'&sem=1&sid='.$sid.'&pid='.$pid.'&level=I" > Reg. Students </a></li>

                                                    </ul>
                                                  </div>';







                                                  //work on the short code for different core courses
                                                      $debt_comb_array =array();

                                                      //get department comb of programme combination
                                                      $debt_comb = get_department_comb_using_programme_id($pid);

                                                        //get headings for the core departments


                                                        //
                                                        if(strpos($debt_comb, ',') !== false )
                                                        {

                                                          for ($i = 0; $i < count($debt_comb);$i++)
                                                          {
                                                             $debt_comb_array = explode(',', $debt_comb);


                                                          }

                                                           $first_debt = $debt_comb_array[0];

                                                           $second_debt = $debt_comb_array[1];


                                                           $first_debt_code = get_department_code($first_debt);

                                                            $second_debt_code = get_department_code($second_debt);

                                                        }
                                                        else
                                                        {

                                                          //get department id using programme id
                                                         $first_debt =  get_department_using_programme_id($pid);

                                                         $first_debt_code = get_department_code($first_debt);
                                                         $second_debt = '';



                                                          //get short code for department

                                                        }


                                                                                           echo '&nbsp&nbsp <div class="btn-group">
                                                    <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"> <i class="glyphicon glyphicon-print"></i>
                                                      Print <span class="caret"></span>
                                                    </button>
                                                    <ul class="dropdown-menu">

                                                      <li><a target="_blank" href="print_form_b2_per_semester.php?mis='.md5('mis').'&ses='. $session.'&sem=1&sid='.$sid.'&pid='.$pid.'&lvl=I" > FORM B2</a> </li>


                                                      <li><a target="_blank" href="print_form_a2_per_semester.php?mis='.md5('mis').'&ses='. $session.'&sem=1&sid='.$sid.'&pid='.$pid.'&lvl=I" > FORM A2 </a></li>

                                                          <li><a target="_blank" href="print_form_a2_per_semester_gse.php?mis='.md5('mis').'&ses='. $session.'&sem=1&sid='.$sid.'&pid='.$pid.'&lvl=I" > GSE FORM A </a></li>

                                                          <li><a target="_blank" href="print_form_a2_per_semester_edu.php?mis='.md5('mis').'&ses='. $session.'&sem=1&sid='.$sid.'&pid='.$pid.'&lvl=I" > EDU FORM A </a></li>


                                                          <li class="divider"></li>';

                                                      echo '<li><a target="_blank" href="print_form_a2_per_semester_core.php?mis='.md5('mis').'&ses='. $session.'&sem=1&sid='.$sid.'&pid='.$pid.'&did='.$first_debt.'&lvl=I&core=1" > '.$first_debt_code.' FORM A </a></li>';

                                                      if($second_debt !== '')
                                                      {
                                                         echo '<li><a target="_blank" href="print_form_a2_per_semester_core.php?mis='.md5('mis').'&ses='. $session.'&sem=1&sid='.$sid.'&pid='.$pid.'&did='.$second_debt.'&lvl=I&core=2" > '.$second_debt_code.' FORM A </a></li>';
                                                      }





                                                   echo
                                                   '</ul>
                                                  </div>'; //end of  /.btn group


                                                                                 ?>


                                                                                 </div>


                                                                                 <div class="col-lg-6">

                                                                                <h4>SECOND SEMESTER</h4>
																				  <?php
                                                                                          //get second semester courses assigned to staff
                                                                                           // echo view_courses_by_programme($session,$sid,$did, $pid,$semester = '2', $level = 'I'); //$user_id
                                                                                           //
                                                                                          if(!check_if_computatation_exist_per_semester($pid,$session,2,'I'))
                                                                                          {
                                                                                          echo '<a target="_blank" href="gateway.php?act=compute_by_school_nce&ses='. $session.'&sem=2&sid='.$sid.'&pid='.$pid.'&level=I&type=do" class="btn btn-warning"> COMPUTE RESULT</a>';

                                                                                         }
                                                                                         else
                                                                                         {
                                                                                            echo '<a target="_blank" href="gateway.php?act=compute_by_school_nce&ses='. $session.'&sem=2&sid='.$sid.'&pid='.$pid.'&level=I&type=redo" class="btn btn-warning"> RE-COMPUTE RESULT</a>';

                                                                                         }



                                                                                           echo '&nbsp&nbsp <div class="btn-group">
                                                    <button type="button" class="btn btn-info dropdown-toggle" data-toggle="dropdown"><i class="glyphicon glyphicon-search"></i>
                                                      View <span class="caret"></span>
                                                    </button>
                                                    <ul class="dropdown-menu">
                                                      <li><a target="_blank" href="gateway.php?act=view_students_list_form_b2&ses='. $session.'&sem=2&sid='.$sid.'&pid='.$pid.'&level=I" > Students </a></li>


                                                    <li><a target="_blank" href="gateway.php?act=view_students_list_enter_scores&ses='. $session.'&sem=2&sid='.$sid.'&pid='.$pid.'&level=I" > Students (Enter Scores) </a></li>


																										<li><a target="_blank" href="gateway.php?act=view_students_reg&ses='. $session.'&sem=2&sid='.$sid.'&pid='.$pid.'&level=I" >Reg. Students </a></li>

                                                    </ul>
                                                  </div>';


                                                                                           echo '&nbsp&nbsp <div class="btn-group">
                                                    <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"> <i class="glyphicon glyphicon-print"></i>
                                                      Print <span class="caret"></span>
                                                    </button>
                                                    <ul class="dropdown-menu">

                                                      <li><a target="_blank" href="print_form_b2_per_semester.php?mis='.md5('mis').'&ses='. $session.'&sem=2&sid='.$sid.'&pid='.$pid.'&lvl=I" > FORM B2</a> </li>


                                                      <li><a target="_blank" href="print_form_a2_per_semester.php?mis='.md5('mis').'&ses='. $session.'&sem=2&sid='.$sid.'&pid='.$pid.'&lvl=I" > FORM A2 </a></li>

<li><a target="_blank" href="print_form_a2_per_semester_gse.php?mis='.md5('mis').'&ses='. $session.'&sem=2&sid='.$sid.'&pid='.$pid.'&lvl=I" > GSE FORM A </a></li>

                                                          <li><a target="_blank" href="print_form_a2_per_semester_edu.php?mis='.md5('mis').'&ses='. $session.'&sem=2&sid='.$sid.'&pid='.$pid.'&lvl=I" > EDU FORM A </a></li>


                                                          <li class="divider"></li>';

                                                      echo '<li><a target="_blank" href="print_form_a2_per_semester_core.php?mis='.md5('mis').'&ses='. $session.'&sem=2&sid='.$sid.'&pid='.$pid.'&did='.$first_debt.'&lvl=I&core=1" > '.$first_debt_code.' FORM A </a></li>';

                                                      if($second_debt !== '')
                                                      {
                                                         echo '<li><a target="_blank" href="print_form_a2_per_semester_core.php?mis='.md5('mis').'&ses='. $session.'&sem=2&sid='.$sid.'&pid='.$pid.'&did='.$second_debt.'&lvl=I&core=2" > '.$second_debt_code.' FORM A </a></li>';
                                                      }





                                                   echo
                                                   '</ul>
                                                  </div>';


                                                                                   ?>

                                                                                </div>



                                                                          </div>
                                                                        </div>
                                                                      </div>






                                                             </div> <!-- /.panel group -->





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

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

							</div>



				</div>





        </div> <!-- /view1 -->


      </div>
</div>

</form>
