<br />
<br />
<script type="text/javascript">
  var type_id;
</script>

<section class="content-header">
            <h1>Allocated Students </h1>
            <ol class="breadcrumb">
                <li class="breadcrumb-item pt-1"><a href="dashboard"><i class="fa fa-fw fa-home"></i> Dashboard</a>
                </li>

            </ol>
        </section>
        <!-- Main content -->
        <section class="content p-l-r-15">
            <div class="row">
                <div class="col-12">
                    <div class="card border-primary ">
                        <div class="card-header text-white  bg-primary">
                            <h4 class="card-title d-inline">
                                <i class="fa fa-fw fa-News"></i> Students List
                            </h4>
                        </div>
                        <div class="card-body">
                          <div class="tab">
                            <button class="tablinks active" onclick="openCity(event, 'prence');setTypeID(1)">PRENCE</button>
                            <button class="tablinks" onclick="openCity(event, 'nce');setTypeID(2)">NCE</button>
                            <button class="tablinks" onclick="openCity(event, 'abu');setTypeID(3)">DUAP (ABU)</button>
                            <button class="tablinks" onclick="openCity(event, 'udus');setTypeID(4)">DUAP (UDUS)</button>
                            <button class="tablinks" onclick="openCity(event, 'summer');setTypeID(5)">SUMMER</button>
                            <button class="tablinks" onclick="openCity(event, 'lvsp');setTypeID(6) ">LVSP</button>
</div>

<div id="prence" class="tabcontent active">
  <h3>PRENCE STUDENTS LIST</h3>
  <p>
    <div class="table-responsive table-responisve-lg table-responsive-xl">
        <table class="table table-bordered" id="table1">
            <thead>
            <tr class="filters">
                <th width="5%"><a href="#" class="button button-3d button-primary button-rounded btn_3d" data-toggle="modal" data-target="#myModal">+
</a></th>


<th > NMAE </th>

<th >MATRIC NUMBER </th>

<th> PROGRAMME </th>

<th > PHONE NUMBER </th>
<th> HOSTEL </th>

