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.145.45.223
Current Path : /var/www/html/oums/src/ |
| Current File : /var/www/html/oums/src/attendance_report_month_summary.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 ="";
$mysql.="select masempl.fdeptcode,masempl.femplcode,femplname,fdesnordr,masdesn.fdesncode from masempl,masdesn,attendance ";
$mysql.="where masempl.fdesncode=masdesn.fdesncode and masempl.femplcode=attendance.femplcode ";
$mysql.="and masempl.fdeptcode='$dept_code' and attendance.fattndate like '$attn_mnth%'";
$mysql.="group by masempl.femplcode order by fempltype,fdesnordr,masdesn.fdesncode,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 MONTHWISE SUMMARY - {$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 ="";
$mysql1.="select ";
$mysql1.="count(case when fattnstat in ('pr','p1','p2','p3','po','d1','d2','d3') then fattnstat end) as lprdays, ";
$mysql1.="count(case when fattnstat='hw' then fattnstat end) as lhwdays, ";
$mysql1.="count(case when fattnstat='ab' then fattnstat end) as labdays, ";
$mysql1.="count(case when fattnstat='cl' then fattnstat end) as lcldays, ";
$mysql1.="count(case when fattnstat='cd' then fattnstat end) as lcddays, ";
$mysql1.="round(sum(case when fattnstat='cd' then fovertime end)) as lcdpack, ";
$mysql1.="time_format(sec_to_time(avg(time_to_sec(case when flogitime<>'0' then flogitime end))),'%r') as llitime,";
$mysql1.="time_format(sec_to_time(avg(time_to_sec(case when flogotime<>'0' then flogotime end))),'%r') as llotime ";
$mysql1.="from attendance where fdeptcode='$dept_code' and left(fattndate,7)='$attn_mnth' and femplcode='$empl_code' ";
$mysql1.="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/attendance_report_month_summary.pdf";
$pdf->output($resp_file,'F');
}
echo json_encode(array("mesg"=>$resp_mesg, "stat"=>$resp_stat, "file"=>$resp_file));
?>
|