
<?php 
set_time_limit(10000);
include('../dbconnect.php');
include('../phps.php');
ob_start();
session_start();

if( !isset($_SESSION['user']) ) {
 header("Location: ../index.php");
 exit;
}
$datefrom = date('m/d/Y');
$dateto = date('m/d/Y');
$week = date('W', strtotime($datefrom));
$year = date('Y', strtotime($dateto));
$indiyear = date('Y', strtotime($indidateto));

 $weekno  = ltrim($week, '0');

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



}



?>
<!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>Super Admin | Report</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="../css/style.css" rel="stylesheet">
    <link rel="icon" href="../images/logo.jpg" type="image/gif" sizes="16x16">
    
    <style>
.tableFixHead    { overflow-y: auto; height: 650px; }
.tableFixHead th { position: sticky; top: 0; }

/* Just common table stuff. Really. */
table  { border-collapse: collapse; width: 100%; }
th, td { padding: 8px 16px; }
th     { background:#eee; }


@media print {
.red {
  background-color: red;
}


}

hr.new1 {
  border-top: 2px solid #333;
}


    </style>





  </head>



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

    <?php include('uppernav.php')?>



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

        <div class="container-fluid">

          <!-- Breadcrumbs-->
          <ol class="breadcrumb">
            <li class="breadcrumb-item">
              <a href="#" > Report LILO</a>
            </li>

          </ol>
            <div class="row p-3" >
                <div class="col-lg-12 p-3 form-inline">
                    <form method="POST">
                        <button type="button"  id="filter"class="btn btn-primary" name="indifilter"> <i class="fa fa-filter" > </i> Filter</button>
                        <select name="empid" id="empid" class="form-control" required>
                            <option> All </option>
                            <optgroup label="Team">
                                <?php 
                                    $team = $conn->query("SELECT * FROM team");
                                    while($row = $team->fetch_assoc()){
                                        echo'<option>'.$row['name'].'</option>';
                                    }
                                ?>
                            </optgroup>
                            
                            <optgroup label="Employee">

                                <?php 
                                $indisqlteam = "SELECT *, empinfo.empid AS 'id' FROM empinfo  JOIN empdetails ON empinfo.empid = empdetails.detailid WHERE empdetails.status='Active'  ";
                                $inditeamres =  mysqli_query($conn, $indisqlteam);
                                while($inditeamrow = mysqli_fetch_assoc($inditeamres)){

                                    if($inditeams == $inditeamrow['empid']){
                                        echo '<option value="'.$inditeamrow['empid'].'" selected>'.$inditeamrow['empid'].' '.$inditeamrow['firstname'].' '.$inditeamrow['surname'].'</option>';
                                    }
                                    
                                    else{
                                        echo '<option value="'.$inditeamrow['empid'].'">'.$inditeamrow['empid'].' '.$inditeamrow['firstname'].' '.$inditeamrow['surname'].'</option>';
                                    }
                                    
                                }
                                
                                ?>
                            </optgroup>
                        </select>

                        <input type="date" id="from" name="from" class="form-control" value="<?php echo $indidatefrom?>" required> - <input type="date" id="to" name= "to" class="form-control" value="<?php echo $indidateto?>" required>

                            
                    </form>
                </div>
                <div class="col-lg-12 pb-2 text-right"><button id="export" type="button" class="btn btn-success btn-sm">Export</button></div>
                <div class="tableFixHead col-lg-12">

                <?php $empinfo = "SELECT * FROM empinfo WHERE empid='$inditeams'";
                $empres = mysqli_query($conn, $empinfo);
                $emprow = mysqli_fetch_assoc($empres);
                
                ?>
                    <table class="table table-bordered" id="table">
                        <thead class="thead-dark text-center">

                      
                            <th>Employee ID </th>
                            <th>Name</th>
                            <th>Team</th>
                            <th>Date</th>
                      
                            <th>Schedule (Manila)</th>

                   
                                        
                        </thead>

                    </table>

                        
                </div>
            

             

            

            </div>


        </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>
        $(document).ready(function () {

            function loadTbl(empid = '',datefrom = '',dateto = ''){

                var tbl = $('#table').DataTable({
                    serverSide: true,
                    paging : true,
                    searching:false,
                    processing: true,
                    ordering: false,
                    ajax : {
                        url: 'ajax.php',
                        type: "POST",
                        data : {
                            'reportSched' : 1,
                            'empid' : empid,
                            'datefrom' : datefrom,
                            'dateto' : dateto
                            

                        }

                    }
                });

            }

            $('#filter').click(function(){
                var empid= $('#empid').val();
                var from = $('#from').val();
                var to = $('#to').val();
                $('#table').DataTable().destroy();
                loadTbl(empid, from, to);
               
            });

            $('#export').click(function(){

                window.location.replace('ajax.php?empid='+$('#empid').val()+'&datefrom='+$('#from').val()+'&dateto='+ $('#to').val()+'&export=1');

            });
            
            
        });
     


    </script>




</body>

</html>
