First Commit
This commit is contained in:
1 parent
5eb9dd037d
commit
2e62c0e60b
11877 files changed
+2035312
No files matched your search
@@ -0,0 +1,242 @@
|
||||
<?php
|
||||
$ValidAccess = 2010;
|
||||
require_once("include/globals.php");
|
||||
|
||||
|
||||
//
|
||||
// Ensure that the user is logged in
|
||||
//
|
||||
if (SessionActive() != 1 || !UserLoggedIn()) {
|
||||
echo("Invalid Access");
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Setup the PDF
|
||||
//
|
||||
$template_file = "Blank.pdf";
|
||||
$document_font = $school_record['document_font'];
|
||||
if (strlen($document_font) == 0) $document_font = "Helvetica";
|
||||
|
||||
$document_font_weight = "";
|
||||
$document_text_color = "#000000";
|
||||
$document_font_size = 10;
|
||||
|
||||
|
||||
//
|
||||
// Setup PDF document
|
||||
//
|
||||
define('FPDF_FONTPATH',"include/font/");
|
||||
require("include/fpdi.php");
|
||||
|
||||
$pdf= new fpdi('P','mm','Letter');
|
||||
|
||||
$pagecount = $pdf->setSourceFile("$template_file");
|
||||
$tplidx = $pdf->ImportPage(1);
|
||||
|
||||
$pdf->addPage();
|
||||
$pdf->useTemplate($tplidx);
|
||||
|
||||
$font_red = hexdec("00");
|
||||
$font_green = hexdec("00");
|
||||
$font_blue = hexdec("00");
|
||||
|
||||
$pdf->SetTextColor($font_red,$font_green,$font_blue);
|
||||
|
||||
$school_name = $school_record['school_name'];
|
||||
|
||||
// Setup parameters for this document
|
||||
$max_rows = 250;
|
||||
$columns = array(30,80,120,160);
|
||||
$start_row = 25;
|
||||
$curr_row = $max_rows + 10;
|
||||
$incr = 5;
|
||||
|
||||
|
||||
// Execute the query statement
|
||||
$query = $_GET['query'];
|
||||
$transactions = db_query($query);
|
||||
|
||||
$sdate = $_GET['sdate'];
|
||||
$edate = $_GET['edate'];
|
||||
$report_title = "From $sdate to $edate";
|
||||
|
||||
|
||||
$pdf->SetFillColor(hexdec("ee"),hexdec("ee"),hexdec("ee"));
|
||||
|
||||
$total = 0;
|
||||
$total_credits = 0;
|
||||
$total_charges = 0;
|
||||
$page = 0;
|
||||
$count = 0;
|
||||
|
||||
while ($row = db_fetch_array($transactions)) {
|
||||
extract($row);
|
||||
|
||||
if ($curr_row > $max_rows) {
|
||||
// Put page titles on the page whenever a page is full
|
||||
if ($page > 0) $pdf->addPage();
|
||||
|
||||
$pdf->SetFont("Arial","B",$document_font_size + 2);
|
||||
$pdf->SetXY(10,8);
|
||||
$pdf->Cell(250,$incr,"$school_name :: Transaction Summary Report Report",'0',1,'L');
|
||||
|
||||
$pdf->SetFont("Arial","B",$document_font_size + 1);
|
||||
$pdf->SetXY(10,13);
|
||||
$pdf->Cell(250,$incr,$report_title,'0',1,'L');
|
||||
$pdf->SetFont("Arial","B",$document_font_size);
|
||||
|
||||
$curr_row = 25;
|
||||
$pdf->SetFillColor(hexdec("cc"),hexdec("cc"),hexdec("cc"));
|
||||
|
||||
$cnum = 0;
|
||||
$curr_col = $columns[$cnum];
|
||||
$width = $columns[$cnum + 1] - $columns[$cnum];
|
||||
$pdf->SetXY($curr_col,$curr_row);
|
||||
$pdf->Cell($width,$incr,"Transaction Type",'0',1,'L',true);
|
||||
|
||||
$cnum++;
|
||||
$curr_col = $columns[$cnum];
|
||||
$width = $columns[$cnum + 1] - $columns[$cnum];
|
||||
$pdf->SetXY($curr_col,$curr_row);
|
||||
$pdf->Cell($width,$incr,"Charges",'0',1,'R',true);
|
||||
|
||||
$cnum++;
|
||||
$curr_col = $columns[$cnum];
|
||||
$width = $columns[$cnum + 1] - $columns[$cnum];
|
||||
$pdf->SetXY($curr_col,$curr_row);
|
||||
$pdf->Cell($width,$incr,"Credits",'0',1,'R',true);
|
||||
|
||||
$pdf->SetFillColor(hexdec("ee"),hexdec("ee"),hexdec("ee"));
|
||||
$pdf->SetFont("Arial","",$document_font_size);
|
||||
$curr_row += $incr;
|
||||
$page++;
|
||||
}
|
||||
|
||||
$bg = false;
|
||||
if ($count % 2) $bg = true;
|
||||
|
||||
$cnum = 0;
|
||||
$curr_col = $columns[$cnum];
|
||||
$width = $columns[$cnum + 1] - $columns[$cnum];
|
||||
$pdf->SetXY($curr_col,$curr_row);
|
||||
$pdf->Cell($width,$incr,$row['transaction_type'],'0',1,'L',$bg);
|
||||
|
||||
// Format the amount
|
||||
$amount = round($amount * 100) / 100;
|
||||
if ($amount < 0.00) $amount_str = "- $currencySymbol" . number_format(abs($amount),2);
|
||||
else $amount_str = $currencySymbol . number_format($amount,2);
|
||||
|
||||
// Determine which column this amount belongs in
|
||||
$charge_str = "";
|
||||
$credit_str = "";
|
||||
|
||||
switch ($transaction_type) {
|
||||
case 'Donation':
|
||||
case 'NSF':
|
||||
case 'Refund':
|
||||
case 'Late Charge':
|
||||
case 'Tax Charge':
|
||||
case 'Paper Order Charge':
|
||||
case 'Remittance Form Fee':
|
||||
case 'Additional Order Fee':
|
||||
case 'Other Charge':
|
||||
case 'Charge Adjustment':
|
||||
case 'Order':
|
||||
case 'Bambora Transaction Fee':
|
||||
case 'PayPal Transaction Fee':
|
||||
case 'Credit Card Transaction Fee':
|
||||
case 'Reversed Payment':
|
||||
$charge_str = $amount_str;
|
||||
$total_charges += $amount;
|
||||
break;
|
||||
|
||||
case 'Complimentary Credit':
|
||||
case 'Payment':
|
||||
case 'Credit':
|
||||
case 'Credit Adjustment':
|
||||
case 'Multiple Order Discount':
|
||||
default:
|
||||
$credit_str = $amount_str;
|
||||
$total_credits += $amount;
|
||||
break;
|
||||
}
|
||||
|
||||
$total += $amount;
|
||||
|
||||
|
||||
$cnum++;
|
||||
$curr_col = $columns[$cnum];
|
||||
$width = $columns[$cnum + 1] - $columns[$cnum];
|
||||
$pdf->SetXY($curr_col,$curr_row);
|
||||
$pdf->Cell($width,$incr,$charge_str,'0',1,'R',$bg);
|
||||
|
||||
$cnum++;
|
||||
$curr_col = $columns[$cnum];
|
||||
$width = $columns[$cnum + 1] - $columns[$cnum];
|
||||
$pdf->SetXY($curr_col,$curr_row);
|
||||
$pdf->Cell($width,$incr,$credit_str,'0',1,'R',$bg);
|
||||
|
||||
$curr_row += $incr;
|
||||
$count++;
|
||||
}
|
||||
|
||||
$pdf->SetFillColor(hexdec("cc"),hexdec("cc"),hexdec("cc"));
|
||||
$pdf->SetFont("Arial","B",$document_font_size);
|
||||
|
||||
|
||||
// Format report totals
|
||||
$total = round($total * 100) / 100;
|
||||
if ($total < 0.00) $total = "- $currencySymbol" . number_format(abs($total),2);
|
||||
else $total = $currencySymbol . number_format($total,2);
|
||||
|
||||
if ($total_charges < 0.00) $total_charges = "- $currencySymbol" . number_format(abs($total_charges),2);
|
||||
else $total_charges = $currencySymbol . number_format($total_charges,2);
|
||||
|
||||
if ($total_credits < 0.00) $total_credits = "- $currencySymbol" . number_format(abs($total_credits),2);
|
||||
else $total_credits = $currencySymbol . number_format($total_credits,2);
|
||||
|
||||
|
||||
// Display totals for the report
|
||||
$cnum = 0;
|
||||
$curr_col = $columns[$cnum];
|
||||
$width = $columns[1] - $columns[0];
|
||||
$pdf->SetXY($curr_col,$curr_row);
|
||||
$pdf->Cell($width,$incr,"Totals :: ",'0',1,'R',true);
|
||||
|
||||
$cnum++;
|
||||
$curr_col = $columns[$cnum];
|
||||
$width = $columns[$cnum + 1] - $columns[$cnum];
|
||||
$pdf->SetXY($curr_col,$curr_row);
|
||||
$pdf->Cell($width,$incr,$total_charges,'0',1,'R',true);
|
||||
|
||||
$cnum++;
|
||||
$curr_col = $columns[$cnum];
|
||||
$width = $columns[$cnum + 1] - $columns[$cnum];
|
||||
$pdf->SetXY($curr_col,$curr_row);
|
||||
$pdf->Cell($width,$incr,$total_credits,'0',1,'R',true);
|
||||
|
||||
|
||||
if ($curr_row < $max_rows) {
|
||||
$pdf->SetFont("Arial","",$document_font_size - 1);
|
||||
$date = date("F j, Y",time());
|
||||
$pdf->SetXY(10,$max_rows);
|
||||
$pdf->Cell(180,$incr,"Transaction Summary: $date",'0',1,'L');
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Output the completed PDF
|
||||
header('Pragma: public');
|
||||
header('Expires: 0');
|
||||
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
|
||||
header('Cache-Control: private',false);
|
||||
header('Content-type: application/pdf');
|
||||
header("Content-Disposition: attachment; filename=transaction-summary.pdf");
|
||||
header('Content-Transfer-Encoding: binary');
|
||||
|
||||
$pdf->Output("transaction-summary.pdf","D");
|
||||
return;
|
||||
|
||||
?>
|
||||
Reference in new issue
Block a user