First Commit
This commit is contained in:
1 parent
5eb9dd037d
commit
2e62c0e60b
11877 files changed
+2035312
No files matched your search
@@ -0,0 +1,235 @@
|
||||
<?php
|
||||
$ValidAccess = 2010;
|
||||
require_once("include/globals.php");
|
||||
|
||||
|
||||
//
|
||||
// Ensure that the user is logged in
|
||||
//
|
||||
if (SessionActive() != 1 || !UserLoggedIn()) {
|
||||
$error_message = getLanguageText('ERRORMSG-ACCESS-DENIED');
|
||||
$action = '';
|
||||
$naction = '';
|
||||
header("Location: /?action=$action&naction=$naction$headerArgs&form_message=" . urlencode($form_message) . "&error_message=" . urlencode($error_message));
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
$report_title = "Hot Lunches On-Line: Revenue Projections Report";
|
||||
$document_name = "Revenue Projections Report";
|
||||
$file_name = "revenue-projections.report.pdf";
|
||||
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Setup the 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 = 9;
|
||||
|
||||
|
||||
// Setup parameters for this document
|
||||
$max_rows = 250;
|
||||
$title_width = 190;
|
||||
$left_col = 10;
|
||||
|
||||
$start_row = 10;
|
||||
$incr = 4;
|
||||
|
||||
$cols = array();
|
||||
$widths = array();
|
||||
$cols[0] = $left_col;
|
||||
$widths[] = 50;
|
||||
$widths[] = 20;
|
||||
$widths[] = 30;
|
||||
$widths[] = 30;
|
||||
$widths[] = 30;
|
||||
$widths[] = 30;
|
||||
|
||||
// Setup columns based on width values
|
||||
for ($i = 0; $i < count($widths); $i++) {
|
||||
$cols[$i + 1] = $cols[$i] + $widths[$i];
|
||||
}
|
||||
|
||||
$headings = array("School Configuration","Count","Rate","Annual","Discounted","Annual");
|
||||
$alignment = array('L','C','R','R','R','R');
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Setup PDF document
|
||||
//
|
||||
require("tcpdf/config/lang/eng.php");
|
||||
require("tcpdf/tcpdf.php");
|
||||
|
||||
$logo_url = $school_record['logo_url'];
|
||||
$logo_image = "images/" . $school_record['logo_image'];
|
||||
$logo_row = $max_rows + 5;
|
||||
|
||||
class PDF extends TCPDF {
|
||||
function Header() {
|
||||
global $incr, $left_col, $start_row, $title_width, $document_font, $document_font_size, $report_title, $report_subtitle, $cols, $widths, $headings, $alignment;
|
||||
|
||||
$row = $start_row;
|
||||
|
||||
// Print the header
|
||||
$this->SetFillColor(hexdec("cc"),hexdec("cc"),hexdec("cc"));
|
||||
$this->SetFont($document_font,"B",$document_font_size + 1);
|
||||
$this->SetXY($left_col,$row);
|
||||
$this->Cell($title_width,$incr + 1,$report_title,'0',1,'L',true,'',1);
|
||||
|
||||
$this->SetFont($document_font,"B",$document_font_size);
|
||||
if (isset($report_subtitle) && strlen($report_subtitle) > 0) {
|
||||
$row = $row + $incr + 2;
|
||||
$this->SetXY($left_col,$row);
|
||||
$this->Cell($title_width,$incr + 1,$report_subtitle,'0',1,'L',true,'',1);
|
||||
}
|
||||
|
||||
$this->SetFillColor(hexdec("dd"),hexdec("dd"),hexdec("dd"));
|
||||
if (isset($headings) && is_array($headings) && count($headings)) {
|
||||
$row += $incr * 2;
|
||||
for ($i = 0; $i < count($headings); $i++) {
|
||||
$col = $cols[$i];
|
||||
$width = $widths[$i];
|
||||
$align = $alignment[$i];
|
||||
$this->SetXY($col,$row);
|
||||
$this->Cell($width,$incr + 1,' ' . $headings[$i] . ' ','1',1,$align,true,'',1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function Footer() {
|
||||
global $incr, $left_col, $title_width, $max_rows, $document_font, $document_font_size, $document_name, $logo_image, $logo_url, $logo_row, $school_name;
|
||||
|
||||
// Print the date
|
||||
$this->SetFont($document_font,"",$document_font_size - 1);
|
||||
$this->SetXY($left_col,$logo_row);
|
||||
$date = dateString('datetime');
|
||||
$this->Cell($title_width,$incr - 1,"$document_name: $date",'0',1,'R','',1);
|
||||
|
||||
$this->SetXY($left_col,$logo_row + $incr);
|
||||
$this->Cell($title_width,$incr - 1,"$school_name",'0',1,'R','',1);
|
||||
|
||||
$this->Image($logo_image,10,$logo_row, 50);
|
||||
|
||||
$this->SetXY(20,$logo_row + 9);
|
||||
$this->SetFont($document_font,"B",$document_font_size);
|
||||
$this->Cell($title_width,$incr,$logo_url,'0',1,'L','',1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$pdf= new PDF('P', 'mm', 'Letter', true, 'UTF-8', false);
|
||||
|
||||
// set default monospaced font
|
||||
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
|
||||
|
||||
//set margins
|
||||
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
|
||||
|
||||
//set auto page breaks
|
||||
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
|
||||
|
||||
//set image scale factor
|
||||
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
|
||||
|
||||
$font_red = hexdec("00");
|
||||
$font_green = hexdec("00");
|
||||
$font_blue = hexdec("00");
|
||||
|
||||
$pdf->SetTextColor($font_red,$font_green,$font_blue);
|
||||
$pdf->SetFont($document_font,"",$document_font_size);
|
||||
|
||||
$pdf->addPage();
|
||||
|
||||
|
||||
//
|
||||
// Get set of records
|
||||
//
|
||||
$query = "SELECT 'hotlunch' AS code, system_configuration AS category, count(*) as number FROM schools WHERE status = 'Active' AND reseller = 'hotlunch' GROUP BY 1,2 " .
|
||||
"UNION " .
|
||||
"SELECT 'resellers', reseller, count(*) as number FROM schools WHERE status = 'Active' AND reseller != 'hotlunch' GROUP BY 1,2 " .
|
||||
"ORDER BY 1,2";
|
||||
$reportData = db_query($query);
|
||||
|
||||
|
||||
//
|
||||
// Generate the report
|
||||
//
|
||||
$curr_row = $start_row + 3 * $incr + 1;
|
||||
$count = 0;
|
||||
|
||||
$grand_total = 0;
|
||||
$disc_total = 0;
|
||||
$count_total = 0;
|
||||
|
||||
while ($row = db_fetch_assoc($reportData)) {
|
||||
|
||||
// New page if current page is full
|
||||
if ($curr_row > $max_rows - $incr - 2) {
|
||||
$pdf->addPage();
|
||||
$curr_row = $start_row + 5 * $incr;
|
||||
$count = 0;
|
||||
}
|
||||
|
||||
extract($row);
|
||||
|
||||
$pdf->SetFont($document_font,"",$document_font_size);
|
||||
$pdf->SetFillColor(hexdec("ee"),hexdec("ee"),hexdec("ee"));
|
||||
|
||||
$fill = true;
|
||||
if ($count % 2) $fill = false;
|
||||
$count++;
|
||||
|
||||
// Format report line
|
||||
$data = array();
|
||||
|
||||
if ($code == 'hotlunch') {
|
||||
$rate = 300;
|
||||
$disc = 250;
|
||||
if ($category == 'Full') {
|
||||
$rate = 400;
|
||||
$disc = 350;
|
||||
}
|
||||
$data = array($category,$number,'$'.number_format($rate,2),'$'.number_format($number * $rate,2),'$'.number_format($disc,2),'$'.number_format($number*$disc,2));
|
||||
$grand_total += $number * $rate;
|
||||
$disc_total += $number * $disc;
|
||||
}
|
||||
else {
|
||||
$reseller = $category;
|
||||
$rate = db_getVal("SELECT annual_rate FROM resellers WHERE reseller_code = '$reseller'");
|
||||
$data = array(strtoupper($category),$number,'$'.number_format($rate,2),'$'.number_format($number * $rate,2),'$'.number_format($rate,2),'$'.number_format($number*$rate,2));
|
||||
$grand_total += $number * $rate;
|
||||
$disc_total += $number * $rate;
|
||||
}
|
||||
|
||||
$count_total += $number;
|
||||
|
||||
for ($i = 0; $i < count($headings); $i++) {
|
||||
$col = $cols[$i];
|
||||
$width = $widths[$i];
|
||||
$align = $alignment[$i];
|
||||
$pdf->SetXY($col,$curr_row);
|
||||
$pdf->Cell($width,$incr,' ' . $data[$i] . ' ','1',1,$align,$fill,'',1);
|
||||
}
|
||||
|
||||
$curr_row += $incr;
|
||||
}
|
||||
|
||||
|
||||
// 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=$file_name");
|
||||
|
||||
$pdf->Output($file_name,"D");
|
||||
|
||||
?>
|
||||
Reference in new issue
Block a user