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.222.182.195
Current Path : /var/www/html/oums/src/ |
| Current File : /var/www/html/oums/src/expense_report_details_date.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'];
$expn_dat1 = $_POST['expn_dat1'];
$expn_dat2 = $_POST['expn_dat2'];
$mysql = "select fexpndate, ex.fdeptcode, ex.femplcode, femplname, facnttype, fheaddesc, fexpnamnt, fexpnremk, fclntshrt
from expenses ex
left join masempl em on ex.femplcode = em.femplcode
left join masclient cl on ex.fclntcode = cl.fclntcode
where ex.fdeptcode like '$dept_code' and ex.femplcode like '$empl_code'
and fexpndate between str_to_date('$expn_dat1','%d/%m/%Y') and str_to_date('$expn_dat2','%d/%m/%Y')
order by fexpndate, ex.fdeptcode, ex.femplcode, facnttype,fheaddesc,fexpnamnt, fexpnremk, fexpnstat ";
$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_date = "";
$totl_recp = 0;
$totl_payt = 0;
$recp_amnt = 0;
$days_recp = 0;
$payt_amnt = 0;
$days_payt = 0;
require("fpdf/fpdf.php");
$line_no = 1;
$pdf = new FPDF('L', 'mm', 'A4');
$pdf->AliasNbPages();
$header_dept_name = get_dept_name($dept_code);
$header_empl_name = get_empl_name($empl_code);
while ($myrow = mysqli_fetch_assoc($myres)) {
if ($expn_date != date('d/m/Y', strtotime($myrow['fexpndate'])) && $expn_date != '') {
$pdf->SetFont('Arial', 'B', 9);
$pdf->Cell(120, 7, "{$expn_date} Total", 1, 0, "R");
$pdf->Cell(25, 7, "{$days_recp}", 1, 0, "R");
$pdf->Cell(25, 7, "{$days_payt}", 1, 0, "R");
$pdf->Cell(100, 7, "", 1, 0, "C");
}
if ($expn_date != date('d/m/Y', strtotime($myrow['fexpndate']))) {
$i = 1;
$days_recp = 0;
$days_payt = 0;
$expn_date = date('d/m/Y', strtotime($myrow['fexpndate']));
$expn_days = date('D', strtotime($myrow['fexpndate']));
$pdf->AddPage();
$pdf->SetMargins(10, 10);
$pdf->SetFont('Arial', 'B', 10);
$pdf->Cell(0, 7, "EXPENSE DETAILS (DATEWISE)", 0, 1, "C");
$line_no++;
$pdf->Cell(0, 7, "{$header_dept_name}", 0, 1, "C");
$line_no++;
$pdf->Cell(140, 7, "Employee Range: {$header_empl_name}", 0, 0, "L");
$pdf->Cell(130, 7, "Date: {$expn_date} {$expn_days}", 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, "Empl Name", 1, 0, "C");
$pdf->Cell(60, 7, "Description", 1, 0, "C");
$pdf->Cell(25, 7, "Receipt", 1, 0, "C");
$pdf->Cell(25, 7, "Payment", 1, 0, "C");
$pdf->Cell(100, 7, "Remarks", 1, 0, "C");
$pdf->ln();
$line_no++;
}
$recp_amnt = 0;
$payt_amnt = 0;
$expn_date = date('d/m/Y', strtotime($myrow['fexpndate']));
$empl_code = $myrow['femplcode'];
$acnt_type = $myrow['facnttype'];
$head_desc = $myrow['fheaddesc'];
$expn_remk = $myrow['fexpnremk'];
$clnt_shrt = $myrow['fclntshrt'];
if ($acnt_type == 'RECEIPT') {
$recp_amnt = $myrow['fexpnamnt'];
$days_recp = $days_recp + $recp_amnt;
$totl_recp = $totl_recp + $recp_amnt;
}
if ($acnt_type == 'PAYMENT') {
$payt_amnt = $myrow['fexpnamnt'];
$days_payt = $days_payt + $payt_amnt;
$totl_payt = $totl_payt + $payt_amnt;
}
$recp_amnt = number_format((float)$recp_amnt, 2, '.', '');
$payt_amnt = number_format((float)$payt_amnt, 2, '.', '');
$totl_recp = number_format((float)$totl_recp, 2, '.', '');
$totl_payt = number_format((float)$totl_payt, 2, '.', '');
$days_recp = number_format((float)$days_recp, 2, '.', '');
$days_payt = number_format((float)$days_payt, 2, '.', '');
$empl_name = get_empl_name($empl_code);
$pdf->SetFont('Arial', '', 9);
$pdf->Cell(10, 7, "{$i}", 1, 0, "C");
$pdf->Cell(50, 7, "{$empl_name}", 1, 0, "L");
$pdf->Cell(60, 7, "{$head_desc}", 1, 0, "L");
$pdf->Cell(25, 7, "{$recp_amnt}", 1, 0, "R");
$pdf->Cell(25, 7, "{$payt_amnt}", 1, 0, "R");
$pdf->Cell(100, 7, "[$clnt_shrt] $expn_remk", 1, 0, "L");
$pdf->ln();
$line_no++;
$i++;
}
$pdf->SetFont('Arial', 'B', 9);
$pdf->Cell(120, 7, "{$expn_date} Total", 1, 0, "R");
$pdf->Cell(25, 7, "{$days_recp}", 1, 0, "R");
$pdf->Cell(25, 7, "{$days_payt}", 1, 0, "R");
$pdf->Cell(100, 7, "", 1, 0, "C");
$pdf->ln();
$line_no++;
$pdf->ln();
$line_no++;
$pdf->Cell(120, 7, "Grand Total", 1, 0, "R");
$pdf->Cell(25, 7, "{$totl_recp}", 1, 0, "R");
$pdf->Cell(25, 7, "{$totl_payt}", 1, 0, "R");
$pdf->Cell(100, 7, "", 1, 0, "C");
$pdf->ln();
$line_no++;
$resp_file = 'reports/expense_daywise_details.pdf';
$pdf->output($resp_file, 'F');
}
echo json_encode(array("mesg" => $resp_mesg, "stat" => $resp_stat, "file" => $resp_file));
|