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

if( !isset($_SESSION['user']) ) {
 header("Location: ../index.php");
 exit;
}
function mnltopst($date, $time){

    $convert = new DateTime($date.' '.$time, new DateTimeZone('Asia/Manila'));
    
    
    $convert->setTimezone(new DateTimeZone('America/Los_Angeles'));
    
    $datetime = $convert->format('m/d/Y h:i A');
    
    
    return ($datetime);
    
    
}
function psttomnl($date, $time){
    
  $convert = new DateTime($date.' '.$time, new DateTimeZone('America/Los_Angeles'));
  
  
  $convert->setTimezone(new DateTimeZone('Asia/Manila'));
  
  $datetime = $convert->format('m/d/Y h:i A');
  
  
  return ($datetime);
  
  
  
  
}
$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'])){

    $all = "selected";
    $datefrom = $_POST['from'];
    $dateto = $_POST['to'];
    $teams = $_POST['team'];

    if($teams == 'All'){

        //$sql = "SELECT *, tbl_login.date AS 'logindate' FROM `tbl_login` JOIN empinfo ON tbl_login.empid = empinfo.empid  JOIN empdetails ON tbl_login.empid = empdetails.empid WHERE  STR_TO_DATE(tbl_login.date, '%m/%d/%Y')  BETWEEN '$datefrom' AND '$dateto'  ORDER BY  tbl_login.date ASC";
         $sql = "SELECT firstname,surname,schedule.team,pststarttime,pstendtime,starttime,endtime, schedule.empid AS 'id',schedule.date AS 'schedate' FROM schedule JOIN empinfo ON schedule.empid = empinfo.empid JOIN empdetails ON schedule.empid = empdetails.detailid WHERE schedule.date 
        BETWEEN '$datefrom' AND '$dateto'   AND  empdetails.status = 'Active' ORDER BY empdetails.detailid, schedule.date DESC ";
    

    }else{

        //$sql = "SELECT *, tbl_login.date AS 'logindate'  FROM `tbl_login` JOIN empinfo ON tbl_login.empid = empinfo.empid  JOIN empdetails ON tbl_login.empid = empdetails.empid WHERE  STR_TO_DATE(tbl_login.date, '%m/%d/%Y')  BETWEEN '$datefrom' AND '$dateto'  AND team='$teams'  ORDER BY tbl_login.date ASC";
        $sql = "SELECT firstname,surname,schedule.team,pststarttime,pstendtime,starttime,endtime, schedule.empid AS 'id',schedule.date AS 'schedate' FROM schedule JOIN empinfo ON schedule.empid = empinfo.empid JOIN empdetails ON schedule.empid = empdetails.detailid WHERE schedule.date 
        BETWEEN '$datefrom' AND '$dateto'   AND  empdetails.status = 'Active' AND empdetails.team = '$teams' ORDER BY empdetails.detailid, schedule.date DESC";
    


    }



}else{
    
    //$sql = "SELECT *, tbl_login.date AS 'logindate'  FROM `tbl_login` JOIN empinfo ON tbl_login.empid = empinfo.empid  JOIN empdetails ON tbl_login.empid = empdetails.empid WHERE  STR_TO_DATE(tbl_login.date, '%m/%d/%Y')  BETWEEN '$datefrom' AND '$dateto' ORDER BY tbl_login.date ASC";
    $sql = "SELECT firstname,surname,schedule.team,pststarttime,pstendtime,starttime,endtime, schedule.empid AS 'id',schedule.date AS 'schedate', schedule.empid AS 'id',schedule.date AS 'schedate' FROM schedule JOIN empinfo ON schedule.empid = empinfo.empid JOIN empdetails ON schedule.empid = empdetails.detailid WHERE schedule.date 
    BETWEEN '$datefrom' AND '$dateto'   AND  empdetails.status = 'Active' ORDER BY empdetails.detailid, schedule.date DESC ";


}


/////////////////////////INDIVIDUAL 


$indidatefrom = date('m/d/Y');
$indidateto = date('m/d/Y');
$indiweek = date('W');

 $indischedweek  = ltrim($indiweek, '0');

 
