<br />
<br />
<section class="content-header">
            <h1>Applicants Listing </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> Applicants List
                            </h4>
                        </div>
                        <div class="card-body">

                          <div class="tab">
  <button class="tablinks active" onclick="openCity(event, 'prence')">PRENCE</button>
  <button class="tablinks" onclick="openCity(event, 'nce')">NCE</button>
  <button class="tablinks" onclick="openCity(event, 'abu')">DUAP (ABU)</button>
  <button class="tablinks" onclick="openCity(event, 'udus')">DUAP (UDUS)</button>
  <button class="tablinks" onclick="openCity(event, 'summer')">SUMMER</button>
  <button class="tablinks" onclick="openCity(event, 'lvsp')">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">
      <span data-toggle="tooltip" title="Total Applicants"><a href="dashboard.php?hub=all_listing&id=1"  class="btn btn-success" target="_blank"> All Students <i class="badge">
<?php echo get_all_total_applicants_prence($conn_1); ?></i></a></span> &nbsp;&nbsp;&nbsp;

<span data-toggle="tooltip" title="Total Paid Applicants"><a href="dashboard.php?hub=view_paid_applicants_app_fees&pt=1"  class="btn btn-success" target="_new"> Total Paid Students <i class="badge">
<?php echo get_total_applicants($conn_1, $type= 1); ?></i></a></span> &nbsp;&nbsp;&nbsp;
<br><br>
<div class="alert alert-warning">
<span class="fa fa-exclamation-triangle"></span>
   Report on Applied Department / Programmes  (Degree)<br>

  Click on each tab to view list of applied candidates

</div>

<?php echo get_programme_lists($conn_1, $pt = 1, $type= 1); //pass programme type ?>



  <hr />

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

<div id="nce" class="tabcontent">
  <h3>NCE STUDENTS LIST</h3>
  <p>
    <div class="table-responsive table-responisve-lg table-responsive-xl">
      <span data-toggle="tooltip" title="Total Applicants"><a href="dashboard.php?hub=all_listing&id=2"  class="btn btn-success" target="_blank"> All Students <i class="badge">
<?php echo get_all_total_applicants_nce($conn_1); ?></i></a></span> &nbsp;&nbsp;&nbsp;

<span data-toggle="tooltip" title="Total Paid Applicants"><a href="dashboard.php?hub=view_paid_applicants_app_fees&pt=2"  class="btn btn-success" target="_new"> Total Paid Students <i class="badge">
<?php echo get_total_applicants($conn_1, $type= 2); ?></i></a></span> &nbsp;&nbsp;&nbsp;
<br><br>
<div class="alert alert-warning">
<span class="fa fa-exclamation-triangle"></span>
   Report on Applied Department / Programmes  (Degree)<br>

  Click on each tab to view list of applied candidates

</div>

<?php echo get_programme_lists($conn_1, $pt = 1, $type= '2'); //pass programme type ?>



  <hr />

    </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">
      <span data-toggle="tooltip" title="Total Applicants"><a href="dashboard.php?hub=all_listing&id=3"  class="btn btn-success" target="_blank"> All Students <i class="badge">
<?php echo get_all_total_applicants_abu($conn_2); ?></i></a></span> &nbsp;&nbsp;&nbsp;

<span data-toggle="tooltip" title="Total Paid Applicants"><a href="dashboard.php?hub=view_paid_applicants_app_fees&pt=3"  class="btn btn-success" target="_new"> Total Paid Students <i class="badge">
<?php echo get_total_applicants($conn_1, $type= 3); ?></i></a></span> &nbsp;&nbsp;&nbsp;
<br><br>
<div class="alert alert-warning">
<span class="fa fa-exclamation-triangle"></span>
   Report on Applied Department / Programmes  (Degree)<br>

  Click on each tab to view list of applied candidates

</div>

<?php echo get_programme_lists_duap($conn_2, $conn_1, $pt = 1, $type= '3'); //pass programme type ?>



  <hr />

    </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">
      <span data-toggle="tooltip" title="Total Applicants"><a href="dashboard.php?hub=all_listing&id=4"  class="btn btn-success" target="_blank"> All Students <i class="badge">
<?php echo get_all_total_applicants_udus($conn_2); ?></i></a></span> &nbsp;&nbsp;&nbsp;

<span data-toggle="tooltip" title="Total Paid Applicants"><a href="dashboard.php?hub=view_paid_applicants_app_fees&pt=4"  class="btn btn-success" target="_new"> Total Paid Students <i class="badge">
<?php echo get_total_applicants($conn_1, $type= 4); ?></i></a></span> &nbsp;&nbsp;&nbsp;
<br><br>
<div class="alert alert-warning">
<span class="fa fa-exclamation-triangle"></span>
   Report on Applied Department / Programmes  (Degree)<br>

  Click on each tab to view list of applied candidates

</div>

<?php echo get_programme_lists_duap($conn_2,$conn_1, $pt = 1, $type= '4'); //pass programme type ?>



  <hr />

    </div>
  </p>
