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 : 13.58.224.40


Current Path : /var/www/html/oums/api/
Upload File :
Current File : /var/www/html/oums/api/getEmpAttListSummary.php

<?php

include("sys_connect.php");

if(!isset($_GET["emplcode"]) || !isset($_GET["month"]) || !isset($_GET["year"])
|| $_GET["emplcode"] == "" || $_GET["month"] == "" || $_GET["year"] == "" ){
    echo json_encode(array("msg" => "Invalid Params", "error_code" => -1));
    die();    
}
$emplcode = $_GET["emplcode"];
$month = $_GET["month"];
$year = $_GET["year"];

$deptcode = $_GET["deptcode"];
$usertype = $_GET["usertype"];
$cond = "";
if(strtoupper($usertype) == 'ADMIN') {
    $cond = "and e.fdeptcode = '{$deptcode}'";
} else {
    $cond = "and e.frepthead = '{$emplcode}' and e.femplcode <> '{$emplcode}'";
}

$query = "select a.fdeptcode, d.fdeptshrt as fdeptname, a.femplcode, 
e.femplname, a.fattnstat, sum(if(a.fattnstat = 'PR', 1, 0)) as fprcount, 
sum(if(a.fattnstat = 'AB', 1, 0)) as fabcount, 
sum(if(a.fattnstat = 'CL', 1, 0)) as fclcount
from attendance a inner join masempl e on a.femplcode = e.femplcode
inner join masdept d on e.fdeptcode = d.fdeptcode
where year(fattndate) = '{$year}' and month(fattndate) = '{$month}' {$cond}
group by e.fdeptcode, a.femplcode";
// var_dump($query);
$myres = mysqli_query($mycon, $query);
$mycnt = mysqli_num_rows($myres);
if($mycnt > 0) {
    $res = [];
    $i = 0;
    while($row = mysqli_fetch_assoc($myres)){
        $res[$i] = $row;
        $i++;
    }
    echo json_encode(array("error_code" => 0, 'data' => $res ));
}
else {
    echo json_encode(array("error_code" => -1, 'data'=> [], 'msg' => "Data Not found!!!" ));
}