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.226.34.148
Current Path : /var/www/html/oums/src/ |
| Current File : /var/www/html/oums/src/expense_report_statement_year.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'];
$empl_code=$_POST['empl_code'];
$acnt_type=$_POST['acnt_type'];
$head_desc=$_POST['head_desc'];
$expn_dat1=$_POST['expn_dat1'];
$expn_dat2=$_POST['expn_dat2'];
$header_dept_name=get_dept_name($dept_code);
$header_empl_name=get_empl_name($empl_code);
//Prev. receipt and payments--------------
// $mysqlx = "select sum(case when facnttype='receipt' then fexpnamnt end) as fexpnrecp,sum(case when facnttype='payment' then fexpnamnt end) as fexpnpayt from expenses ";
// $mysqlx.= "where fdeptcode='$dept_code' and femplcode like '$empl_code' and fexpndate < str_to_date('$expn_dat1','%d/%m/%Y') and facnttype like '$acnt_type' and fheaddesc like '$head_desc'";
// $myresx=mysqli_query($mycon,$mysqlx);
// while($rowx = mysqli_fetch_assoc($myresx))
// {
// $totl_recp=$rowx['fexpnrecp'];
// $totl_payt=$rowx['fexpnpayt'];
// }
// $totl_baln=$totl_recp-$totl_payt;
// $totl_recp=number_format((float)$totl_recp,2,'.','');
// $totl_payt=number_format((float)$totl_payt,2,'.','');
// $totl_baln=number_format((float)$totl_baln,2,'.','');
// $pdf->Cell(10,7,"{$i}",1,0,"C");
// $pdf->Cell(25,7,"-",1,0,"C");
// $pdf->Cell(70,7,"BALANCE BEFORE {$expn_dat1}",1,0,"L");
// $pdf->Cell(25,7,"{$totl_recp}",1,0,"R");
// $pdf->Cell(25,7,"{$totl_payt}",1,0,"R");
// $pdf->Cell(25,7,"{$totl_baln}",1,0,"R");
// $pdf->Cell(100,7,"",1,0,"L");
// $pdf->ln();$line_no++;
// $i++;
//amount for given range
$mysql = "select left(fexpndate,4) as fexpnyear,facnttype, sum(case when facnttype='receipt' then fexpnamnt end) as fexpnrecp,sum(case when facnttype='payment' then fexpnamnt end) as fexpnpayt from expenses ";
$mysql.= "where fdeptcode='$dept_code' and femplcode like '$empl_code' and fexpndate <= str_to_date('$expn_dat2','%d/%m/%Y') and facnttype like '$acnt_type' group by left(fexpndate,4)";
$myres=mysqli_query($mycon,$mysql);
$mycnt=mysqli_num_rows($myres);
if($mycnt==0)
{
$resp_stat="F";
$resp_mesg="No records found!";
}
else
{
$i=1;
$expn_year="";
$curr_baln=0;
$prev_baln=0;
$expn_recp=0;
$expn_payt=0;
$totl_recp=0;
$totl_payt=0;
$header_dept_name=get_dept_name($dept_code);
$header_empl_name=get_empl_name($empl_code);
require("fpdf/fpdf.php");
$line_no=0;
$pdf = new FPDF('P','mm','A4');
$pdf->AddPage();
$pdf->SetMargins(10,15);
$pdf->SetFont('Arial','B',10);
$pdf->Cell(0,7,"EXPENSE STATEMENT (YEARWISE SUMMARY)",0,1,"C");$line_no++;
$pdf->Cell(0,7,"{$header_dept_name}",0,1,"C"); $line_no++;
$pdf->Cell(0,7,"Employee Range: {$header_empl_name}",0,1,"C");$line_no++;
$pdf->SetFont('Arial','B',9);
$pdf->Cell(10,7,"Sl No",1,0,"C");
$pdf->Cell(30,7,"Year",1,0,"C");
$pdf->Cell(30,7,"Prev. Balance",1,0,"C");
$pdf->Cell(30,7,"Receipt",1,0,"C");
$pdf->Cell(30,7,"Payment",1,0,"C");
$pdf->Cell(30,7,"Balance",1,0,"C");
$pdf->Cell(30,7,"Remarks",1,0,"C");
$pdf->ln();$line_no++;
$pdf->SetFont('Arial','',9);
while($myrow = mysqli_fetch_assoc($myres))
{
$expn_year=$myrow['fexpnyear'];
$acnt_type=$myrow['facnttype'];
$expn_recp=$myrow['fexpnrecp'];
$expn_payt=$myrow['fexpnpayt'];
$expn_recp=number_format((float)$expn_recp,2,'.','');
$expn_payt=number_format((float)$expn_payt,2,'.','');
$totl_recp=$totl_recp+$expn_recp;
$totl_payt=$totl_payt+$expn_payt;
$curr_baln=$curr_baln+($expn_recp-$expn_payt);
$totl_recp=number_format((float)$totl_recp,2,'.','');
$totl_payt=number_format((float)$totl_payt,2,'.','');
$curr_baln=number_format((float)$curr_baln,2,'.','');
$pdf->Cell(10,7,"{$i}",1,0,"C");
$pdf->Cell(30,7,"{$expn_year}",1,0,"C");
$pdf->Cell(30,7,"{$prev_baln}",1,0,"R");
$pdf->Cell(30,7,"{$expn_recp}",1,0,"R");
$pdf->Cell(30,7,"{$expn_payt}",1,0,"R");
$pdf->Cell(30,7,"{$curr_baln}",1,0,"R");
$pdf->Cell(30,7,"",1,0,"C");
$pdf->ln();$line_no++;
$i++;
$prev_baln = $curr_baln;
}
$totl_amnt=$totl_payt+$totl_recp;
$totl_amnt=number_format((float)$totl_amnt,2,'.','');
$curr_baln=number_format((float)$curr_baln,2,'.','');
$pdf->Cell(40,7,"Grand Total",1,0,"C");
$pdf->Cell(30,7,"{$prev_baln}",1,0,"R");
$pdf->Cell(30,7,"{$totl_recp}",1,0,"R");
$pdf->Cell(30,7,"{$totl_payt}",1,0,"R");
$pdf->Cell(30,7,"{$curr_baln}",1,0,"R");
$pdf->Cell(30,7,"",1,0,"C");
$pdf->ln();$line_no++;
$resp_file='reports/expense_report_statement_year.pdf';
$pdf->output($resp_file,'F');
}
echo json_encode(array("mesg"=>$resp_mesg, "stat"=>$resp_stat, "file"=>$resp_file));
?>
|