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


Current Path : /var/www/html/oums/src/
Upload File :
Current File : /var/www/html/oums/src/attendance_report_yearwise_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_year=$_POST['attn_year'];	

	$mysql ="";
	$mysql.="select mas_empl.fdeptcode,mas_empl.femplcode,femplname,fdesnordr,left(fattndate,7) as latmnth, ";
	$mysql.="count(case when fattnstat in ('pr','p1','p2','p3','po','d1','d2','d3') then fattnstat end) as lprdays, ";
	$mysql.="count(case when fattnstat in ('hd','wo') then fattnstat end) as lhddays, ";
	$mysql.="count(case when fattnstat='hw' then fattnstat end) as lhwdays, ";	
	$mysql.="count(case when fattnstat='ab' then fattnstat end) as labdays, ";
	$mysql.="count(case when fattnstat='cl' then fattnstat end) as lcldays ";
	$mysql.="from mas_empl,mas_desn,attendance ";
	$mysql.="where mas_empl.fdesncode=mas_desn.fdesncode and mas_empl.femplcode=attendance.femplcode ";
	$mysql.="and mas_empl.fdeptcode='$dept_code' and attendance.fattndate like '$attn_year%' ";
	$mysql.="group by mas_empl.fdeptcode,mas_empl.femplcode,femplname,fdesnordr,left(fattndate,7) order by 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,"YEARWISE ATTENDANCE SUMMARY",0,1,"C");	$line_no++;							
				$pdf->Cell(95,7,"Department 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/attendance_report_year_summary.pdf";
		$pdf->output($resp_file,'F');		
	}
	echo json_encode(array("mesg"=>$resp_mesg, "stat"=>$resp_stat, "file"=>$resp_file));
?>