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.15.198.120


Current Path : /var/www/misc/public_html/oums_old/phpscript/
Upload File :
Current File : /var/www/misc/public_html/oums_old/phpscript/attendance_report_datewise.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_dat1=$_POST['attn_dat1'];	
	$attn_dat2=$_POST['attn_dat2'];			

	$mysql ="";
	$mysql.="select attendance.fdeptcode,attendance.femplcode,femplname,";
	$mysql.="fattndate,attendance.fattnstat,fstatdesc,attendance.flogitime,attendance.flogotime,";
	$mysql.="flogidiff,flogodiff,fworkhour from attendance,masempl,masattnstat,masdesn where ";
	$mysql.="attendance.fdeptcode='$dept_code' and fattndate between str_to_date('$attn_dat1','%d-%m-%Y') ";
	$mysql.="and str_to_date('$attn_dat2','%d-%m-%Y') and attendance.femplcode=masempl.femplcode ";
	$mysql.="and attendance.fattnstat=masattnstat.fattnstat and attendance.fdeptcode=masattnstat.fdeptcode ";	
	$mysql.="and masempl.fdesncode=masdesn.fdesncode order by fattndate,fempltype,fdesnordr,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($row = mysqli_fetch_assoc($myres))	
		{
			if($attn_date<>$row['fattndate'])
			{
				$line_no=0;
				$i=1;			
			}
			
			if($line_no==0||$line_no%36==0)			
			{
				$attn_date=$row['fattndate'];
				$dept_code=$row['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 REPORT (DATEWISE)",0,1,"C");	$line_no++;		
				$pdf->Cell(95,7,"Department 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=$row['femplcode'];
			$pdf->SetFont('Arial','',9);				
			$pdf->Cell(10,7,"{$i}",1,0,"C");					
			$pdf->Cell(15,7,"{$row['femplcode']}",1,0,"C");											
			$pdf->Cell(50,7,"{$row['femplname']}",1,0,"L");														
			$pdf->Cell(25,7,"{$row['fstatdesc']}",1,0,"C");																										
			$attn_stat=strtolower($row['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 = $row['flogitime'];
				$logi_diff = $row['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 = $row['flogotime'];
				$logo_diff = $row['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} delay",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= $row['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/attendance_report_datewise.pdf";
		$pdf->output($resp_file,'F');			
	}		
	echo json_encode(array("mesg"=>$resp_mesg, "stat"=>$resp_stat, "file"=>$resp_file));
?>