<?php
 error_reporting(E_ERROR | E_PARSE);
 error_reporting(0);
 session_start(); 
?>

        <!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.0">
            <title>Emp_Prod_Benchmark</title>
            <link rel="shortcut icon" href="images/Files_Download.png" type="image/x-icon"/>
        </head>
        <style>
            .split.bor{
                    margin-left:5%;
                    transition: 1s; 
                }
            #nav-toggle:checked ~ .split.bor
            {  
                margin-left:15%;
                transition: 1s;
                /* margin-right:15%; */
                
            }
            
            h5{
                text-align:center;
            }
        
        .t{     
         
         background-color: #ffefea;
         margin-top:15px;
         border-radius: 7px;
            }
        
        .container-table{
        
        /* margin-top:-10px; */
        height:330px;
        overflow-x:hidden;
        overflow-y: scroll;
        }
        
    .head-container{
        background-color: #ffefea;
        width: 950px;
        border-radius: 22px;
        height: 40px;
        margin-top:85px;
        }
    .form-group{
    text-align: center;
    font-weight: 800;
    width: 100px;
    border-radius: 5px;
    }
   

        </style>
        <body>
            <?php
                include "Nav.php";
                include "Connection.php"; 
                date_default_timezone_set('Asia/Kolkata');
                $date =  date('Y-m-d h:i:s');
            ?>
        <br><br><br>
                <div class="container split bor">
                <h5 style="margin-top: -10px;">Employee Report</h5>

    <div class="container" >
        <div class="row">
            <div class="col-md-10" ><br>
                <form  action="" method = "POST" enctype="multipart/form-data">
                    
                        <div class="form-control" style="background-color:#ffefea;">
                            <label for="Project" class="control-label" style="padding-left:8%;"><b>Select Project :</b></label>
                            <select id="Project" name="Project" class="" placeholder="Select-Project" value="<?php ?>">
                            <option value="" ></option>
                                <?php
                                $_SESSION['pro'] = $proj;
                                $q = mysqli_query($con,"SELECT * FROM epb_tbl WHERE PROJECT in ('PL','OPL','CC');");
                                while($q_row= mysqli_fetch_array($q)) {
                                ?>
                                <option>
                                <?php echo $project = $q_row['PROJECT'];?></option>
                                <?php
                                }
                                ?>
                            </select>
                            <label class="control-label " style="padding-left:10%;"><b>Emp Name :</b></label>
                            <input type="text" name="EmpName" value="" autocomplete="off">
                            
                            <button class="btn btn-success btn-sm ml-lg-5" type="submit" name="search" value="Search" style="border-radius:15px;" onclick="mytable()">Search</button>
                     </div>
                </form>
            </div>
        </div>
 
        <?php
            $proj = $_SESSION['proj']; 
            if(isset($_POST['search'])){
            $EmpName       = $_POST['EmpName'];
            $Project       = $_POST['Project'];
            $up = "select * from epb_tbl where Project='$Project'" ;
            $Query = mysqli_query($con, $up);
            if(!$Query){
                    echo("Failed");
            }else{
            while($r = mysqli_fetch_array($Query)){ 
                $D_B = $r['Database'];
                $S_I = $r['Server_ip'];
                $U_N = $r['Username'];
                $P_W = $r['Password'];
               } 
            }
        ?>

        <?php
        $server  = $S_I;
        $user    = $U_N;
        $password= $P_W;
        $db      = $D_B ;
        $connect =mysqli_connect($server,$user,$password,$db);
        if($connect->connect_error){
        die("Connection Failed");
        }
        else{
        }   }        
        ?>
       
         <?php
        
      if($Project != "FINBO_SAVING"){
            $up ="SELECT L.EMPNO,EM.EMPNAME AS N,B.IMAGENAME as IMAGENAME,L.PROCESS as PROCESS ,L.PASS as PASS, L.startTime as startTime, L.EndTime EndTime, 
            LEFT(SEC_TO_TIME(TIMESTAMPDIFF(SECOND, L.startTime, L.EndTime)),8) as TDif,LEFT(SEC_TO_TIME(BM.BTD),8) as BTD , IF(BM.BTD < TIMESTAMPDIFF(SECOND, L.startTime, L.EndTime), 'NO', 'YES') AS FinalStatus ,IF(BM.BTD < TIMESTAMPDIFF(SECOND,L.startTime, L.EndTime), LEFT(SEC_TO_TIME((TIMESTAMPDIFF(SECOND, L.startTime, L.EndTime)-BM.BTD)),8), LEFT(SEC_TO_TIME((TIMESTAMPDIFF(SECOND, L.startTime, L.EndTime)-BM.BTD)),9)) AS TIMEEXCEED  from LOGIN_FINAL  L left JOIN BATCHES B ON B.BATCHNO = L.BATCHNO left JOIN MASTER_BENCHMARK BM ON BM.PROCESS = CONCAT(L.PROCESS,L.PASS) left JOIN empmaster EM ON EM.EMPNO = L.EMPNO Where left(starttime,10)=CURDATE() and L.EMPNO = '$EmpName' ORDER BY L.startTime ,L.EndTime";  
    
            ini_set('max_execution_time', '300');
            $Query = mysqli_query($connect, $up);
            $RES=mysqli_num_rows($Query);

             $r=mysqli_fetch_array($Query);
                
            $Q = mysqli_query($connect,"SELECT L.EMPNO,EM.EMPNAME,B.IMAGENAME as IMAGENAME,L.PROCESS as PROCESS ,L.PASS as PASS, L.startTime as startTime, L.EndTime EndTime, 
            LEFT(SEC_TO_TIME(TIMESTAMPDIFF(SECOND, L.startTime, L.EndTime)),8) as TDif,LEFT(SEC_TO_TIME(BM.BTD),8) as BTD , IF(BM.BTD < TIMESTAMPDIFF(SECOND, L.startTime, L.EndTime), 'NO', 'YES') AS FinalStatus ,IF(BM.BTD < TIMESTAMPDIFF(SECOND,L.startTime, L.EndTime), LEFT(SEC_TO_TIME((TIMESTAMPDIFF(SECOND, L.startTime, L.EndTime)-BM.BTD)),8), LEFT(SEC_TO_TIME((TIMESTAMPDIFF(SECOND, L.startTime, L.EndTime)-BM.BTD)),9)) AS TIMEEXCEED  from LOGIN_FINAL  L left JOIN BATCHES B ON B.BATCHNO = L.BATCHNO left JOIN MASTER_BENCHMARK BM ON BM.PROCESS = CONCAT(L.PROCESS,L.PASS) left JOIN empmaster EM ON EM.EMPNO = L.EMPNO Where left(starttime,10)=CURDATE() AND L.PROCESS= 'PRETRANS' AND L.EMPNO = '$EmpName' ORDER BY L.startTime ,L.EndTime");
            $q=mysqli_num_rows($Q);

            $Q1 = mysqli_query($connect,"SELECT L.EMPNO,EM.EMPNAME,B.IMAGENAME as IMAGENAME,L.PROCESS as PROCESS ,L.PASS as PASS, L.startTime as startTime, L.EndTime EndTime, 
            LEFT(SEC_TO_TIME(TIMESTAMPDIFF(SECOND, L.startTime, L.EndTime)),8) as TDif,LEFT(SEC_TO_TIME(BM.BTD),8) as BTD , IF(BM.BTD < TIMESTAMPDIFF(SECOND, L.startTime, L.EndTime), 'NO', 'YES') AS FinalStatus ,IF(BM.BTD < TIMESTAMPDIFF(SECOND,L.startTime, L.EndTime), LEFT(SEC_TO_TIME((TIMESTAMPDIFF(SECOND, L.startTime, L.EndTime)-BM.BTD)),8),LEFT(SEC_TO_TIME((TIMESTAMPDIFF(SECOND, L.startTime, L.EndTime)-BM.BTD)),9)) AS TIMEEXCEED  from LOGIN_FINAL  L left JOIN BATCHES B ON B.BATCHNO = L.BATCHNO left JOIN MASTER_BENCHMARK BM ON BM.PROCESS = CONCAT(L.PROCESS,L.PASS) left JOIN empmaster EM ON EM.EMPNO = L.EMPNO Where left(starttime,10)=CURDATE() AND L.PROCESS= 'TRANS' AND L.EMPNO = '$EmpName' ORDER BY L.startTime ,L.EndTime");
            $q1=mysqli_num_rows($Q1);
       
            $Q2 = mysqli_query($connect,"SELECT L.EMPNO,EM.EMPNAME,B.IMAGENAME as IMAGENAME,L.PROCESS as PROCESS ,L.PASS as PASS, L.startTime as startTime, L.EndTime EndTime, 
            LEFT(SEC_TO_TIME(TIMESTAMPDIFF(SECOND, L.startTime, L.EndTime)),8) as TDif,LEFT(SEC_TO_TIME(BM.BTD),8) as BTD , IF(BM.BTD < TIMESTAMPDIFF(SECOND, L.startTime, L.EndTime), 'NO', 'YES') AS FinalStatus ,IF(BM.BTD < TIMESTAMPDIFF(SECOND,L.startTime, L.EndTime), LEFT(SEC_TO_TIME((TIMESTAMPDIFF(SECOND, L.startTime, L.EndTime)-BM.BTD)),8), LEFT(SEC_TO_TIME((TIMESTAMPDIFF(SECOND, L.startTime, L.EndTime)-BM.BTD)),9)) AS TIMEEXCEED  from LOGIN_FINAL  L left JOIN BATCHES B ON B.BATCHNO = L.BATCHNO left JOIN MASTER_BENCHMARK BM ON BM.PROCESS = CONCAT(L.PROCESS,L.PASS) left JOIN empmaster EM ON EM.EMPNO = L.EMPNO Where left(starttime,10)=CURDATE() AND L.PROCESS= 'DATAENTRY' AND L.PASS='PASS1' AND L.EMPNO = '$EmpName' ORDER BY L.startTime ,L.EndTime");
            $q2=mysqli_num_rows($Q2);

            $Q3 = mysqli_query($connect,"SELECT L.EMPNO,EM.EMPNAME,B.IMAGENAME as IMAGENAME,L.PROCESS as PROCESS ,L.PASS as PASS, L.startTime as startTime, L.EndTime EndTime, 
            LEFT(SEC_TO_TIME(TIMESTAMPDIFF(SECOND, L.startTime, L.EndTime)),8) as TDif,LEFT(SEC_TO_TIME(BM.BTD),8) as BTD , IF(BM.BTD < TIMESTAMPDIFF(SECOND, L.startTime, L.EndTime), 'NO', 'YES') AS FinalStatus ,IF(BM.BTD < TIMESTAMPDIFF(SECOND,L.startTime, L.EndTime), LEFT(SEC_TO_TIME((TIMESTAMPDIFF(SECOND, L.startTime, L.EndTime)-BM.BTD)),8), LEFT(SEC_TO_TIME((TIMESTAMPDIFF(SECOND, L.startTime, L.EndTime)-BM.BTD)),9)) AS TIMEEXCEED  from LOGIN_FINAL  L left JOIN BATCHES B ON B.BATCHNO = L.BATCHNO left JOIN MASTER_BENCHMARK BM ON BM.PROCESS = CONCAT(L.PROCESS,L.PASS) left JOIN empmaster EM ON EM.EMPNO = L.EMPNO Where left(starttime,10)=CURDATE() AND L.PROCESS= 'DATAENTRY' AND L.PASS='PASS2' AND L.EMPNO = '$EmpName' ORDER BY L.startTime ,L.EndTime");
            $q3=mysqli_num_rows($Q3);

            $Q4 = mysqli_query($connect,"SELECT L.EMPNO,EM.EMPNAME,B.IMAGENAME as IMAGENAME,L.PROCESS as PROCESS ,L.PASS as PASS, L.startTime as startTime, L.EndTime EndTime, 
            LEFT(SEC_TO_TIME(TIMESTAMPDIFF(SECOND, L.startTime, L.EndTime)),8) as TDif,LEFT(SEC_TO_TIME(BM.BTD),8) as BTD , IF(BM.BTD < TIMESTAMPDIFF(SECOND, L.startTime, L.EndTime), 'NO', 'YES') AS FinalStatus ,IF(BM.BTD < TIMESTAMPDIFF(SECOND,L.startTime, L.EndTime), LEFT(SEC_TO_TIME((TIMESTAMPDIFF(SECOND, L.startTime, L.EndTime)-BM.BTD)),8), LEFT(SEC_TO_TIME((TIMESTAMPDIFF(SECOND, L.startTime, L.EndTime)-BM.BTD)),9)) AS TIMEEXCEED  from LOGIN_FINAL  L left JOIN BATCHES B ON B.BATCHNO = L.BATCHNO left JOIN MASTER_BENCHMARK BM ON BM.PROCESS = CONCAT(L.PROCESS,L.PASS) left JOIN empmaster EM ON EM.EMPNO = L.EMPNO Where left(starttime,10)=CURDATE() AND L.PROCESS= 'COMPARE' AND L.EMPNO = '$EmpName' ORDER BY L.startTime ,L.EndTime");
            $q4=mysqli_num_rows($Q4);

            $Q5 = mysqli_query($connect,"SELECT L.EMPNO,EM.EMPNAME,B.IMAGENAME as IMAGENAME,L.PROCESS as PROCESS ,L.PASS as PASS, L.startTime as startTime, L.EndTime EndTime, 
            LEFT(SEC_TO_TIME(TIMESTAMPDIFF(SECOND, L.startTime, L.EndTime)),8) as TDif,LEFT(SEC_TO_TIME(BM.BTD),8) as BTD , IF(BM.BTD < TIMESTAMPDIFF(SECOND, L.startTime, L.EndTime), 'NO', 'YES') AS FinalStatus ,IF(BM.BTD < TIMESTAMPDIFF(SECOND,L.startTime, L.EndTime), LEFT(SEC_TO_TIME((TIMESTAMPDIFF(SECOND, L.startTime, L.EndTime)-BM.BTD)),8), LEFT(SEC_TO_TIME((TIMESTAMPDIFF(SECOND, L.startTime, L.EndTime)-BM.BTD)),9)) AS TIMEEXCEED  from LOGIN_FINAL  L left JOIN BATCHES B ON B.BATCHNO = L.BATCHNO left JOIN MASTER_BENCHMARK BM ON BM.PROCESS = CONCAT(L.PROCESS,L.PASS) left JOIN empmaster EM ON EM.EMPNO = L.EMPNO Where left(starttime,10)=CURDATE() AND L.PROCESS= 'QC' AND L.EMPNO = '$EmpName' ORDER BY L.startTime ,L.EndTime");
            $q5=mysqli_num_rows($Q5);

            ?>
            <div class="container col-sm-4 t " style="margin-left:10px ">
                <b style="color: #6e1213;"><?php  echo 'Employee Name: ' . $r['N'] . '<br>';?></b>
                <br>
                <label for=""><b>Project Name :</b></label>
                <input class="form-group ml-5" style="background-color:#e3a3bf" type="text" value="<?php echo $Project;?>">
                <label for=""><b>Total Count :</b></label>
                <input class="form-group" style="margin-left:64px;background-color:#b9f7b7" type="text" value="<?php echo $RES;?>">
                <label for=""><b>Pretrans :</b></label>
                <input class="form-group" style="margin-left:89px; background-color:#e6e497"  type="text" value="<?php echo $q;?>">
                <br>
                <label for=""><b>Trans :</b></label>
                <input class="form-group" style="margin-left:110px; background-color:#a6ede2" type="text" value="<?php echo $q1;?>">
                <br>
                <label for=""><b>DataEntry 1 :</b></label>
                <input class="form-group" style="margin-left:60px; background-color:#afc5db;" type="text" value="<?php echo $q2;?>">
                <label for=""><b>DataEntry 2 :</b></label>
                <input class="form-group" style="margin-left:60px;background-color:coral" type="text" value="<?php echo $q3;?>">
                <label for=""><b>Compare :</b></label>
                <input class="form-group" style="margin-left:80px;background-color:#dfd0f5" type="text" value="<?php echo $q4;?>">
                <br>
                <label for=""><b>QC :</b></label>
                <input class="form-group" style="margin-left:125px;background-color:#ebced4" type="text" value="<?php echo $q5;?>">
               
         </div>
     <?php }
     else{
        $up =" SELECT L.assignedto,EM.username,B.applicationnumber as IMAGENAME,L.assignedto as EMPNAME ,L.processid as PROCESS  , L.startdate as startTime, L.completeddate AS EndTime,LEFT(SEC_TO_TIME(TIMESTAMPDIFF(SECOND, L.startdate, L.completeddate)),8) as TDif,LEFT(SEC_TO_TIME(BM.BTD),8) as BTD , IF(BM.BTD < TIMESTAMPDIFF(SECOND, L.startdate, L.completeddate), 'NO', 'YES') AS FinalStatus ,IF(BM.BTD < TIMESTAMPDIFF(SECOND,L.startdate, L.completeddate), LEFT(SEC_TO_TIME((TIMESTAMPDIFF(SECOND, L.startdate, L.completeddate)-BM.BTD)),8), LEFT(SEC_TO_TIME((TIMESTAMPDIFF(SECOND, L.startdate, L.completeddate)-BM.BTD)),9)) AS TIMEEXCEED from application_process  L 
        left JOIN Application B ON B.applicationnumber = L.applicationnumber 
        left JOIN MASTER_BENCHMARK BM ON BM.PROCESS = L.processid 
        left JOIN user EM ON EM.userid = L.assignedto 
        Where left(startdate,10) =CURDATE() and EM.userid='$EmpName'  ORDER BY B.applicationnumber,L.startdate";  

        ini_set('max_execution_time', '300');
        $Query = mysqli_query($connect, $up);
        $RES=mysqli_num_rows($Query);
        $r=mysqli_fetch_array($Query);
                                                                                                                                                                                                
        $Q = mysqli_query($connect," SELECT L.assignedto,EM.username,B.applicationnumber as IMAGENAME,L.assignedto as EMPNAME ,L.processid as PROCESS  , L.startdate as startTime, L.completeddate AS EndTime,LEFT(SEC_TO_TIME(TIMESTAMPDIFF(SECOND, L.startdate, L.completeddate)),8) as TDif,LEFT(SEC_TO_TIME(BM.BTD),8) as BTD , IF(BM.BTD < TIMESTAMPDIFF(SECOND, L.startdate, L.completeddate), 'NO', 'YES') AS FinalStatus ,IF(BM.BTD < TIMESTAMPDIFF(SECOND,L.startdate, L.completeddate), LEFT(SEC_TO_TIME((TIMESTAMPDIFF(SECOND, L.startdate, L.completeddate)-BM.BTD)),8), LEFT(SEC_TO_TIME((TIMESTAMPDIFF(SECOND, L.startdate, L.completeddate)-BM.BTD)),9)) AS TIMEEXCEED from application_process  L 
        left JOIN Application B ON B.applicationnumber = L.applicationnumber 
        left JOIN MASTER_BENCHMARK BM ON BM.PROCESS = L.processid 
        left JOIN user EM ON EM.userid = L.assignedto 
        Where left(startdate,10) =CURDATE() and EM.userid='$EmpName' and L.processid ='1' ORDER BY B.applicationnumber,L.startdate");
        $q=mysqli_num_rows($Q);

        $Q1 = mysqli_query($connect,"SELECT L.assignedto,EM.username,B.applicationnumber as IMAGENAME,L.assignedto as EMPNAME ,L.processid as PROCESS  , L.startdate as startTime, L.completeddate AS EndTime,LEFT(SEC_TO_TIME(TIMESTAMPDIFF(SECOND, L.startdate, L.completeddate)),8) as TDif,LEFT(SEC_TO_TIME(BM.BTD),8) as BTD , IF(BM.BTD < TIMESTAMPDIFF(SECOND, L.startdate, L.completeddate), 'NO', 'YES') AS FinalStatus ,IF(BM.BTD < TIMESTAMPDIFF(SECOND,L.startdate, L.completeddate), LEFT(SEC_TO_TIME((TIMESTAMPDIFF(SECOND, L.startdate, L.completeddate)-BM.BTD)),8), LEFT(SEC_TO_TIME((TIMESTAMPDIFF(SECOND, L.startdate, L.completeddate)-BM.BTD)),9)) AS TIMEEXCEED from application_process  L 
        left JOIN Application B ON B.applicationnumber = L.applicationnumber 
        left JOIN MASTER_BENCHMARK BM ON BM.PROCESS = L.processid 
        left JOIN user EM ON EM.userid = L.assignedto 
        Where left(startdate,10) =CURDATE() and EM.userid='$EmpName' and L.processid ='2' ORDER BY B.applicationnumber,L.startdate");
        $q1=mysqli_num_rows($Q1);
   
        $Q2 = mysqli_query($connect,"SELECT L.assignedto,EM.username,B.applicationnumber as IMAGENAME,L.assignedto as EMPNAME ,L.processid as PROCESS  , L.startdate as startTime, L.completeddate AS EndTime,LEFT(SEC_TO_TIME(TIMESTAMPDIFF(SECOND, L.startdate, L.completeddate)),8) as TDif,LEFT(SEC_TO_TIME(BM.BTD),8) as BTD , IF(BM.BTD < TIMESTAMPDIFF(SECOND, L.startdate, L.completeddate), 'NO', 'YES') AS FinalStatus ,IF(BM.BTD < TIMESTAMPDIFF(SECOND,L.startdate, L.completeddate), LEFT(SEC_TO_TIME((TIMESTAMPDIFF(SECOND, L.startdate, L.completeddate)-BM.BTD)),8), LEFT(SEC_TO_TIME((TIMESTAMPDIFF(SECOND, L.startdate, L.completeddate)-BM.BTD)),9)) AS TIMEEXCEED from application_process  L 
        left JOIN Application B ON B.applicationnumber = L.applicationnumber 
        left JOIN MASTER_BENCHMARK BM ON BM.PROCESS = L.processid 
        left JOIN user EM ON EM.userid = L.assignedto 
        Where left(startdate,10) =CURDATE() and EM.userid='$EmpName' and L.processid ='3' ORDER BY B.applicationnumber,L.startdate");
        $q2=mysqli_num_rows($Q2);

        $Q3 = mysqli_query($connect,"SELECT L.assignedto,EM.username,B.applicationnumber as IMAGENAME,L.assignedto as EMPNAME ,L.processid as PROCESS  , L.startdate as startTime, L.completeddate AS EndTime,LEFT(SEC_TO_TIME(TIMESTAMPDIFF(SECOND, L.startdate, L.completeddate)),8) as TDif,LEFT(SEC_TO_TIME(BM.BTD),8) as BTD , IF(BM.BTD < TIMESTAMPDIFF(SECOND, L.startdate, L.completeddate), 'NO', 'YES') AS FinalStatus ,IF(BM.BTD < TIMESTAMPDIFF(SECOND,L.startdate, L.completeddate), LEFT(SEC_TO_TIME((TIMESTAMPDIFF(SECOND, L.startdate, L.completeddate)-BM.BTD)),8), LEFT(SEC_TO_TIME((TIMESTAMPDIFF(SECOND, L.startdate, L.completeddate)-BM.BTD)),9)) AS TIMEEXCEED from application_process  L 
        left JOIN Application B ON B.applicationnumber = L.applicationnumber 
        left JOIN MASTER_BENCHMARK BM ON BM.PROCESS = L.processid 
        left JOIN user EM ON EM.userid = L.assignedto 
        Where left(startdate,10) =CURDATE() and EM.userid='$EmpName' and L.processid ='4' ORDER BY B.applicationnumber,L.startdate");
        $q3=mysqli_num_rows($Q3);

        $Q4 = mysqli_query($connect,"SELECT L.assignedto,EM.username,B.applicationnumber as IMAGENAME,L.assignedto as EMPNAME ,L.processid as PROCESS  , L.startdate as startTime, L.completeddate AS EndTime,LEFT(SEC_TO_TIME(TIMESTAMPDIFF(SECOND, L.startdate, L.completeddate)),8) as TDif,LEFT(SEC_TO_TIME(BM.BTD),8) as BTD , IF(BM.BTD < TIMESTAMPDIFF(SECOND, L.startdate, L.completeddate), 'NO', 'YES') AS FinalStatus ,IF(BM.BTD < TIMESTAMPDIFF(SECOND,L.startdate, L.completeddate), LEFT(SEC_TO_TIME((TIMESTAMPDIFF(SECOND, L.startdate, L.completeddate)-BM.BTD)),8), LEFT(SEC_TO_TIME((TIMESTAMPDIFF(SECOND, L.startdate, L.completeddate)-BM.BTD)),9)) AS TIMEEXCEED from application_process  L 
        left JOIN Application B ON B.applicationnumber = L.applicationnumber 
        left JOIN MASTER_BENCHMARK BM ON BM.PROCESS = L.processid 
        left JOIN user EM ON EM.userid = L.assignedto 
        Where left(startdate,10) =CURDATE() and EM.userid='$EmpName' and L.processid ='5' ORDER BY B.applicationnumber,L.startdate");
        $q4=mysqli_num_rows($Q4);

        $Q5 = mysqli_query($connect,"SELECT L.assignedto,EM.username,B.applicationnumber as IMAGENAME,L.assignedto as EMPNAME ,L.processid as PROCESS  , L.startdate as startTime, L.completeddate AS EndTime,LEFT(SEC_TO_TIME(TIMESTAMPDIFF(SECOND, L.startdate, L.completeddate)),8) as TDif,LEFT(SEC_TO_TIME(BM.BTD),8) as BTD , IF(BM.BTD < TIMESTAMPDIFF(SECOND, L.startdate, L.completeddate), 'NO', 'YES') AS FinalStatus ,IF(BM.BTD < TIMESTAMPDIFF(SECOND,L.startdate, L.completeddate), LEFT(SEC_TO_TIME((TIMESTAMPDIFF(SECOND, L.startdate, L.completeddate)-BM.BTD)),8), LEFT(SEC_TO_TIME((TIMESTAMPDIFF(SECOND, L.startdate, L.completeddate)-BM.BTD)),9)) AS TIMEEXCEED from application_process  L 
        left JOIN Application B ON B.applicationnumber = L.applicationnumber 
        left JOIN MASTER_BENCHMARK BM ON BM.PROCESS = L.processid 
        left JOIN user EM ON EM.userid = L.assignedto 
        Where left(startdate,10) =CURDATE() and EM.userid='$EmpName' and L.processid ='6' ORDER BY B.applicationnumber,L.startdate");
        $q5=mysqli_num_rows($Q5);

        ?>
        
     <?php
     }
  
     ?>
     <div class=" container-table  col-lg-9" style="margin-top:-410px;margin-left:380px; ">
     <table class="table table-bordered table-sm " style="background-color:#ffefea;">
     <tr>
       <th style="padding:8px">Project</th>
       <th style="padding:8px">Category</th>
       <th style="padding:8px">Process</th>
       <th style="padding:8px">StartTime</th>
       <th style="padding:8px">EndTime</th>
       <th style="padding:8px">TimeTaken</th>
       <th style="padding:8px">TimeExceed</th>
       </tr>
       <?php
       $od="SELECT E.EMP,E.PROJECT as PROJECT,E.CATEGORY as CATEGORY,E.PROCESS as PROCESS,RIGHT(E.START_TIME,8) AS START_TIME,RIGHT(E.END_TIME,8) AS END_TIME,LEFT(SEC_TO_TIME(TIMESTAMPDIFF(SECOND,E.START_TIME,E.END_TIME)),8)AS TD,LEFT(SEC_TO_TIME(MP.BENCHMARK),8) AS BENCHMARK ,IF(MP.BENCHMARK < TIMESTAMPDIFF(SECOND, E.START_TIME, E.END_TIME), 'NO', 'YES') AS FinalStatus,
       IF(MP.BENCHMARK < TIMESTAMPDIFF(SECOND, E.START_TIME, E.END_TIME), LEFT(SEC_TO_TIME((TIMESTAMPDIFF(SECOND, E.START_TIME, E.END_TIME)-MP.BENCHMARK)),8),LEFT(SEC_TO_TIME((TIMESTAMPDIFF(SECOND, E.START_TIME, E.END_TIME)-MP.BENCHMARK)),9)) AS TIMEEXCEED FROM EMPDATA_TBL E left JOIN master_process_copy MP ON E.PROJECT= MP.PROJECT AND E.CATEGORY= MP.CATEGORY  AND E.PROCESS= MP.PROCESS  WHERE EMP='$EmpName'  AND left(START_TIME,10)=CURDATE() ORDER BY E.START_TIME DESC";
       $other=mysqli_query($con,$od);
       while( $otherdata=mysqli_fetch_assoc($other)){
        $F_S =  $otherdata['FinalStatus'];
		if($F_S == "YES")
		{
		echo '
		<tr>
		<td style="">'.$otherdata["PROJECT"].' </td> 
		<td style=""> '.$otherdata["CATEGORY"].'</td> 
		<td style=""> '.$otherdata["PROCESS"].'</td> 
		<td style=""> '.$otherdata["START_TIME"].' </td> 
		<td style="">'.$otherdata["END_TIME"].' </td> 
		<td style="" >'.$otherdata["TD"].' </td> 
	    <td style="background-color:#c3e6cb ;">'.$otherdata['TIMEEXCEED']. '</td>';
 		}
		else{ echo '
        <tr>
		<td style="">'.$otherdata["PROJECT"].' </td> 
		<td style=""> '.$otherdata["CATEGORY"].'</td> 
		<td style="bolder;color:#db1709"> '.$otherdata["PROCESS"].'</td> 
		<td style=""> '.$otherdata["START_TIME"].' </td> 
		<td style="">'.$otherdata["END_TIME"].' </td> 
		<td style="">'.$otherdata["TD"].' </td> 
        <td style="background-color:#f5c6cb;font-weight:bold;color:#8f1b1b;">'.$otherdata['TIMEEXCEED']. '</td></tr>';
    }
    
	 }
    ?>
     </table>
     </div>
    
            <div class="container-fluid head-container">
            <?php
            $qryla=mysqli_query($con," SELECT  DATE as date FROM `login_time` where NAME='$EmpName' AND LEFT(DATE,10)=CURDATE() limit 1;");
            $la=mysqli_fetch_array($qryla);
            $log_at = $la['date'];
            $log1 =  substr($log_at ,strrpos($log_at,' ')+1);
            $qrylo=mysqli_query($con,"SELECT logout_time as time From `user_reg_tbl` where name='$EmpName' and LEFT(logout_time,10) = CURDATE()");
            $lo=mysqli_fetch_array($qrylo);
            $log_out = $lo['time'];
            $log2 =  substr($log_out ,strrpos($log_out,' ')+1);
            $qrytotal=mysqli_query($con," SELECT LEFT(SEC_TO_TIME(SUM(total_time)),8) as totaltime  from login_time  where name= '$EmpName' and LEFT(DATE,10) = CURDATE()");
            $tt=mysqli_fetch_array($qrytotal);
            $total_time = $tt['totaltime'];

            ?>
            <label for="" class="font-weight-bold pl-5" style="margin-left:10px;font-family:Arial, Helvetica, sans-serif;padding-top:8px ;color:#065c0d">Login At:</label></center>
            <input class="forms font-weight-bold text-center" type="text" value="<?php echo $log1;?>"  style="width: 10%; border-radius:10px" >
                
            <label for="" class="font-weight-bold " style="margin-left:40px;color:#db5704;font-family:Arial, Helvetica, sans-serif">Logout At :</label>
            <input  class="forms font-weight-bold text-center" type="text" value="<?php echo $log2;?>" style="width: 10%;border-radius:10px">

            <label for="" class="font-weight-bold" style="margin-left:40px;color:#0b00f7;font-family:Arial, Helvetica, sans-serif">Lunch Time:</label>
                <?php
                    $query1 =mysqli_query($con ,"SELECT project as Proj,process as Sp,RIGHT(START_TIME,8) AS START_TIME,RIGHT(END_TIME,8) AS END_TIME,LEFT(SEC_TO_TIME(TIMESTAMPDIFF(SECOND,START_TIME,END_TIME)),8)AS TD from empdata_tbl where Emp='$EmpName' and process = 'LUNCHBREAK' and  LEFT(START_TIME,10) =CURDATE()");
                    $q=mysqli_fetch_array($query1);
                    $lunch_brk = $q['TD'];
                    $S= gmdate('H:i:s',1200);
                    if($lunch_brk > $S)
                    {
                 ?>
                <input  class="forms text-danger font-weight-bold text-center" type="text" value="<?php echo $lunch_brk; ?>" style="width: 10%;border-radius:10px">
                <?php } else{?>
            <input  class="forms text-success font-weight-bold text-center" type="text" value="<?php echo $lunch_brk; ?>" style="width: 10%;border-radius:10px">
                        <?php  } ?>
                
          <label for="" class="font-weight-bold " style="color:#4a070d;margin-left:25px;font-family:Arial, Helvetica, sans-serif"> Total Login Time:</label>
          <input  class="forms font-weight-bold text-center" type="text" value="<?php echo $total_time;?>" style="width: 10%;border-radius:10px">
          </div>

    </div>
 </div>
</body>
</html>