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


Current Path : /var/www/misc/public_html/oums_old/phpscript/
Upload File :
Current File : /var/www/misc/public_html/oums_old/phpscript/salary.php

<?php	
	include("sys_session.php");
	include("sys_connect.php");
	include("sys_mainphp.php");	

	$load_data=$_POST["load_data"];
	$resp_mesg="";
	$resp_stat="F";
	$resp_file="";
	
	if($load_data=='dept_data')
	{
		if($type_id=='ADMIN')
		{
			$mysql="select * from masdept where fsalrcomp='T' order by fdeptname";
		}
		elseif($type_id=='CHIEF')
		{
			$mysql="select * from masdept where fsalrcomp='T' and fdepthead='$empl_id' order by fdeptname";
		}		
		else
		{
			$mysql="select * from masdept where fsalrcomp='T' and fdeptcode='$dept_id' order by fdeptname";
		}
		$myres=mysqli_query($mycon,$mysql);
		if(mysqli_num_rows($myres)>1)
		{
			echo "<option value=0>--Select--</option>";
		}
		while($row = mysqli_fetch_assoc($myres))
		{
			echo "<option value='$row[fdeptcode]'>$row[fdeptname]</option>";
		}
	}
	
	if($load_data=='salr_mnth')
	{
		$dept_code=$_POST["dept_code"];		
		$mysql="select left(fattndate,7) as lsalrmnth from attendance where fdeptcode like '$dept_code' group by left(fattndate,7)  order by left(fattndate,7) desc";
		$myres=mysqli_query($mycon,$mysql);
		echo "<option value='0'>--Select--</option>	";		
		if(mysqli_num_rows($myres)!=0)
		{
			while($row = mysqli_fetch_assoc($myres))
			{
			echo "<option value='$row[lsalrmnth]'>$row[lsalrmnth]</option>";
			}
		}
	}

	if($load_data=='last_updt')
	{
		$dept_code=$_POST["dept_code"];		
		$salr_mnth=$_POST["salr_mnth"];		
		$mysql="select * from salary where fdeptcode='$dept_code' and fsalrmnth='$salr_mnth'";
		$myres=mysqli_query($mycon,$mysql);
		$rows = array();
		while($r = mysqli_fetch_assoc($myres)) 
		{
			$rows = $r;
		}
		echo json_encode($rows);
	}

	if($load_data=='save_data')
	{
		$dept_code=$_POST["dept_code"];								
		$salr_mnth=$_POST["salr_mnth"];

		$mysql="select * from masdept where fdeptcode like '$dept_code'";
		$myres=mysqli_query($mycon,$mysql);
		while($row = mysqli_fetch_assoc($myres))	
		{
			$code_rate=$row['fcoderate'];
		}
		
		$year=substr($salr_mnth,0,4);
		$mnth=substr($salr_mnth,5,2);				
		$mnth_days=cal_days_in_month(CAL_GREGORIAN, $mnth, $year);
		
		$mysql1="";
		$mysql1.="select fdeptcode,femplcode, ";
		$mysql1.="count(case when fattnstat='pr' then fattnstat end) as ldayspr,";
		$mysql1.="count(case when fattnstat='p1' then fattnstat end) as ldaysp1,";			
		$mysql1.="count(case when fattnstat='p2' then fattnstat end) as ldaysp2,";						
		$mysql1.="count(case when fattnstat='d1' then fattnstat end) as ldaysd1,";			
		$mysql1.="count(case when fattnstat='d2' then fattnstat end) as ldaysd2,";						
		$mysql1.="count(case when fattnstat='po' then fattnstat end) as ldayspo,";			
		$mysql1.="count(case when fattnstat='cd' then fattnstat end) as ldayscd,";			
		$mysql1.="count(case when fattnstat='hw' then fattnstat end) as ldayshw,";
		$mysql1.="count(case when fattnstat='cl' then fattnstat end) as ldayscl,";												
		$mysql1.="count(case when fattnstat='ab' then fattnstat end) as ldaysab,";
		$mysql1.="sum(case when fattnstat='cd' then fovertime end) as lpackcd,";			
		$mysql1.="sum(case when fattnstat='pr' then fovertime end) as lhourot,";
		$mysql1.="sum(case when fattnstat='p1' then fovertime end) as lhouro1,";			
		$mysql1.="sum(case when fattnstat='p2' then fovertime end) as lhouro2,";						
		$mysql1.="sum(ftrvlamnt) as lamntta ";
		$mysql1.="from attendance ";
		$mysql1.="where fdeptcode like '$dept_code' and left(fattndate,7)='$salr_mnth' ";			
		$mysql1.="group by fdeptcode, femplcode";
		
		$myres1=mysqli_query($mycon,$mysql1);
		while($row1 = mysqli_fetch_assoc($myres1))	
		{
			$dept_code=$row1['fdeptcode'];
			$empl_code=$row1['femplcode'];								
			
			$mysql2="select * from masempl where femplcode='$empl_code' and ifnull(fsalrcomp,'F')='T'";
			$myres2=mysqli_query($mycon,$mysql2);
			while($row2 = mysqli_fetch_assoc($myres2))	
			{
				$base_salr=$row2['fsalrbase'];
				$days_salr=$row2['fsalrdays'];
				$hour_salr=$row2['fsalrhour'];
				$salr_type=$row2['fsalrtype'];
				
				$days_pr=0;
				$days_p1=0;			
				$days_p2=0;			
				$salr_pr=0;			
				
				$days_po=0;
				$days_d1=0;			
				$days_d2=0;			
				
				$days_hw=0;						
				$salr_hw=0;
				
				$days_cl=0;			
				
				$days_ab=0;						
				$salr_ab=0;
				
				$salr_ta=0;
				
				$hour_ot=0;
				$salr_ot=0;
				
				$pack_cd=0;
				$salr_cd=0;
				
				$totl_salr=0;
				$salr_remk="";			
				
				$days_pr=$row1['ldayspr']+$row1['ldaysp1']+$row1['ldaysp2']+($row1['ldaysd1']/2)+($row1['ldaysd2']/2);				
								
				$days_po=$row1['ldayspo'];				
				$days_cd=$row1['ldayscd'];
				$days_hw=$row1['ldayshw'];								
				$days_cl=$row1['ldayscl'];
				$days_ab=$row1['ldaysab']+($row1['ldaysd1']/2)+($row1['ldaysd2']/2);										
				
				$salr_ta=$row1['lamntta'];						
				$hour_ot=$row1['lhourot'];
				$pack_cd=$row1['lpackcd'];						
				
				$salr_ot=$hour_ot*$hour_salr;						
				
				$salr_cd=$pack_cd*$code_rate;
	
				$salr_pr=$days_pr*$days_salr;						
				
				if($salr_type=='C')
				{
					$salr_hw=$days_hw*$days_salr;						
					$salr_ab=$days_ab*$days_salr;
					$totl_salr=$base_salr+$salr_hw+$salr_ta+$salr_ot-$salr_ab;
				}
	
				if($salr_type=='D')
				{
					$totl_salr=$salr_pr+$salr_ta+$salr_ot+$salr_cd;
				}
			
				
				$mysql3="select * from salary where fdeptcode='$dept_code' and femplcode='$empl_code' and fsalrmnth='$salr_mnth'";

				$myres3=mysqli_query($mycon,$mysql3);
				$mycnt3=mysqli_num_rows($myres3);
				if($mycnt3==0)
				{
					$mysql4="";
					$mysql4.="insert into salary (";
					$mysql4.="fsalrmnth, fdeptcode, femplcode, fsalrbase, fsalrdays, fsalrhour, ftotlsalr, ";
					$mysql4.="fdayspr, fdayspo, fdayscl, fdayscd, fpackcd, fsalrcd, fdayshw, fsalrhw, ";
					$mysql4.="fdaysab, fsalrab, fsalrta, fhourot, fsalrot, fsalrremk, fupdtuser, fupdttime) ";
					$mysql4.="values('$salr_mnth', '$dept_code', '$empl_code', '$base_salr', '$days_salr', '$hour_salr', '$totl_salr', ";																									
					$mysql4.="'$days_pr', '$days_po', '$days_cl', '$days_cd', '$pack_cd', '$salr_cd', '$days_hw', '$salr_hw', ";																									
					$mysql4.="'$days_ab', '$salr_ab', '$salr_ta', '$hour_ot', '$salr_ot', '$salr_remk', '$user_id', now())";																																										
				}
				else
				{
					$mysql4="";
					$mysql4.="update salary set ";			
					$mysql4.="fdeptcode='$dept_code',fsalrbase='$base_salr', fsalrdays='$days_salr', fsalrhour='$hour_salr', ftotlsalr='$totl_salr', ";					
					$mysql4.="fdayspr='$days_pr', fdayspo='$days_po', fdayshw='$days_hw', fdayscl='$days_cl', ";			
					$mysql4.="fdayscd='$days_cd', fpackcd='$pack_cd', fsalrcd='$salr_cd', fdayshw='$days_hw', fsalrhw='$salr_hw', ";			
					$mysql4.="fdaysab='$days_ab', fsalrab='$salr_ab', fsalrta='$salr_ta', fhourot='$hour_ot', fsalrot='$salr_ot', ";			
					$mysql4.="fsalrremk='$salr_remk', fupdtuser='$user_id', fupdttime=now() ";
					$mysql4.="where femplcode='$empl_code' and fsalrmnth='$salr_mnth'";			
				}
				$myres4=mysqli_query($mycon,$mysql4);				
			}
		}	
		$resp_mesg="Salary updated!";
		$resp_stat="T";
		echo json_encode(array("mesg"=>$resp_mesg, "stat"=>$resp_stat, "file"=>$resp_file));			
	}

	if($load_data=='dele_data')
	{
		$dept_code=$_POST["dept_code"];		
		$salr_mnth=$_POST["salr_mnth"];		
		if($type_id == "ADMIN" or $type_id == "CHIEF")
		{
			$mysql="delete from salary where fdeptcode='$dept_code' and fsalrmnth='$salr_mnth'";		
			$myres=mysqli_query($mycon,$mysql);			
			$resp_mesg="Salary details deleted!";			
			$resp_stat="T";			
		}
		else
		{
			$resp_mesg="Salary details could not be deleted! Contact Administrator";			
			$resp_stat="F";					
		}

		echo json_encode(array("mesg"=>$resp_mesg, "stat"=>$resp_stat, "file"=>$resp_file));					
	}

	if($load_data=='view_data')
	{
		$dept_code=$_POST["dept_code"];								
		$salr_mnth=$_POST["salr_mnth"];	
		
		$mysql ="";
		$mysql.="select masempl.*,masdesn.*,salary.* from masempl,masdesn,salary where masempl.fdesncode=masdesn.fdesncode ";		
		$mysql.="and masempl.femplcode=salary.femplcode and fsalrmnth='$salr_mnth' and salary.fdeptcode like '$dept_code' ";		
		$mysql.="and ftotlsalr<>0 order by salary.fdeptcode,fempltype,fdesnordr,masdesn.fdesncode,femplname";		
		$myres=mysqli_query($mycon,$mysql);
		$mycnt=mysqli_num_rows($myres);
		if($mycnt==0)
		{
			$resp_mesg="No data found!";
			$resp_stat="F";
		}
		else
		{
			$resp_stat="T";
			$i=1;
			$dept_code="";
			$year=substr($salr_mnth,0,4);
			$mnth=substr($salr_mnth,5,2);				
			$mnth_days=cal_days_in_month(CAL_GREGORIAN, $mnth, $year);
			
			$line_no=0;
			$totl_pr=0;
			$totl_cl=0;
			$totl_hw=0;
			$totl_hwsalr=0;
			$totl_ta=0;
			$totl_ot=0;
			$totl_otsalr=0;
			$totl_ab=0;
			$totl_absalr=0;
			$totl_salr=0;
			$totl_cd_days=0;
			$totl_cd=0;
			$totl_cdslr=0;
			require("fpdf/fpdf.php");	
			$pdf = new FPDF('L','mm','A4');			
			while($row = mysqli_fetch_assoc($myres))	
			{		
				if($dept_code<>$row['fdeptcode']&&$dept_code!="")
				{
					$totl_hwsalr=number_format((float)$totl_hwsalr,2,'.','');
					$totl_ta=number_format((float)$totl_ta,2,'.','');					
					$totl_ot=number_format((float)$totl_ot,1,'.','');					
					$totl_otsalr=number_format((float)$totl_otsalr,2,'.','');										
					$totl_absalr=number_format((float)$totl_absalr,2,'.','');					
					$totl_cdsalr=number_format((float)$totl_cdsalr,2,'.','');						
					$totl_salr=number_format((float)$totl_salr,2,'.','');					
				
					$pdf->Cell(95,7,"Total",1,0,"C");		
					$pdf->Cell(15,7,"{$totl_pr}",1,0,"C");				
					$pdf->Cell(15,7,"{$totl_cl}",1,0,"C");						
					$pdf->Cell(15,7,"{$totl_ta}",1,0,"R");								
					$pdf->Cell(10,7,"{$totl_ot}",1,0,"C");									
					$pdf->Cell(15,7,"{$totl_otsalr}",1,0,"R");										
					$pdf->Cell(10,7,"{$totl_hw}",1,0,"C");										
					$pdf->Cell(15,7,"{$totl_hwsalr}",1,0,"R");											
					$pdf->Cell(10,7,"{$totl_ab}",1,0,"C");										
					$pdf->Cell(15,7,"{$totl_absalr}",1,0,"R");												
					$pdf->Cell(10,7,"{$totl_cd}",1,0,"C");										
					$pdf->Cell(15,7,"{$totl_cdsalr}",1,0,"R");												
					$pdf->Cell(20,7,"{$totl_salr}",1,0,"R");											
					$pdf->Cell(20,7,"",1,0,"L");												
					$pdf->ln();$line_no++;
		
					$line_no=0;
					$i=1;	
					$totl_pr=0;
					$totl_cl=0;
					$totl_hw=0;
					$totl_hwsalr=0;
					$totl_ta=0;
					$totl_ot=0;
					$totl_otsalr=0;
					$totl_ab=0;
					$totl_absalr=0;
					$totl_salr=0;
				}	
	
				$header_dept_name=get_dept_name($row['fdeptcode']);
				$header_salr_mnth=strtoupper(date('F Y',strtotime($salr_mnth)));
					
				if($line_no==0||$line_no%24==0)
				{
					$pdf->AddPage();
					$pdf->SetFont('Arial','B',10);				
					$pdf->Cell(0,7,"LOGISYS, BANGALORE",0,1,"C");	$line_no++;
					$pdf->Cell(0,7,"SALARY STATEMENT - {$header_salr_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,14,"Sl No",1,0,"C");
					$pdf->Cell(50,14,"Employee Name",1,0,"C");		
				
					$x = $pdf->GetX();	$y = $pdf->GetY();		
					$pdf->MultiCell(15,7,"Salary / Month",1,"C");			
					
					$pdf->SetXY($x + 15, $y);	
					$pdf->MultiCell(15,7,"Salary / Day",1,"C");		
					
					$pdf->SetXY($x + 30, $y);	
					$pdf->MultiCell(10,7,"Total PR",1,"C");				
					
					$pdf->SetXY($x + 40, $y);		
					$pdf->MultiCell(10,7,"Total CL",1,"C");				

					$pdf->SetXY($x + 50, $y);		
					$pdf->MultiCell(15,7,"Travel Allow.",1,"C");				
				
					$pdf->SetXY($x + 65, $y);		
					$pdf->MultiCell(25,7,"Over Time",1,"C");				
					
					$pdf->SetXY($x + 65, $y+7);		
					$pdf->MultiCell(10,7,"Hour",1,"C");				
					
					$pdf->SetXY($x + 75, $y+7);		
					$pdf->MultiCell(15,7,"Amount",1,"C");				
					
					$pdf->SetXY($x + 90, $y);	
					$pdf->MultiCell(25,7,"Holiday Work",1,"C");				
					
					$pdf->SetXY($x + 90, $y+7);	
					$pdf->MultiCell(10,7,"Days",1,"C");				
				
					$pdf->SetXY($x + 100, $y+7);	
					$pdf->MultiCell(15,7,"Amount",1,"C");				
		
					$pdf->SetXY($x + 115, $y);	
					$pdf->MultiCell(25,7,"Absent deduct.",1,"C");				
					
					$pdf->SetXY($x + 115, $y+7);	
					$pdf->MultiCell(10,7,"Days",1,"C");				
				
					$pdf->SetXY($x + 125, $y+7);	
					$pdf->MultiCell(15,7,"Amount",1,"C");				
					
					$pdf->SetXY($x + 140, $y);	
					$pdf->MultiCell(35,7,"Coding work",1,"C");				
				
					$pdf->SetXY($x + 140, $y+7);	
					$pdf->MultiCell(10,7,"Days",1,"C");				

					$pdf->SetXY($x + 150, $y+7);	
					$pdf->MultiCell(10,7,"Pack",1,"C");				
				
					$pdf->SetXY($x + 160, $y+7);	
					$pdf->MultiCell(15,7,"Amount",1,"C");				
					
					$pdf->SetXY($x + 175, $y);	
					$pdf->MultiCell(20,14,"Net Salary",1,"C");				
					
					$pdf->SetXY($x + 195, $y);	
					$pdf->Cell(20,14,"Remarks",1,0,"C");												
					$pdf->ln();$line_no++;
				}
				
				$pdf->SetFont('Arial','',9);				
				$pdf->Cell(10,7,"{$i}",1,0,"C");
				$pdf->Cell(50,7,"{$row['femplname']}",1,0,"L");		
				$pdf->Cell(15,7,"{$row['fsalrbase']}",1,0,"R");		
				$pdf->Cell(15,7,"{$row['fsalrdays']}",1,0,"R");				
				$pdf->Cell(10,7,"{$row['fdayspr']}"+"{$row['fdayspo']}",1,0,"C");				
				$pdf->Cell(10,7,"{$row['fdayscl']}",1,0,"C");						
				$pdf->Cell(15,7,"{$row['fsalrta']}",1,0,"R");								
				$pdf->Cell(10,7,"{$row['fhourot']}",1,0,"C");									
				$pdf->Cell(15,7,"{$row['fsalrot']}",1,0,"R");										
				$pdf->Cell(10,7,"{$row['fdayshw']}",1,0,"C");										
				$pdf->Cell(15,7,"{$row['fsalrhw']}",1,0,"R");											
				$pdf->Cell(10,7,"{$row['fdaysab']}",1,0,"C");										
				$pdf->Cell(15,7,"{$row['fsalrab']}",1,0,"R");												
				$pdf->Cell(10,7,"{$row['fdayscd']}",1,0,"C");										
				$pdf->Cell(10,7,"{$row['fpackcd']}",1,0,"C");														
				$pdf->Cell(15,7,"{$row['fsalrcd']}",1,0,"R");												
				$pdf->Cell(20,7,"{$row['ftotlsalr']}",1,0,"R");	
				$pdf->Cell(20,7,"{$row['fsalrremk']}",1,0,"L");													
				$pdf->ln();$line_no++;
		
				$totl_pr=$totl_pr+$row["fdayspr"];
				$totl_cl=$totl_cl+$row["fdayscl"];
				$totl_hw=$totl_hw+$row["fdayshw"];
				$totl_hwsalr=$totl_hwsalr+$row["fsalrhw"];
				$totl_ta=$totl_ta+$row["fsalrta"];
				$totl_ot=$totl_ot+$row["fhourot"];
				$totl_otsalr=$totl_otsalr+$row["fsalrot"];
				$totl_ab=$totl_ab+$row["fdaysab"];					
				$totl_absalr=$totl_absalr+$row["fsalrab"];
				$totl_cd_days=$totl_cd_days+$row["fdayscd"];					
				$totl_cd=$totl_cd+$row["fpackcd"];					
				$totl_cdsalr=$totl_cdsalr+$row["fsalrcd"];
				$totl_salr=$totl_salr+$row["ftotlsalr"];	
				$i++;
			}	
			$totl_hwsalr=number_format((float)$totl_hwsalr,2,'.','');
			$totl_ta=number_format((float)$totl_ta,2,'.','');					
			$totl_ot=number_format((float)$totl_ot,1,'.','');					
			$totl_otsalr=number_format((float)$totl_otsalr,2,'.','');										
			$totl_absalr=number_format((float)$totl_absalr,2,'.','');					
			$totl_cdsalr=number_format((float)$totl_cdsalr,2,'.','');						
			$totl_salr=number_format((float)$totl_salr,2,'.','');					
		
			$pdf->Cell(90,7,"Total",1,0,"C");		
			$pdf->Cell(10,7,"{$totl_pr}",1,0,"C");				
			$pdf->Cell(10,7,"{$totl_cl}",1,0,"C");						
			$pdf->Cell(15,7,"{$totl_ta}",1,0,"R");								
			$pdf->Cell(10,7,"{$totl_ot}",1,0,"C");									
			$pdf->Cell(15,7,"{$totl_otsalr}",1,0,"R");										
			$pdf->Cell(10,7,"{$totl_hw}",1,0,"C");										
			$pdf->Cell(15,7,"{$totl_hwsalr}",1,0,"R");											
			$pdf->Cell(10,7,"{$totl_ab}",1,0,"C");										
			$pdf->Cell(15,7,"{$totl_absalr}",1,0,"R");												
			$pdf->Cell(10,7,"{$totl_cd_days}",1,0,"C");										
			$pdf->Cell(10,7,"{$totl_cd}",1,0,"C");													
			$pdf->Cell(15,7,"{$totl_cdsalr}",1,0,"R");												
			$pdf->Cell(20,7,"{$totl_salr}",1,0,"R");											
			$pdf->Cell(20,7,"",1,0,"L");												
			$pdf->ln();$line_no++;
			
			$resp_stat="T";
			$resp_file='reports/'.$year.' '.$mnth.' salary_statement.pdf';
			$pdf->output($resp_file,'F');		
		}
		echo json_encode(array("mesg"=>$resp_mesg, "stat"=>$resp_stat, "file"=>$resp_file));			
	}

	if($load_data=='view_rept')
	{
		$dept_code=$_POST["dept_code"];								
		$salr_mnth=$_POST["salr_mnth"];	
		$dept_bank="0";
		
		$mysql="select * from masdept where fdeptcode='$dept_code'";
		$myres=mysqli_query($mycon,$mysql);
		while($row = mysqli_fetch_assoc($myres))			
		{
			$dept_bank=$row['fdeptbank'];
		}
		
		//other bank
		$mysql ="";
		$mysql.="select masempl.*,salary.* from masempl,salary where ";
		$mysql.="masempl.femplcode=salary.femplcode and fsalrmnth='$salr_mnth' and salary.fdeptcode like '$dept_code' ";
		$mysql.="and ftotlsalr<>0 and ifnull(fbankcode,'0')<>'$dept_bank' ";
		$mysql.="order by salary.fdeptcode,fbankifsc, femplname";
		$myres=mysqli_query($mycon,$mysql);
		$mycnt=mysqli_num_rows($myres);
		if($mycnt==0)
		{
			$resp_mesg="No data found!";
			$resp_stat="F";
		}
		else
		{
			$resp_stat="T";
			$i=1;
			$year=substr($salr_mnth,0,4);
			$mnth=substr($salr_mnth,5,2);				
			$mnth_days=cal_days_in_month(CAL_GREGORIAN, $mnth, $year);
			
			$line_no=0;
			$totl_salr=0;
			require("fpdf/fpdf.php");	
			$pdf = new FPDF('L','mm','A4');			
			while($row = mysqli_fetch_assoc($myres))	
			{		
				if($dept_code<>$row['fdeptcode']&&$dept_code!="")
				{
					$totl_salr=number_format((float)$totl_salr,2,'.','');					
				
					$pdf->Cell(255,7,"Grand Total",1,0,"R");		
					$pdf->Cell(20,7,"{$totl_salr}",1,0,"R");											
					$pdf->ln();$line_no++;
		
					$line_no=0;
					$i=1;	
					$totl_salr=0;
				}	
	
				$header_dept_name=get_dept_name($row['fdeptcode']);
	
				$header_salr_mnth=strtoupper(date('F Y',strtotime($salr_mnth)));
					
				if($line_no==0||$line_no%25==0)
				{
					$pdf->AddPage();
					$pdf->SetFont('Arial','B',10);				
					$pdf->Cell(0,7,"BANK STATEMENT",0,1,"C");$line_no++;						
					$pdf->Cell(0,7,"$row[fdeptcode] - {$header_salr_mnth}",0,1,"C");$line_no++;											
			
					$pdf->SetFont('Arial','B',9);				
					$pdf->Cell(10,7,"Sl No",1,0,"C");
					$pdf->Cell(60,7,"Employee Name",1,0,"C");		
					$pdf->Cell(60,7,"Beneficiary Name",1,0,"C");						
					$pdf->Cell(40,7,"Account No.",1,0,"C");											
					$pdf->Cell(30,7,"IFSC Code",1,0,"C");																
					$pdf->Cell(55,7,"Bank Name",1,0,"C");																
					$pdf->Cell(20,7,"Amount",1,0,"C");																
					$pdf->ln();$line_no++;
				}
				
				$pdf->SetFont('Arial','',9);				
				$pdf->Cell(10,7,"{$i}",1,0,"C");
				$pdf->Cell(60,7,"{$row['femplname']}",1,0,"L");		
				$pdf->Cell(60,7,"{$row['facntname']}",1,0,"L");													
				$pdf->Cell(40,7,"{$row['facntnumb']}",1,0,"C");																	
				$pdf->Cell(30,7,"{$row['fbankifsc']}",1,0,"C");																	
				$bank_name=get_bank_name($row['fbankcode']);
				$pdf->Cell(55,7,"{$bank_name}",1,0,"L");																	
				$pdf->Cell(20,7,"{$row['ftotlsalr']}",1,0,"R");																	
				$pdf->ln();$line_no++;		
				$totl_salr=$totl_salr+$row["ftotlsalr"];	
				$i++;
			}	
			$totl_salr=number_format((float)$totl_salr,2,'.','');					
		
			$pdf->Cell(255,7,"Grand Total",1,0,"R");		
			$pdf->Cell(20,7,"{$totl_salr}",1,0,"R");											
			$pdf->ln();$line_no++;
		}

		//home banks
		$mysql ="";
		$mysql.="select masempl.*,salary.* from masempl,salary where ";
		$mysql.="masempl.femplcode=salary.femplcode and fsalrmnth='$salr_mnth' and salary.fdeptcode like '$dept_code' ";
		$mysql.="and ftotlsalr<>0 and ifnull(fbankcode,'0')='$dept_bank' ";
		$mysql.="order by salary.fdeptcode,fbankifsc,femplname";
		$myres=mysqli_query($mycon,$mysql);
		$mycnt=mysqli_num_rows($myres);
		if($mycnt!=0)
		{
			$i=1;
			$year=substr($salr_mnth,0,4);
			$mnth=substr($salr_mnth,5,2);				
			$mnth_days=cal_days_in_month(CAL_GREGORIAN, $mnth, $year);
			
			$line_no=0;
			$totl_salr=0;
			while($row = mysqli_fetch_assoc($myres))	
			{		
				if($dept_code<>$row['fdeptcode']&&$dept_code!="")
				{
					$totl_salr=number_format((float)$totl_salr,2,'.','');					
				
					$pdf->Cell(230,7,"Grand Total",1,0,"R");		
					$pdf->Cell(20,7,"{$totl_salr}",1,0,"R");											
					$pdf->ln();$line_no++;
		
					$line_no=0;
					$i=1;	
					$totl_salr=0;
				}	
	
				$header_dept_name=get_dept_name($row['fdeptcode']);
	
				$header_salr_mnth=strtoupper(date('F Y',strtotime($salr_mnth)));
					
				if($line_no==0||$line_no%25==0)
				{
					$pdf->AddPage();
					$pdf->SetFont('Arial','B',10);				
					$pdf->Cell(0,7,"BANK STATEMENT",0,1,"C");$line_no++;						
					$pdf->Cell(0,7,"$row[fdeptcode] - {$header_salr_mnth}",0,1,"C");$line_no++;											
			
					$pdf->SetFont('Arial','B',9);				
					$pdf->Cell(10,7,"Sl No",1,0,"C");
					$pdf->Cell(60,7,"Employee Name",1,0,"C");		
					$pdf->Cell(60,7,"Beneficiary Name",1,0,"C");						
					$pdf->Cell(40,7,"Account No.",1,0,"C");											
					$pdf->Cell(30,7,"IFSC Code",1,0,"C");																
					$pdf->Cell(55,7,"Bank Name",1,0,"C");																
					$pdf->Cell(20,7,"Amount",1,0,"C");																
					$pdf->ln();$line_no++;
				}
				
				$pdf->SetFont('Arial','',9);				
				$pdf->Cell(10,7,"{$i}",1,0,"C");
				$pdf->Cell(60,7,"{$row['femplname']}",1,0,"L");		
				$pdf->Cell(60,7,"{$row['facntname']}",1,0,"L");													
				$pdf->Cell(40,7,"{$row['facntnumb']}",1,0,"C");																	
				$pdf->Cell(30,7,"{$row['fbankifsc']}",1,0,"C");																	
				$bank_name=get_bank_name($row['fbankcode']);
				$pdf->Cell(55,7,"{$bank_name}",1,0,"L");																	
				$pdf->Cell(20,7,"{$row['ftotlsalr']}",1,0,"R");																	
				$pdf->ln();$line_no++;		
				$totl_salr=$totl_salr+$row["ftotlsalr"];	
				$i++;
			}	
			$totl_salr=number_format((float)$totl_salr,2,'.','');					
		
			$pdf->Cell(255,7,"Grand Total",1,0,"R");		
			$pdf->Cell(20,7,"{$totl_salr}",1,0,"R");											
			$pdf->ln();$line_no++;
		}
		$resp_stat="T";
		$resp_file='reports/salary_statement_bank.pdf';
		$pdf->output($resp_file,'F');		
		echo json_encode(array("mesg"=>$resp_mesg, "stat"=>$resp_stat, "file"=>$resp_file));			
	}
?>