<?php 

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'])){

    $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 *, 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 *, 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 *, 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 *, 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";
        $indisql = "SELECT *, 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 *, 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 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 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>Login</th>
                                            <th>Logout</th>
                                            <th>Late</th>
                                            <th>Pre OT</th>
                                            <th>Post OT</th>
                                            <th>RDOT</th>
                                
                                            <th>Schedule</th>

                                            
                            </thead>

                            <?php 

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

                                    $sqllogin = "SELECT * 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));

                                    $hrssql = "SELECT starttime FROM schedule WHERE year='$year' AND week = '$schedweek' AND starttime != 'OFF' AND endtime != 'HOLIDAY OFF' AND empid='$emp' ";
                                    $hrssched = mysqli_query($conn, $hrssql);
                                    $hrsrow = mysqli_fetch_assoc($hrssched);
                                    $mnlhrs = $hrsrow['starttime'];


                                    
                                    $schedPSTST1 = new DateTime($mnlhrs, new DateTimeZone('Asia/Manila'));
                                    
                                    $schedPSTST1->setTimezone(new DateTimeZone('America/Los_Angeles'));
                                    $mnltopsthrs = $schedPSTST1->format('h:i A');




                                    $MNLdate = new DateTime($date.' '.$mnltopsthrs, new DateTimeZone('America/Los_Angeles'));
                                

                                    $MNLdate->setTimezone(new DateTimeZone('Asia/Manila'));
                                    $scheddate = $MNLdate->format('Y-m-d');


                                     $schedsql = "SELECT * FROM schedule WHERE year='$year' AND date='$scheddate' AND  empid='$emp'";
                                    $schedres = mysqli_query($conn, $schedsql);
                                    $schedrow =  mysqli_fetch_assoc($schedres);
                                    $schedST = $schedrow['starttime'];
                                    $schedET = $schedrow['endtime'];
                                   
                                    $idl = $schedrow['idl'];
                                    $leaveduration = $schedrow['leaveduration'];



                                    ///OT 


                                    $otsql = "SELECT * 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'];

                




                                    if($schedST == 'OFF'){

                                    

                                        if(!empty($ottype)){


                                            $schedPSTstarttime = 'OFF';
                                            $OT =  $ottype.' '.$othrs;


                                        }else{

                                            $schedule = 'OFF';

                                        


                                        }

                                        if(empty($sqlloginrow['timein'])){

                                            $in = '---';
                                            $out = '---';


                                        }else{
                                            $in = $sqlloginrow['timein'];
                                            $out = $sqlloginrow['timeout'];
                                        }


                                    }else if($schedST == 'HOLIDAY OFF'){
                                        $schedule = 'HOLIDAY OFF';

                                        if(empty($sqlloginrow['timein'])){

                                            $in = '---';
                                            $out = '---';


                                        }else{
                                            $in = $sqlloginrow['timein'];
                                            $out = $sqlloginrow['timeout'];
                                        }



                                    } else if(!empty($idl)){

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


                                        if(mysqli_num_rows($leaveres) > 0){

                                            if($leaveduration == '0.5'){

                                                if(empty($sqlloginrow['timein'])){
    
                                                    $in = '---';
                                                    $out = '---';
                        
                        
                                                }else{
                                                    $in = $sqlloginrow['timein'];
                                                    $out = $sqlloginrow['timeout'];
                                                }
                        
    
                                                $schedule = $leavename.' Half Day';
                                                
                                            }
                                            
                                            else{
    
                                                $in = '---';
                                                $out = '---';
    
                                                $schedule = $leavename;
                                            }

                                            }else{


                                            $schedPSTST = new DateTime($schedST, new DateTimeZone('Asia/Manila'));         
                                            $schedPSTST->setTimezone(new DateTimeZone('America/Los_Angeles'));
                                             $schedPSTstarttime = $schedPSTST->format('h:i A');
    
    
                                            $schedPSTET = new DateTime($schedET, new DateTimeZone('Asia/Manila'));         
                                            $schedPSTET->setTimezone(new DateTimeZone('America/Los_Angeles'));
                                            $schedPSTendtime = $schedPSTET->format('h:i A');
    
                                            $OT =  $othrs;
                                            $schedule = $schedPSTstarttime.' - '.$schedPSTendtime;

                                            $in = $sqlloginrow['timein'];
                                            $out = $sqlloginrow['timeout'];

                                            if(empty($sqlloginrow['timein'])){

                                                $in = '---';
                                                $out = '---';



                                            }else{

                                                $in = $sqlloginrow['timein'];
                                                $out = $sqlloginrow['timeout'];


                                            }

                                       



                                        }





                                        

                                        

                                    } 
                                    else{


                                        $schedPSTST = new DateTime($schedST, new DateTimeZone('Asia/Manila'));         
                                        $schedPSTST->setTimezone(new DateTimeZone('America/Los_Angeles'));
                                         $schedPSTstarttime = $schedPSTST->format('h:i A');


                                        $schedPSTET = new DateTime($schedET, new DateTimeZone('Asia/Manila'));         
                                        $schedPSTET->setTimezone(new DateTimeZone('America/Los_Angeles'));
                                        $schedPSTendtime = $schedPSTET->format('h:i A');

                                        $OT =  $othrs;
                                        $schedule = $schedPSTstarttime.' - '.$schedPSTendtime;

                                        $logintime = $sqlloginrow['timein'];

                                    $logintime.' - '.$schedPSTstarttime.'<br>';


                                        $login = new DateTime($logintime);
                                        $starttime = new DateTime($schedPSTstarttime);
                                        $tday = new DateTime(date('m/d/Y'));
                                        $logindate = new DateTime($date);

                                        if(empty($logintime)){

                                            if($logindate > $tday){
                                                $late = '0';
                                                $in = '---';
                                        
                                                $out = '---';
    

                                            }else{
                                                
                                            $late = '0';
                                            $in = 'ABSENT';
                                    
                                            $out = 'ABSENT';
                                            }

                                            






                                        }else{

                                            $in = $sqlloginrow['timein'];
                                            $out = $sqlloginrow['timeout'];
                                            $late = '0';

                                

                                            if($login > $starttime){

                                                $lateelapse = $starttime->diff($login);
                    
                                                $late = $lateelapse->format('%H:%I');
                    
                                            }else{
                                                $late = '0';

                                            }
                                        }



                    

                
                    
                                    

                                    }








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

                                

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

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

                                    
                                    
                                    $ottype = "SELECT * FROM ottype";
                                    $ottyperes = mysqli_query($conn, $ottype);

                                        


                                        
                                    while($ottyperow = mysqli_fetch_assoc($ottyperes)){
                                       $typeofot = $ottyperow['type'];

                                       $otget = "SELECT * FROM ot WHERE empid='$emp' AND attendance ='$liloid' AND status='3' AND type='$typeofot'";
                                        $otgetres = mysqli_query($conn, $otget);
                                        $otrows = mysqli_fetch_assoc($otgetres);


                                        if(empty($otrows['hrs'])){

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


                                        }else{

                                            echo' <td> '.$otrows['hrs'].' </td>';

                                            
                                        }



                                        


                                    }
                                    
                    


                                    echo'

                                    
                                    <td>'.$schedule.'</td>

                                    

                                    
                                    
                                    </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>Login</th>
                                            <th>Logout</th>
                                            <th>Late</th>
                                            <th>Pre OT</th>
                                            <th>Post OT</th>
                                            <th>RDOT</th>
                                
                                            <th>Schedule</th>

                                            
                            </thead>

                            <?php 

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

                                    $sqllogin = "SELECT * 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));

                                    $hrssql = "SELECT starttime FROM schedule WHERE year='$year' AND week = '$schedweek' AND starttime != 'OFF' AND endtime != 'HOLIDAY OFF' AND empid='$emp' ";
                                    $hrssched = mysqli_query($conn, $hrssql);
                                    $hrsrow = mysqli_fetch_assoc($hrssched);
                                    $mnlhrs = $hrsrow['starttime'];


                                    
                                    $schedPSTST1 = new DateTime($mnlhrs, new DateTimeZone('Asia/Manila'));
                                    
                                    $schedPSTST1->setTimezone(new DateTimeZone('America/Los_Angeles'));
                                    $mnltopsthrs = $schedPSTST1->format('h:i A');




                                    $MNLdate = new DateTime($date.' '.$mnltopsthrs, new DateTimeZone('America/Los_Angeles'));
                                

                                    $MNLdate->setTimezone(new DateTimeZone('Asia/Manila'));
                                    $scheddate = $MNLdate->format('Y-m-d');


                                    $schedsql = "SELECT * FROM schedule WHERE year='$year' AND date='$scheddate' AND  empid='$emp'";
                                    $schedres = mysqli_query($conn, $schedsql);
                                    $schedrow =  mysqli_fetch_assoc($schedres);
                                    $schedST = $schedrow['starttime'];
                                    $schedET = $schedrow['endtime'];
                                    $idl = $schedrow['idl'];
                                    $leaveduration = $schedrow['leaveduration'];



                                    ///OT 


                                    $otsql = "SELECT * 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'];

                




                                    if($schedST == 'OFF'){

                                    

                                        if(!empty($ottype)){


                                            $schedPSTstarttime = 'OFF';
                                            $OT =  $ottype.' '.$othrs;


                                        }else{

                                            $schedule = 'OFF';

                                        


                                        }

                                        if(empty($sqlloginrow['timein'])){

                                            $in = '---';
                                            $out = '---';


                                        }else{
                                            $in = $sqlloginrow['timein'];
                                            $out = $sqlloginrow['timeout'];
                                        }


                                    }else if($schedST == 'HOLIDAY OFF'){
                                        $schedule = 'HOLIDAY OFF';

                                        if(empty($sqlloginrow['timein'])){

                                            $in = '---';
                                            $out = '---';


                                        }else{
                                            $in = $sqlloginrow['timein'];
                                            $out = $sqlloginrow['timeout'];
                                        }



                                    } else if(!empty($idl)){

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


                                        if(mysqli_num_rows($leaveres) > 0){

                                            if($leaveduration == '0.5'){

                                                if(empty($sqlloginrow['timein'])){
    
                                                    $in = '---';
                                                    $out = '---';
                        
                        
                                                }else{
                                                    $in = $sqlloginrow['timein'];
                                                    $out = $sqlloginrow['timeout'];
                                                }
                        
    
                                                $schedule = $leavename.' Half Day';
                                                
                                            }
                                            
                                            else{
    
                                                $in = '---';
                                                $out = '---';
    
                                                $schedule = $leavename;
                                            }

                                            }else{


                                            $schedPSTST = new DateTime($schedST, new DateTimeZone('Asia/Manila'));         
                                            $schedPSTST->setTimezone(new DateTimeZone('America/Los_Angeles'));
                                             $schedPSTstarttime = $schedPSTST->format('h:i A');
    
    
                                            $schedPSTET = new DateTime($schedET, new DateTimeZone('Asia/Manila'));         
                                            $schedPSTET->setTimezone(new DateTimeZone('America/Los_Angeles'));
                                            $schedPSTendtime = $schedPSTET->format('h:i A');
    
                                            $OT =  $othrs;
                                            $schedule = $schedPSTstarttime.' - '.$schedPSTendtime;

                                            
                                            if(empty($sqlloginrow['timein'])){

                                                $in = 'ABSENT';
                                                $out = 'ABSENT';



                                            }else{

                                                $in = $sqlloginrow['timein'];
                                                $out = $sqlloginrow['timeout'];


                                            }

                                            


                                       



                                        }





                                        

                                        

                                        

                                    } 
                                    else{


                                        $schedPSTST = new DateTime($schedST, new DateTimeZone('Asia/Manila'));         
                                        $schedPSTST->setTimezone(new DateTimeZone('America/Los_Angeles'));
                                        $schedPSTstarttime = $schedPSTST->format('h:i A');


                                        $schedPSTET = new DateTime($schedET, new DateTimeZone('Asia/Manila'));         
                                        $schedPSTET->setTimezone(new DateTimeZone('America/Los_Angeles'));
                                        $schedPSTendtime = $schedPSTET->format('h:i A');

                                        $OT =  $othrs;
                                        $schedule = $schedPSTstarttime.' - '.$schedPSTendtime;

                                        $logintime = $sqlloginrow['timein'];

                                    $logintime.' - '.$schedPSTstarttime.'<br>';


                                        $login = new DateTime($logintime);
                                        $starttime = new DateTime($schedPSTstarttime);

                                        if(empty($logintime)){


                                            if($logindate > $tday){
                                                $late = '0';
                                                $in = '---';
                                        
                                                $out = '---';
    

                                            }else{
                                                
                                            $late = '0';
                                            $in = 'ABSENT';
                                    
                                            $out = 'ABSENT';
                                            }





                                        }else{

                                            $in = $sqlloginrow['timein'];
                                            $out = $sqlloginrow['timeout'];
                                            $late = '0';

                                

                                            if($login > $starttime){

                                                $lateelapse = $starttime->diff($login);
                    
                                                $late = $lateelapse->format('%H:%I');
                    
                                            }else{
                                                $late = '0';

                                            }
                                        }



                    

                
                    
                                    

                                    }








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

                                

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

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

                                    
                                    $ottype = "SELECT * FROM ottype";
                                    $ottyperes = mysqli_query($conn, $ottype);

                                        


                                        
                                    while($ottyperow = mysqli_fetch_assoc($ottyperes)){
                                       $typeofot = $ottyperow['name'];

                                       $otget = "SELECT * FROM ot WHERE empid='$emp' AND attendance ='$liloid' AND status='3' AND type='$typeofot'";
                                        $otgetres = mysqli_query($conn, $otget);
                                        $otrows = mysqli_fetch_assoc($otgetres);


                                        if(empty($otrows['hrs'])){

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


                                        }else{

                                            echo' <td> '.$otrows['hrs'].' </td>';

                                            
                                        }



                                        


                                    }

                                    
                                    
                    


                                        


                                    


                                    echo'

                                    
                                    <td>'.$schedule.'</td>

                                    

                                    
                                    
                                    </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 *, 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>';
                                }
                                
                            }
                            
                            ?>
                            </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 * 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='8'><h6 class="text-left"><?php echo $inditeams ?> | <?php echo $emprow['firstname'].' '.$emprow['surname']?></h6></th>
                                </tr>
                                <tr>

                                    <th>Date </th>
                                    <th>Login</th>
                                    <th>Logout</th>
                                    <th>Late</th>
                                    <th>Pre OT</th>
                                    <th>Post OT</th>
                                    <th>RDOT</th>
                                    <th>Schedule</th>
                                </tr>

                                            
                            </thead>

                            <?php 

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


                                    $indisqllogin = "SELECT * 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));

                                    $indihrssql = "SELECT starttime FROM schedule WHERE year='$indiyear' AND week = '$indischedweek' AND starttime != 'OFF' AND endtime != 'HOLIDAY OFF' AND empid='$indiemp' ";
                                    $indihrssched = mysqli_query($conn, $indihrssql);
                                    $indihrsrow = mysqli_fetch_assoc($indihrssched);
                                    $indimnlhrs = $indihrsrow['starttime'];


                                    
                                    $indischedPSTST1 = new DateTime($indimnlhrs, new DateTimeZone('Asia/Manila'));
                                    
                                    $indischedPSTST1->setTimezone(new DateTimeZone('America/Los_Angeles'));
                                    $indimnltopsthrs = $indischedPSTST1->format('h:i A');




                                    $indiMNLdate = new DateTime($indidate.' '.$indimnltopsthrs, new DateTimeZone('America/Los_Angeles'));
                                

                                    $indiMNLdate->setTimezone(new DateTimeZone('Asia/Manila'));
                                    $indischeddate = $indiMNLdate->format('Y-m-d');


                                    $indischedsql = "SELECT * FROM schedule WHERE year='$indiyear' AND date='$indischeddate' AND  empid='$indiemp'";
                                    $indischedres = mysqli_query($conn, $indischedsql);
                                    $indischedrow =  mysqli_fetch_assoc($indischedres);
                                    $indischedST = $indischedrow['starttime'];
                                    $indischedET = $indischedrow['endtime'];
                                    $indiidl = $indischedrow['idl'];
                                    $indileaveduration = $indischedrow['leaveduration'];



                                    ///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'];

                




                                    if($indischedST == 'OFF'){

                                    

                                        if(!empty($indiottype)){


                                            $indischedPSTstarttime = 'OFF';
                                            $indiOT =  $indiottype.' '.$indiothrs;


                                        }else{

                                            $indischedule = 'OFF';

                                        


                                        }

                                        if(empty($indisqlloginrow['timein'])){

                                            $indiin = '---';
                                            $indiout = '---';


                                        }else{
                                            $indiin = $indisqlloginrow['timein'];
                                            $indiout = $indisqlloginrow['timeout'];
                                        }


                                    }else if($indischedST == 'HOLIDAY OFF'){
                                        $indischedule = 'HOLIDAY OFF';

                                        if(empty($indisqlloginrow['timein'])){

                                            $indiin = '---';
                                            $indiout = '---';


                                        }else{
                                            $indiin = $indisqlloginrow['timein'];
                                            $indiout = $indisqlloginrow['timeout'];
                                        }



                                    } else if(!empty($indiidl)){

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


                                        if(mysqli_num_rows($indileaveres) > 0){

                                            if($indileaveduration == '0.5'){

                                                if(empty($indisqlloginrow['timein'])){
    
                                                    $indiin = '---';
                                                    $indiout = '---';
                        
                        
                                                }else{
                                                    $indiin = $indisqlloginrow['timein'];
                                                    $indiout = $indisqlloginrow['timeout'];
                                                }
                        
    
                                                $indischedule = $indileavename.' Half Day';
                                                
                                            }
                                            
                                            else{
    
                                                $indiin = '---';
                                                $indiout = '---';
    
                                                $indischedule = $indileavename;
                                            }

                                            }else{


                                            $indischedPSTST = new DateTime($indischedST, new DateTimeZone('Asia/Manila'));         
                                            $indischedPSTST->setTimezone(new DateTimeZone('America/Los_Angeles'));
                                             $indischedPSTstarttime = $indischedPSTST->format('h:i A');
    
    
                                            $indischedPSTET = new DateTime($indischedET, new DateTimeZone('Asia/Manila'));         
                                            $indischedPSTET->setTimezone(new DateTimeZone('America/Los_Angeles'));
                                            $indischedPSTendtime = $indischedPSTET->format('h:i A');
    
                                            $indiOT =  $indiothrs;
                                            $indischedule = $indischedPSTstarttime.' - '.$indischedPSTendtime;

                                            if(empty($indisqlloginrow['timein'])){


                                                $indiin = 'ABSENT';
                                                $indiout = 'ABSENT';



                                            }else{

                                                $indiin = $indisqlloginrow['timein'];
                                                $indiout = $indisqlloginrow['timeout'];


                                            }




                                       



                                        }





    


                                        

                                        

                                    } 
                                    else{


                                        $indischedPSTST = new DateTime($indischedST, new DateTimeZone('Asia/Manila'));         
                                        $indischedPSTST->setTimezone(new DateTimeZone('America/Los_Angeles'));
                                        $indischedPSTstarttime = $indischedPSTST->format('h:i A');


                                        $indischedPSTET = new DateTime($indischedET, new DateTimeZone('Asia/Manila'));         
                                        $indischedPSTET->setTimezone(new DateTimeZone('America/Los_Angeles'));
                                        $indischedPSTendtime = $indischedPSTET->format('h:i A');

                                        $indiOT =  $indiothrs;
                                        $indischedule = $indischedPSTstarttime.' - '.$indischedPSTendtime;

                                        $indilogintime = $indisqlloginrow['timein'];

                                    $indilogintime.' - '.$indischedPSTstarttime.'<br>';


                                        $indilogin = new DateTime($indilogintime);
                                        $indistarttime = new DateTime($indischedPSTstarttime);
                                        $inditday = new DateTime(date('m/d/Y'));
                                        $indilogindate = new DateTime($indidate);

                                        if(empty($indilogintime)){



                                            if($indilogindate > $inditday){
                                                $indilate = '0';
                                                $indiin = '---';
                                        
                                                $indiout = '---';
    

                                            }else{
                                                
                                            $indilate = '0';
                                            $indiin = 'ABSENT';
                                    
                                            $indiout = 'ABSENT';
                                            }





                                        }else{

                                            $indiin = $indisqlloginrow['timein'];
                                            $indiout = $indisqlloginrow['timeout'];
                                            $indilate = '0';

                                

                                            if($indilogin > $indistarttime){

                                                $indilateelapse = $indistarttime->diff($indilogin);
                    
                                                $indilate = $indilateelapse->format('%H:%I');
                    
                                            }else{
                                                $indilate = '0';

                                            }
                                        }



                    

                
                    
                                    

                                    }








                                    echo'<tr>

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

                                

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

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


                                    
                                    $ottype = "SELECT * FROM ottype";
                                    $ottyperes = mysqli_query($conn, $ottype);

                                        


                                        
                                    while($ottyperow = mysqli_fetch_assoc($ottyperes)){
                                       $typeofot = $ottyperow['name'];

                                       $otget = "SELECT * FROM ot WHERE empid='$indiemp' AND attendance ='$indililoid' AND status='3' AND type='$typeofot'";
                                        $otgetres = mysqli_query($conn, $otget);
                                        $otrows = mysqli_fetch_assoc($otgetres);


                                        if(empty($otrows['hrs'])){

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


                                        }else{

                                            echo' <td> '.$otrows['hrs'].' </td>';

                                            
                                        }



                                        


                                    }


                                    echo'

                                    
                                    <td>'.$indischedule.'</td>

                                    

                                    
                                    
                                    </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 table-sm" >
                            <thead class="thead-dark text-center">
                            
                                <tr> 
                                    <th colspan='8'><h6 class="text-left"><?php echo $inditeams ?> | <?php echo $emprow['firstname'].' '.$emprow['surname']?></h6></th>
                                </tr>
                                <tr>

                                    <th>Date </th>
                                    <th>Login</th>
                                    <th>Logout</th>
                                    <th>Late</th>
                                    <th>Pre OT</th>
                                    <th>Post OT</th>
                                    <th>RDOT</th>
                                    <th>Schedule</th>
                                </tr>

                                            
                            </thead>

                            <?php 

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


                                    $indisqllogin = "SELECT * 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));

                                    $indihrssql = "SELECT starttime FROM schedule WHERE year='$indiyear' AND week = '$indischedweek' AND starttime != 'OFF' AND endtime != 'HOLIDAY OFF' AND empid='$indiemp' ";
                                    $indihrssched = mysqli_query($conn, $indihrssql);
                                    $indihrsrow = mysqli_fetch_assoc($indihrssched);
                                    $indimnlhrs = $indihrsrow['starttime'];


                                    
                                    $indischedPSTST1 = new DateTime($indimnlhrs, new DateTimeZone('Asia/Manila'));
                                    
                                    $indischedPSTST1->setTimezone(new DateTimeZone('America/Los_Angeles'));
                                    $indimnltopsthrs = $indischedPSTST1->format('h:i A');




                                    $indiMNLdate = new DateTime($indidate.' '.$indimnltopsthrs, new DateTimeZone('America/Los_Angeles'));
                                

                                    $indiMNLdate->setTimezone(new DateTimeZone('Asia/Manila'));
                                    $indischeddate = $indiMNLdate->format('Y-m-d');


                                    $indischedsql = "SELECT * FROM schedule WHERE year='$indiyear' AND date='$indischeddate' AND  empid='$indiemp'";
                                    $indischedres = mysqli_query($conn, $indischedsql);
                                    $indischedrow =  mysqli_fetch_assoc($indischedres);
                                    $indischedST = $indischedrow['starttime'];
                                    $indischedET = $indischedrow['endtime'];
                                    $indiidl = $indischedrow['idl'];
                                    $indileaveduration = $indischedrow['leaveduration'];



                                    ///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'];

                




                                    if($indischedST == 'OFF'){

                                    

                                        if(!empty($indiottype)){


                                            $indischedPSTstarttime = 'OFF';
                                            $indiOT =  $indiottype.' '.$indiothrs;


                                        }else{

                                            $indischedule = 'OFF';

                                        


                                        }

                                        if(empty($indisqlloginrow['timein'])){

                                            $indiin = '---';
                                            $indiout = '---';


                                        }else{
                                            $indiin = $indisqlloginrow['timein'];
                                            $indiout = $indisqlloginrow['timeout'];
                                        }


                                    }else if($indischedST == 'HOLIDAY OFF'){
                                        $indischedule = 'HOLIDAY OFF';

                                        if(empty($indisqlloginrow['timein'])){

                                            $indiin = '---';
                                            $indiout = '---';


                                        }else{
                                            $indiin = $indisqlloginrow['timein'];
                                            $indiout = $indisqlloginrow['timeout'];
                                        }



                                    } else if(!empty($indiidl)){


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


                                        if(mysqli_num_rows($indileaveres) > 0){

                                            if($indileaveduration == '0.5'){

                                                if(empty($indisqlloginrow['timein'])){
    
                                                    $indiin = '---';
                                                    $indiout = '---';
                        
                        
                                                }else{
                                                    $indiin = $indisqlloginrow['timein'];
                                                    $indiout = $indisqlloginrow['timeout'];
                                                }
                        
    
                                                $indischedule = $indileavename.' Half Day';
                                                
                                            }
                                            
                                            else{
    
                                                $indiin = '---';
                                                $indiout = '---';
    
                                                $indischedule = $indileavename;
                                            }

                                            }else{


                                            $indischedPSTST = new DateTime($indischedST, new DateTimeZone('Asia/Manila'));         
                                            $indischedPSTST->setTimezone(new DateTimeZone('America/Los_Angeles'));
                                             $indischedPSTstarttime = $indischedPSTST->format('h:i A');
    
    
                                            $indischedPSTET = new DateTime($indischedET, new DateTimeZone('Asia/Manila'));         
                                            $indischedPSTET->setTimezone(new DateTimeZone('America/Los_Angeles'));
                                            $indischedPSTendtime = $indischedPSTET->format('h:i A');
    
                                            $indiOT =  $indiothrs;
                                            $indischedule = $indischedPSTstarttime.' - '.$indischedPSTendtime;

                                            if(empty($indisqlloginrow['timein'])){


                                                $indiin = 'ABSENT';
                                                $indiout = 'ABSENT';



                                            }else{

                                                $indiin = $indisqlloginrow['timein'];
                                                $indiout = $indisqlloginrow['timeout'];


                                            }




                                       



                                        }

                                        

                                    } 
                                    else{


                                        $indischedPSTST = new DateTime($indischedST, new DateTimeZone('Asia/Manila'));         
                                        $indischedPSTST->setTimezone(new DateTimeZone('America/Los_Angeles'));
                                        $indischedPSTstarttime = $indischedPSTST->format('h:i A');


                                        $indischedPSTET = new DateTime($indischedET, new DateTimeZone('Asia/Manila'));         
                                        $indischedPSTET->setTimezone(new DateTimeZone('America/Los_Angeles'));
                                        $indischedPSTendtime = $indischedPSTET->format('h:i A');

                                        $indiOT =  $indiothrs;
                                        $indischedule = $indischedPSTstarttime.' - '.$indischedPSTendtime;

                                        $indilogintime = $indisqlloginrow['timein'];

                                    $indilogintime.' - '.$indischedPSTstarttime.'<br>';


                                        $indilogin = new DateTime($indilogintime);
                                        $indistarttime = new DateTime($indischedPSTstarttime);
                                        $inditday = new DateTime(date('m/d/Y'));
                                        $indilogindate = new DateTime($indidate);

                                        if(empty($indilogintime)){



                                            if($indilogindate > $inditday){
                                                $indilate = '0';
                                                $indiin = '---';
                                        
                                                $indiout = '---';
    

                                            }else{
                                                
                                            $indilate = '0';
                                            $indiin = 'ABSENT';
                                    
                                            $indiout = 'ABSENT';
                                            }





                                        }else{

                                            $indiin = $indisqlloginrow['timein'];
                                            $indiout = $indisqlloginrow['timeout'];
                                            $indilate = '0';

                                

                                            if($indilogin > $indistarttime){

                                                $indilateelapse = $indistarttime->diff($indilogin);
                    
                                                $indilate = $indilateelapse->format('%H:%I');
                    
                                            }else{
                                                $indilate = '0';

                                            }
                                        }



                    

                
                    
                                    

                                    }








                                    echo'<tr>

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

                                

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

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


                                    
                                    $ottype = "SELECT * FROM ottype";
                                    $ottyperes = mysqli_query($conn, $ottype);

                                        


                                        
                                    while($ottyperow = mysqli_fetch_assoc($ottyperes)){
                                       $typeofot = $ottyperow['name'];

                                       $otget = "SELECT * FROM ot WHERE empid='$indiemp' AND attendance ='$indililoid' AND status='3' AND type='$typeofot'";
                                        $otgetres = mysqli_query($conn, $otget);
                                        $otrows = mysqli_fetch_assoc($otgetres);


                                        if(empty($otrows['hrs'])){

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


                                        }else{

                                            echo' <td> '.$otrows['hrs'].' </td>';

                                            
                                        }



                                        


                                    }


                                    echo'

                                    
                                    <td>'.$indischedule.'</td>

                                    

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