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 : 3.133.155.253
Current Path : /var/www/html/oums/src/ |
| Current File : /var/www/html/oums/src/attendance_report.php |
<?php
include("sys_session.php");
include("sys_connect.php");
include("sys_mainphp.php");
$resp_mesg = "";
$resp_stat = "";
$resp_file = "";
if ($_POST["load_data"] == 'dept_data') {
if ($type_id == 'ADMIN') {
$mysql = "select * from masdept where fdeptstat='T' and fattnenbl='T' order by fdeptname";
} else {
$mysql = "select * from masdept d
inner join masdept_user u on d.fdeptcode = u.fdeptcode and fusercode='$user_id'
where d.fdeptstat='T' and d.fattnenbl='T' order by fdeptname";
}
$myres = mysqli_query($mycon, $mysql);
if (mysqli_num_rows($myres) > 1) {
echo "<option value='%'>ALL [CLIENTS]</option>";
}
while ($myrow = mysqli_fetch_assoc($myres)) {
echo "<option value='$myrow[fdeptcode]'>$myrow[fdeptname] [$myrow[fdeptcode]]</option>";
}
}
if ($_POST["load_data"] == 'desn_data') {
$mysql = "select * from masdesn where ifnull(fdeleted,'F')<>'T' order by fempldesn";
$myres = mysqli_query($mycon, $mysql);
if (mysqli_num_rows($myres) > 1) {
echo "<option value='%'>ALL [DESIGNATIONS]</option>";
}
while ($myrow = mysqli_fetch_assoc($myres)) {
echo "<option value='$myrow[fempldesn]'>$myrow[fempldesn]</option>";
}
}
if ($_POST['load_data'] == 'empl_data') {
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 = " inner join masdept_user du on em.fdeptcode = du.fdeptcode and em.fusercode='$user_id' ";
}
$mysql = "select distinct em.femplcode,femplname from masempl em
inner join attendance at on em.femplcode = at.femplcode and em.fdeptcode = at.fdeptcode " . $myqry . "
where em.fdeptcode like '$_POST[dept_code]' order by femplname";
$myres = mysqli_query($mycon, $mysql);
if (mysqli_num_rows($myres) > 1) {
echo "<option value='%'>ALL [EMPLOYEES]</option>";
}
while ($myrow = mysqli_fetch_assoc($myres)) {
echo "<option value='$myrow[femplcode]'>$myrow[femplname] [$myrow[femplcode]]</option>";
}
}
if ($_POST["load_data"] == 'attn_mnth') {
$dept_code = $_POST["dept_code"];
$mysql = "select date_format(fattndate,'%Y-%m') as lattnmnth,date_format(fattndate,'%Y %M') as ldispmnth from attendance
where fdeptcode like '%'
group by lattnmnth
order by lattnmnth desc;";
$myres = mysqli_query($mycon, $mysql);
if (mysqli_num_rows($myres) != 0) {
while ($row = mysqli_fetch_assoc($myres)) {
echo "<option value=$row[lattnmnth]>$row[ldispmnth]</option>";
}
}
}
if ($_POST["load_data"] == 'attn_year') {
$dept_code = $_POST["dept_code"];
$mysql = "select left(fattndate,4) as lattnyear from attendance where fdeptcode like '$dept_code'
group by left(fattndate,4) order by left(fattndate,4) desc";
$myres = mysqli_query($mycon, $mysql);
if (mysqli_num_rows($myres) != 0) {
while ($row = mysqli_fetch_assoc($myres)) {
echo "<option value=$row[lattnyear]>$row[lattnyear]</option>";
}
}
}
// MONTHWISE ATTENDANCE REPORT (INDIVIDUAL)
if ($_POST["load_data"] == 'attn_summ_empl') {
$dept_code = $_POST['dept_code'];
$attn_mnth = $_POST['attn_mnth'];
$empl_code = "";
$mysql = "select attendance.femplcode from masempl,masdesn,attendance
where masempl.fempldesn=masdesn.fempldesn and attendance.fdeptcode like '$dept_code'
and masempl.femplcode=attendance.femplcode and left(attendance.fattndate,7)='$attn_mnth'
group by attendance.femplcode ";
$myres = mysqli_query($mycon, $mysql);
$mycnt = mysqli_num_rows($myres);
if ($mycnt == 0) {
$resp_mesg = "No records found!";
$resp_stat = "F";
} else {
$line_no = 0;
$i = 1;
require_once("fpdf/fpdf.php");
$pdf = new FPDF('P', 'mm', 'A4');
$pdf->SetMargins(15, 15);
$pdf->SetFont('Arial', '', 9);
while ($myrow = mysqli_fetch_assoc($myres)) {
if ($empl_code <> $myrow['femplcode']) {
$line_no = 0;
$i = 1;
}
$empl_code = $myrow['femplcode'];
$year = substr($attn_mnth, 0, 4);
$mnth = substr($attn_mnth, 5, 2);
$days = cal_days_in_month(CAL_GREGORIAN, $mnth, $year);
$strt_date = date("01-m-Y");
$curr_date = date("d/m/Y");
for ($j = 1; $j <= $days; $j++) {
if ($line_no == 0 || $line_no % 36 == 0) {
$header_dept_code = $dept_code;
$header_dept_name = get_dept_name($dept_code);
$header_empl_code = $empl_code;
$header_empl_name = get_empl_name($empl_code);
$header_attn_mnth = strtoupper(date('F Y', strtotime($attn_mnth)));
$pdf->AddPage();
$pdf->SetFont('Arial', 'B', 10);
$pdf->Cell(0, 7, "LOGISYS, BANGALORE", 0, 1, "C");
$line_no++;
$pdf->Cell(0, 7, "ATTENDANCE SUMMARY (EMPL. WISE)", 0, 1, "C");
$line_no++;
$pdf->Cell(90, 7, "Employee Name: {$header_empl_name}", 0, 0, "L");
$pdf->Cell(90, 7, "Month: {$header_attn_mnth}", 0, 0, "R");
$pdf->ln();
$line_no++;
$pdf->SetFont('Arial', 'B', 9);
$x = $pdf->GetX();
$y = $pdf->GetY();
$pdf->MultiCell(10, 7, "Sl. No.", 1, "C");
$pdf->SetXY($x + 10, $y);
$pdf->MultiCell(20, 14, "Date", 1, "C");
$pdf->SetXY($x + 30, $y);
$pdf->MultiCell(40, 14, "Status", 1, "C");
$pdf->SetXY($x + 70, $y);
$pdf->MultiCell(45, 7, "Log In", 1, "C");
$pdf->SetXY($x + 70, $y + 7);
$pdf->MultiCell(15, 7, "Time", 1, "C");
$pdf->SetXY($x + 85, $y + 7);
$pdf->MultiCell(30, 7, "Remarks", 1, "C");
$pdf->SetXY($x + 115, $y);
$pdf->MultiCell(45, 7, "Log Out", 1, "C");
$pdf->SetXY($x + 115, $y + 7);
$pdf->MultiCell(15, 7, "Time", 1, "C");
$pdf->SetXY($x + 130, $y + 7);
$pdf->MultiCell(30, 7, "Remarks", 1, "C");
$pdf->SetXY($x + 160, $y);
$pdf->MultiCell(20, 14, "Work Hours", 1, "C");
$line_no++;
}
$pdf->SetFont('Arial', '', 9);
$attn_stat = "";
$caln_date = $attn_mnth . '-' . substr('0' . $j, -2, 2);
echo $mysql1 = "select attendance.*, masattn_stat.fstatdesc from masattn_stat,attendance
where femplcode='$empl_code' and fattndate='$caln_date'
and attendance.fdeptcode=masattn_stat.fdeptcode and attendance.fdeptcode like '$dept_code'
and attendance.fattnstat=masattn_stat.fattnstat ";
$myres1 = mysqli_query($mycon, $mysql1);
$myrow1 = mysqli_fetch_assoc($myres1);
$mycnt1 = mysqli_num_rows($myres1);
if ($mycnt1 == 0) {
$pdf->Cell(10, 7, "{$i}", 1, 0, "C"); //SL NO
$pdf->Cell(20, 7, "{$caln_date}", 1, 0, "C"); //DATE
$pdf->Cell(40, 7, "Pending", 1, 0, "C"); //STATUS
$pdf->Cell(15, 7, "-", 1, 0, "C"); //LOGIN TIME
$pdf->Cell(30, 7, "-", 1, 0, "C"); //LOGIN DIFF
$pdf->Cell(15, 7, "-", 1, 0, "C"); //LOGOUT TIME
$pdf->Cell(30, 7, "-", 1, 0, "C"); //LOGOUT DIFF
$pdf->Cell(20, 7, "-", 1, 0, "C"); //WORK HOURS
} else {
$attn_stat = strtolower($myrow1['fattnstat']);
$attn_desc = $myrow1['fstatdesc'];
$pdf->Cell(10, 7, "{$i}", 1, 0, "C");
$pdf->Cell(20, 7, "{$caln_date}", 1, 0, "C");
$pdf->Cell(40, 7, "{$attn_desc}", 1, 0, "C");
if ($attn_stat == "ab" || $attn_stat == "cl" || $attn_stat == "hd" || $attn_stat == "wo") {
$pdf->Cell(15, 7, "-", 1, 0, "C");
$pdf->Cell(30, 7, "-", 1, 0, "C");
$pdf->Cell(15, 7, "-", 1, 0, "C");
$pdf->Cell(30, 7, "-", 1, 0, "C");
$pdf->Cell(20, 7, "-", 1, 0, "C");
} else {
$logi_time = $myrow1['flogitime'];
$logi_diff = $myrow1['flogidiff'];
$pdf->Cell(15, 7, "{$logi_time}", 1, 0, "C");
if ($logi_diff > "00:00:00") {
$pdf->Cell(30, 7, "{$logi_diff} delay", 1, 0, "C");
} elseif ($logi_diff < "00:00:00") {
$pdf->Cell(30, 7, "{$logi_diff} early", 1, 0, "C");
} else {
$pdf->Cell(30, 7, "-", 1, 0, "C");
}
$logo_time = $myrow1['flogotime'];
$logo_diff = $myrow1['flogodiff'];
if ($logo_time == "00:00:00") {
$pdf->Cell(15, 7, "-", 1, 0, "C");
$pdf->Cell(30, 7, "Pending", 1, 0, "C");
} else {
if ($logo_diff > "00:00:00") {
$pdf->Cell(15, 7, "{$logo_time}", 1, 0, "C");
$pdf->Cell(30, 7, "{$logo_diff} late", 1, 0, "C");
} elseif ($logo_diff < "00:00:00") {
$pdf->Cell(15, 7, "{$logo_time}", 1, 0, "C");
$pdf->Cell(30, 7, "{$logo_diff} early", 1, 0, "C");
} elseif ($logo_diff == "00:00:00") {
$pdf->Cell(15, 7, "{$logo_time}", 1, 0, "C");
$pdf->Cell(30, 7, "-", 1, 0, "C");
} else {
$pdf->Cell(15, 7, "-", 1, 0, "C");
$pdf->Cell(30, 7, "-", 1, 0, "C");
}
}
$work_hour = $myrow1['fworkhour'];
if ($work_hour > "00:00:00") {
$pdf->Cell(20, 7, "{$work_hour}", 1, 0, "C");
} else {
$pdf->Cell(20, 7, "-", 1, 0, "C");
}
}
}
$i++;
$pdf->ln();
$line_no++;
}
}
$resp_file = "reports/rep_" . $_POST["load_data"] . ".pdf";
$pdf->output($resp_file, 'F');
}
}
// ATTENDANCE MONTHWISE SUMMARY - MONTH
if ($_POST["load_data"] == 'attn_summ_mnth') {
$dept_code = $_POST['dept_code'];
$attn_mnth = $_POST['attn_mnth'];
$mysql = "select masempl.fdeptcode,masempl.femplcode,femplname,fdesnordr,masdesn.fempldesn from masempl,masdesn,attendance
where masempl.fempldesn=masdesn.fempldesn and masempl.femplcode=attendance.femplcode
and masempl.fdeptcode like '$dept_code' and attendance.fattndate like '$attn_mnth%'
group by masempl.femplcode order by fdeptcode,fempltype,fdesnordr,masdesn.fempldesn,femplname";
$myres = mysqli_query($mycon, $mysql);
$mycnt = mysqli_num_rows($myres);
if ($mycnt == 0) {
$mess_text = "No records found!";
$resp_stat = "F";
} else {
$resp_stat = "T";
$dept_code = "";
$line_no = 0;
require_once("fpdf/fpdf.php");
$pdf = new FPDF('P', 'mm', 'A4');
$pdf->SetMargins(15, 15);
$pdf->SetFont('Arial', '', 9);
while ($row = mysqli_fetch_assoc($myres)) {
if ($dept_code <> $row['fdeptcode']) {
$line_no = 0;
$i = 1;
}
if ($line_no == 0 || $line_no % 38 == 0) {
$dept_code = $row['fdeptcode'];
$header_dept_code = $dept_code;
$header_dept_name = get_dept_name($dept_code);
$header_attn_mnth = strtoupper(date('F Y', strtotime($attn_mnth)));
$pdf->AddPage();
$pdf->SetFont('Arial', 'B', 10);
$pdf->Cell(0, 7, "LOGISYS, BANGALORE", 0, 1, "C");
$line_no++;
$pdf->Cell(0, 7, "ATTENDANCE SUMMARY (MONTH WISE) - {$header_attn_mnth}", 0, 1, "C");
$line_no++;
$pdf->Cell(0, 7, "[{$header_dept_name}]", 0, 1, "C");
$line_no++;
$pdf->SetFont('Arial', 'B', 9);
$pdf->Cell(10, 7, "Sl No", 1, 0, "C");
$pdf->Cell(55, 7, "Empl. Name", 1, 0, "C");
$pdf->Cell(15, 7, "Total PR", 1, 0, "C");
$pdf->Cell(15, 7, "Total HW", 1, 0, "C");
$pdf->Cell(15, 7, "Total AB", 1, 0, "C");
$pdf->Cell(15, 7, "Total CL", 1, 0, "C");
$pdf->Cell(15, 7, "Total CD", 1, 0, "C");
$pdf->Cell(40, 7, "Remarks", 1, 0, "C");
$pdf->ln();
$line_no++;
}
$empl_code = $row['femplcode'];
$pdf->SetFont('Arial', '', 9);
$pdf->Cell(10, 7, "{$i}", 1, 0, "C");
$pdf->Cell(55, 7, "{$row['femplname']}", 1, 0, "L");
$mysql1 = "select
count(case when fattnstat in ('pr','p1','p2','p3','po','d1','d2','d3') then fattnstat end) as lprdays,
count(case when fattnstat='hw' then fattnstat end) as lhwdays,
count(case when fattnstat='ab' then fattnstat end) as labdays,
count(case when fattnstat='cl' then fattnstat end) as lcldays,
count(case when fattnstat='cd' then fattnstat end) as lcddays,
round(sum(case when fattnstat='cd' then fovertime end)) as lcdpack,
time_format(sec_to_time(avg(time_to_sec(case when flogitime<>'0' then flogitime end))),'%r') as llitime,
time_format(sec_to_time(avg(time_to_sec(case when flogotime<>'0' then flogotime end))),'%r') as llotime
from attendance where fdeptcode like '$dept_code' and left(fattndate,7)='$attn_mnth' and femplcode='$empl_code'
order by fdeptcode,femplcode";
$myres1 = mysqli_query($mycon, $mysql1);
while ($row1 = mysqli_fetch_assoc($myres1)) {
$attn_remk = "";
$pdf->Cell(15, 7, "{$row1['lprdays']}", 1, 0, "C");
$pdf->Cell(15, 7, "{$row1['lhwdays']}", 1, 0, "C");
$pdf->Cell(15, 7, "{$row1['labdays']}", 1, 0, "C");
$pdf->Cell(15, 7, "{$row1['lcldays']}", 1, 0, "C");
$pdf->Cell(15, 7, "{$row1['lcddays']}", 1, 0, "C");
if ($row1['lcdpack'] > 0) {
$pdf->Cell(40, 7, "Coding: {$row1['lcdpack']}", 1, 0, "L");
} else {
$pdf->Cell(40, 7, "", 1, 0, "L");
}
}
$i++;
$pdf->ln();
$line_no++;
}
$resp_file = "reports/rep_" . $_POST["load_data"] . ".pdf";
$pdf->output($resp_file, 'F');
}
}
// ATTENDANCE REPORT (DATEWISE)
if ($_POST["load_data"] == 'attn_stat_date') {
$dept_code = $_POST['dept_code'];
$attn_dat1 = $_POST['attn_dat1'];
$attn_dat2 = $_POST['attn_dat2'];
$mysql = "select em.fdeptcode,em.femplcode,em.femplname,ad.fattndate,ad.fattnstat,
ma.fstatdesc,ad.flogitime,ad.flogotime,ad.flogidiff,ad.flogodiff,ad.fworkhour
from attendance ad
inner join masempl em on ad.femplcode = em.femplcode
inner join masattn ma on em.fdeptcode = ma.fdeptcode and ad.fattnstat = ma.fattnstat
where ad.fdeptcode like '$_POST[dept_code]' and ad.fattndate between str_to_date('$_POST[attn_dat1]','%d/%m/%Y') and str_to_date('$_POST[attn_dat2]','%d/%m/%Y')
order by fattndate,fdeptcode,femplname";
$myres = mysqli_query($mycon, $mysql);
$mycnt = mysqli_num_rows($myres);
if ($mycnt == 0) {
$resp_mesg = "No details found!";
$resp_stat = "F";
} else {
$resp_stat = "T";
$dept_code = "";
$line_no = 0;
$i = 1;
require_once("fpdf/fpdf.php");
$pdf = new FPDF('P', 'mm', 'A4');
$pdf->SetMargins(15, 15);
$pdf->SetFont('Arial', '', 9);
while ($myrow = mysqli_fetch_assoc($myres)) {
if ($attn_date <> $myrow['fattndate']) {
$line_no = 0;
$i = 1;
}
if ($line_no == 0 || $line_no % 36 == 0) {
$attn_date = $myrow['fattndate'];
$dept_code = $myrow['fdeptcode'];
$rept_date = date('d/m/Y', strtotime($attn_date));
$header_dept_code = $dept_code;
$header_dept_name = get_dept_name($dept_code);
$pdf->AddPage();
$pdf->SetFont('Arial', 'B', 10);
$pdf->Cell(0, 7, "LOGISYS, BANGALORE", 0, 1, "C");
$line_no++;
$pdf->Cell(0, 7, "ATTENDANCE STATEMENT (DATE WISE)", 0, 1, "C");
$line_no++;
$pdf->Cell(95, 7, "Client Name: {$header_dept_name}", 0, 0, "L");
$pdf->Cell(90, 7, "Date: {$rept_date}", 0, 0, "R");
$pdf->ln();
$line_no++;
$pdf->SetFont('Arial', 'B', 9);
$x = $pdf->GetX();
$y = $pdf->GetY();
$pdf->MultiCell(10, 7, "Sl. No.", 1, "C");
$pdf->SetXY($x + 10, $y);
$pdf->MultiCell(15, 7, "Empl. Code", 1, "C");
$pdf->SetXY($x + 25, $y);
$pdf->MultiCell(50, 14, "Employee Name", 1, "C");
$pdf->SetXY($x + 75, $y);
$pdf->MultiCell(25, 14, "Status", 1, "C");
$pdf->SetXY($x + 100, $y);
$pdf->MultiCell(35, 7, "Log In", 1, "C");
$pdf->SetXY($x + 100, $y + 7);
$pdf->MultiCell(15, 7, "Time", 1, "C");
$pdf->SetXY($x + 115, $y + 7);
$pdf->MultiCell(20, 7, "Remarks", 1, "C");
$pdf->SetXY($x + 135, $y);
$pdf->MultiCell(35, 7, "Log Out", 1, "C");
$pdf->SetXY($x + 135, $y + 7);
$pdf->MultiCell(15, 7, "Time", 1, "C");
$pdf->SetXY($x + 150, $y + 7);
$pdf->MultiCell(20, 7, "Remarks", 1, "C");
$pdf->SetXY($x + 170, $y);
$pdf->MultiCell(15, 7, "Work Hours", 1, "C");
$line_no++;
}
$empl_code = $myrow['femplcode'];
$pdf->SetFont('Arial', '', 9);
$pdf->Cell(10, 7, "{$i}", 1, 0, "C");
$pdf->Cell(15, 7, "{$myrow['femplcode']}", 1, 0, "C");
$pdf->Cell(50, 7, "{$myrow['femplname']}", 1, 0, "L");
$pdf->Cell(25, 7, "{$myrow['fstatdesc']}", 1, 0, "C");
$attn_stat = strtolower($myrow['fattnstat']);
if ($attn_stat == "ab" || $attn_stat == "cl" || $attn_stat == "hd" || $attn_stat == "wo") {
$pdf->Cell(15, 7, "-", 1, 0, "C");
$pdf->Cell(20, 7, "-", 1, 0, "C");
$pdf->Cell(15, 7, "-", 1, 0, "C");
$pdf->Cell(20, 7, "-", 1, 0, "C");
$pdf->Cell(15, 7, "-", 1, 0, "C");
} else {
$logi_time = $myrow['flogitime'];
$logi_diff = $myrow['flogidiff'];
$pdf->Cell(15, 7, "{$logi_time}", 1, 0, "C");
if ($logi_diff > "00:00:00") {
$pdf->Cell(20, 7, "{$logi_diff} delay", 1, 0, "C");
} elseif ($logi_diff < "00:00:00") {
$pdf->Cell(20, 7, "{$logi_diff} early", 1, 0, "C");
} else {
$pdf->Cell(20, 7, "-", 1, 0, "C");
}
$logo_time = $myrow['flogotime'];
$logo_diff = $myrow['flogodiff'];
if ($logo_time == "00:00:00") {
$pdf->Cell(15, 7, "-", 1, 0, "C");
$pdf->Cell(20, 7, "Pending", 1, 0, "C");
} else {
if ($logo_diff > "00:00:00") {
$pdf->Cell(15, 7, "{$logo_time}", 1, 0, "C");
$pdf->Cell(20, 7, "{$logo_diff} late", 1, 0, "C");
} elseif ($logo_diff < "00:00:00") {
$pdf->Cell(15, 7, "{$logo_time}", 1, 0, "C");
$pdf->Cell(20, 7, "{$logo_diff} early", 1, 0, "C");
} elseif ($logo_diff == "00:00:00") {
$pdf->Cell(15, 7, "{$logo_time}", 1, 0, "C");
$pdf->Cell(20, 7, "-", 1, 0, "C");
} else {
$pdf->Cell(15, 7, "-", 1, 0, "C");
$pdf->Cell(20, 7, "-", 1, 0, "C");
}
}
$work_hour = $myrow['fworkhour'];
if ($work_hour > "00:00:00") {
$pdf->Cell(15, 7, "{$work_hour}", 1, 0, "C");
} else {
$pdf->Cell(15, 7, "-", 1, 0, "C");
}
}
$i++;
$pdf->ln();
$line_no++;
}
$resp_file = "reports/rep_" . $_POST["load_data"] . ".pdf";
$pdf->output($resp_file, 'F');
}
}
// ATTENDANCE SUMMARY - MONTH
if ($_POST["load_data"] == 'attn_stat_mnth') {
$dept_code = $_POST['dept_code'];
$attn_mnth = $_POST['attn_mnth'];
echo $mysql = "select masempl.fdeptcode,masempl.femplcode,femplname,fdesnordr from masempl,masdesn,attendance
where masempl.fempldesn=masdesn.fempldesn and masempl.femplcode=attendance.femplcode
and masempl.fdeptcode like '$dept_code' and attendance.fattndate like '$attn_mnth%'
group by masempl.fdeptcode,masempl.femplcode,femplname,fdesnordr order by fdeptcode,fempltype,fdesnordr,femplname";
$myres = mysqli_query($mycon, $mysql);
$mycnt = mysqli_num_rows($myres);
if ($mycnt == 0) {
$resp_mesg = "No records found!";
$resp_stat = "F";
} else {
$resp_stat = "T";
$dept_code = "";
$line_no = 0;
$i = 0;
require_once("fpdf/fpdf.php");
$pdf = new FPDF('L', 'mm', 'Legal');
while ($row = mysqli_fetch_assoc($myres)) {
$attn_date = $row['fattndate'];
$year = substr($attn_mnth, 0, 4);
$mnth = substr($attn_mnth, 5, 2);
$days = cal_days_in_month(CAL_GREGORIAN, $mnth, $year);
if ($line_no == 0 || $line_no % 24 == 0) {
$d = 1;
$dept_code = $row['fdeptcode'];
$header_dept_code = $dept_code;
$header_dept_name = get_dept_name($row['fdeptcode']);
$header_attn_mnth = strtoupper(date('F Y', strtotime($attn_mnth)));
$pdf->AddPage();
$pdf->SetMargins(10, 10);
$pdf->SetFont('Arial', 'B', 10);
$pdf->Cell(0, 7, "LOGISYS, BANGALORE", 0, 1, "C");
$line_no++;
$pdf->Cell(0, 7, "ATTENDANCE STATEMENT (MONTH WISE) - {$header_attn_mnth}", 0, 1, "C");
$line_no++;
$pdf->Cell(0, 7, "{$header_dept_name}", 0, 0, "C");
$pdf->ln();
$line_no++;
$pdf->SetFont('Arial', 'B', 9);
$pdf->Cell(10, 7, "Sl No", 1, 0, "C");
$pdf->Cell(55, 7, "Employee Name", 1, 0, "C");
$pdf->Cell(10, 7, "Ab.", 1, 0, "C");
$pdf->Cell(10, 7, "C.L.", 1, 0, "C");
$pdf->Cell(10, 7, "H.W.", 1, 0, "C");
$pdf->Cell(10, 7, "Pr.", 1, 0, "C");
$pdf->Cell(10, 7, "Cd.", 1, 0, "C");
$pdf->Cell(5, 7, "", 0, 0, "C");
for ($d = 1; $d <= $days; $d++) {
$pdf->Cell(7, 7, "{$d}", 1, 0, "C");
}
}
$i++;
$empl_code = $row['femplcode'];
$mysql2 = "select
sum(case when fattnstat in ('pr','p1','p2','p3','po','d1','d2','d3') then 1 else 0 end) as lprdays,
sum(case when fattnstat='hw' then 1 else 0 end) as lhwdays,
sum(case when fattnstat = 'ab' then 1 else 0 end) as labdays,
sum(case when fattnstat = 'cl' then 1 else 0 end) as lcldays,
sum(case when fattnstat = 'cd' then 1 else 0 end) as lcddays,
round(sum(case when fattnstat = 'cd' then fcodepack end)) as lcdpack
from attendance where fdeptcode like '$dept_code' and left(fattndate,7)='$attn_mnth' and femplcode='$empl_code'
group by femplcode";
$myres2 = mysqli_query($mycon, $mysql2);
$myrow2 = mysqli_fetch_assoc($myres2);
$pdf->SetFont('Arial', '', 9);
$pdf->ln();
$line_no++;
$pdf->Cell(10, 7, "{$i}", 1, 0, "C");
$pdf->Cell(55, 7, "{$row['femplcode']} {$row['femplname']}", 1, 0, "L");
$pdf->Cell(10, 7, "{$myrow2['labdays']}", 1, 0, "C");
$pdf->Cell(10, 7, "{$myrow2['lcldays']}", 1, 0, "C");
$pdf->Cell(10, 7, "{$myrow2['lhwdays']}", 1, 0, "C");
$pdf->Cell(10, 7, "{$myrow2['lprdays']}", 1, 0, "C");
$pdf->Cell(10, 7, "{$myrow2['lcdpack']}", 1, 0, "C");
$pdf->Cell(5, 7, "", 0, 0, "C");
for ($j = 1; $j <= $days; $j++) {
$attn_stat = "";
$caln_date = $attn_mnth . '-' . substr('0' . $j, -2, 2);
$mysql1 = "select * from attendance where femplcode='$empl_code' and fattndate='$caln_date'";
$myres1 = mysqli_query($mycon, $mysql1);
while ($myrow1 = mysqli_fetch_assoc($myres1)) {
$attn_stat = strtoupper($myrow1['fattnstat']);
if ($attn_stat == "CD") {
$attn_stat = intval($myrow1['fcodepack']);
}
}
$pdf->Cell(7, 7, "{$attn_stat}", 1, 0, "C");
}
$tot_abdays = $tot_abdays + $myrow2['labdays'];
$tot_cldays = $tot_cldays + $myrow2['lcldays'];
$tot_hwdays = $tot_hwdays + $myrow2['lhwdays'];
$tot_prdays = $tot_prdays + $myrow2['lprdays'];
$tot_cddays = $tot_cddays + $myrow2['lcdpack'];
}
$pdf->ln();
$line_no++;
$pdf->Cell(65, 7, "Total", 1, 0, "C");
$pdf->Cell(10, 7, "{$tot_abdays}", 1, 0, "C");
$pdf->Cell(10, 7, "{$tot_cldays}", 1, 0, "C");
$pdf->Cell(10, 7, "{$tot_hwdays}", 1, 0, "C");
$pdf->Cell(10, 7, "{$tot_prdays}", 1, 0, "C");
$pdf->Cell(10, 7, "{$tot_cddays}", 1, 0, "C");
$resp_file = "reports/rep_" . $_POST["load_data"] . ".pdf";
$pdf->output($resp_file, 'F');
}
}
// YEARWISE ATTENDANCE SUMMARY
if ($_POST["load_data"] == 'attn_summ_year') {
$dept_code = $_POST['dept_code'];
$attn_year = $_POST['attn_year'];
$mysql = "select masempl.fdeptcode,masempl.femplcode,femplname,fdesnordr,left(fattndate,7) as latmnth,
count(case when fattnstat in ('pr','p1','p2','p3','po','d1','d2','d3') then fattnstat end) as lprdays,
count(case when fattnstat in ('hd','wo') then fattnstat end) as lhddays,
count(case when fattnstat='hw' then fattnstat end) as lhwdays,
count(case when fattnstat='ab' then fattnstat end) as labdays,
count(case when fattnstat='cl' then fattnstat end) as lcldays
from masempl,masdesn,attendance
where masempl.fempldesn=masdesn.fempldesn and masempl.femplcode=attendance.femplcode
and masempl.fdeptcode like '$dept_code' and attendance.fattndate like '$attn_year%'
group by masempl.fdeptcode,masempl.femplcode,femplname,fdesnordr,left(fattndate,7) order by fdeptcode,fempltype,fdesnordr,femplname,left(fattndate,7)";
$myres = mysqli_query($mycon, $mysql);
$mycnt = mysqli_num_rows($myres);
if ($mycnt == 0) {
$resp_mesg = "No records found!";
$resp_stat = "F";
} else {
$resp_stat = "T";
$dept_code = "";
$empl_code = "";
$line_no = 0;
$i = 0;
require_once("fpdf/fpdf.php");
$pdf = new FPDF('P', 'mm', 'A4');
while ($myrow = mysqli_fetch_assoc($myres)) {
if ($empl_code <> $myrow['femplcode']) {
$d = 1;
$dept_code = $myrow['fdeptcode'];
$header_dept_code = $dept_code;
$header_dept_name = get_dept_name($myrow['fdeptcode']);
$header_empl_name = get_empl_name($myrow['femplcode']);
if ($empl_code != "") {
$pdf->ln();
$line_no++;
$pdf->Cell(60, 7, "Total", 1, 0, "C");
$pdf->Cell(15, 7, "{$tmtdays}", 1, 0, "C");
$pdf->Cell(15, 7, "{$thddays}", 1, 0, "C");
$pdf->Cell(15, 7, "{$tprdays}", 1, 0, "C");
$pdf->Cell(15, 7, "{$thwdays}", 1, 0, "C");
$pdf->Cell(15, 7, "{$tcldays}", 1, 0, "C");
$pdf->Cell(15, 7, "{$tabdays}", 1, 0, "C");
$pdf->Cell(40, 7, "", 1, 0, "C");
$i = 0;
$tmtdays = 0;
$tprdays = 0;
$thwdays = 0;
$tcldays = 0;
$tabdays = 0;
}
$pdf->AddPage();
$pdf->SetMargins(10, 10);
$pdf->SetFont('Arial', 'B', 10);
$pdf->Cell(0, 7, "LOGISYS, BANGALORE", 0, 1, "C");
$line_no++;
$pdf->Cell(0, 7, "ATTENDANCE SUMMARY (YEAR WISE)", 0, 1, "C");
$line_no++;
$pdf->Cell(95, 7, "Client Name: {$header_dept_name}", 0, 0, "L");
$pdf->Cell(90, 7, "Empl.: {$header_empl_name}", 0, 0, "R");
$pdf->ln();
$line_no++;
$pdf->SetFont('Arial', 'B', 9);
$pdf->Cell(10, 7, "Sl No", 1, 0, "C");
$pdf->Cell(50, 7, "Month", 1, 0, "C");
$pdf->Cell(15, 7, "Days", 1, 0, "C");
$pdf->Cell(15, 7, "Hol.", 1, 0, "C");
$pdf->Cell(15, 7, "Pr.", 1, 0, "C");
$pdf->Cell(15, 7, "H.W.", 1, 0, "C");
$pdf->Cell(15, 7, "C.L.", 1, 0, "C");
$pdf->Cell(15, 7, "Ab.", 1, 0, "C");
$pdf->Cell(40, 7, "Remarks", 1, 0, "C");
}
$i++;
$pdf->SetFont('Arial', '', 9);
$pdf->ln();
$line_no++;
$year = substr($myrow['latmnth'], 0, 4);
$mnth = substr($myrow['latmnth'], 5, 2);
$days = cal_days_in_month(CAL_GREGORIAN, $mnth, $year);
$mnth = $myrow['latmnth'] . " " . strtoupper(date('F', strtotime($myrow['latmnth'])));
$pdf->Cell(10, 7, "{$i}", 1, 0, "C");
$pdf->Cell(50, 7, "{$mnth}", 1, 0, "L");
$pdf->Cell(15, 7, "{$days}", 1, 0, "C");
$pdf->Cell(15, 7, "{$myrow['lhddays']}", 1, 0, "C");
$pdf->Cell(15, 7, "{$myrow['lprdays']}", 1, 0, "C");
$pdf->Cell(15, 7, "{$myrow['lhwdays']}", 1, 0, "C");
$pdf->Cell(15, 7, "{$myrow['lcldays']}", 1, 0, "C");
$pdf->Cell(15, 7, "{$myrow['labdays']}", 1, 0, "C");
$pdf->Cell(40, 7, "", 1, 0, "C");
$tmtdays = $tmtdays + $days;
$thddays = $thddays + $myrow['lhddays'];
$tprdays = $tprdays + $myrow['lprdays'];
$thwdays = $thwdays + $myrow['lhwdays'];
$tabdays = $tabdays + $myrow['labdays'];
$tcldays = $tcldays + $myrow['lcldays'];
$empl_code = $myrow['femplcode'];
}
$resp_file = "reports/rep_" . $_POST["load_data"] . ".pdf";
$pdf->output($resp_file, 'F');
}
}
// ABSENT REPORT (DATEWISE)
if ($_POST["load_data"] == 'attn_detl_absn') {
if ($type_id != "ADMIN") {
$mycnd = " inner join masdept_user du on ad.fdeptcode = du.fdeptcode and du.fusercode = '$user_id' ";
}
$mysql = "select date_format(ad.fattndate,'%d/%m/%Y') as lattndate,ad.fattndate,dp.fdeptcode,dp.fdeptname,dp.fdeptshrt,
em.femplcode,femplname,fempldesn,ad.fattnstat
from attendance ad
inner join masempl em on ad.femplcode = em.femplcode
inner join masdesn ds on em.fempldesn = ds.fempldesn and em.fempldesn like '$_POST[empl_desn]'
inner join masdept dp on ad.fdeptcode = dp.fdeptcode
inner join masattn_stat ap on ad.fattnstat = ap.fattnstat and ad.fdeptcode = ap.fdeptcode " . $mycnd . "
where ad.fdeptcode like '$_POST[dept_code]' and ad.fattnstat in ('AB','CL')
and ad.fattndate between str_to_date('$_POST[attn_dat1]','%d/%m/%Y') and str_to_date('$_POST[attn_dat2]','%d/%m/%Y')
order by fattndate,fdeptname,femplname";
$myres = mysqli_query($mycon, $mysql);
$mycnt = mysqli_num_rows($myres);
if ($mycnt == 0) {
$resp_mesg = "No details found!";
$resp_stat = "F";
} else {
$resp_stat = "T";
$dept_code = "";
$line_no = 0;
$i = 1;
require_once("fpdf/fpdf.php");
$pdf = new FPDF('P', 'mm', 'A4');
$pdf->SetMargins(15, 15);
$pdf->SetFont('Arial', '', 9);
while ($myrow = mysqli_fetch_assoc($myres)) {
if ($line_no == 0 || $line_no % 37 == 0) {
$pdf->AddPage();
$pdf->SetFont('Arial', 'B', 10);
$pdf->Cell(0, 7, "ABSENT REPORT (DATE WISE)", 0, 1, "C");
$line_no++;
$pdf->Cell(0, 7, "Client: {$_POST['dept_name']}", 0, 1, "C");
$line_no++;
$pdf->Cell(0, 7, "Designation: {$_POST['desn_name']}, Date Range: {$_POST['attn_dat1']} to {$_POST['attn_dat2']}", 0, 1, "C");
$line_no++;
$pdf->SetFont('Arial', 'B', 9);
$pdf->Cell(10, 7, "Sl. No.", 1, 0, "C");
$pdf->Cell(20, 7, "Date", 1, 0, "C");
$pdf->Cell(25, 7, "Client", 1, 0, "C");
$pdf->Cell(70, 7, "Employee Name", 1, 0, "C");
$pdf->Cell(40, 7, "Designation", 1, 0, "C");
$pdf->Cell(20, 7, "Remarks", 1, 1, "C");
$line_no++;
}
$pdf->SetFont('Arial', '', 9);
$pdf->Cell(10, 7, "{$i}", 1, 0, "C");
$pdf->Cell(20, 7, "{$myrow['lattndate']}", 1, 0, "C");
$pdf->Cell(25, 7, "[{$myrow['fdeptcode']}] {$myrow['fdeptshrt']}", 1, 0, "C");
$pdf->Cell(70, 7, "[{$myrow['femplcode']}] {$myrow['femplname']}", 1, 0, "L");
$pdf->Cell(40, 7, "{$myrow['fempldesn']}", 1, 0, "C");
$pdf->Cell(20, 7, "{$myrow['fattnstat']}", 1, 0, "C");
$i++;
$pdf->ln();
$line_no++;
}
$resp_file = "reports/rep_" . $_POST["load_data"] . ".pdf";
$pdf->output($resp_file, 'F');
}
}
// EXCEPTIONAL REPORT (DATEWISE)
if ($_POST["load_data"] == 'attn_detl_expt') {
if ($type_id != "ADMIN") {
$mycnd = " inner join masdept_user du on ad.fdeptcode = du.fdeptcode and du.fusercode = '$user_id' ";
}
$mysql = "select date_format(ad.fattndate,'%d/%m/%Y') as lattndate,ad.fattndate,dp.fdeptcode,dp.fdeptname,dp.fdeptshrt,
em.femplcode,femplname,fempldesn,dp.flogitime,dp.flogotime,ad.flogitime as llogitime,ad.flogotime as llogotime,
(case when ap.fattntype='PR' and dp.flogitime<ad.flogitime and ad.flogitime<>'00:00:00' then concat('Login late by ',time_format(abs(timediff(dp.flogitime,ad.flogitime)),'%H:%i:%s')) else '' end) as flogiremk,
(case when ap.fattntype='PR' and dp.flogotime>ad.flogotime and ad.flogotime<>'00:00:00' then concat('Logout early by ',time_format(abs(timediff(dp.flogotime,ad.flogotime)),'%H:%i:%s')) else '' end) as flogoremk
from attendance ad
inner join masempl em on ad.femplcode = em.femplcode
inner join masdesn ds on em.fempldesn = ds.fempldesn and em.fempldesn like '$_POST[empl_desn]'
inner join masdept dp on ad.fdeptcode = dp.fdeptcode
inner join masattn_stat ap on ad.fattnstat = ap.fattnstat and ad.fdeptcode = ap.fdeptcode " . $mycnd . "
where ad.fdeptcode like '$_POST[dept_code]' and ad.fattndate between str_to_date('$_POST[attn_dat1]','%d/%m/%Y') and str_to_date('$_POST[attn_dat2]','%d/%m/%Y')
and ap.fattntype='PR' and ((dp.flogitime<ad.flogitime and ad.flogitime<>'00:00:00') or (dp.flogotime>ad.flogotime and ad.flogotime<>'00:00:00'))
order by ad.fattndate,fdeptname,femplname";
$myres = mysqli_query($mycon, $mysql);
$mycnt = mysqli_num_rows($myres);
if ($mycnt == 0) {
$resp_mesg = "No details found!";
$resp_stat = "F";
} else {
$resp_stat = "T";
$dept_code = "";
$line_no = 0;
$i = 1;
require_once("fpdf/fpdf.php");
$pdf = new FPDF('L', 'mm', 'A4');
$pdf->SetMargins(15, 15);
$pdf->SetFont('Arial', '', 9);
while ($myrow = mysqli_fetch_assoc($myres)) {
if ($line_no == 0 || $line_no % 24 == 0) {
$pdf->AddPage();
$pdf->SetFont('Arial', 'B', 10);
$pdf->Cell(0, 7, "EXCEPTIONAL REPORT (DATE WISE)", 0, 1, "C");
$line_no++;
$pdf->Cell(0, 7, "Client: {$_POST['dept_name']}", 0, 1, "C");
$line_no++;
$pdf->Cell(0, 7, "Designation: {$_POST['desn_name']}, Date Range: {$_POST['attn_dat1']} to {$_POST['attn_dat2']}", 0, 1, "C");
$line_no++;
$pdf->SetFont('Arial', 'B', 9);
$pdf->Cell(10, 7, "Sl. No.", 1, 0, "C");
$pdf->Cell(20, 7, "Date", 1, 0, "C");
$pdf->Cell(25, 7, "Client", 1, 0, "C");
$pdf->Cell(60, 7, "Employee Name", 1, 0, "C");
$pdf->Cell(40, 7, "Designation", 1, 0, "C");
$pdf->Cell(20, 7, "In Time", 1, 0, "C");
$pdf->Cell(20, 7, "Out Time", 1, 0, "C");
$pdf->Cell(70, 7, "Remarks", 1, 1, "C");
$line_no++;
}
$pdf->SetFont('Arial', '', 9);
$pdf->Cell(10, 7, "{$i}", 1, 0, "C");
$pdf->Cell(20, 7, "{$myrow['lattndate']}", 1, 0, "C");
$pdf->Cell(25, 7, "[{$myrow['fdeptcode']}] {$myrow['fdeptshrt']}", 1, 0, "C");
$pdf->Cell(60, 7, "[{$myrow['femplcode']}] {$myrow['femplname']}", 1, 0, "L");
$pdf->Cell(40, 7, "{$myrow['fempldesn']}", 1, 0, "L");
$pdf->Cell(20, 7, "{$myrow['llogitime']}", 1, 0, "C");
$pdf->Cell(20, 7, "{$myrow['llogotime']}", 1, 0, "C");
if ($myrow['flogiremk'] == '') {
$pdf->Cell(70, 7, "{$myrow['flogoremk']}", 1, 0, "L");
} else {
$pdf->Cell(70, 7, "{$myrow['flogiremk']} {$myrow['flogoremk']}", 1, 0, "L");
}
$i++;
$pdf->ln();
$line_no++;
}
$resp_file = "reports/rep_" . $_POST["load_data"] . ".pdf";
$pdf->output($resp_file, 'F');
}
}
echo json_encode(array("mesg" => $resp_mesg, "stat" => $resp_stat, "file" => $resp_file));
|