<?php

ob_start();


//call the session start

session_start();

//collect action if ther is
if(isset($_REQUEST['act']))
{
	//collect the action
	$act = $_REQUEST['act'];
}




//collect quick links if there is
if(isset($_REQUEST['qlk']))
{
	//collect the quick link
	$encripted_qlk = $_REQUEST['qlk'];
}

//includes functions and classes
//include 'includes/functions.php';


//include functions
include ('includes/includes.php');




include_once 'includes/session_timer.php'; // call the session and cookie checkings





//include authenticator
include 'includes/auth.php';




//declare current page to be the base name
$currentPage = basename($_SERVER['SCRIPT_NAME']);


//get user id first
$user_id = get_user_id();

//echo $user_id;
  //get user olevel
  //if

/*  echo activate_olevel($session = 4);
  exit();*/

//when user have not applied for a change of course
if (!applicant_course_change_exist($user_id)) {

  //if olevel already uploaded
  if (applicant_olevel_exist($user_id)) {

    $qual =  check_applicant_qualified_status($user_id);

    if ($qual !== 1) {
    //validate and display suggestion
     validate_applicant_all_olevel($user_id);

    }else{

    }



  }else {



  }

//when already applied for a change of course
}else {

  $pg = get_user_programme_applied_for_change($user_id);

  $pg_title = get_programme_title($pg);
  $_SESSION['cs_change'] = '
                <ul class="list-group">
                  <li class="list-group-item list-group-item-info">
                      <h5>
                      <i class="glyphicon glyphicon-info-sign"></i>
                      <span class=""> You have applied for a change of Course to <b>'.$pg_title.'</b> Please be patient while it is being processed!</i>
                    </span>
                </ul>
              ';

}


//redirect accessed if the session / cookie was timed out
//redirect_asset($user_id);



?>

<body>


               <?php /*?>
                   <span class="label label-warning pull-right" > <i class="glyphicon glyphicon-info-sign"></i> last login:<?php echo  get_user_last_loggedout($user_id); ?>
                   </span>&nbsp;&nbsp;
                   <span class="label label-success pull-right"> <i class="glyphicon glyphicon-info-sign"></i> IP: <?php echo get_user_ip($user_id);?> </span>  &nbsp;&nbsp;
                 </div>
             <?php */?>

				<!-- header goes here -->
                <div id="header">

    					<?php include('includes/header.php');?>
                </div>

				<div style="height:4px;"></div>

<!-- container -->
          <div class="">




                <div class="col-md-12"><!-- col-md-12-->
                  <!-- profile menu -->
                    <div class="col-md-3">

                   	<?php include 'includes/php/get_student_info.php'; ?>

                  	</div><!-- col-md-3-->

                      <div class="col-md-2">


                      		<?php include 'includes/menu/menu.php'; ?>


                      <br>



                      </div><!-- col -md  - 2 ends -->
                      <div class="col-md-7">
                        <!-- notification layout -->
                        <div class="row">

                          <?php
														//commented on the 4th of July , 2019

														///no need for olevel clearance for the degeree the programmes
                            $clr_stats = get_applicant_olevel_clear_status($user_id);
                            $clr_res = get_applicant_clear_reason($user_id);
                            $tk = md5(rand(1,10000));
                            if($clr_stats == 1){
                              $msg = '<div class="alert alert-success"><h2>Olevel Clearance Status:</h2><br>
                                        <h4  class="alert-success">'.$clr_res.'</h4>

                                         <li class="list-group-item"><a class="btn btn-primary"  style="width:100%;" href="create_OL_clearance_slip.php?u='.$user_id.'&c='.$tk.'" data-toggle="tooltip" target="_blank" data-placement="top" data-original-title="Click here to print your OLevel Clearance Slip"><i class="glyphicon glyphicon-print"> </i> &nbsp; Click here to print your OLevel Clearance Slip</a></li>

                                      </div>';
                            }else{
                              if (applicant_olevel_exist($user_id)) {

                                if ($clr_res !=='') {
                                    $msg = '<div class="alert alert-danger"><h2>Olevel Clearance Status:</h2><br>
                                          <h4  class="alert-danger">'.$clr_res.'</h4>
                                        </div>';
                                }else{
                                  $msg = '<div class="alert alert-info"><h2>Olevel Clearance Status:</h2><br>
                                          <h4  class="alert-info">Kindly be patient while your Olevel Result(s) is/are been Verified and Cleared</h4>
                                        </div>';
                                }


                              }else{

                                 $msg = '<div class="alert alert-danger"><h2>Olevel Clearance Status:</h2><br>
                                          <h4  class="alert-danger">Please, Kindly Ensure that you Upload your Olevel Result(s)</h4>
                                        </div>';
                              }

                            }


                            //echo $msg;

                          ?>

                            <div style="height:5px; display:block;"> </div> <?php include 'includes/notifications.php';?></div> <!-- /notification -->

                      		<?php include 'includes/switch/switch_.php'; ?>

                      </div><!-- col -md  - 7 ends -->


                <!-- footer -->




            </div><!-- col-md-12-->



	</div>
    <!-- /container -->
    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->


    <?php include 'includes/js_plugins.php';?>






  </body>

	<!-- #########################plugins for the ric text editor############################################ -->
    <?php //include 'includes/jquery.rte.plugins.php';?>
    <!-- ##########################plugins for rich text editor################################### -->


    <!-- tracker -->
    <?php  //set_user_log($user_id, $act);?>









