<br />
<br />
<section class="content-header">
            <h1>System Logs </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> Logs List
                            </h4>
                        </div>
                        <div class="card-body">
                            <div class="table-responsive table-responisve-lg table-responsive-xl">
                                <table class="table table-bordered display" 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 > NAME </th>

                                    <th > STAFF ID </th>

                                    <th> EMAIL </th>

                                    <th > PHONE NUMBER </th>
                                    <th > CREATED </th>


										                 <th>Status</th>
                                        <th>Actions</th>
                                    </tr>
                                    </thead>
                                    <tbody>

									<?php




									$select= "SELECT admin_user_id, staff_id, CONCAT_WS(' ', first_name, middle_name, last_name) as name,phone_number, admin_role_id,email,
                                			 DATE_FORMAT(date_added, '%b %e, %Y  %l:%i:%p')as date_added FROM admin_users  ORDER BY date_added";
									$sql_select = mysqli_query($con,$select);
									$num_rows=mysqli_num_rows($sql_select);
									if($num_rows > 0){
										$sn=1;
										while($row=mysqli_fetch_array($sql_select)){


                      $id=$row['admin_user_id'];
                      $name=$row['name'];
                      $staff_id=$row['staff_id'];
                      $email=$row['email'];
                      $phone_number=$row['phone_number'];

                      $date_added = $row['date_added'];

                            $status='Admin';



                          echo $tr = '<tr>
    														<td><center>'.$sn.'</center></td>
    														<td>'.$name.'</td>
    														<td>'.$staff_id.'</td>
    														<td>'.$email.'</td>
    														<td>'.$phone_number.'</td>
                                <td>'.$date_added.'</td>
    														<td>'.$status.'</td>



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

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

    													</tr>';
    													$sn++;





										}


									}

									?>
                                    </tbody>
                                </table>

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

<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/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_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_qualified.php',{token:token},
      function(response,status){

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

});
}

</script>