</div>
<div id="summer" class="tabcontent">
  <h3>SUMMER STUDENTS LIST</h3>
  <p>
    <div class="table-responsive table-responisve-lg table-responsive-xl">
      <span data-toggle="tooltip" title="Total Applicants"><a href="dashboard.php?hub=all_listing&id=5"  class="btn btn-success" target="_blank"> All Students <i class="badge">
<?php echo get_all_total_applicants_summer($conn_1); ?></i></a></span> &nbsp;&nbsp;&nbsp;

<span data-toggle="tooltip" title="Total Paid Applicants"><a href="dashboard.php?hub=view_paid_applicants_app_fees&pt=5"  class="btn btn-success" target="_new"> Total Paid Students <i class="badge">
<?php echo get_total_applicants($conn_1, $type= 5); ?></i></a></span> &nbsp;&nbsp;&nbsp;
<br><br>
<div class="alert alert-warning">
<span class="fa fa-exclamation-triangle"></span>
   Report on Applied Department / Programmes  (Degree)<br>

  Click on each tab to view list of applied candidates

</div>

<?php echo get_programme_lists($conn_1, $pt = 1, $type= '5'); //pass programme type ?>



  <hr />

    </div>
  </p>
</div>
<div id="lvsp" class="tabcontent">
  <h3>LVSP STUDENTS LIST</h3>
  <p>
    <div class="table-responsive table-responisve-lg table-responsive-xl">
      <span data-toggle="tooltip" title="Total Applicants"><a href="dashboard.php?hub=all_listing&id=6"  class="btn btn-success" target="_blank"> All Students <i class="badge">
<?php echo get_all_total_applicants_lvsp($conn_1); ?></i></a></span> &nbsp;&nbsp;&nbsp;

<span data-toggle="tooltip" title="Total Paid Applicants"><a href="dashboard.php?hub=view_paid_applicants_app_fees&pt=6"  class="btn btn-success" target="_new"> Total Paid Students <i class="badge">
<?php echo get_total_applicants($conn_1, $type= 6); ?></i></a></span> &nbsp;&nbsp;&nbsp;
<br><br>
<div class="alert alert-warning">
<span class="fa fa-exclamation-triangle"></span>
   Report on Applied Department / Programmes  (Degree)<br>

  Click on each tab to view list of applied candidates

</div>

<?php echo get_programme_lists($conn_1, $pt = 1, $type= '6'); //pass programme type ?>



  <hr />

    </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">Delete Faculty</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
                                    delete this Faculty?
                                </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 Faculty</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 Faculty ?
                                </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 FACULTY </span></h2>
          <button type="button" class="close" data-dismiss="modal">&times;</button>
        </div>

        <!-- Modal body -->
        <div class="modal-body">
		<form method="POST" id="form_faculty" >
          <div class="form-group row">
				<label for="category" class="col-sm-3 col-form-label text-right">School *</label>
                                                <div class="col-sm-9">
                                                    <select class="form-control select21" id="school"
                                                            title="Select School..." name="school_id">
                                                        <option disabled selected>Select School</option>
														<?php
														echo get_all_schools($conn_1);
														?>

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

			 <div class="form-group row">
				<label for="title" class="col-sm-3 col-form-label text-right">Title : (*)
				</label>
					<div class="col-sm-9">
						<input id="title" name="title" type="text"
						placeholder="Title " class="form-control required" required />
					</div>
             </div>

			 <div class="form-group row">
				<label for="code" class="col-sm-3 col-form-label text-right">Code : (*)
				</label>
					<div class="col-sm-9">
						<input id="Code" name="code" type="text"
						placeholder="Code " class="form-control required" required />
					</div>
             </div>

			 <div class="form-group row">
				<label for="email" class="col-sm-3 col-form-label text-right">Email
				</label>
					<div class="col-sm-9">
						<input id="email" name="email" type="text"
						placeholder="email " class="form-control required" />
					</div>
             </div>


			 <div class="form-group row">
				<label for="location" class="col-sm-3 col-form-label text-right">Location
				</label>
					<div class="col-sm-9">
						<input id="text" name="location" type="text"
						placeholder="Location " class="form-control required"  />
					</div>
             </div>

			 <div class="form-group row">
				<label for="Phone Number" class="col-sm-3 col-form-label text-right">Phone Number
				</label>
					<div class="col-sm-9">
						<input id="text" name="phone_contacts" type="text"
						placeholder="Phone Number " class="form-control required"  />
					</div>
             </div>
							<div class="form-group row">
												<label class="col-sm-3 col-form-label text-right"> Description</label>
									<div class="col-sm-9">
										<textarea class="form-control" rows="2" name="description" id="comment"></textarea>
									</div>
							</div>



						<div id="button">
							<center>
														<button class="button button-3d button-primary button-rounded btn_3d" onclick="add_sub_cat()">Save
												</button>
						</div>
             </form>


        </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"> Editing Faculty </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">
$(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/update_faculty.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("Faculty Updated 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_faculty',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_faculty',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/delete_faculty.php",{token:token},
			function(response,status){

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

					  swal("Faculty Deleted");
					  links();


				}else{
					swal(response);
				}


			});
 }


 function load_edit_faculty(token){


			$('#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_faculty.php',{token:token},
			function(response,status){

			document.getElementById("edit_form_faculty").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>
