<?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();


$dept_id = get_user_department_id($user_id);

$prog_id = get_user_programme_id($user_id);
$level = get_user_level($user_id);


// $pids  = '';
// $std_type = '';
// //$dept_id = 30;
// //checking either new special edu course or old
// if ($dept_id == 12 || $dept_id == 30) {
//
//   if ( $dept_id == 12) {
//     $pids = get_programme_ids( '%SED%',$type_id = 2, $mode = 1,$dept_idd = '= 12');
//
//      $std_type = 'sed';
//   }else if ( $dept_id == 30) {
//     $pids = get_programme_ids_bse( '%BSE%',$type_id = 2, $mode = 1,$dept_idd = '= 30');
//     $std_type = 'bse';
//
//   }
// }else{
//   /*if ( $dept_id != 12) {
//     $pids = get_programme_ids( '%SED%',$type_id = 2, $mode = 1,$dept_idd = '!= 12');
//
//   }
//
//   if ( $dept_id != 30) {
//
//       $pids = get_programme_ids_bse( '%BSE%',$type_id = 2, $mode = 1,$dept_idd = '!= 30');
//
//   }*/
// }
//
//
//
// //verify programme id presence
// $sed_std1 = false;
// $sed_std2 = false;
// if ($std_type == 'bse'){
//   $main_prog = 80;
//
//   $sed_std1 = true;
//   $sed_prog_id = get_user_sed_prog_id($user_id);  //get_user_sed_prog_id its to be used for sed programme but we are using same founction for Business Education
//   $prog_code = get_programme_code($main_prog);
//
// }elseif (!empty($pids) && in_array($prog_id, $pids)){
//     $sed_std2 = true;
//     $sed_prog_id = get_user_sed_prog_id($user_id);
//     $prog_code = get_programme_code($prog_id);
//
// }

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




<!-- signature Modal -->
<?php

/* <div class="modal fade" id="myModallSign" 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 Signature</h4>
      </div>
      <div class="modal-body">
      <div class="col-md-7" style="padding-right:0px">

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

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


                <?php } ?>

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




    </center>
      </div>
      <div class="col-md-5" 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 200px by 100px<br/>
                        * Signature must be with Black Ink<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 Signature">Upload Signature</button>
                <button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>


               </div>

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




            </form>



    </div>
  </div>
</div>
</div>
<!-------------------------------signature modal ------------------------------------------------------------------->
*/ ?>
<!-- Pdf Upload Modal -->
<div class="modal fade" id="myModall_pdf_upload" 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 credentials in Single PDF</h4>
      </div>
      <div class="modal-body">

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






                           <h4 class="alert alert-danger">Instructions</h4>
                               <div class="alert alert-danger">

                                    <p>

                                    Please scan all your required documents &
                                    credentials and convert all into a SINGLE PDF file of not more than 2 MB.
                                    The single pdf file with all the credentials should then be uploaded.

                                    </p>
                                  <br/>
                                    <p>
                                      Click on the choose file button to select your PDF .
                                      The uploaded PDF MUST conform with the following:
                                      <li>* Pdf format ONLY</li>
                                      <li>* Must be less than 2MB</li>
                                    </p>
                               </div>


                        <input    name="pdf_file" class="form-control" class="form-control" type="file" ></input>

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




                 </div>

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


               </div>

              </form>



    </div>
  </div>
</div>
</div>
<!------------------------------- pdf upload  modal ------------------------------------------------------------------->



<!-- modal for changing password 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"> <img src="images/change_password.png" /> &nbsp;Change Password</h4>
      </div>
      <div class="modal-body">
        <form>
          <div id="feedback_message" class="text-center text-success"></div><!-- feed back message if successful or not -->
          <div class="form-group">
            <label for="recipient-name" class="control-label">Old Password</label>
            <input type="password" class="form-control" id="old_password" name="old_password" required>
            <span class="error_msg_old_pw help-block text-danger"> This field cannot be blank</span>
          </div>


           <div class="form-group">
            <label for="recipient-name" class="control-label">New Password</label>
            <input type="password" class="form-control" id="new_password" name="new_password" required>
            <span class="error_msg_new_pw help-block text-danger"> This field cannot be blank</span>
          </div>

           <div class="form-group">
            <label for="recipient-name" class="control-label">Confirm New Password</label>
            <input type="password" class="form-control" id="confirm_new_password" id="confirm_new_password" required>

             <span class="error_msg_cm_pw help-block text-danger">Confirmed Password doesnt match</span>
          </div>

        </form>
      </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" >Update</button>
      </div>


      <div id="flash" class="label label-success pull-right"></div>
      <div style="height:20px;"></div>
    </div>
  </div>
</div>

<!-- modal for special edu courses -->
<?php /* ?>
<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;Special Education Programme Category</h4>
      </div>




      <div class="modal-body">

        <?php

        //this triggers the modal box
        if ($sed_std2 && isset($pids) && !empty($pids) && $sed_prog_id == 0 && $level != 'I') {

            echo '<span class="hidden" id="pid_change" >yes</span>';

            //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 ($dept_id != '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);

        }

          ?>

          <ul class="list-group">
              <li class="list-group-item list-group-item-info">
                  <h5>
                    <i class="glyphicon glyphicon-info-sign"></i>
                     <i class="">Please select a Special Education Programme Category Below</i><br>


                  </h5>
              </li>
          </ul>

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

              <select class="form-control" name="sed_prog" id="sed_prog" required>
                <option value=""> Select Programme </option>
                <?php



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


          <?php





         ?>


      </div>
      <div class="modal-footer">
        <button type="submit"  class="btn btn-success hidden " id="sed_prog_btn" >Save</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>



<!-- modal for business edu courses -->
<div class="modal fade" id="myModalCourse2" 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;Business Education Programme Category</h4>
      </div>




      <div class="modal-body">

        <?php

         //this triggers the modal box
        if ($sed_std1 && isset($pids) && !empty($pids) && $sed_prog_id == 0 && $level == 'III' ) {

            echo '<span class="hidden" id="pid_change2" >yes</span>';

            //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 = ['BEA','BES'];
            $prog_ids_arr = [];

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

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

                $prog_full_code = $prog_code_str1.'-'.$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 $prog_full_code;

        }

          ?>

          <ul class="list-group">
              <li class="list-group-item list-group-item-info">
                  <h5>
                    <i class="glyphicon glyphicon-info-sign"></i>
                     <i class="">Please select a Business Education Programme Category Below</i><br>


                  </h5>
              </li>
          </ul>

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

              <select class="form-control" name="bse_prog" id="bse_prog" required>
                <option value=""> Select Programme </option>
                <?php



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


          <?php





         ?>


      </div>
      <div class="modal-footer">
        <button type="submit"  class="btn btn-success hidden " id="bse_prog_btn" >Save</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>


<?php */ ?>

<!-- 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 = 2, $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();?>