if(isset($_POST['indifilter'])){
    $indiall = "selected";
    $indidatefrom = $_POST['indifrom'];
    $indidateto = $_POST['indito'];
    $inditeams = $_POST['inditeam'];

    if($inditeams == 'All'){

        //$indisql = "SELECT *, tbl_login.date AS 'logindate' FROM `tbl_login` JOIN empinfo ON tbl_login.empid = empinfo.empid  JOIN empdetails ON tbl_login.empid = empdetails.empid WHERE  STR_TO_DATE(tbl_login.date, '%m/%d/%Y')  BETWEEN '$indidatefrom' AND '$indidateto'  ORDER BY  tbl_login.date ASC";
        $indisql = "SELECT idl,firstname,surname,schedule.team,pststarttime,pstendtime,starttime,endtime, schedule.empid AS 'id',schedule.date AS 'schedate' FROM schedule JOIN empinfo ON schedule.empid = empinfo.empid JOIN empdetails ON schedule.empid = empdetails.detailid WHERE schedule.date 
        BETWEEN '$indidatefrom' AND '$indidateto'   AND  empdetails.status = 'Active'  ORDER BY schedule.date DESC";
    

    }else{

        //$indisql = "SELECT *, tbl_login.date AS 'logindate'  FROM `tbl_login` JOIN empinfo ON tbl_login.empid = empinfo.empid  JOIN empdetails ON tbl_login.empid = empdetails.empid WHERE  STR_TO_DATE(tbl_login.date, '%m/%d/%Y')  BETWEEN '$indidatefrom' AND '$indidateto'  AND team='$inditeams'  ORDER BY tbl_login.date ASC";
       echo $indisql = "SELECT idl,firstname,surname,schedule.team,pststarttime,pstendtime,starttime,endtime, schedule.empid AS 'id',schedule.date AS 'schedate' FROM schedule JOIN empinfo ON schedule.empid = empinfo.empid JOIN empdetails ON schedule.empid = empdetails.detailid WHERE schedule.date 
        BETWEEN '$indidatefrom' AND '$indidateto'   AND  empdetails.status = 'Active' AND empdetails.empid = '$inditeams' ORDER BY schedule.date DESC ";
    


    }



}else{
    
    //$indisql = "SELECT *, tbl_login.date AS 'logindate'  FROM `tbl_login` JOIN empinfo ON tbl_login.empid = empinfo.empid  JOIN empdetails ON tbl_login.empid = empdetails.empid WHERE  STR_TO_DATE(tbl_login.date, '%m/%d/%Y')  BETWEEN '$indidatefrom' AND '$indidateto' ORDER BY tbl_login.date ASC";
    $indisql = "SELECT idl,firstname,surname,schedule.team,pststarttime,pstendtime,starttime,endtime, schedule.empid AS 'id',schedule.date AS 'schedate' FROM schedule JOIN empinfo ON schedule.empid = empinfo.empid JOIN empdetails ON schedule.empid = empdetails.detailid WHERE schedule.date 
    BETWEEN '$indidatefrom' AND '$indidateto'   AND  empdetails.status = 'Active' ORDER BY schedule.date DESC ";


}



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

  <head><meta http-equiv="Content-Type" content="text/html; 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>

        <ul class="nav nav-tabs" id="myTab" role="tablist">
            <li class="nav-item">
                <a class="nav-link active" id="home-tab" data-toggle="tab" href="#home" role="tab" aria-controls="home" aria-selected="true">Team</a>
            </li>
            <li class="nav-item">
                <a class="nav-link" id="profile-tab" data-toggle="tab" href="#profile" role="tab" aria-controls="profile" aria-selected="false">Individual</a>
            </li>

        </ul>
        <div class="tab-content" id="myTabContent">
            <div class="tab-pane fade show active" id="home" role="tabpanel" aria-labelledby="home-tab">

                <div class="row p-3" >
                    <div class="col-lg-12 p-3 form-inline">
                        <form method="POST">
                            <button type="submit" class="btn btn-primary" name="teamfilter"> <i class="fa fa-filter" > </i> Filter</button>
                            <select name="team" id="team" class="form-control" required>
                            <option value="All" <?php echo $all?>> All </option>
                            <?php 
                            $sqlteam = "SELECT team FROM empdetails WHERE team != 'Management' GROUP BY team";
                            $teamres =  mysqli_query($conn, $sqlteam);
                            while($teamrow = mysqli_fetch_assoc($teamres)){

                                if($teams == $teamrow['team']){
                                    echo '<option value="'.$teamrow['team'].'" selected>'.$teamrow['team'].'</option>';
                                }
     
                                else{
                                    echo '<option value="'.$teamrow['team'].'">'.$teamrow['team'].'</option>';
                                }
                                
                            }
                            
                            ?>
                            </select>

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

                                
                        </form>
                    </div>
                    <div class="tableFixHead col-lg-12">
                        <table class="table table-bordered" id='mytable'>
                            <thead class="thead-dark text-center">
                                <th>Employee ID</th>
                                <th>Name</th>
                                <th>Team</th>
                                <th>Date </th>
                                <th><small>Pacific</small> <br>Login</th>
                                <th><small>Pacific</small> <br>Logout</th>
                                <th><small>Manila</small> <br>Login</th>
                                <th><small>Manila</small> <br>Logout</th>
                                <th>Late</th>
                                <th>First Break</th>
                                <th>Second Break</th>
                                <th>Toilet Break</th>
                                <th>Lunch Break</th>
                                <th>Prod</th>
                                <th>Non-Prod</th>
                                <th>Admin</th>

                                            
                            </thead>

                            <?php 

                                $sqlres = mysqli_query($conn, $sql);
                    
                                while($sqlrow = mysqli_fetch_assoc($sqlres)){
                                    $emp = $sqlrow['id'];
                                    $date = date('m/d/Y', strtotime($sqlrow['schedate']));
                                 

                                  //  $idl = $sqlrow['idl'];


                                    $sqllogin = "SELECT id,timein,timeout FROM tbl_login WHERE empid='$emp' AND date='$date'";
                                    $sqlloginres = mysqli_query($conn, $sqllogin);
                                    $sqlloginrow = mysqli_fetch_assoc($sqlloginres);
                                    $liloid = $sqlloginrow['id'];
                                    $schedweek = date('W',strtotime($date));
                                    $year = date('Y', strtotime($date));

                                



                                    ///OT 


                                    $otsql = "SELECT type,hrs FROM ot WHERE empid='$emp' AND attendance ='$liloid' AND status='3'";
                                    $otres = mysqli_query($conn, $otsql);
                                    $otrow =  mysqli_fetch_assoc($otres);
                                    $ottype = $otrow['type'];
                                    $othrs = $otrow['hrs'];

                                    $Ymddate = date('Y-m-d', strtotime($sqlrow['schedate']));
                                    $getidl  ="SELECT idl FROM schedule WHERE empid='$emp' AND pstdate='$Ymddate'";
                                    $getidlres = mysqli_query($conn, $getidl);
        
                                    $getidlrow = mysqli_fetch_assoc($getidlres);
                                   $idl = $getidlrow['idl'];


                                    
                                    $leavesql ="SELECT name FROM `leave` WHERE idl='$idl' AND status='3'";
                                    $leaveres = mysqli_query($conn, $leavesql);
                                    $leaverow = mysqli_fetch_assoc($leaveres);

                                    $tday = new DateTime(date('Y-m-d'));
                                    $curdate = new DateTime($date);



                                    if(empty($sqlloginrow['timein'])){
                                        $late = 0;
                                        if($sqlrow['pststarttime'] ==  'OFF'){
                                            $in = 'OFF';
                                            $out='---';
                                            $mnlin = '';
                                            $mnlout = '';
                                        }else if($sqlrow['pststarttime'] ==  'HOLIDAY OFF'){

                                            $in = 'HOLIDAY OFF';
                                            $out='---';
                                            $mnlin = '';
                                            $mnlout = '';

                                        }else if(!empty($leaverow['name'])){

                                            $in = $leaverow['name'];
                                            $out='---';
                                            $mnlin = '';
                                            $mnlout = '';
                      
                                            
                                        }else{

                                            
                                            if($curdate >= $tday){

                                                $in = '---';
                                                $out ='---';
                                                $mnlin = '';
                                                $mnlout = '';


                                            }else{
                                                $in = 'ABSENT';
                                                $out ='---';
                                                $mnlin = '';
                                                $mnlout = '';

                                            }

                                        }

                                    }else{

                                        $in = date('h:i A', strtotime($sqlloginrow['timein']));
                                        $conmnlin = psttomnl($sqlrow['schedate'],$in);
                                        $mnlin = date('h:i A', strtotime($conmnlin));
                                                                               
                                        if(empty($sqlloginrow['timeout'])){
                                            $out = $sqlloginrow['timeout'];
                                            $mnlout = '';


                                        }else{

                                            $out = date('h:i A', strtotime($sqlloginrow['timeout']));

                                            $conmnlout = psttomnl($sqlrow['schedate'],$out);
                                            $mnlout = date('h:i A', strtotime($conmnlout));
                                

                                        }
                                    

                                        $late = '0';

                                        if(!empty($leaverow['name'])){
        
                                            $in = $leaverow['name'].' Halfday';
                                    
                                         
                                            
                                        }else if($sqlrow['pststarttime'] == 'OFF'){
                                            $in ='OFF';
                                     
        
        
        
                                        }else{
        
                                            
                                            $pststarttime = date('h:i A', strtotime($sqlrow['pststarttime']));
                                     
        
                                            $pststart = new DateTime($pststarttime);
                                            $timein = new DateTime($in);
        
        
                                            if($timein > $pststart){
                                                $late = $timein->diff($pststart);
                                                $late = $late->format('%H:%I');
                                            }else{
                                                $late ='0';
                                            }
        
        
        
        
                                        }
        
        



                                    }



                        

                





                                    echo'<tr>
                                        <td>'.$sqlrow['id'].'</td>
                                       
                                    <td>'.$sqlrow['firstname'].' '.$sqlrow['surname'].'</td>
                                    <td>'.$sqlrow['team'].'</td>
                                    <td>'.$date.'</td>';

                                

                                        echo'
                                    
                                    <td>'.$in.'</td>
                                    <td>'.$out.'</td>
                                    <td>'.$mnlin.'</td>
                                    <td>'.$mnlout.'</td>

                                    
                                    <td>'.$late.'</td>
                                    ';


                                    $activity = array("1st Break","2nd Break", "Toilet Break","Lunch Break");
                                    $type= array("Prod","Non-Prod","Admin");

                            

                                    $utildate = date('m/d/Y', strtotime($date));

                                    for($a=0;$a<count($activity); $a++){
                                    
                                      $actsql = " SELECT SUM(elapsedtime) AS 'EPLT'  FROM `tbl_utilization` WHERE empid= '$emp' AND date = '$utildate' AND activity='$activity[$a]'";

                                        $actres = $conn->query($actsql);
                                        $actrow = $actres->fetch_assoc();

                                        if ($actrow['EPLT'] > 0) {

                                        echo '<td>'.$actrow['EPLT'].'</td>';
                                        }
                                        else{

                                            echo '<td>---</td>';
                                        }



                                    }


                                    for($b=0;$b<count($type); $b++){

                                        $typesql = "SELECT SUM(elapsedtime) AS 'EPLT'  FROM `tbl_utilization` WHERE empid= '$emp' AND date = '$utildate' AND type='$type[$b]'";

                                        $typeres = $conn->query($typesql);
                                        $typrow = $typeres->fetch_assoc();


                                        if (empty($actrow['EPLT'])) {

                                   

                                        echo '<td >---</td>';
                                        }
                                        else{

                                            echo '<td>'.$typrow['EPLT'].'</td>';
                                        }



                                    }


                                    
                                    
                                 
                    


                                    echo'

                                    
                                  

                                    

                                    
                                    
                                    </tr>';
                                    
                    
                                }
                    
                                ?>
                            
                        </table>

                            
                    </div>
                    <div name="printArea" id="printArea" hidden>
                        <div style="margin:0 auto; width:50%"> 

                            <img src="../images/logo1.jpg"style="float:left; padding:10px 20px;" >
                            &nbsp &nbsp &nbsp &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
                            <h1 style="font-size: 40px"> ATV International ROHQ </h1>
                        
                            
                            <br>

                        </div>
                        <div class="col-12">
                
                
                            <hr class="new1">
                        </div>
                        <h5> <?php echo $teams.' | '.date('F d, Y', strtotime($datefrom)).' - '.date('F d, Y', strtotime($dateto))?></h5>
                        <table class="table table-bordered">
                            <thead class="thead-dark text-center">
                                            <th>Employee ID</th>
                                            <th>Name</th>
                                            <th>Team</th>
                                            <th>Date </th>
                                            <th><small>Pacific</small> <br>Login</th>
                                            <th><small>Pacific</small> <br>Logout</th>
                                            <th><small>Manila</small> <br>Login</th>
                                            <th><small>Manila</small> <br>Logout</th>
                                            <th>Late</th>
                                            <th>First Break</th>
                                            <th>Second Break</th>
                                            <th>Toilet Break</th>
                                            <th>Lunch Break</th>
                                            <th>Prod</th>
                                            <th>Non-Prod</th>
                                            <th>Admin</th>

                                            
                            </thead>

                            <?php 

                                $sqlres = mysqli_query($conn, $sql);
                    
                    
                                while($sqlrow = mysqli_fetch_assoc($sqlres)){
                                    $emp = $sqlrow['id'];
                                    $date = date('m/d/Y', strtotime($sqlrow['schedate']));
                                 

                                  //  $idl = $sqlrow['idl'];


                                    $sqllogin = "SELECT id,timein,timeout FROM tbl_login WHERE empid='$emp' AND date='$date'";
                                    $sqlloginres = mysqli_query($conn, $sqllogin);
                                    $sqlloginrow = mysqli_fetch_assoc($sqlloginres);
                                    $liloid = $sqlloginrow['id'];
                                    $schedweek = date('W',strtotime($date));
                                    $year = date('Y', strtotime($date));

                                



                                    ///OT 


                                    $otsql = "SELECT type, hrs FROM ot WHERE empid='$emp' AND attendance ='$liloid' AND status='3'";
                                    $otres = mysqli_query($conn, $otsql);
                                    $otrow =  mysqli_fetch_assoc($otres);
                                    $ottype = $otrow['type'];
                                    $othrs = $otrow['hrs'];

                                    $Ymddate = date('Y-m-d', strtotime($sqlrow['schedate']));
                                    $getidl  ="SELECT idl FROM schedule WHERE empid='$emp' AND pstdate='$Ymddate'";
                                    $getidlres = mysqli_query($conn, $getidl);
        
                                    $getidlrow = mysqli_fetch_assoc($getidlres);
                                   $idl = $getidlrow['idl'];


                                    
                                    $leavesql ="SELECT idl FROM `leave` WHERE idl='$idl' AND status='3'";
                                    $leaveres = mysqli_query($conn, $leavesql);
                                    $leaverow = mysqli_fetch_assoc($leaveres);

                                    $tday = new DateTime(date('Y-m-d'));
                                    $curdate = new DateTime($date);



                                    if(empty($sqlloginrow['timein'])){
                                        $late = 0;
                                        if($sqlrow['pststarttime'] ==  'OFF'){
                                            $in = 'OFF';
                                            $out='---';
                                            $mnlin = '';
                                            $mnlout = '';
                                        }else if($sqlrow['pststarttime'] ==  'HOLIDAY OFF'){

                                            $in = 'HOLIDAY OFF';
                                            $out='---';
                                            $mnlin = '';
                                            $mnlout = '';

                                        }else if(!empty($leaverow['name'])){

                                            $in = $leaverow['name'];
                                            $out='---';
                                            $mnlin = '';
                                            $mnlout = '';
                      
                                            
                                        }else{

                                            
                                            if($curdate >= $tday){

                                                $in = '---';
                                                $out ='---';
                                                $mnlin = '';
                                                $mnlout = '';


                                            }else{
                                                $in = 'ABSENT';
                                                $out ='---';
                                                $mnlin = '';
                                                $mnlout = '';

                                            }

                                        }

                                    }else{

                                        $in = date('h:i A', strtotime($sqlloginrow['timein']));
                                        $conmnlin = psttomnl($sqlrow['schedate'],$in);
                                        $mnlin = date('h:i A', strtotime($conmnlin));
                                                                               
                                        if(empty($sqlloginrow['timeout'])){
                                            $out = $sqlloginrow['timeout'];
                                            $mnlout ='';


                                        }else{

                                            $out = date('h:i A', strtotime($sqlloginrow['timeout']));

                                            $conmnlout = psttomnl($sqlrow['schedate'],$out);
                                            $mnlout = date('h:i A', strtotime($conmnlout));
                                

                                        }
                                    

                                        $late = '0';

                                        if(!empty($leaverow['name'])){
        
                                            $in = $leaverow['name'].' Halfday';
                                    
                                         
                                            
                                        }else if($sqlrow['pststarttime'] == 'OFF'){
                                            $in ='OFF';
                                     
        
        
        
                                        }else{
        
                                            
                                            $pststarttime = date('h:i A', strtotime($sqlrow['pststarttime']));
                                     
        
                                            $pststart = new DateTime($pststarttime);
                                            $timein = new DateTime($in);
        
        
                                            if($timein > $pststart){
                                                $late = $timein->diff($pststart);
                                                $late = $late->format('%H:%I');
                                            }else{
                                                $late ='0';
                                            }
        
        
        
        
                                        }
        
        



                                    }



                        

                





                                    echo'<tr>
                                        <td>'.$sqlrow['id'].'</td>
                                       
                                    <td>'.$sqlrow['firstname'].' '.$sqlrow['surname'].'</td>
                                    <td>'.$sqlrow['team'].'</td>
                                    <td>'.$date.'</td>';

                                

                                        echo'
                                    
                                    <td>'.$in.'</td>
                                    <td>'.$out.'</td>
                                    <td>'.$mnlin.'</td>
                                    <td>'.$mnlout.'</td>

                                    
                                    <td>'.$late.'</td>
                                    ';


                                    $activity = array("1st Break","2nd Break", "Toilet Break","Lunch Break");
                                    $type= array("Prod","Non-Prod","Admin");

                            

                                    $utildate = date('m/d/Y', strtotime($date));

                                    for($a=0;$a<count($activity); $a++){
                                    
                                      $actsql = " SELECT SUM(elapsedtime) AS 'EPLT'  FROM `tbl_utilization` WHERE empid= '$emp' AND date = '$utildate' AND activity='$activity[$a]'";

                                        $actres = $conn->query($actsql);
                                        $actrow = $actres->fetch_assoc();

                                        if ($actrow['EPLT'] > 0) {

                                        echo '<td>'.$actrow['EPLT'].'</td>';
                                        }
                                        else{

                                            echo '<td>---</td>';
                                        }



                                    }


                                    for($b=0;$b<count($type); $b++){

                                        $typesql = "SELECT SUM(elapsedtime) AS 'EPLT'  FROM `tbl_utilization` WHERE empid= '$emp' AND date = '$utildate' AND type='$type[$b]'";

                                        $typeres = $conn->query($typesql);
                                        $typrow = $typeres->fetch_assoc();


                                        if (empty($actrow['EPLT'])) {

                                   

                                        echo '<td >---</td>';
                                        }
                                        else{

                                            echo '<td>'.$typrow['EPLT'].'</td>';
                                        }



                                    }


                                    
                                    
                                 
                    


                                    echo'

                                    
                                  

                                    

                                    
                                    
                                    </tr>';
                                    
                    
                                }
                    
                    
                                ?>
                            
                        </table>
                      


                    </div>

                    <div class="col-lg-12">

                        <span class="pull-right">
                            <button type="button" class="btn btn-danger" onclick="printContent('printArea')"> <i class="fas fa-file-pdf"></i> PDF</button>
                            <button onclick="exportTableToExcel('mytable', 'emp_lilo')" class="btn btn-success"> <i class="fa fa-table"></i> Excel</button>
                            <br>        
                        </span>

                  

                    </div>


                

                </div>


      
            </div>
            <div class="tab-pane fade" id="profile" role="tabpanel" aria-labelledby="profile-tab">

                <div class="row p-3" >
                    <div class="col-lg-12 p-3 form-inline">
                        <form method="POST">
                            <button type="submit" class="btn btn-primary" name="indifilter"> <i class="fa fa-filter" > </i> Filter</button>
                            <select name="inditeam" id="inditeam" class="form-control" required>
                          
                            <?php 
                            $indisqlteam = "SELECT firstname,surname, empinfo.empid AS 'id' FROM empinfo  JOIN empdetails ON empinfo.empid = empdetails.detailid WHERE empdetails.status='Active' AND empdetails.team != 'Management'";
                            $inditeamres =  mysqli_query($conn, $indisqlteam);
                            while($inditeamrow = mysqli_fetch_assoc($inditeamres)){

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

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

                                
                        </form>
                    </div>
                    <div class="tableFixHead col-lg-12">

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

                                <tr> 
                                    <th colspan='13'><h6 class="text-left"><?php echo $inditeams ?> | <?php echo $emprow['firstname'].' '.$emprow['surname']?></h6></th>
                                </tr>
                                <tr>

     

                 
                                            <th>Date </th>
                                            <th><small>Pacific</small> <br>Login</th>
                                            <th><small>Pacific</small> <br>Logout</th>
                                            <th><small>Manila</small> <br>Login</th>
                                            <th><small>Manila</small> <br>Logout</th>
                                            <th>Late</th>
                                            <th>First Break</th>
                                            <th>Second Break</th>
                                            <th>Toilet Break</th>
                                            <th>Lunch Break</th>
                                            <th>Prod</th>
                                            <th>Non-Prod</th>
                                            <th>Admin</th>
                                </tr>

                                            
                            </thead>

                            <?php 

                                $indisqlres = mysqli_query($conn, $indisql);
                    
                    
                                while($indisqlrow = mysqli_fetch_assoc($indisqlres)){
                                    $indiemp = $indisqlrow['id'];
                                    $indidate = date('m/d/Y', strtotime($indisqlrow['schedate']));

                                    $indiidl = $indisqlrow['idl'];


                                    $indisqllogin = "SELECT timein,timeout,id FROM tbl_login WHERE empid='ATV19-176' AND date='$indidate'";
                                    $indisqlloginres = mysqli_query($conn, $indisqllogin);
                                    $indisqlloginrow = mysqli_fetch_assoc($indisqlloginres);
                                    $indililoid = $indisqlloginrow['id'];
                                    $indischedweek = date('W',strtotime($indidate));
                                    $indiyear = date('Y', strtotime($indidate));

                                



                                    ///OT 


                                    $indiotsql = "SELECT * FROM ot WHERE empid='$indiemp' AND attendance ='$indililoid' AND status='3'";
                                    $indiotres = mysqli_query($conn, $indiotsql);
                                    $indiotrow =  mysqli_fetch_assoc($indiotres);
                                    $indiottype = $indiotrow['type'];
                                    $indiothrs = $indiotrow['hrs'];

                                    $Ymddate = date('Y-m-d', strtotime($indisqlrow['schedate']));

                                     $getidl  ="SELECT idl FROM schedule WHERE empid='$indiemp' AND pstdate='$Ymddate'";
                                    $getidlres = mysqli_query($conn, $getidl);
        
                                    $getidlrow = mysqli_fetch_assoc($getidlres);
                                   $indiidl = $getidlrow['idl'];


                                    
                                     $indileavesql ="SELECT name FROM `leave` WHERE idl='$indiidl' AND status='3'";
                                    $indileaveres = mysqli_query($conn, $indileavesql);
                                    $indileaverow = mysqli_fetch_assoc($indileaveres);

                                    $tday = new DateTime(date('Y-m-d'));
                                    $curdate = new DateTime($date);


                                    if(empty($indisqlloginrow['timein'])){
                                        $indilate = 0;
                                        if($indisqlrow['pststarttime'] ==  'OFF'){
                                            $indiin = 'OFF';
                                            $indiout='---';
                                            $psttimein = '';
                                            $psttimeout = '';
                                        }else if($indisqlrow['pststarttime'] ==  'HOLIDAY OFF'){

                                            $indiin = 'HOLIDAY OFF';
                                            $indiout='---';
                                            $psttimein = '';
                                            $psttimeout = '';

                                        }else if(!empty($indileaverow['name'])){

                                            $indiin = $indileaverow['name'];
                                            $indiout='---';
                                            $psttimein = '';
                                            $psttimeout = '';
                      
                                            
                                        }else{
                                            if($curdate >= $tday){

                                                $indiin = '---';
                                                $indiout ='---';
                                                $psttimein = '';
                                                $psttimeout = '';


                                            }else{
                                                $indiin = 'ABSENT';
                                                $indiout ='---';
                                                $psttimein = '';
                                                $psttimeout = '';

                                            }


                                            
                                        }

                                    }else{
                                        $timeinindi = date('h:i A', strtotime($indisqlloginrow['timein']));
                                        

                                        $indiin = date('h:i A', strtotime($indisqlloginrow['timein']));
                                        $conpsttimein = psttomnl($indisqlrow['schedate'],$indiin);
                                        $psttimein = date('h:i A', strtotime($conpsttimein));

                                        
                                        if(empty($indisqlloginrow['timeout'])){
                                            $indiout = $indisqlloginrow['timeout'];
                                            $psttimeout = '';


                                        }else{

                                            $indiout = date('h:i A', strtotime($indisqlloginrow['timeout']));

                                            $conpsttimeout = psttomnl($indisqlrow['schedate'],$indiout);
                                            $psttimeout = date('h:i A', strtotime($conpsttimeout));

                                            
                                

                                        }
                                       

                                        $indilate = '0';

                                        if(!empty($indileaverow['name'])){
        
                                            $indiin = $indileaverow['name'].' Halfday';
                                    
                                         
                                            
                                        }else if($indisqlrow['pststarttime'] == 'OFF'){
                                            $indiin ='OFF';
                                     
        
        
        
                                        }else{
        
                                            
                                            $indipststarttime = date('h:i A', strtotime($indisqlrow['pststarttime']));
                                     
        
                                            $indipststart = new DateTime($indipststarttime);
                                            $inditimein = new DateTime($indiin);
        
        
                                            if($inditimein > $indipststart){
                                                $indilate = $inditimein->diff($indipststart);
                                                $indilate = $indilate->format('%H:%I');
                                            }else{
                                                $indilate ='0';
                                            }
        
        
        
        
                                        }
        
        



                                    }


                                


                                    echo'<tr>

                                    <td>'.$indidate.'</td>';

                                

                                        echo'
                                    
                                    <td>'.$indiin.'</td>
                                    <td>'.$indiout.'</td>
                                    <td>'.$psttimein.'</td>
                                    <td>'.$psttimeout.'</td>

                                    
                                    <td>'.$indilate.'</td>
                                    ';


                                    $indiactivity = array("1st Break","2nd Break", "Toilet Break","Lunch Break");
                                    $inditype= array("Prod","Non-Prod","Admin");

                            

                                    $indiutildate = date('m/d/Y', strtotime($indidate));

                                    for($india=0;$india<count($indiactivity); $india++){
                                    
                                      $indiactsql = " SELECT SUM(elapsedtime) AS 'EPLT'  FROM `tbl_utilization` WHERE empid= '$indiemp' AND date = '$indiutildate' AND activity='$indiactivity[$india]'";

                                        $indiactres = $conn->query($indiactsql);
                                        $indiactrow = $indiactres->fetch_assoc();

                                        if ($indiactrow['EPLT'] > 0) {

                                        echo '<td>'.$indiactrow['EPLT'].'</td>';
                                        }
                                        else{

                                            echo '<td>---</td>';
                                        }



                                    }


                                    for($indib=0;$indib<count($inditype); $indib++){

                                        $inditypesql = "SELECT SUM(elapsedtime) AS 'EPLT'  FROM `tbl_utilization` WHERE empid= '$indiemp' AND date = '$indiutildate' AND type='$inditype[$indib]'";

                                        $indityperes = $conn->query($inditypesql);
                                        $indityprow = $indityperes->fetch_assoc();


                                        if (empty($indiactrow['EPLT'])) {

                                   

                                        echo '<td >---</td>';
                                        }
                                        else{

                                            echo '<td>'.$indityprow['EPLT'].'</td>';
                                        }



                                    }

                                    
                    




                                    echo'

                                    
                   

                                    

                                    
                                    
                                    </tr>';
                                    
                    
                                }
                    
                                ?>
                            
                        </table>

                            
                    </div>
                    <div name="printArea" id="indiprintArea" hidden>
                        <div style="margin:0 auto; width:50%"> 

                            <img src="../images/logo1.jpg"style="float:left; padding:10px 20px;" >
                            &nbsp &nbsp &nbsp &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
                            <h1 style="font-size: 40px"> ATV International ROHQ </h1>
                        
                            
                            <br>

                        </div>
                        <div class="col-12">
                
                
                            <hr class="new1">
                        </div>
                        <h5> Employee LILO <?php echo date('F d, Y', strtotime($indidatefrom)).' - '.date('F d, Y', strtotime($indidateto))?></h5>

                        <table class="table table-bordered">
                            <thead class="thead-dark text-center">

                                <tr> 
                                    <th colspan='11'><h6 class="text-left"><?php echo $inditeams ?> | <?php echo $emprow['firstname'].' '.$emprow['surname']?></h6></th>
                                </tr>
                                <tr>

     

                 
                                            <th>Date </th>
                                            <th><small>Pacific</small> <br>Login</th>
                                            <th><small>Pacific</small> <br>Logout</th>
                                            <th><small>Manila</small> <br>Login</th>
                                            <th><small>Manila</small> <br>Logout</th>
                                            <th>Late</th>
                                            <th>First Break</th>
                                            <th>Second Break</th>
                                            <th>Toilet Break</th>
                                            <th>Lunch Break</th>
                                            <th>Prod</th>
                                            <th>Non-Prod</th>
                                            <th>Admin</th>
                                </tr>

                                            
                            </thead>

                            <?php 

                                $indisqlres = mysqli_query($conn, $indisql);
                    
                    
                                while($indisqlrow = mysqli_fetch_assoc($indisqlres)){
                                    $indiemp = $indisqlrow['id'];
                                    $indidate = date('m/d/Y', strtotime($indisqlrow['schedate']));

                                    $indiidl = $indisqlrow['idl'];


                                    $indisqllogin = "SELECT timein,timeout,id FROM tbl_login WHERE empid='$indiemp' AND date='$indidate'";
                                    $indisqlloginres = mysqli_query($conn, $indisqllogin);
                                    $indisqlloginrow = mysqli_fetch_assoc($indisqlloginres);
                                    $indililoid = $indisqlloginrow['id'];
                                    $indischedweek = date('W',strtotime($indidate));
                                    $indiyear = date('Y', strtotime($indidate));

                                



                                    ///OT 


                                    $indiotsql = "SELECT * FROM ot WHERE empid='$indiemp' AND attendance ='$indililoid' AND status='3'";
                                    $indiotres = mysqli_query($conn, $indiotsql);
                                    $indiotrow =  mysqli_fetch_assoc($indiotres);
                                    $indiottype = $indiotrow['type'];
                                    $indiothrs = $indiotrow['hrs'];

                                    $Ymddate = date('Y-m-d', strtotime($indisqlrow['schedate']));

                                     $getidl  ="SELECT idl FROM schedule WHERE empid='$indiemp' AND pstdate='$Ymddate'";
                                    $getidlres = mysqli_query($conn, $getidl);
        
                                    $getidlrow = mysqli_fetch_assoc($getidlres);
                                   $indiidl = $getidlrow['idl'];


                                    
                                     $indileavesql = "SELECT name FROM `leave` WHERE idl='$indiidl' AND status='3'";
                                    $indileaveres = mysqli_query($conn, $indileavesql);
                                    $indileaverow = mysqli_fetch_assoc($indileaveres);

                                    $tday = new DateTime(date('Y-m-d'));
                                    $curdate = new DateTime($date);


                                    if(empty($indisqlloginrow['timein'])){
                                        $indilate = 0;
                                        if($indisqlrow['pststarttime'] ==  'OFF'){
                                            $indiin = 'OFF';
                                            $indiout='---';
                                            $psttimein = '';
                                            $psttimeout = '';
                                        }else if($indisqlrow['pststarttime'] ==  'HOLIDAY OFF'){

                                            $indiin = 'HOLIDAY OFF';
                                            $indiout='---';
                                            $psttimein = '';
                                            $psttimeout = '';

                                        }else if(!empty($indileaverow['name'])){

                                            $indiin = $indileaverow['name'];
                                            $indiout='---';
                                            $psttimein = '';
                                            $psttimeout = '';
                      
                                            
                                        }else{
                                            if($curdate >= $tday){

                                                $indiin = '---';
                                                $indiout ='---';
                                                $psttimein = '';
                                                $psttimeout = '';


                                            }else{
                                                $indiin = 'ABSENT';
                                                $indiout ='---';
                                                $psttimein = '';
                                                $psttimeout = '';

                                            }


                                            
                                        }

                                    }else{
                                        $timeinindi = date('h:i A', strtotime($indisqlloginrow['timein']));
                                        

                                        $indiin = date('h:i A', strtotime($indisqlloginrow['timein']));
                                        $conpsttimein = psttomnl($indisqlrow['schedate'],$indiin);
                                        $psttimein = date('h:i A', strtotime($conpsttimein));

                                        
                                        if(empty($indisqlloginrow['timeout'])){
                                            $indiout = $indisqlloginrow['timeout'];
                                            $psttimeout = '';


                                        }else{

                                            $indiout = date('h:i A', strtotime($indisqlloginrow['timeout']));

                                            $conpsttimeout = psttomnl($indisqlrow['schedate'],$indiout);
                                            $psttimeout = date('h:i A', strtotime($conpsttimeout));

                                            
                                

                                        }
                                       

                                        $indilate = '0';

                                        if(!empty($indileaverow['name'])){
        
                                            $indiin = $indileaverow['name'].' Halfday';
                                    
                                         
                                            
                                        }else if($indisqlrow['pststarttime'] == 'OFF'){
                                            $indiin ='OFF';
                                     
        
        
        
                                        }else{
        
                                            
                                            $indipststarttime = date('h:i A', strtotime($indisqlrow['pststarttime']));
                                     
        
                                            $indipststart = new DateTime($indipststarttime);
                                            $inditimein = new DateTime($indiin);
        
        
                                            if($inditimein > $indipststart){
                                                $indilate = $inditimein->diff($indipststart);
                                                $indilate = $indilate->format('%H:%I');
                                            }else{
                                                $indilate ='0';
                                            }
        
        
        
        
                                        }
        
        



                                    }


                                


                                    echo'<tr>

                                    <td>'.$indidate.'</td>';

                                

                                        echo'
                                    
                                    <td>'.$indiin.'</td>
                                    <td>'.$indiout.'</td>
                                    <td>'.$psttimein.'</td>
                                    <td>'.$psttimeout.'</td>

                                    
                                    <td>'.$indilate.'</td>
                                    ';


                                    $indiactivity = array("1st Break","2nd Break", "Toilet Break","Lunch Break");
                                    $inditype= array("Prod","Non-Prod","Admin");

                            

                                    $indiutildate = date('m/d/Y', strtotime($indidate));

                                    for($india=0;$india<count($indiactivity); $india++){
                                    
                                      $indiactsql = " SELECT SUM(elapsedtime) AS 'EPLT'  FROM `tbl_utilization` WHERE empid= '$indiemp' AND date = '$indiutildate' AND activity='$indiactivity[$india]'";

                                        $indiactres = $conn->query($indiactsql);
                                        $indiactrow = $indiactres->fetch_assoc();

                                        if ($indiactrow['EPLT'] > 0) {

                                        echo '<td>'.$indiactrow['EPLT'].'</td>';
                                        }
                                        else{

                                            echo '<td>---</td>';
                                        }



                                    }


                                    for($indib=0;$indib<count($inditype); $indib++){

                                        $inditypesql = "SELECT SUM(elapsedtime) AS 'EPLT'  FROM `tbl_utilization` WHERE empid= '$indiemp' AND date = '$indiutildate' AND type='$inditype[$indib]'";

                                        $indityperes = $conn->query($inditypesql);
                                        $indityprow = $indityperes->fetch_assoc();


                                        if (empty($indiactrow['EPLT'])) {

                                   

                                        echo '<td >---</td>';
                                        }
                                        else{

                                            echo '<td>'.$indityprow['EPLT'].'</td>';
                                        }



                                    }

                                    
                    




                                    echo'

                                    
                   

                                    

                                    
                                    
                                    </tr>';
                                    
                    
                                }
								mysqli_close($conn);
                    
                                
                    
                                ?>
                            
                        </table>
                    </div>

                    <div class="col-lg-12">

                        <span class="pull-right">
                            <button type="button" class="btn btn-danger" onclick="printContent('indiprintArea')"> <i class="fas fa-file-pdf"></i> PDF</button>
                            <button onclick="exportTableToExcel('indimytable', 'emp_lilo')" class="btn btn-success"> <i class="fa fa-table"></i> Excel</button>
                            <br>        
                        </span>

                  

                    </div>


                

                </div>

                            
            
            </div>

        </div>








         
 
        

        

        <!-- 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 src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.5.3/jspdf.min.js"></script>

            <script>
            $('a[data-toggle="tab"]').click(function (e) {
            e.preventDefault();
            $(this).tab('show');
            });

            $('a[data-toggle="tab"]').on("shown.bs.tab", function (e) {
                var id = $(e.target).attr("href");
                localStorage.setItem('selectedTab', id)
            });

            var selectedTab = localStorage.getItem('selectedTab');
            if (selectedTab != null) {
                $('a[data-toggle="tab"][href="' + selectedTab + '"]').tab('show');
            }



          </script>


    <script>
function printContent(el){

  var css = '@page { size: auto}',
    head = document.head || document.getElementsByTagName('head')[0],
    style = document.createElement('style');

style.type = 'text/css';
style.media = 'print';

if (style.styleSheet){
  style.styleSheet.cssText = css;
} else {
  style.appendChild(document.createTextNode(css));
}

head.appendChild(style);



	var restorepage = document.body.innerHTML;
	var printcontent = document.getElementById(el).innerHTML;
	document.body.innerHTML = printcontent;
	window.print();
	document.body.innerHTML = restorepage;
}

function doCsv(){
  var table = document.getElementById("mytable").innerHTML;
  var data = table.replace(/<thead>/g, '')
  .replace(/<\/thead>/g, '')
  .replace(/<tbody>/g, '')
  .replace(/<\/tbody>/g, '')
  .replace(/<tr>/g, '')
  .replace(/<\/tr>/g, '\r\n')
  .replace(/<th>/g, '')
  .replace(/<\/th>/g, ';')
  .replace(/<td>/g, '')
  .replace(/<\/td>/g, '')
  .replace(/\t/g, '')
  .replace(/\n/g, '');

  var mylink = document.createElement('a');
  mylink.download = "csvname.csv";
  mylink.href = "data:application/csv," + escape(data);
  mylink.click();
  

}

function exportTableToExcel(tableID, filename = ''){
    var downloadLink;
    var dataType = 'application/vnd.ms-excel';
    var tableSelect = document.getElementById(tableID);
    var tableHTML = tableSelect.outerHTML.replace(/ /g, '%20');
    
    // Specify file name
    filename = filename?filename+'.xls':'excel_data.xls';
    
    // Create download link element
    downloadLink = document.createElement("a");
    
    document.body.appendChild(downloadLink);
    
    if(navigator.msSaveOrOpenBlob){
        var blob = new Blob(['\ufeff', tableHTML], {
            type: dataType
        });
        navigator.msSaveOrOpenBlob( blob, filename);
    }else{
        // Create a link to the file
        downloadLink.href = 'data:' + dataType + ', ' + tableHTML;
    
        // Setting the file name
        downloadLink.download = filename;
        
        //triggering the function
        downloadLink.click();
    }
}

</script>

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

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



        </script>
</body>

</html>
