<?php 

include('../dbconnect.php');
include('../phps.php');
ob_start();
session_start();

if(!isset($_SESSION['user'])) {
 header("Location: ../index.php");
 exit;
}
include('uppernav.php');




?>
<!DOCTYPE html>
<html lang="en">

  <head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>Tools</title>

    <!-- Bootstrap core CSS-->
    <link href="../vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">

    <!-- Custom fonts for this template-->
    <link href="../vendor/fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css">

    <!-- Page level plugin CSS-->
    <link href="../vendor/datatables/dataTables.bootstrap4.css" rel="stylesheet">

    <!-- Custom styles for this template-->
    <link href="../css/sb-admin.css" rel="stylesheet">
    <link href="../css/style.css" rel="stylesheet">

    <link href="https://cdn.datatables.net/buttons/1.6.0/css/buttons.dataTables.min.css" rel="stylesheet">





  </head>

  <body id="page-top" onload=display_ct();>

    <div id="preloader">
        <img src="../images/loaderS.gif" alt="processing..." height="150px" width="200px"/>
    </div>




      <!-- Sidebar -->
      
      <?php 
      $employee="active";
      $team="active";
      include('sidebar.php');
       ?>
      <div id="content-wrapper">

        <div class="container-fluid">

          <!-- Breadcrumbs-->
          <ol class="breadcrumb">

            <li class="breadcrumb-item active">Employee Tools</li>
          </ol>
          
               
                <h5>Employee Tools</h5>
              <div class="row">
                <div class="col-lg-12">
                  <form method="POST">
                    <div class="row">
                      <div class= "col-lg-1 text-right"> 
                        Filter : 
                      </div>

                      <div class= "col-lg-3">
                    
                            <select class="form-control"  name="tools" id="tools">
                                <option value="All" <?php echo isset($_POST['tools']) && $_POST['tools'] == 'All' ? 'selected': '' ?>>All</option>
                                <?php 
                                  $sql = "SELECT * FROM individualshared ORDER BY type ASC";
                                  $res = $conn->query($sql);
                                  while($row = $res->fetch_assoc()){
                                    if($row['type'] == 'Individual'){
                                   
                                      echo '<option value="'.$row['id'].'" '.(isset($_POST['tools']) && $_POST['tools'] == $row['id'] ? 'selected' : '' ).' >Individual - '.$row['name'].'</option>';


                                    }else{

                                      echo '<option value="'.$row['id'].'" '.(isset($_POST['tools']) && $_POST['tools'] == $row['id'] ? 'selected' : '' ).' >Shared - '.$row['name'].'</option>';


                                    }
                                   
                                  }

                                  
                                ?>
                                
                            </select>
                           
                        
                      </div>

                      <div class= "col-lg-3">
                    
                            <select class="form-control" name="emp" id="emp">
                            <option value="All" <?php echo (isset($_POST['emp']) && $_POST['emp']  == 'All' ? 'selected': '' )?>>All</option>
                            <?php 
                                  $empsql = "SELECT * FROM empinfo";
                                  $empres = $conn->query($empsql);
                                  while($emprow = $empres->fetch_assoc()){
                                    echo '<option value="'.$emprow['empid'].'" '.(isset($_POST['emp']) && $_POST['emp'] == $emprow['empid'] ? 'selected' : '' ).'>'.$emprow['empid'].' '.$emprow['firstname'].' '.$emprow['surname'].'</option>';

                                  }

                                  
                                ?>
                                
                            </select>
                        
                      </div>
                      <div class= "col-lg-3">
                          <button type="submit" name="filterReport" class="btn btn-primary">filter </button>
                      </div>
                    </div>
                  </form>
                </div>
                <div class= "col-lg-12">
                
                  <table class="table table-striped" id="emptable">
                      <thead class="thead-dark">
                          <th>Empoyee ID </th>
                          <th>Name </th>
                          <th>Team </th>
                          <th>Tools Name </th>
                          <th> Type </th>
                          <th> Username </th>
                          <th> Password </th>
                          <th> Date Updated </th>
                          <th> Description </th>
                      </thead>
                      <tbody>
                          <?php 

                          if(isset($_POST['filterReport'])){

                            $reportfilter = '1';
                            include('form.php'); 


                          }else{

                            $report= '1';
                            include('tbldata.php'); 
                          }
                         ?>
                      </tbody>

                  </table>
                </div>



            


                
            
            </div>


        
      
        <!-- /.container-fluid -->

        <!-- Sticky Footer -->

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

    </div>
    <!-- /#wrapper -->

    <!-- Scroll to Top Button-->
    <a class="scroll-to-top rounded" href="#page-top">
      <i class="fas fa-angle-up"></i>
    </a>

    <!-- Logout Modal-->
    <div class="modal fade" id="logoutModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
      <div class="modal-dialog" role="document">
        <div class="modal-content">
          <div class="modal-header">
            <h5 class="modal-title" id="exampleModalLabel">Ready to Leave?</h5>
            <button class="close" type="button" data-dismiss="modal" aria-label="Close">
              <span aria-hidden="true">×</span>
            </button>
          </div>
          <div class="modal-body">Select "Logout" below if you are ready to end your current session.</div>
          <div class="modal-footer">
            <button class="btn btn-secondary" type="button" data-dismiss="modal">Cancel</button>
            <a class="btn btn-primary" href="login.html">Logout</a>
          </div>
        </div>
      </div>
    </div>

    <!-- Bootstrap core JavaScript-->
    <script src="../vendor/jquery/jquery.min.js"></script>
    <script src="../vendor/bootstrap/js/bootstrap.bundle.min.js"></script>

    <!-- Core plugin JavaScript-->
    <script src="../vendor/jquery-easing/jquery.easing.min.js"></script>

    <!-- Page level plugin JavaScript-->
    <script src="../vendor/chart.js/Chart.min.js"></script>
    <script src="../vendor/datatables/jquery.dataTables.js"></script>
    <script src="../vendor/datatables/dataTables.bootstrap4.js"></script>

    <!-- Custom scripts for all pages-->
    <script src="../js/sb-admin.min.js"></script>

    <!-- Demo scripts for this page-->
    <script src="../js/demo/datatables-demo.js"></script>
    <script src="../js/demo/chart-area-demo.js"></script>

    <script type="text/javascript" src="https://cdn.datatables.net/buttons/1.3.1/js/dataTables.buttons.min.js"></script> 
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
    <script type="text/javascript" src="https://cdn.datatables.net/buttons/1.3.1/js/buttons.html5.min.js"></script>



    <script language="javascript" type="text/javascript">
            $(document).ready(function(){
            $("form").on("submit", function(){
                $("#pageloader").fadeIn();
            });//submit

             $('#preloader').fadeOut();
            });//document ready

            $(document).ready( function () {
                $('#emptable').DataTable({

                  dom: 'Blfrtip',
                  buttons: [
                      'excel'
                  ],
                  lengthChange : false
                    
                });
                
                
            } );




    </script>
</body>

</html>