<th > BLOCK </th>
<th > ROOM </th>


  <th>Status</th>
  <th>Actions</th>
            </tr>
            </thead>
            <tbody>
    <?php
    $sn=1;
    //get all the students
    $all_students = mysqli_query($conn_1,"SELECT *FROM hostel_allocation WHERE type_id='1' ");
    $num_rows=mysqli_num_rows($all_students);
    if($num_rows > 0){
    while($rows=mysqli_fetch_array($all_students)){
      $student_id = $rows['student_id'];
      $campus_id = $rows['campus_id'];
      $block_id = $rows['block_id'];
      $room_id = $rows['room_id'];
      $select="SELECT COUNT(id)
          FROM  students_prence WHERE id ='$student_id'
          ORDER BY students_prence.application_number ASC";
      $sql_select = mysqli_query($conn_1,$select);
      $num_rows=mysqli_num_rows($sql_select);
      if($num_rows > 0){
        
        while($row=mysqli_fetch_array($sql_select)){
          //get his room title
          $allocate = mysqli_query($conn_1, "SELECT  title FROM hostel_rooms WHERE id='$room_id' ") or die(mysqli_error($conn_1));
          $sql_room = mysqli_fetch_assoc($allocate);
          $Room_title = $sql_room['title'];

          //get his room title
          $allocate = mysqli_query($conn_1, "SELECT  title FROM hostel_campuses WHERE id='$campus_id' ") or die(mysqli_error($conn_1));
          $sql_site = mysqli_fetch_assoc($allocate);
          $Site_title = $sql_site['title'];

          //get his category title
          $allocate = mysqli_query($conn_1, "SELECT  title FROM hostel_blocks WHERE id='$block_id' ") or die(mysqli_error($conn_1));
          $sql_category = mysqli_fetch_assoc($allocate);
          $Cat_title = $sql_category['title'];

          //get students details
          $allocate = mysqli_query($conn_1, "SELECT  CONCAT_WS(' ', first_name, middle_name, other_names) as name,
          gender, id, programme_type_applied_for, department_id,
          number, programme_id, application_number,
             state_id, lga_id,  phone_no, gender,  email,
              DATE_FORMAT(date_added, '%M %d, %Y %l:%i:%p') as date_added
              FROM  students_prence WHERE id ='$student_id'
              ORDER BY students_prence.application_number ASC ") or die(mysqli_error($conn_1));
          $row = mysqli_fetch_assoc($allocate);


          $student_id=$row['id'];
          $name=$row['name'];
          $matric_number=$row['number'];
          $email=$row['email'];
          $programme_id=$row['programme_id'];
          $gender=$row['gender'];
          $phone_contacts=$row['phone_no'];
          $date_added=$row['date_added'];
          $faculty_status=$row['department_id'];

          $status='Active';


          echo $tr = '<tr>
          <td><center>'.$sn.'</center></td>
          <td>'.$name.'</td>
          <td>'.$matric_number.'</td>
          <td>'.get_programmes_by_id($conn_1,$programme_id).'</td>
          <td>'.$phone_contacts.'</td>
          <td>'.$Site_title.'</td>
          <td>'.$Cat_title.'</td>
          <td>'.$Room_title.'</td>
          <td>'.$status.'</td>



                <td><a href="#" class="edit_faculty" id="'.$student_id.'"><i
                    class="fa fa-fw fa-pencil text-primary actions_icon " title="Edit Faculty"></i></a>
                    <a
                    href="#"
                    id="'.$student_id.'"
                    data-toggle="modal"

                    class="delete_qualified"
                    ><i
                    class="fa fa-fw fa-times text-danger actions_icon" title="Delete Faculty"></i>
                </a></td>

              </tr>';
              $sn++;

        }
      }
    }
  }else{
    echo "<td colspan='10'>no records to display</td>";
  }
    ?>
  </tbody>
</table>

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

<div id="nce" class="tabcontent">
  <h3>NCE STUDENTS LIST</h3>
  <p>
    <div class="table-responsive table-responisve-lg table-responsive-xl">
        <table class="table table-bordered" id="table">
            <thead>
            <tr class="filters">
                <th width="5%"><a href="#" class="button button-3d button-primary button-rounded btn_3d" data-toggle="modal" data-target="#myModal">+
</a></th>


<th > NMAE </th>

<th >MATRIC NUMBER </th>

<th> PROGRAMME </th>

<th > PHONE NUMBER </th>
<th> HOSTEL </th>

<th > BLOCK </th>
<th > ROOM </th>


  <th>Status</th>
  <th>Actions</th>
            </tr>
            </thead>
            <tbody>
    <?php
    $sn=1;
    //get all the students
    $all_students = mysqli_query($conn_1,"SELECT *FROM hostel_allocation WHERE type_id='2' ");
    $num_rows=mysqli_num_rows($all_students);
    if($num_rows > 0){
      
    while($rows=mysqli_fetch_array($all_students)){

      $student_id = $rows['student_id'];
      $campus_id = $rows['campus_id'];
      $block_id = $rows['block_id'];
      $room_id = $rows['room_id'];
      $select="SELECT COUNT(id)
          FROM  students_nce WHERE id = $student_id
          ORDER BY students_nce.id ASC";
          $sql_select = mysqli_query($conn_1,$select);
      //$num_rows=mysqli_num_rows($sql_select);
      if(mysqli_num_rows($sql_select) > 0){

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


          //get his room title
          $allocate = mysqli_query($conn_1, "SELECT  title FROM hostel_rooms WHERE id='$room_id' ") or die(mysqli_error($conn_1));
          $sql_room = mysqli_fetch_assoc($allocate);
          $Room_title = $sql_room['title'];

          //get his room title
          $allocate = mysqli_query($conn_1, "SELECT  title FROM hostel_campuses WHERE id='$campus_id' ") or die(mysqli_error($conn_1));
          $sql_site = mysqli_fetch_assoc($allocate);
          $Site_title = $sql_site['title'];

          //get his category title
          $allocate = mysqli_query($conn_1, "SELECT  title FROM hostel_blocks WHERE id='$block_id' ") or die(mysqli_error($conn_1));
          $sql_category = mysqli_fetch_assoc($allocate);
          $Cat_title = $sql_category['title'];

          //get students details
          $allocate = mysqli_query($conn_1, "SELECT  CONCAT_WS(' ', first_name, middle_name, other_names) as name,
          gender, id, programme_type_applied_for, department_id,
          number, programme_id, application_number,
             state_id, lga_id,  phone_no, gender,  email,
              DATE_FORMAT(date_added, '%M %d, %Y %l:%i:%p') as date_added
              FROM  students_nce WHERE id ='$student_id'
              ORDER BY students_nce.application_number ASC ") or die(mysqli_error($conn_1));
          $row = mysqli_fetch_assoc($allocate);


          $student_id=$row['id'];
          $name=$row['name'];
          $matric_number=$row['number'];
          $email=$row['email'];
          $programme_id=$row['programme_id'];
          $gender=$row['gender'];
          $phone_contacts=$row['phone_no'];
          $date_added=$row['date_added'];
          $faculty_status=$row['department_id'];

          $status='Active';


          echo $tr = '<tr>
          <td><center>'.$sn.'</center></td>
          <td>'.$name.'</td>
          <td>'.$matric_number.'</td>
          <td>'.get_programmes_by_id($conn_1,$programme_id).'</td>
          <td>'.$phone_contacts.'</td>
          <td>'.$Site_title.'</td>
          <td>'.$Cat_title.'</td>
          <td>'.$Room_title.'</td>
          <td>'.$status.'</td>



                <td><a href="#" class="edit_qualified" id="'.$student_id.'"><i
                    class="fa fa-fw fa-pencil text-primary actions_icon " title="Edit Allocation"></i></a>
                    <a
                    href="#"
                    id="'.$student_id.'"
                    data-toggle="modal"

                    class="delete_qualified"
                    ><i
                    class="fa fa-fw fa-times text-danger actions_icon" title="Delete Faculty"></i>
                </a></td>

              </tr>';
              $sn++;

        }
      }
    }
  }else{
    echo "<td colspan='10'>no records to display</td>";
  }
    ?>
  </tbody>
</table>

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

<div id="abu" class="tabcontent">
  <h3>DUAP (ABU) STUDENTS LIST</h3>
  <p>
    <div class="table-responsive table-responisve-lg table-responsive-xl">
        <table class="table table-bordered" id="table">
            <thead>
            <tr class="filters">
                <th width="5%"><a href="#" class="button button-3d button-primary button-rounded btn_3d" data-toggle="modal" data-target="#myModal">+
</a></th>


<th > NMAE </th>

<th >MATRIC NUMBER </th>

<th> PROGRAMME </th>

<th > PHONE NUMBER </th>
<th> HOSTEL </th>

<th > BLOCK </th>
<th > ROOM </th>


  <th>Status</th>
  <th>Actions</th>
            </tr>
            </thead>
            <tbody>
    <?php
    $sn=1;
    //get all the students
    $all_students = mysqli_query($conn_1,"SELECT *FROM hostel_allocation WHERE type_id='3' ");
    $num_rows=mysqli_num_rows($all_students);
    if($num_rows > 0){
    while($rows=mysqli_fetch_array($all_students)){
      $student_id = $rows['student_id'];
      $campus_id = $rows['campus_id'];
      $block_id = $rows['block_id'];
      $room_id = $rows['room_id'];
      $select="SELECT COUNT(id)
          FROM  students_nce WHERE id ='$student_id'
          ORDER BY students_nce.application_number ASC";
      $sql_select = mysqli_query($conn_2,$select);
      $num_rows=mysqli_num_rows($sql_select);
      if($num_rows > 0){
       
        while($row=mysqli_fetch_array($sql_select)){
          //get his room title
          $allocate = mysqli_query($conn_1, "SELECT  title FROM hostel_rooms WHERE id='$room_id' ") or die(mysqli_error($conn_1));
          $sql_room = mysqli_fetch_assoc($allocate);
          $Room_title = $sql_room['title'];

          //get his room title
          $allocate = mysqli_query($conn_1, "SELECT  title FROM hostel_campuses WHERE id='$campus_id' ") or die(mysqli_error($conn_1));
          $sql_site = mysqli_fetch_assoc($allocate);
          $Site_title = $sql_site['title'];

          //get his category title
          $allocate = mysqli_query($conn_1, "SELECT  title FROM hostel_blocks WHERE id='$block_id' ") or die(mysqli_error($conn_1));
          $sql_category = mysqli_fetch_assoc($allocate);
          $Cat_title = $sql_category['title'];

          //get students details
          $allocate = mysqli_query($conn_2, "SELECT  CONCAT_WS(' ', first_name, middle_name, other_names) as name,
          gender, id, programme_type_applied_for, department_id,
          number, programme_id, application_number,
             state_id, lga_id,  phone_no, gender,  email,
              DATE_FORMAT(date_added, '%M %d, %Y %l:%i:%p') as date_added
              FROM  students_nce WHERE id ='$student_id'
              ORDER BY students_nce.application_number ASC ") or die(mysqli_error($conn_1));
          $row = mysqli_fetch_assoc($allocate);


          $student_id=$row['id'];
          $name=$row['name'];
          $matric_number=$row['number'];
          $email=$row['email'];
          $programme_id=$row['programme_id'];
          $gender=$row['gender'];
          $phone_contacts=$row['phone_no'];
          $date_added=$row['date_added'];
          $faculty_status=$row['department_id'];

          $status='Active';


          echo $tr = '<tr>
          <td><center>'.$sn.'</center></td>
          <td>'.$name.'</td>
          <td>'.$matric_number.'</td>
          <td>'.get_programmes_by_id_duap($conn_2,$programme_id).'</td>
          <td>'.$phone_contacts.'</td>
          <td>'.$Site_title.'</td>
          <td>'.$Cat_title.'</td>
          <td>'.$Room_title.'</td>
          <td>'.$status.'</td>



                <td><a href="#" class="edit_qualified" id="'.$student_id.'"><i
                    class="fa fa-fw fa-pencil text-primary actions_icon " title="Edit Allocation"></i></a>
                    <a
                    href="#"
                    id="'.$student_id.'"
                    data-toggle="modal"

                    class="delete_qualified"
                    ><i
                    class="fa fa-fw fa-times text-danger actions_icon" title="Delete Faculty"></i>
                </a></td>

              </tr>';
              $sn++;

        }
      }
    }
  }else{
    echo "<td colspan='10'>no records to display</td>";
  }
    ?>
  </tbody>
</table>

</div>
  </p>
</div>
<div id="udus" class="tabcontent">
  <h3>DUAP (UDUS) STUDENTS LIST</h3>
  <p>
    <div class="table-responsive table-responisve-lg table-responsive-xl">
        <table class="table table-bordered" id="table">
            <thead>
            <tr class="filters">
                <th width="5%"><a href="#" class="button button-3d button-primary button-rounded btn_3d" data-toggle="modal" data-target="#myModal">+
</a></th>


<th > NMAE </th>

<th >MATRIC NUMBER </th>

<th> PROGRAMME </th>

<th > PHONE NUMBER </th>
<th> HOSTEL </th>

<th > BLOCK </th>
<th > ROOM </th>


  <th>Status</th>
  <th>Actions</th>
            </tr>
            </thead>
            <tbody>
    <?php
    $sn=1;
    //get all the students
    $all_students = mysqli_query($conn_1,"SELECT *FROM hostel_allocation WHERE type_id='4' ");
    $num_rows=mysqli_num_rows($all_students);
    if($num_rows > 0){
    while($rows=mysqli_fetch_array($all_students)){
      $student_id = $rows['student_id'];
      $campus_id = $rows['campus_id'];
      $block_id = $rows['block_id'];
      $room_id = $rows['room_id'];
      $select="SELECT COUNT(id)
          FROM  students_nce WHERE id ='$student_id'
          ORDER BY students_nce.application_number ASC";
      $sql_select = mysqli_query($conn_2,$select);
      $num_rows=mysqli_num_rows($sql_select);
      if($num_rows > 0){
        
        while($row=mysqli_fetch_array($sql_select)){
          //get his room title
          $allocate = mysqli_query($conn_1, "SELECT  title FROM hostel_rooms WHERE id='$room_id' ") or die(mysqli_error($conn_1));
          $sql_room = mysqli_fetch_assoc($allocate);
          $Room_title = $sql_room['title'];

          //get his room title
          $allocate = mysqli_query($conn_1, "SELECT  title FROM hostel_campuses WHERE id='$campus_id' ") or die(mysqli_error($conn_1));
          $sql_site = mysqli_fetch_assoc($allocate);
          $Site_title = $sql_site['title'];

          //get his category title
          $allocate = mysqli_query($conn_1, "SELECT  title FROM hostel_blocks WHERE id='$block_id' ") or die(mysqli_error($conn_1));
          $sql_category = mysqli_fetch_assoc($allocate);
          $Cat_title = $sql_category['title'];

          //get students details
          $allocate = mysqli_query($conn_2, "SELECT  CONCAT_WS(' ', first_name, middle_name, other_names) as name,
          gender, id, programme_type_applied_for, department_applied_for,
          number, programme_applied_for, application_number,
             state_id, lga_id,  phone_no, gender,  email,
              DATE_FORMAT(date_added, '%M %d, %Y %l:%i:%p') as date_added
              FROM  students_udus WHERE id ='$student_id'
              ORDER BY students_udus.number ASC ") or die(mysqli_error($conn_1));
          $row = mysqli_fetch_assoc($allocate);


          $student_id=$row['id'];
          $name=$row['name'];
          $matric_number=$row['number'];
          $email=$row['email'];
          $programme_id=$row['programme_applied_for'];
          $gender=$row['gender'];
          $phone_contacts=$row['phone_no'];
          $date_added=$row['date_added'];
          $faculty_status=$row['department_applied_for'];

          $status='Active';


          echo $tr = '<tr>
          <td><center>'.$sn.'</center></td>
          <td>'.$name.'</td>
          <td>'.$matric_number.'</td>
          <td>'.get_programmes_by_id_duap($conn_2,$programme_id).'</td>
          <td>'.$phone_contacts.'</td>
          <td>'.$Site_title.'</td>
          <td>'.$Cat_title.'</td>
          <td>'.$Room_title.'</td>
          <td>'.$status.'</td>



                <td><a href="#" class="edit_qualified" id="'.$student_id.'"><i
                    class="fa fa-fw fa-pencil text-primary actions_icon " title="Edit Allocation"></i></a>
                    <a
                    href="#"
                    id="'.$student_id.'"
                    data-toggle="modal"

                    class="delete_qualified"
                    ><i
                    class="fa fa-fw fa-times text-danger actions_icon" title="Delete Faculty"></i>
                </a></td>

              </tr>';
              $sn++;

        }
      }
    }
  }else{
    echo "<td colspan='10'>no records to display</td>";
  }
    ?>
  </tbody>
</table>

</div>
  </p>
</div>
<div id="summer" class="tabcontent">
  <h3>SUMMER STUDENTS LIST</h3>
  <p>
    <div class="table-responsive table-responisve-lg table-responsive-xl">
        <table class="table table-bordered" id="table">
            <thead>
            <tr class="filters">
                <th width="5%"><a href="#" class="button button-3d button-primary button-rounded btn_3d" data-toggle="modal" data-target="#myModal">+
</a></th>


<th > NMAE </th>

<th >MATRIC NUMBER </th>

<th> PROGRAMME </th>

<th > PHONE NUMBER </th>
<th> HOSTEL </th>

<th > BLOCK </th>
<th > ROOM </th>


  <th>Status</th>
  <th>Actions</th>
            </tr>
            </thead>
            <tbody>
    <?php
    $sn=1;
    //get all the students
    $all_students = mysqli_query($conn_1,"SELECT *FROM hostel_allocation WHERE type_id='5' ");
    $num_rows=mysqli_num_rows($all_students);
    if($num_rows > 0){
    while($rows=mysqli_fetch_array($all_students)){
      $student_id = $rows['student_id'];
      $campus_id = $rows['campus_id'];
      $block_id = $rows['block_id'];
      $room_id = $rows['room_id'];
      $select="SELECT COUNT(id)
          FROM  summer_students WHERE id ='$student_id'
          ORDER BY summer_students.application_number ASC";
      $sql_select = mysqli_query($conn_1,$select);
      $num_rows=mysqli_num_rows($sql_select);
      if($num_rows > 0){
       
        while($row=mysqli_fetch_array($sql_select)){
          //get his room title
          $allocate = mysqli_query($conn_1, "SELECT  title FROM hostel_rooms WHERE id='$room_id' ") or die(mysqli_error($conn_1));
          $sql_room = mysqli_fetch_assoc($allocate);
          $Room_title = $sql_room['title'];

          //get his room title
          $allocate = mysqli_query($conn_1, "SELECT  title FROM hostel_campuses WHERE id='$campus_id' ") or die(mysqli_error($conn_1));
          $sql_site = mysqli_fetch_assoc($allocate);
          $Site_title = $sql_site['title'];

          //get his category title
          $allocate = mysqli_query($conn_1, "SELECT  title FROM hostel_blocks WHERE id='$block_id' ") or die(mysqli_error($conn_1));
          $sql_category = mysqli_fetch_assoc($allocate);
          $Cat_title = $sql_category['title'];

          //get students details
          $allocate = mysqli_query($conn_1, "SELECT  CONCAT_WS(' ', first_name, middle_name, other_names) as name,
          gender, id, programme_type_applied_for, department_id,
          number, programme_id, application_number,
             state_id, lga_id,  phone_no, gender,  email,
              DATE_FORMAT(date_added, '%M %d, %Y %l:%i:%p') as date_added
              FROM  summer_students WHERE id ='$student_id'
              ORDER BY summer_students.application_number ASC ") or die(mysqli_error($conn_1));
          $row = mysqli_fetch_assoc($allocate);


          $student_id=$row['id'];
          $name=$row['name'];
          $matric_number=$row['number'];
          $email=$row['email'];
          $programme_id=$row['programme_id'];
          $gender=$row['gender'];
          $phone_contacts=$row['phone_no'];
          $date_added=$row['date_added'];
          $faculty_status=$row['department_id'];

          $status='Active';


          echo $tr = '<tr>
          <td><center>'.$sn.'</center></td>
          <td>'.$name.'</td>
          <td>'.$matric_number.'</td>
          <td>'.get_programmes_by_id($conn_1,$programme_id).'</td>
          <td>'.$phone_contacts.'</td>
          <td>'.$Site_title.'</td>
          <td>'.$Cat_title.'</td>
          <td>'.$Room_title.'</td>
          <td>'.$status.'</td>



                <td><a href="#" class="edit_qualified" id="'.$student_id.'"><i
                    class="fa fa-fw fa-pencil text-primary actions_icon " title="Edit Allocation"></i></a>
                    <a
                    href="#"
                    id="'.$student_id.'"
                    data-toggle="modal"

                    class="delete_qualified"
                    ><i
                    class="fa fa-fw fa-times text-danger actions_icon" title="Delete Faculty"></i>
                </a></td>

              </tr>';
              $sn++;

        }
      }
    }
  }else{
    echo "<td colspan='10'>no records to display</td>";
  }
    ?>
  </tbody>
</table>

</div>
  </p>
</div>
<div id="lvsp" class="tabcontent">
  <h3>LVSP STUDENTS LIST</h3>
  <p>
    <div class="table-responsive table-responisve-lg table-responsive-xl">
        <table class="table table-bordered" id="table">
            <thead>
            <tr class="filters">
                <th width="5%"><a href="#" class="button button-3d button-primary button-rounded btn_3d" data-toggle="modal" data-target="#myModal">+
</a></th>


<th > NMAE </th>

<th >MATRIC NUMBER </th>

<th> PROGRAMME </th>

<th > PHONE NUMBER </th>
<th> HOSTEL </th>

<th > BLOCK </th>
<th > ROOM </th>


  <th>Status</th>
  <th>Actions</th>
            </tr>
            </thead>
            <tbody>
    <?php
    $sn=1;
    //get all the students
    $all_students = mysqli_query($conn_1,"SELECT *FROM hostel_allocation WHERE type_id='6' ");
    $num_rows=mysqli_num_rows($all_students);
    if($num_rows > 0){
    while($rows=mysqli_fetch_array($all_students)){
      $student_id = $rows['student_id'];
      $campus_id = $rows['campus_id'];
      $block_id = $rows['block_id'];
      $room_id = $rows['room_id'];
      $select="SELECT COUNT(id)
          FROM  summer_students WHERE id ='$student_id'
          ORDER BY summer_students.application_number ASC";
      $sql_select = mysqli_query($conn_1,$select);
      $num_rows=mysqli_num_rows($sql_select);
      if($num_rows > 0){
        
        while($row=mysqli_fetch_array($sql_select)){
          //get his room title
          $allocate = mysqli_query($conn_1, "SELECT  title FROM hostel_rooms WHERE id='$room_id' ") or die(mysqli_error($conn_1));
          $sql_room = mysqli_fetch_assoc($allocate);
          $Room_title = $sql_room['title'];

          //get his room title
          $allocate = mysqli_query($conn_1, "SELECT  title FROM hostel_campuses WHERE id='$campus_id' ") or die(mysqli_error($conn_1));
          $sql_site = mysqli_fetch_assoc($allocate);
          $Site_title = $sql_site['title'];

          //get his category title
          $allocate = mysqli_query($conn_1, "SELECT  title FROM hostel_blocks WHERE id='$block_id' ") or die(mysqli_error($conn_1));
          $sql_category = mysqli_fetch_assoc($allocate);
          $Cat_title = $sql_category['title'];

          //get students details
          $allocate = mysqli_query($conn_1, "SELECT  CONCAT_WS(' ', first_name, middle_name, other_names) as name,
          gender, id, programme_type_applied_for, department_id,
          number, programme_id, application_number,
             state_id, lga_id,  phone_no, gender,  email,
              DATE_FORMAT(date_added, '%M %d, %Y %l:%i:%p') as date_added
              FROM  summer_students WHERE id ='$student_id'
              ORDER BY summer_students.application_number ASC ") or die(mysqli_error($conn_1));
          $row = mysqli_fetch_assoc($allocate);


          $student_id=$row['id'];
          $name=$row['name'];
          $matric_number=$row['number'];
          $email=$row['email'];
          $programme_id=$row['programme_id'];
          $gender=$row['gender'];
          $phone_contacts=$row['phone_no'];
          $date_added=$row['date_added'];
          $faculty_status=$row['department_id'];

          $status='Active';


          echo $tr = '<tr>
          <td><center>'.$sn.'</center></td>
          <td>'.$name.'</td>
          <td>'.$matric_number.'</td>
          <td>'.get_programmes_by_id($conn_1,$programme_id).'</td>
          <td>'.$phone_contacts.'</td>
          <td>'.$Site_title.'</td>
          <td>'.$Cat_title.'</td>
          <td>'.$Room_title.'</td>
          <td>'.$status.'</td>



                <td><a href="#" class="edit_qualified" id="'.$student_id.'"><i
                    class="fa fa-fw fa-pencil text-primary actions_icon " title="Edit Allocation"></i></a>
                    <a
                    href="#"
                    id="'.$student_id.'"
                    data-toggle="modal"

                    class="delete_qualified"
                    ><i
                    class="fa fa-fw fa-times text-danger actions_icon" title="Delete Faculty"></i>
                </a></td>

              </tr>';
              $sn++;

        }
      }
    }
  }else{
    echo "<td colspan='10'>no records to display</td>";
  }
    ?>
  </tbody>
</table>

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

                        </div>
                    </div>
                </div>
                <div class="modal fade" id="delete" tabindex="-1" role="dialog" aria-labelledby="Heading"
                     aria-hidden="true">
                    <div class="modal-dialog">
                        <div class="modal-content">
                            <div class="modal-header">
                                <h4 class="modal-title custom_align" id="Heading">Revoke Allocation</h4>
                                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                            </div>
                            <div class="modal-body">
                                <div class="alert alert-warning">
                                    <span class="fa fa-exclamation-triangle"></span> Are you sure you want to
                                    Revoke this Allocation?
                                </div>
                            </div>
                            <div class="modal-footer" id="delete_footer">

                            </div>
                        </div>
                        <!-- /.modal-content -->
                    </div>
                </div>

				<div class="modal fade" id="edit_faculty" tabindex="-1" role="dialog" aria-labelledby="Heading"
                     aria-hidden="true">
                    <div class="modal-dialog">
                        <div class="modal-content">
                            <div class="modal-header">
                                <h4 class="modal-title custom_align" id="Heading">Edit Allocation</h4>
                                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                            </div>
                            <div class="modal-body">
                                <div class="alert alert-warning">
                                    <span class="fa fa-exclamation-triangle"></span> Are you sure you want to
                                    edit this Allocation ?
                                </div>
                            </div>
                            <div class="modal-footer" id="edit_footer">

                            </div>
                        </div>
                        <!-- /.modal-content -->
                    </div>
                </div>


            </div>
            <!-- row-->

        </section>

 <!-- The Modal -->
  <div class="modal fade" id="myModal">
    <div class="modal-dialog modal-lg">
      <div class="modal-content">

        <!-- Modal Header -->
        <div class="modal-header">
          <h2 class="modal-title"><span class="badge badge-pill badge-danger"> ADD STUDENT </span></h2>
          <button type="button" class="close" data-dismiss="modal">&times;</button>
        </div>

        <!-- Modal body -->
        <div class="modal-body">
          <div class="alert alert-warning">
              <span class="fa fa-exclamation-triangle"></span> You can't Add Student from Here!
          </div>


        </div>

        <!-- Modal footer -->
        <div class="modal-footer">
			<center>
				<div id="output_error">

				</div>
			</center>

        </div>

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



<div class="modal fade" id="edit_loading" tabindex="-1" role="dialog" aria-labelledby="Heading"
                     aria-hidden="true">
                    <div class="modal-dialog">
                        <div class="modal-content">
                            <div class="modal-header">
                                <h2 class="modal-title custom_align" id="Heading"> <span class="badge badge-pill badge-danger"> Edit Allocation </span> </h2>
                                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                            </div>
                            <div class="modal-body" id="edit_modal_body">
							<form method="POST" id="edit_form_faculty" >

							</form>

                            </div>
                            <div class="modal-footer" id="edit_footer">

                            </div>
                        </div>
                        <!-- /.modal-content -->
                    </div>
                </div>
                <style>
                body {font-family: Arial;}

                /* Style the tab */
                .tab {
                  overflow: hidden;
                  border: 1px solid #ccc;
                  background-color: #f1f1f1;
                }

                /* Style the buttons inside the tab */
                .tab button {
                  background-color: inherit;
                  float: left;
                  border: none;
                  outline: none;
                  cursor: pointer;
                  padding: 14px 16px;
                  transition: 0.3s;
                  font-size: 17px;
                }

                /* Change background color of buttons on hover */
                .tab button:hover {
                  background-color: #ddd;
                }

                /* Create an active/current tablink class */
                .tab button.active {
                  background-color: #ccc;
                }

                /* Style the tab content */
                .tabcontent {
                  display: none;
                  padding: 6px 12px;
                  border: 1px solid #ccc;
                  border-top: none;
                }
                </style>
<script type="text/javascript">
var type_id;
function setTypeID(id)
{
  type_id = id;
  //alert(type_id);
}
 function load_edit_faculty(token){
//var id = type_id;
  //alert(type_id);
			$('#edit_faculty').modal('hide');
			$('#edit_loading').modal('show');

			document.getElementById("edit_form_faculty").innerHTML ='<div style="margin-top:10px"><center>loading Data, please wait...<br/><img src="images/ajax-loader1.gif" width="10%"/></center></div>';

			$.post('hub/php/load_edit_qualified.php',{token:token,type_id:type_id},
			function(response,status){

			document.getElementById("edit_form_faculty").innerHTML =response;

			});
}


$(document).ready(function(e){



		$("#form_faculty").submit(function(event){
			event.preventDefault(); //prevent default action
			var post_url = "hub/php/add_faculty.php"; //get form action url
			var request_method = $(this).attr("method"); //get form GET/POST method

			$("#output_error").html('<div style="margin-top:10px"><center>login, please wait...<br/><img src="images/ajax-loader1.gif" width="20%"/></center></div>');
			document.getElementById("button").style.display = "none";
			var form_data = new FormData(this); //Creates new FormData object


				$.ajax({
					url : post_url,
					type: request_method,
					data : form_data,
					contentType: false,
					cache: false,
					processData:false
				}).done(function(response){ //

					if(response==1){

						$('#form_faculty')[0].reset();
						swal("Faculty saved successfully");
						document.getElementById("button").style.display = "block";
						$("#output_error").html("");
						links();

					}else{

					$("#output_error").html(response);
					document.getElementById("button").style.display = "block";

					}
				});

		});




    $("#edit_form_faculty").submit(function(event){

      event.preventDefault(); //prevent default action
      var post_url = "hub/php/edit_allocate.php"; //get form action url
      var request_method = $(this).attr("method"); //get form GET/POST method

      $("#output_error_edit").html('<div style="margin-top:10px"><center>login, please wait...<br/><img src="images/ajax-loader1.gif" width="20%"/></center></div>');
      document.getElementById("button_edit").style.display = "none";
      var form_data = new FormData(this); //Creates new FormData object


        $.ajax({
          url : post_url,
          type: request_method,
          data : form_data,
          contentType: false,
          cache: false,
          processData:false
        }).done(function(response){ //

          if(response==1){

            $('#edit_form_faculty')[0].reset();
            swal("Allocation edited Successfully");
            document.getElementById("button_edit").style.display = "block";
            $("#output_error_edit").html("");
            links();

          }else{

          $("#output_error_edit").html(response);
          document.getElementById("button_edit").style.display = "block";

          }
        });

    });







    // load delete faculty modal
    $(document).on('click','.delete_qualified',function(){
      var token=$(this).attr("id");
      $('#delete').modal('show');
      document.getElementById("delete_footer").innerHTML ='<a href="#" class="btn btn-danger" onclick="delete_faculty('+token+')"><span class="fa fa-check"></span> Yes</a><button type="button" class="btn btn-success" data-dismiss="modal"><span class="fa fa-close"></span> No</button>';


    });
    // delete faculty end

    // load edit faculty start modal
    $(document).on('click','.edit_qualified',function(){
      var token=$(this).attr("id");
      $('#edit_faculty').modal('show');
      document.getElementById("edit_footer").innerHTML ='<a href="#" class="btn btn-danger" onclick="load_edit_faculty('+token+')"><span class="fa fa-check"></span> Yes</a><button type="button" class="btn btn-success" data-dismiss="modal"><span class="fa fa-close"></span> No</button>';


    });
    // edit faculty end




});

function links(){
  location.reload();
 }


  function delete_faculty(token){
      //alert(token);
      $.post("hub/php/revoke_allocation.php",{token:token},
      function(response,status){

        if(response == 1 ){
          $('#delete').modal('hide');

            swal("Allocation Revoked");
            links();


        }else{
          swal(response);
        }


      });
 }





function load_block(){




  var campus_id = document.getElementById("campus_id").value;
  var gender = document.getElementById("gender").value;


$.post('hub/php/load_block.php',{campus_id:campus_id,gender:gender},
function(response,status){

document.getElementById("block_id").innerHTML =response;

});
}

function load_room(){




  var block_id = document.getElementById("block_id").value;
//alert(block_id);


$.post('hub/php/load_room.php',{block_id:block_id},
function(response,status){

document.getElementById("room_id").innerHTML =response;

});
}

function openCity(evt, cityName) {
  var i, tabcontent, tablinks;
  tabcontent = document.getElementsByClassName("tabcontent");
  for (i = 0; i < tabcontent.length; i++) {
    tabcontent[i].style.display = "none";
  }
  tablinks = document.getElementsByClassName("tablinks");
  for (i = 0; i < tablinks.length; i++) {
    tablinks[i].className = tablinks[i].className.replace(" active", "");
  }
  document.getElementById(cityName).style.display = "block";
  evt.currentTarget.className += " active";
}
</script>