<!-- passport Modal -->
<div class="modal fade" id="myModall" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel">Upload your passport</h4>
      </div>
      <div class="modal-body">
			<div class="col-md-5" style="padding-right:0px">

			<form action="dashboard.php" method="post" enctype="multipart/form-data">
				<?php if(get_user_image($user_id) == ''){ ?>
				 <a href="#" class="btn btn-default" data-toggle="modal" data-target="#myModall"> <img class="thumbnail img-responsive text-center" style="height:170px;"  src="images/bg.jpg" ></img></a>

				<?php }else{ ?>
                       <a href="#" class="btn btn-default" data-toggle="modal" data-target="#myModall"> <img class="thumbnail img-responsive text-center" style="height:170px;"  src="../uploads/<?php echo get_user_image($user_id); ?>" alt="Click here to upload image"></img></a><!-- passed mymodall for upload -->


                <?php } ?>

				 <input type="file" name="image" />




		</center>
			</div>
			<div class="col-md-7" style="padding-left:0px">
				<div class="list-group">
				<div class="form-group">
					<div class="list-group">
					<div><h4 class="alert alert-danger">Instructions</h4></div>
						Your picture to be uploaded MUST conform with the following:<br/>

                        * Jpeg format ONLY<br/>
                        * Less than 30KB<br/>
                        * Exactly 150px by 150px<br/>
                        * Recent Photograph<br/>
                        * Of good quality<br/>
                        * Of plain white background<br/>
				</div>

				</div>
			</div>
      </div>
                <div class="modal-footer">
                 <button type="submit"  class="btn btn-success"  value="Upload Passport">Upload Passport</button>
                <button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>


               </div>

                  <input type="hidden" name="act" value="upload_image" />




            </form>



    </div>
  </div>
</div>
</div>
<!-------------------------------passport modal ------------------------------------------------------------------->




<!-- modal for applciation status s -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel">  &nbsp;Application Status</h4>
      </div>

         <?php //get admission status

        if(is_applicant_admitted($user_id)) //if admitted
      {
        ?>

      &nbsp;&nbsp;<h3 class="alert alert-info">Congratulations!.</h3>



                <?php

      }
      else
      {


     ?>

       &nbsp;&nbsp;<h4 class="alert alert-danger">You have NOT been offered Admission yet, please check back later.</h4>


    <?php

      }
      ?>



      <div class="modal-body">

      <?php //get admission status

        if(is_applicant_admitted($user_id)) //if admitted
      {
        ?>




              <h5> Dear Candidate, you have been offered admission into
                  <strong><?php echo strtoupper(show_programme_type(get_user_programme_type_admitted_to($user_id))); ?></strong>
                  programme to study <strong><?php echo strtoupper(get_programme_title(get_user_programme_admitted_to($user_id))); ?></strong> for
                  <strong><?php echo get_session_title(get_current_session($id = 1)); ?></strong> Academic Session.
              </h5>
              <h5>Registration & Screening will commence immediately to 15th Feb.2019.</h5>
              Signed: Management.
                <hr/>

                <ul class="list-group">


                   <li class="list-group-item"><a class="btn btn-danger"  style="width:100%;" href="create_application_letter.php?u=<?php echo $user_id;?>&c=<?php echo md5('EasyBrother'); ?>" data-toggle="tooltip" target="_blank" data-placement="top" data-original-title="Click here to print your Notification Letter"><i class="glyphicon glyphicon-print"> </i> &nbsp; Click here to print your Notification Letter</a></li>

                   <li class="list-group-item"><a class="btn btn-info"  style="width:100%;" href="dashboard.php?act=payments&qlk=<?php //echo $pf_qlk;?>" data-toggle="tooltip"  data-placement="top" data-original-title="Click here to start Registration"><i class="glyphicon glyphicon-ok"> </i> &nbsp; Click here to start Registration / Generate Invoice</a></li>
                  <!--  <li class="list-group-item"><a class="btn btn-danger"  style="width:100%;" href="#" data-toggle="tooltip" target="_blank" data-placement="top" data-original-title="Click here to print your Notification Letter"><i class="glyphicon glyphicon-print"> </i> &nbsp; Click here to print your Notification Letter</a></li>

                   <li class="list-group-item"><a class="btn btn-info"  style="width:100%;" href="#" data-toggle="tooltip"  data-placement="top" data-original-title="Click here to start Registration"><i class="glyphicon glyphicon-ok"> </i> &nbsp; Click here to start Registration / Generate Invoice</a></li> -->


                </ul>


                <?php

      }


     ?>





      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
       <!-- <button type="button" class="btn btn-success change_password" ></button>-->
      </div>


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


