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.188.245.104
Current Path : /var/www/html/oums/src/ |
| Current File : /var/www/html/oums/src/xattendance_report_04.php |
<?php
include("sys_session.php");
include("sys_connect.php");
include("sys_mainphp.php");
$resp_mesg = "";
$resp_stat = "";
$resp_file = "";
$dept_code = $_POST['dept_code'];
$attn_mnth = $_POST['attn_mnth'];
$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='$dept_code' and attendance.fattndate like '$attn_mnth%'
group by masempl.fdeptcode,masempl.femplcode,femplname,fdesnordr order by 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 SUMMARY - {$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, "C.P.", 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='$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['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/attendance_report_month_summary.pdf";
$pdf->output($resp_file, 'F');
}
echo json_encode(array("mesg" => $resp_mesg, "stat" => $resp_stat, "file" => $resp_file));
|