<!-- modal for applciation status s -->
<div class="modal fade" id="myOLevelModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel">  &nbsp;O-Level Result Screening</h4>
      </div>




      <div class="modal-body">

       &nbsp;&nbsp;<h4 class="alert alert-danger">O-Level Result Screening Date will be disclosed soon!</h4>

      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
       <!-- <button type="button" class="btn btn-success change_password" ></button>-->
      </div>


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

<!-- modal for course suggestion s -->
<div class="modal fade" id="myModalCourse" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header bg-warning">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title " id="myModalLabel">  &nbsp;Course Suggestion</h4>
      </div>




      <div class="modal-body">

        <?php

        //when user have already applied for a change of course
        if (applicant_course_change_exist($user_id)) {
            if (isset($_SESSION['course_sugg'])) {
                unset($_SESSION['course_sugg']);
            }

            if (isset($_SESSION['sugg_err'])) {
                unset($_SESSION['sugg_err']);
            }

            echo '<span class="hidden" id="cs_change" >'.$_SESSION['cs_change'].'</span>';
            echo  $_SESSION['cs_change'];

        }

        //hidden to be used with Jquery
        if (isset($_SESSION['course_sugg'])) {
            echo '<span class="hidden" id="course_sugg" >'.$_SESSION['course_sugg'].'</span>';
            unset($_SESSION['cs_change']);
         }

         if (isset($_SESSION['sugg_err'])) {
            echo '<span class="hidden" id="sugg_err" >'.$_SESSION['sugg_err'].'</span>';
             unset($_SESSION['cs_change']);
         }

         //displaying error
          if (isset($_SESSION['sugg_err'])) {

              echo '
                <ul class="list-group">
                  <li class="list-group-item list-group-item-danger">
                      <h5>
                      <i class="glyphicon glyphicon-info-sign"></i>
                      <i class=""> Sorry, you are <b>NOT</b> qualified for <b>'.$app_prog .'</b> Please check the Olevel submitted</i>
                    </li>
                </ul>
              ';

          }
          //print_r($_SESSION['cs_lists']);

          //when there is suggestion
          if (isset($_SESSION['cs_lists']) && ! empty($_SESSION['cs_lists'] && empty($_SESSION['cs_change'])) ) {

            $cs_arr = $_SESSION['cs_lists'];

          ?>

          <ul class="list-group">
              <li class="list-group-item list-group-item-info">
                  <h5>
                    <i class="glyphicon glyphicon-info-sign"></i>
                    <i class=""> Sorry, you are <b>NOT</b> qualified to apply for <b> <?php echo $app_prog; ?>.</b></i>
                     <i class="">But you are qualified to apply any of the under-listed courses</i><br>

                     <?php  echo list_course2( $cs_arr); ?>
                     <i class="list-group-item"> You are advised to kindly apply for a switch of course using the drop-down below. <b>Thank you</b></i>
                  </h5>
              </li>
          </ul>r

          <form method="POST" action="dashboard.php" enctype="multipart/form-data">

              <select class="form-control" name="course" id="sug_courses" required>
                <option value=""> Select Course </option>
                <?php



                  //displaying the courses
                  echo list_course($cs_arr);
                ?>
              </select>
            <input type="hidden" name="act" value="update_course" />


          <?php


          }


         ?>


      </div>
      <div class="modal-footer">
        <button type="submit"  class="btn btn-success hidden " id="change_cs" >Apply for Change of Course</button>

        <button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
       <!-- <button type="button" class="btn btn-success change_password" ></button>-->
      </div>

      </form>

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




<!-- transaction Modal -->
<div class="modal fade modal-lg" id="myModallTLOG" tabindex="-1" role="dialog" aria-labelledby="myModalLabelTLOG" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabelTLOG">View Transaction Log</h4>
      </div>



      <div class="modal-body">

        <?php echo view_remita_pay_transaction_log_min($user_id, $t_type = 0, $t_for= 0); ?>




      </div>





      <div class="modal-footer">
          <button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
      </div>






  </div>
</div>
</div>
<!---transaction modal ------------------------------------------------------------------->




<!-- transaction Modal for accceptance -->
<div class="modal fade modal-lg" id="myModallTLOG2" tabindex="-1" role="dialog" aria-labelledby="myModalLabelTLOG2" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabelTLOG">View Transaction Log</h4>
      </div>



      <div class="modal-body">

        <?php echo view_remita_pay_transaction_log_min($user_id, $t_type = 1, $t_for= 1); ?>




      </div>





      <div class="modal-footer">
          <button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
      </div>






  </div>
</div>
</div>
<!---transaction modal ------------------------------------------------------------------->


<!-- transaction Modal -->
<div class="modal fade modal-lg" id="myModalSchTLOG" tabindex="-1" role="dialog" aria-labelledby="myModalLabelTLOG" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabelTLOG">View Transaction Log</h4>
      </div>



      <div class="modal-body">

        <?php echo view_remita_pay_transaction_log_min_2($user_id, $t_type = 1, $t_for= 2); ?>




      </div>





      <div class="modal-footer">
          <button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
      </div>






  </div>
</div>
</div>
<!-- transaction modal - -->



<?php include 'includes/hide_notification.php'; ?>

<?php //ob_end_flush();?>
