Files
HotLunches/hotlunch.order_details.generate.php
T
2026-10-19 15:22:52 -07:00

1294 lines
53 KiB
PHP

<?php
$ValidAccess = 2010;
require_once("include/globals.php");
// Session already started in index.php
// session_name($sessionName);
// session_start();
// if ($_SESSION['UserInfo']['type'] == 'SuperUser') startLog("hotlunch.order_details.generate.php");
//
// Ensure that the user is logged in
//
if (SessionActive() != 1 || !UserLoggedIn()) {
header("Location: /?action=order-details&schedule_num=$schedule_num&menu_num=$menu_num&error_code=NOACCESS");
exit();
}
// Check permissions
$AllowedUserTypes = array('SuperUser','System Administrator','Application Administrator','Application Volunteer','Schedule Volunteer','Administration Team','Schedule Team','Supplier','Financial Team','Schedule Reporting');
if (checkPermission($AllowedUserTypes) != 1) {
header("Location: /?action=order-details&schedule_num=$schedule_num&menu_num=$menu_num&error_code=NOACCESS");
exit();
}
if (array_key_exists('reseller_school',$_GET)) $reseller_school = intval($_GET['reseller_school']);
if (array_key_exists('reseller_menu_num',$_GET)) $reseller_menu_num = intval($_GET['reseller_menu_num']);
if (isset($reseller_school) && isset($reseller_menu_num)) {
$school_num = $reseller_school;
$base_school_num = $reseller_school;
$menu_num = $reseller_menu_num;
$query = "SELECT * FROM schools WHERE record_num = $school_num";
writeLog($query);
$results = db_query($query);
$school_record = db_fetch_assoc($results);
$schedule_num = db_getVal("SELECT schedule_num FROM hotlunch_menu_dates WHERE school_num = $reseller_school AND record_num = $menu_num");
writeLog("school_num: $school_num");
writeLog("menu_num: $menu_num");
writeLog("schedule_num: $schedule_num");
writeLog("school: ".$school_record['school_name']);
writeLog("logo: ".$school_record['logo_image']);
$schedule_num = db_getVal("SELECT schedule_num FROM hotlunch_menu_dates WHERE school_num = $reseller_school AND record_num = $reseller_menu_num");
$query = "SELECT * FROM form_defaults WHERE school_num = $school_num AND action = 'order-details'";
writeLog($query);
$results = db_query($query);
while ($row = db_fetch_array($results)) {
$fname = $row['field'];
$$fname = $row['default_value'];
writeLog("$fname: ".$$fname);
}
if (isset($report_sort)) writeLog("report_sort: $report_sort");
}
else {
$post = print_r($_POST,true);
writeLog($post);
}
//
// Get and validate the parameters
//
if (!isset($displayDetails)) $displayDetails = 'Y';
if (!isset($contactInfo)) $contactInfo = 'Student';
if (!isset($document_format)) $document_format = 'List';
if (!isset($studentInfo)) $studentInfo = 'All';
if (!isset($printTotals)) $printTotals = 'Y';
if (array_key_exists('schedule_num',$_POST)) $schedule_num = intval($_POST['schedule_num']);
if (array_key_exists('menu_num',$_POST)) $menu_num = intval($_POST['menu_num']);
if (array_key_exists('document_format',$_POST)) $document_format = db_escape_string($_POST['document_format']);
if (array_key_exists('report_sort',$_POST)) $report_sort = db_escape_string($_POST['report_sort']);
if (array_key_exists('display_payment_status',$_POST)) $display_payment_status = db_escape_string($_POST['display_payment_status']);
if (array_key_exists('display_contact_details',$_POST)) $display_contact_details = db_escape_string($_POST['display_contact_details']);
if (array_key_exists('include_allergy_info',$_POST)) $include_allergy_info = $_POST['include_allergy_info'];
if (array_key_exists('contactInfo',$_POST)) $contactInfo = db_escape_string($_POST['contactInfo']);
if (array_key_exists('studentInfo',$_POST)) $studentInfo = db_escape_string($_POST['studentInfo']);
if (array_key_exists('studentName',$_POST)) $studentName = db_escape_string($_POST['studentName']);
if (array_key_exists('printTotals',$_POST)) $printTotals = db_escape_string($_POST['printTotals']);
if (array_key_exists('selectedClasses',$_POST) && is_array($_POST['selectedClasses']) && count($_POST['selectedClasses'])) $selectedClasses = db_escape_string($_POST['selectedClasses']);
if (array_key_exists('fontSize',$_POST)) $fontSize = db_escape_string($_POST['fontSize']);
if (array_key_exists('display_details',$_POST)) $displayDetails = db_escape_string($_POST['display_details']);
if (array_key_exists('display_details',$_POST)) $display_details = db_escape_string($_POST['display_details']);
if (!isset($orderStatus)) $orderStatus = 'Active';
if (array_key_exists('orderStatus', $_POST)) $orderStatus = db_escape_string($_POST['orderStatus']);
if (!isset($display_user_data)) $display_user_data = 'Y';
if (array_key_exists('display_user_data',$_POST)) db_escape_string($display_user_data = $_POST['display_user_data']);
if (!isset($with_page_breaks)) $with_page_breaks = 'N';
if (array_key_exists('with_page_breaks',$_POST)) $with_page_breaks = db_escape_string($_POST['with_page_breaks']);
// if ($_SESSION['UserInfo']['type'] == 'SuperUser') $with_page_breaks = 'Y';
$titleHighlights = 'Y';
if (array_key_exists('titleHighlights',$_POST)) $titleHighlights = db_escape_string($_POST['titleHighlights']);
if (!isset($schedule_num)) {
header("Location: /?action=order-details&schedule_num=$schedule_num&menu_num=$menu_num&error_code=NOSCHED");
exit();
}
if (!isset($menu_num)) {
header("Location: /?action=order-details&schedule_num=$schedule_num&menu_num=$menu_num&error_code=NOMENU");
exit();
}
if ($displayDetails == 'N') $document_format = 'list';
writeLog("school_num: $school_num");
writeLog("menu_num: $menu_num");
writeLog("schedule_num: $schedule_num");
writeLog("school: ".$school_record['school_name']);
writeLog("schedules found: ".db_num_rows($results));
// Update form defaults
$formFields = array('document_format',
'report_sort',
'display_payment_status',
'display_contact_details',
'contactInfo',
'studentInfo',
'studentName',
'display_user_data',
'orderStatus',
'display_details',
'printTotals',
'include_people',
'fontSize',
'titleHighlights',
'include_allergy_info');
if (!isset($reseller_school) && !isset($reseller_menu_num)) {
for ($i = 0; $i < count($formFields); $i++) {
$fname = $formFields[$i];
$value = isset($_POST[$fname]) ? $_POST[$fname] : '';
$value = db_escape_string($value);
db_query("INSERT INTO form_defaults VALUES ($school_num,'order-details','$fname','$value') ON DUPLICATE KEY UPDATE default_value = '$value'");
}
}
// Check if this is a valid schedule
$query = "select * from hotlunch_schedules " .
"where school_num = $school_num " .
"and record_num = $schedule_num";
$results = db_query($query);
if (db_num_rows($results) == 0) {
header("Location: /?action=order-details&schedule_num=$schedule_num&menu_num=$menu_num&error_code=INVALIDSCHED");
exit();
}
$hotlunch_schedule = db_fetch_array($results);
$schedule_name = $hotlunch_schedule['schedule_name'];
$ClassNumField = "class_num";
if ($school_record['implement_meal_locations'] == 'Y' && $hotlunch_schedule['class_sort_field'] == 'D' || $hotlunch_schedule['class_sort_field'] == 'L') {
// Get set of valid meal locations
$locations = array();
$results = db_query("SELECT record_num FROM meal_locations WHERE school_num = $school_num UNION SELECT record_num FROM classes WHERE school_num = $school_num");
while ($row = db_fetch_assoc($results)) {
$locations[] = $row['record_num'];
}
$lnums = implode(',', $locations);
$ClassNumField = "meal_location";
if (strlen($lnums)) {
db_query("UPDATE people SET meal_location = class_num WHERE school_num = $base_school_num AND (meal_location IS NULL OR meal_location NOT IN ($lnums))");
}
else {
db_query("UPDATE people SET meal_location = class_num WHERE school_num = $base_school_num AND meal_location IS NULL");
}
}
// If this is a ScheduleTeam user check if they have permission to access this schedule
if (in_array($_SESSION['UserInfo']['type'],array('Schedule Team','Schedule Volunteer'))) {
$userNum = intval($_SESSION['UserInfo']['record_num']);
$access = db_getVal("SELECT count(*) FROM hotlunch_schedules_people WHERE school_num = $school_num AND schedule_num = $schedule_num AND user_num = $userNum");
if (!$access || $access == 0) {
header("Location: /?action=order-details&schedule_num=$schedule_num&menu_num=$menu_num&error_code=NOACCESS");
exit();
}
}
// Check if this is a valid menu
$query = "select * from hotlunch_menu_dates " .
"where school_num = $school_num " .
"and schedule_num = $schedule_num " .
"and record_num = $menu_num";
$results = db_query($query);
if (db_num_rows($results) == 0) {
header("Location: /?action=order-details&schedule_num=$schedule_num&menu_num=$menu_num&error_code=INVALIDMENU");
exit();
}
$hotlunch_menu_date = db_fetch_array($results);
$menu_title = $hotlunch_menu_date['menu_title'];
$menu_date = date("D M j Y",strtotime($hotlunch_menu_date['menu_date']));
$mdate = date("Y-m-d",strtotime($hotlunch_menu_date['menu_date']));
// Determine which items have been selected
$selected_items = array();
$query = "select * from hotlunch_menu_items " .
"where school_num = $school_num " .
"and menu_num = $menu_num " .
"order by sequence";
$results = db_query($query);
$total_orders = 0;
$selected_item_titles = array();
while ($row = db_fetch_array($results)) {
$record_num = $row['record_num'];
if (array_key_exists("item_$record_num", $_POST) && $_POST["item_$record_num"] == 'Y') {
$selected_items[] = $record_num;
$item_title = trim($row['item_title']);
if (!in_array($item_title,$selected_item_titles)) $selected_item_titles[] = trim($row['item_title']);
}
else {
if (isset($reseller_school)) {
$selected_items[] = $record_num;
$item_title = trim($row['item_title']);
if (!in_array($item_title,$selected_item_titles)) $selected_item_titles[] = trim($row['item_title']);
}
}
}
if (count($selected_items) == 0) {
header("Location: /?action=order-details&schedule_num=$schedule_num&menu_num=$menu_num&error_code=NOITEMS");
exit();
}
$school_name = $school_record['school_name'];
writeLog("school_name: $school_name");
writeLog("school_num: $school_num");
writeLog("-------------------");
//
// Orders to print
//
$items = implode(',',$selected_items);
$groupByClass = true;
$order_by = "last_name,first_name";
if (isset($report_sort)) {
switch ($report_sort) {
case 'byClass':
$order_by = "sequence,people_type desc,last_name,first_name";
$item_sequence = "";
$date_field = false;
break;
case 'byGrade':
$order_by = "grade,people_type desc,last_name,first_name";
$item_sequence = "";
$date_field = false;
$groupByClass = false;
break;
case 'byStudent':
$order_by = "last_name,first_name";
$item_sequence = "";
$date_field = false;
$groupByClass = false;
break;
case 'byEnteredDate':
$order_by = "added_date,order_num";
$item_sequence = "";
$date_field = "added_date";
$date_text = getLanguageText('TEXT-ORDER-DATE');
$groupByClass = false;
break;
case 'byPaidDate':
$order_by = "paid_date,order_num";
$item_sequence = "";
$date_field = "paid_date";
$date_text = getLanguageText('TEXT-PAID-DATE');
$groupByClass = false;
break;
case 'byMenuItem':
$order_by = "item_sequence,last_name,first_name";
$item_sequence = ",hlmi.sequence as item_sequence";
$date_field = false;
$groupByClass = false;
break;
case 'byClassFirstName':
$order_by = "sequence,people_type desc,first_name,last_name";
$item_sequence = "";
$date_field = false;
break;
case 'byStudentFirstName':
$order_by = "first_name,last_name";
$item_sequence = "";
$date_field = false;
$groupByClass = false;
break;
}
}
// Setup order status where clause
$oswhere = "and hloh.status not in ('Inactive','Deleted') ";
if (isset($orderStatus) && $orderStatus == 'Any') $oswhere = "and hloh.status != 'Deleted' ";
// Get all orders for this menu date
if ($school_record['staff_meals_to_classroom'] != 'N' || $school_record['implement_meal_locations'] == 'Y') {
if ($school_record['delivery_report_staff'] == 'Y') {
if (!isset($item_sequence)) $item_sequence = '';
if (!isset($order_by)) $order_by = 'last_name, first_name';
$query = "select distinct p.people_type,hloi.ordered_by_num,p.first_name,p.last_name,p.label_note,p.$ClassNumField AS class_num,p.user_num,c.division,c.sequence,c.grade,hloi.order_num," .
"p.class_num AS clnum, p.meal_location AS mlnum,hloh.added_date,hloh.paid_date,hloh.status,delivered$item_sequence " .
"from hotlunch_order_header as hloh, hotlunch_order_items as hloi, hotlunch_menu_items as hlmi, " .
"people as p left join classes as c on c.school_num = $base_school_num and p.$ClassNumField = c.record_num left join people as p1 on c.teacher1 = p1.record_num " .
"where hloh.record_num = hloi.order_num " .
$oswhere .
"and hloi.ordered_by_num = p.record_num " .
"and hloh.ordered_by_num = p.record_num " .
"and hloi.school_num = $school_num " .
"and hlmi.school_num = $school_num " .
"and p.school_num = $base_school_num " .
"and p.status != 'Inactive' " .
"and hloi.menu_item_num in ($items) " .
"and hloi.menu_item_num = hlmi.record_num " .
"and hloi.active != 'N' " .
"order by $order_by";
}
else {
$query = "select distinct p.people_type,hloi.ordered_by_num,p.first_name,p.last_name,p.label_note,p.$ClassNumField AS class_num,p.user_num,c.division,c.sequence,c.grade,hloi.order_num," .
"p.class_num AS clnum, p.meal_location AS mlnum,hloh.added_date,hloh.paid_date,hloh.status,delivered$item_sequence " .
"from hotlunch_order_header as hloh, hotlunch_order_items as hloi, hotlunch_menu_items as hlmi, " .
"people as p left join classes as c on c.school_num = $base_school_num and p.$ClassNumField = c.record_num left join people as p1 on c.teacher1 = p1.record_num " .
"where hloh.record_num = hloi.order_num " .
$oswhere .
"and hloi.ordered_by_num = p.record_num " .
"and hloh.ordered_by_num = p.record_num " .
"and hloi.school_num = $school_num " .
"and hlmi.school_num = $school_num " .
"and p.school_num = $base_school_num " .
"and p.status != 'Inactive' " .
"and hloi.menu_item_num in ($items) " .
"and hloi.menu_item_num = hlmi.record_num " .
"and hloi.active != 'N' " .
"order by $order_by";
}
}
else {
if ($school_record['delivery_report_staff'] == 'Y') {
$query = "select distinct p.people_type,hloi.ordered_by_num,p.first_name,p.last_name,p.label_note,0 as class_num,p.user_num,0 as division,0 as sequence,0 as grade,hloi.order_num," .
"p.class_num AS clnum, p.meal_location AS mlnum,hloh.added_date,hloh.paid_date,hloh.status,delivered$item_sequence " .
"from hotlunch_order_header as hloh, hotlunch_order_items as hloi, hotlunch_menu_items as hlmi, " .
"people as p left join classes as c on c.school_num = $base_school_num and p.$ClassNumField = c.record_num left join people as p1 on c.teacher1 = p1.record_num " .
"where hloh.record_num = hloi.order_num " .
$oswhere .
"and hloi.ordered_by_num = p.record_num " .
"and hloh.ordered_by_num = p.record_num " .
"and hloi.school_num = $school_num " .
"and hlmi.school_num = $school_num " .
"and p.school_num = $base_school_num " .
"and p.status != 'Inactive' " .
"and hloi.menu_item_num in ($items) " .
"and hloi.menu_item_num = hlmi.record_num " .
"and p.people_type = 'Staff' " .
"and hloi.active != 'N' " .
"UNION " .
"select distinct p.people_type,hloi.ordered_by_num,p.first_name,p.last_name,p.label_note,p.$ClassNumField AS class_num,p.user_num,c.division,c.sequence,c.grade,hloi.order_num," .
"p.class_num AS clnum, p.meal_location AS mlnum,hloh.added_date,hloh.paid_date,hloh.status,delivered$item_sequence " .
"from hotlunch_order_header as hloh, hotlunch_order_items as hloi, hotlunch_menu_items as hlmi, " .
"people as p left join classes as c on c.school_num = $base_school_num and p.$ClassNumField = c.record_num left join people as p1 on c.teacher1 = p1.record_num " .
"where hloh.record_num = hloi.order_num " .
"and hloh.status not in ('Inactive','Deleted') " .
"and hloi.ordered_by_num = p.record_num " .
"and hloh.ordered_by_num = p.record_num " .
"and hloi.school_num = $school_num " .
"and hlmi.school_num = $school_num " .
"and p.school_num = $base_school_num " .
"and p.status != 'Inactive' " .
"and hloi.menu_item_num in ($items) " .
"and hloi.menu_item_num = hlmi.record_num " .
"and p.people_type != 'Staff' " .
"and hloi.active != 'N' " .
"order by $order_by";
}
else {
$query = "select distinct p.people_type,hloi.ordered_by_num,p.first_name,p.last_name,p.label_note,p.$ClassNumField AS class_num,p.user_num,c.division,c.sequence,c.grade,hloi.order_num," .
"p.class_num AS clnum, p.meal_location AS mlnum,hloh.added_date,hloh.paid_date,hloh.status,delivered$item_sequence " .
"from hotlunch_order_header as hloh, hotlunch_order_items as hloi, hotlunch_menu_items as hlmi, " .
"people as p left join classes as c on c.school_num = $base_school_num and p.$ClassNumField = c.record_num left join people as p1 on c.teacher1 = p1.record_num " .
"where hloh.record_num = hloi.order_num " .
$oswhere .
"and hloi.ordered_by_num = p.record_num " .
"and hloh.ordered_by_num = p.record_num " .
"and hloi.school_num = $school_num " .
"and hlmi.school_num = $school_num " .
"and p.school_num = $base_school_num " .
"and p.status != 'Inactive' " .
"and hloi.menu_item_num in ($items) " .
"and hloi.menu_item_num = hlmi.record_num " .
"and p.people_type != 'Staff' " .
"and hloi.active != 'N' " .
"order by $order_by";
}
}
writeLog($query);
$orders = db_query($query);
writeLog("Num Orders: ".db_num_rows($orders));
if (db_num_rows($orders) == 0) {
$error_message = getLanguageText('ERRORMSG-NO-ORDERS-FOUND');
header("Location: ?error_message=".urlencode($error_message));
exit();
}
// Initialize the PDF document
$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;
if (isset($fontSize)) $document_font_size = $fontSize;
$incr = 3.2;
if ($document_font_size > 10) $incr = 4.0;
//
// Setup PDF document
//
require("tcpdf/config/lang/eng.php");
require("tcpdf/tcpdf.php");
// Set parameters for this document
$start_row = 8;
$title_width = 190;
$status_width = $title_width - 30;
$item_width = $title_width - 100;
$max_rows = 230;
$curr_row = $start_row;
$left_col = 12;
$qty_col = 20;
$item_col = 25;
$items_col = 25;
$notes_col = 40;
$max_line_length = 5;
$notes_width = 150;
$logo_url = '';
$logo_image = '';
if (strlen($school_record['logo_url'])) $logo_url = $school_record['logo_url'];
if (strlen($school_record['logo_image'])) $logo_image = "images/" . $school_record['logo_image'];
$logo_row = 250;
$document_name = $OrderDetailsText;
// Initialize variables used later to avoid undefined variable warnings (which cause output before headers)
$font_parm = ""; // Font style parameter for TCPDF SetFont
$additional_info = ""; // Accumulates extra info to display beside names
$line_width = $title_width; // Fallback width when printing customer address lines
class PDF extends TCPDF {
function Header() {
global $incr, $left_col, $start_row, $title_width, $document_font, $document_font_size, $report_title, $report_subtitle,
$document_format, $groupByClass, $displayDetails, $class_info, $titleHighlights;
$curr_row = $start_row;
writeLog("Header: $left_col $start_row - $report_title");
$header_font_size = $document_font_size;
if ($document_font_size > 12) $header_font_size = 12;
// if ($document_format != 'report' && $document_format != 'list') return;
if (!in_array($document_format,array('report','list','page'))) return;
// Print the header
$this->SetFillColor(hexdec("bb"),hexdec("bb"),hexdec("bb"));
$this->SetFont($document_font,"B",$header_font_size + 1);
$this->SetXY($left_col,$start_row);
$fill = true;
if (isset($titleHighlights) && $titleHighlights == 'N') $fill = false;
$this->Cell($title_width,$incr + 1," $report_title",'0',1,'L',$fill,'',1);
if (isset($report_subtitle) && strlen($report_subtitle) > 0) {
$offset = 100;
$this->SetXY($left_col + $offset,$start_row);
$col = $left_col + $offset;
writeLog("Header: $col $start_row - $report_subtitle");
$this->Cell($title_width - $offset,$incr + 1,"$report_subtitle ",'0',1,'R',$fill,'',1);
}
if ($groupByClass && $displayDetails == 'Y') {
$this->SetXY($left_col,$start_row + $incr + 3);
$this->Cell($title_width,$incr + 1,$class_info,'0',1,'L',$fill,'',1);
}
}
function Footer() {
global $incr, $left_col, $title_width, $max_rows, $document_font, $document_font_size, $document_name, $logo_image, $logo_url, $logo_row, $document_format, $school_name;
if ($document_format == 'receipt') return;
// Print the date
$this->SetFont($document_font,"",intval($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',false);
$this->SetXY($left_col,$logo_row + $incr);
$this->Cell($title_width,$incr - 1,"$school_name",'0',1,'R','',1);
if (strlen($logo_image) && strlen($logo_url)) {
$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',false);
}
}
}
// Force exact physical size for Letter to avoid any library/config defaults
// Letter: 8.5 x 11 inches => 215.9mm x 279.4mm (portrait)
$pageFormat = array(215.9, 279.4);
$pdf= new PDF('P', 'mm', $pageFormat, 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->SetFillColor(hexdec("dd"),hexdec("dd"),hexdec("dd"));
$pdf->SetTextColor($font_red,$font_green,$font_blue);
$pdf->SetFont($document_font,"",$document_font_size);
$fill = true;
if ($document_format == 'report') $fill = false;
$prev_class_num = -1;
$new_page = true;
$curr_row = $max_rows + 10;
$grand_totals = array();
$totals = array();
$classPrinted = false;
$report_title = $school_name . " - " . $schedule_name;
$report_subtitle = $menu_title;
if ($hotlunch_schedule['schedule_type'] == 'Hot Lunch' || $hotlunch_schedule['schedule_type'] == 'Date Sensitive' || $hotlunch_schedule['display_menu_date'] == 'Y') $report_subtitle = "$menu_date - $menu_title";
// Process each record
$page = 0;
$count = 0;
$totalsPrinted = false;
while ($entry = db_fetch_array($orders)) {
extract($entry);
// Get order header record
$results = db_query("SELECT * FROM hotlunch_order_header WHERE school_num = $school_num AND record_num = $order_num");
$order_header = db_fetch_assoc($results);
if ($groupByClass && $class_num != $prev_class_num) {
// Print class totals
writeLog("printTotals: $printTotals prev_class_num: $prev_class_num displayDetails: $displayDetails document_format: $document_format");
if ($printTotals == 'Y' && $prev_class_num != -1) {
$numTotals = count($totals) + 1;
if ($curr_row + $incr * $numTotals > $max_rows) {
$pdf->addPage();
$curr_row = $start_row + $incr + $incr;
if ($displayDetails == 'N') $curr_row = $start_row + 8;
if ($document_format == 'page' || $document_format == 'report') $curr_row = $start_row + $incr;
}
$curr_row += $incr;
$pdf->SetXY($left_col,$curr_row);
writeLog("$left_col,$curr_row TOTAL");
$pdf->SetFont($document_font,'B',$document_font_size);
$pdf->SetFillColor(hexdec("bb"),hexdec("bb"),hexdec("bb"));
$text = getLanguageText('TEXT-TOTAL');
if ($groupByClass) $text .= " - $class_info";
$text .= " ($total_orders)";
$fill = true;
if (isset($titleHighlights) && $titleHighlights == 'N') $fill = false;
$pdf->Cell($title_width,$incr + 3,$text,'0',1,'L',$fill);
$pdf->SetFillColor(hexdec("dd"),hexdec("dd"),hexdec("dd"));
$curr_row += $incr + 2;
$pdf->SetFont($document_font,'',$document_font_size - 1);
for ($t = 0; $t < count($selected_item_titles); $t++) {
$key = $selected_item_titles[$t];
if (array_key_exists($key, $totals) && $totals[$key] > 0) {
$pdf->SetXY($left_col,$curr_row);
$pdf->Cell($title_width,$incr + 1,sprintf("%8d - %s",$totals[$key],$key),'0',1,'L',$fill);
$curr_row += $incr + 1;
}
}
$total_orders = 0;
$totalsPrinted = true;
}
if (isset($class_num) && is_numeric($class_num)) $class_info = getClassInfo($class_num);
$prev_class_num = $class_num;
$report_subtitle = $menu_title;
if ($hotlunch_schedule['schedule_type'] == 'Hot Lunch' || $hotlunch_schedule['schedule_type'] == 'Date Sensitive' || $hotlunch_schedule['display_menu_date'] == 'Y') $report_subtitle = "$menu_date - $menu_title";
if ($groupByClass) {
$curr_row = $max_rows + 10;
}
$totals = array();
}
$total_orders++;
// Get order items for this order
$query = "select hloi.*,hlmi.item_title,hlmi.sequence from hotlunch_order_items as hloi, hotlunch_menu_items as hlmi " .
"where hloi.school_num = $school_num " .
"and hlmi.school_num = $school_num " .
"and hloi.menu_num = $menu_num " .
"and hloi.order_num = $order_num " .
"and hloi.menu_item_num in ($items) " .
"and hloi.menu_item_num = hlmi.record_num " .
"and hloi.active != 'N' " .
"order by sequence";
$ordered_items = db_query($query);
// Start new page if required
if ($curr_row > ($max_rows - db_num_rows($ordered_items) * $incr)) {
$pdf->addPage();
$curr_row = $start_row + $incr;
if ($displayDetails == 'N') $curr_row = $start_row + 8;
if ($document_format == 'page' || $document_format == 'report') $curr_row = $start_row + $incr;
if (!$groupByClass) $curr_row = $curr_row - $incr;
$new_page = true;
}
// Display titles in report format on each page
if ($displayDetails == 'Y' && $new_page && (in_array($document_format,array('report','list','page')))) {
if (count($selected_items) == 1) {
$item_title = db_getVal("SELECT item_title FROM hotlunch_menu_items WHERE school_num = $school_num AND record_num = $items");
$curr_row += $incr + 1;
if (strlen($report_subtitle)) $curr_row += 4;
$pdf->SetFillColor(hexdec("bb"),hexdec("bb"),hexdec("bb"));
$pdf->SetFont($document_font,'B',$document_font_size + 1);
$pdf->SetXY($left_col,$curr_row);
$fill = true;
if (isset($titleHighlights) && $titleHighlights == 'N') $fill = false;
$pdf->Cell($title_width,$incr + 2,$item_title,'0',1,'L',$fill);
$pdf->SetFillColor(hexdec("dd"),hexdec("dd"),hexdec("dd"));
}
$new_page = false;
$curr_row += $incr + 8;
}
// Display ordered by name
$pdf->SetFont($document_font,$font_parm,$document_font_size);
$pdf->SetFillColor(hexdec("dd"),hexdec("dd"),hexdec("dd"));
$fill = true;
if (count($selected_items) == 1) {
$fill = true;
$count++;
}
// Get parent contact info if required
$info = getContactInfo($user_num);
$user_record = '';
$address = '';
if (array_key_exists(3, $info)) $user_record = $info[3];
if ($displayDetails == 'Y' && isset($contactInfo) && ($contactInfo == 'Student' || $contactInfo == 'Both' || $contactInfo == 'BothNames')) {
$name = trim($first_name . ' ' . $last_name);
if (isset($studentName) && $studentName == 'First') $name = $first_name;
if ($people_type == 'Staff') $name .= " (Staff)";
if (isset($orderStatus) && $orderStatus == 'Any') $name .= " - " . $status;
$linked_to_student = db_getVal("SELECT linked_to_student FROM users WHERE school_num = $base_school_num AND record_num = $user_num");
if (strlen($linked_to_student)) $name .= " ($linked_to_student)";
// Get order status
if (isset($display_payment_status) && $display_payment_status == 'Y') {
$order_status = $order_header['status'];
$order_total = $currencySymbol . $order_header['order_total'];
$name .= " - $order_status ($order_total)";
}
// Include quantity if required
if (count($selected_items) == 1) {
$qty = db_getVal("SELECT qty FROM hotlunch_order_items WHERE school_num = $school_num AND ordered_by_num = $ordered_by_num AND schedule_num = $schedule_num AND menu_item_num = $items");
$name .= " (x$qty)";
}
if ($hotlunch_schedule['schedule_type'] != 'Hot Lunch' && in_array($siteType,array('hotlunch','yearbook','tickets','fundraising'))) $name .= " ($delivered)";
if ($school_record['implement_meal_locations'] == 'Y' && $hotlunch_schedule['class_sort_field'] == 'D' || $hotlunch_schedule['class_sort_field'] == 'L') {
if ($clnum > 0 && $clnum != $mlnum) $name = "*** $name ***";
}
$allergies = '';
if (isset($include_allergy_info) && $include_allergy_info == 'Y') {
$query = "SELECT allergen FROM allergies AS a, allergens " .
"WHERE a.school_num = $school_num " .
"AND allergens.school_num = $school_num " .
"AND allergens.record_num = a.allergen_num " .
"AND a.people_num = $ordered_by_num";
$ar = db_query($query);
if (db_num_rows($ar)) {
while ($r = db_fetch_assoc($ar)) {
if (strlen($allergies)) $allergies .= ", ";
$allergies .= $r['allergen'];
}
$name .= " - $allergies";
}
}
// Print name
$pdf->SetXY($left_col,$curr_row);
writeLog("$left_col,$curr_row - $name");
if (isset($titleHighlights) && $titleHighlights == 'N') $fill = false;
$pdf->Cell($title_width,$incr,$name,'0',1,'L',$fill);
// Print additional info if required
$additional_info = "";
if (strlen($label_note)) $additional_info = $label_note;
$results = db_query("SELECT * FROM people WHERE school_num = $base_school_num AND record_num = $ordered_by_num");
$ainfo = db_fetch_array($results);
// Include class info if only one item has been selected or not grouped by class
$classPrinted = false;
if ($studentInfo != 'Name' && (count($selected_items) == 1 || $groupByClass == false)) {
if (strlen($additional_info) > 0) $additional_info .= " / ";
$additional_info .= getClassInfo($class_num);
$classPrinted = true;
}
// Student number
if ($studentInfo == 'All' && $school_record['collect_student_number'] == 'Y' && strlen($ainfo['student_number']) > 0) {
if (strlen($additional_info) > 0) $additional_info .= " / ";
$additional_info .= getLanguageText('TEXT-STUDENT-NUMBER') . ": " . $ainfo['student_number'];
}
// Student birthdate
if ($studentInfo == 'All' && $school_record['collect_student_birthdate'] == 'Y' && strlen($ainfo['birthdate']) > 0) {
if (strlen($additional_info) > 0) $additional_info .= " / ";
$additional_info .= getLanguageText('TEXT-BIRTH-DATE') . ": " . date($school_record['date_format'],strtotime($ainfo['birthdate']));
}
// Student sex
if ($studentInfo == 'All' && $school_record['collect_student_sex'] == 'Y' && strlen($ainfo['sex']) > 0) {
if (strlen($additional_info) > 0) $additional_info .= " / ";
$additional_info .= $ainfo['sex'];
}
// Student age
if ($studentInfo == 'All' && $school_record['collect_student_age'] == 'Y' && strlen($ainfo['age']) > 0) {
if (strlen($additional_info) > 0) $additional_info .= " / ";
$additional_info .= getLanguageText('TEXT-AGE') . ": " . $ainfo['age'];
}
// Student grade
if ($studentInfo == 'All' && $school_record['collect_student_grade'] == 'Y' && strlen($ainfo['school_grade']) > 0) {
if (strlen($additional_info) > 0) $additional_info .= " / ";
$additional_info .= getLanguageText('TEXT-GRADE') . ": " . $ainfo['school_grade'];
}
// Student permission
if ($studentInfo == 'All' && ($school_record['collect_permission'] == 'Y' || $school_record['collect_permission'] == 'W') && strlen($ainfo['additional_permission']) > 0) {
if (strlen($additional_info) > 0) $additional_info .= " / ";
$additional_info .= $school_record['permission_prompt'] . ": " . $ainfo['additional_permission'];
if (strlen($ainfo['additional_permission_note'])) $additional_info .= " - " . $ainfo['additional_permission_note'];
}
// User Defined Data
if ($studentInfo == 'All' && $school_record['user_defined_values'] == 'Y' && strlen($school_record['user_defined_title']) > 0 && strlen($ainfo['user_defined_value'])) {
if (strlen($additional_info) > 0) $additional_info .= " / ";
$additional_info .= $school_record['user_defined_title'] . ": " . $ainfo['user_defined_value'];
}
if ($date_field) {
$odate = dateString('shortdate',strtotime($$date_field));
$additional_info .= " ($odate)";
}
if (strlen($additional_info)) {
$width = 100;
$info_col = $left_col + $title_width - $width;
$pdf->SetXY($info_col,$curr_row);
$pdf->SetFont($document_font,"",$document_font_size - 2);
$pdf->Cell($width,$incr,$additional_info,'0',1,'R',false,'',1);
$pdf->SetFont($document_font,"",$document_font_size);
}
// Customer address info
if ($people_type == 'Customer') {
$results = db_query("SELECT * FROM people WHERE record_num = $ordered_by_num");
$r = db_fetch_assoc($results);
$cust_text = "";
if ($school_record['customer_address'] == 'Y') {
$cust_text .= $r['cust_address'].", ".$r['cust_city'].", ".$r['cust_province']." ".$r['cust_country']." ".$r['cust_postal']." ";
}
if ($school_record['customer_phone'] == 'Y') {
$cust_text .= $r['cust_phone']." ";
}
if ($school_record['customer_email'] == 'Y') {
$cust_text .= $r['cust_email'];
}
if (strlen($cust_text)) {
$curr_row += $incr + 1;
$pdf->SetFont($document_font,"",$document_font_size - 1);
$pdf->SetXY($left_col,$curr_row);
$pdf->Cell($line_width,$incr,$cust_text,'0',1,'L',false);
}
}
}
else {
$name = $info[0];
// Include quantity if required
if (count($selected_items) == 1) {
$qty = db_getVal("SELECT qty FROM hotlunch_order_items WHERE school_num = $school_num AND ordered_by_num = $ordered_by_num AND schedule_num = $schedule_num AND menu_item_num = $items");
$name .= " (x$qty)";
}
$allergies = '';
if (isset($include_allergy_info) && $include_allergy_info == 'Y') {
$query = "SELECT allergen FROM allergies AS a, allergens " .
"WHERE a.school_num = $school_num " .
"AND allergens.school_num = $school_num " .
"AND allergens.record_num = a.allergen_num " .
"AND a.people_num = $ordered_by_num";
$ar = db_query($query);
if (db_num_rows($ar)) {
while ($r = db_fetch_assoc($ar)) {
if (strlen($allergies)) $allergies .= ", ";
$allergies .= $r['allergen'];
}
$name .= " - $allergies";
}
}
// Print name
$pdf->SetXY($left_col,$curr_row);
if (isset($titleHighlights) && $titleHighlights == 'N') $fill = false;
$pdf->Cell($title_width,$incr,$name,'0',1,'L',$fill);
// Print phone & email
$pdf->SetXY($left_col + 80,$curr_row);
$pdf->Cell($title_width - 80,$incr,$info[1] . ' - ' . $info[2],'0',1,'L',$fill);
if (isset($display_contact_details) && $display_contact_details == 'Y') {
$pdf->SetFont($document_font,"",$document_font_size - 1);
if (is_array($user_record)) $address = $user_record['address'] . ", " . $user_record['city'] . " " . $user_record['province'] . " " . $user_record['postal'];
$curr_row += $incr + 1;
$pdf->SetXY($left_col,$curr_row);
$pdf->Cell($title_width,$incr," ",'0',1,'L',$fill);
$pdf->SetXY($left_col + 80,$curr_row);
$pdf->Cell($title_width - 80,$incr,$address,'0',1,'L',$fill);
$pdf->SetFont($document_font,"",$document_font_size);
}
// Customer address info
if ($people_type == 'Customer') {
$results = db_query("SELECT * FROM people WHERE record_num = $ordered_by_num");
$r = db_fetch_assoc($results);
$cust_text = "";
if ($school_record['customer_address'] == 'Y') {
$cust_text .= $r['cust_address'].", ".$r['cust_city'].", ".$r['cust_province']." ".$r['cust_country']." ".$r['cust_postal']." ";
}
if ($school_record['customer_phone'] == 'Y') {
$cust_text .= $r['cust_phone']." ";
}
if ($school_record['customer_email'] == 'Y') {
$cust_text .= $r['cust_email'];
}
if (strlen($cust_text)) {
$curr_row += $incr + 1;
$pdf->SetFont($document_font,"",$document_font_size - 1);
$pdf->SetXY($left_col,$curr_row);
$pdf->Cell($line_width,$incr,$cust_text,'0',1,'L',false);
}
}
}
// Receipt format will be cut so print class and meal info
if ($document_format == 'receipt') {
$pdf->SetFont($document_font,"",$document_font_size - 1);
$pdf->SetXY($left_col + 100,$curr_row);
if (isset($titleHighlights) && $titleHighlights == 'N') $fill = false;
if ($hotlunch_schedule['schedule_type'] == 'Hot Lunch' || $hotlunch_schedule['schedule_type'] == 'Date Sensitive' || $hotlunch_schedule['display_menu_date'] == 'Y') {
$pdf->Cell($title_width - 100,$incr,"$class_info - $menu_title, $menu_date",'0',1,'R',$fill);
}
else {
$pdf->Cell($title_width - 100,$incr,"$class_info - $menu_title",'0',1,'R',$fill);
}
}
// If not grouped by class include the class info
if (strlen($additional_info) == 0 && $contactInfo != 'Parent' && $document_format != 'receipt' && $document_format != 'report' && $groupByClass == false) {
$width = 200;
$info_col = $qty_col;
$pdf->SetFont($document_font,"",$document_font_size - 2);
$pdf->SetXY($info_col,$curr_row);
if (count($selected_items) > 1) {
if ($hotlunch_schedule['schedule_type'] == 'Hot Lunch' || $hotlunch_schedule['schedule_type'] == 'Date Sensitive' || $hotlunch_schedule['display_menu_date'] == 'Y') {
$pdf->Cell($width,$incr,"$class_info - $menu_title, $menu_date",'0',1,'R',false,'',1);
}
else {
$pdf->Cell($width,$incr,"$class_info - $menu_title",'0',1,'R',false,'',1);
}
}
else {
$pdf->Cell($width,$incr,"$class_info",'0',1,'R',false,'',1);
}
}
$curr_row += $incr - 1;
// Print parent contact info if required
if ($contactInfo == 'Both' || $contactInfo == 'BothNames') {
$curr_row += 2;
$contact_info = $info[0];
if ($contactInfo == 'Both') $contact_info = sprintf("%-s %12s - %s",$info[0],$info[1],$info[2]);
if ($class_num == 2) {
$students = db_query("SELECT * FROM people WHERE school_num = $base_school_num AND user_num = $user_num AND record_num != $ordered_by_num");
$n = db_num_rows($students);
$contact_info = "";
while ($r = db_fetch_assoc($students)) {
$c = getClassInfo($r['class_num']);
$contact_info .= " - ".$r['first_name'].' '.$r['last_name']." ($c) ";
}
}
$pdf->SetXY($left_col,$curr_row);
$pdf->SetFont($document_font,"",$document_font_size - 2);
if (isset($titleHighlights) && $titleHighlights == 'N') $fill = false;
$pdf->Cell($title_width,$incr,$contact_info,'0',1,'R',$fill);
if (isset($display_contact_details) && $display_contact_details == 'Y') {
$pdf->SetFont($document_font,"",$document_font_size - 1);
if (is_array($user_record)) $address = $user_record['address'] . ", " . $user_record['city'] . " " . $user_record['province'] . " " . $user_record['postal'];
$curr_row += $incr;
$pdf->SetXY($left_col,$curr_row);
$pdf->Cell($title_width,$incr,$address,'0',1,'R',$fill);
$pdf->SetFont($document_font,"",$document_font_size);
}
$pdf->SetFont($document_font,"",$document_font_size);
$curr_row += $incr;
}
// Print Additional Data
if ($display_user_data == 'Y' && strlen(trim($school_record['additional_registration_data_field1'])) > 0) {
$curr_row += 2;
$pdf->SetFont($document_font,"",$document_font_size - 2);
$pdf->SetXY($left_col,$curr_row);
$pdf->Cell($title_width,$incr,' ','0',1,'L',$fill);
$pdf->SetXY($left_col + 40,$curr_row);
$pdf->Cell($title_width - 80,$incr,trim($school_record['additional_registration_data_field1']) . ": " . $info[3]['additional1'],'0',1,'L',$fill);
$pdf->SetFont($document_font,"",$document_font_size);
$curr_row += $incr;
}
if ($display_user_data == 'Y' && strlen(trim($school_record['additional_registration_data_field2'])) > 0) {
$pdf->SetFont($document_font,"",$document_font_size - 3);
$pdf->SetXY($left_col,$curr_row);
$pdf->Cell($title_width,$incr,' ','0',1,'L',$fill);
$pdf->SetXY($left_col + 40,$curr_row);
$pdf->Cell($title_width - 80,$incr,trim($school_record['additional_registration_data_field2']) . ": " . $info[3]['additional2'],'0',1,'L',$fill);
$pdf->SetFont($document_font,"",$document_font_size);
$curr_row += $incr;
}
if ($people_type != 'Staff' && $document_format == 'report' && !$groupByClass) {
if ($classPrinted == false) {
$class_info = '';
if (isset($class_num) && is_numeric($class_num)) $class_info = getClassInfo($class_num);
if (strlen($class_info)) {
$curr_row += $incr;
$pdf->SetXY($left_col + 20,$curr_row);
$pdf->SetFont($document_font,"",$document_font_size - 3);
$pdf->Cell($title_width,$incr,"- $class_info",'0',1,'L',$fill);
$pdf->SetFont($document_font,"",$document_font_size);
$curr_row += $incr;
}
}
}
// Display the items
switch ($document_format) {
case 'receipt':
case 'list':
case 'page':
$numItems = db_num_rows($ordered_items);
if ($numItems > 0 && $displayDetails == 'Y') $curr_row += $incr / 2;
while ($row = db_fetch_array($ordered_items)) {
extract($row);
$item_title = trim($item_title);
// Calculate the totals
if (array_key_exists($item_title,$totals)) $totals[$item_title] += $qty;
else $totals[$item_title] = $qty;
if (array_key_exists($item_title,$grand_totals)) $grand_totals[$item_title] += $qty;
else $grand_totals[$item_title] = $qty;
// Check for item options
$options = "";
$oordered = "";
$options_ordered = trim($options_ordered);
$options2_ordered = trim($options2_ordered);
$options3_ordered = trim($options3_ordered);
if (strlen($options_ordered)) $oordered = $options_ordered;
if (strlen($options2_ordered)) {
if (strlen($oordered)) $oordered .= "\n";
$oordered .= "$options2_ordered";
}
if (strlen($options3_ordered)) {
if (strlen($oordered)) $oordered .= "\n";
$oordered .= "\n$options3_ordered";
}
$options_ordered = trim($oordered);
if (strlen($oordered) > 0) {
$options = trim(str_replace("\n",", ",trim($oordered)));
if (strlen($options) > 0) $options = " ($options)";
}
// Display selected items
if ($displayDetails == 'Y') {
if (count($selected_items) > 1) {
$curr_row += $incr;
$pdf->SetXY($qty_col,$curr_row);
$pdf->Cell(5,$incr,$qty,'0',1,'R',false);
// Print item title and options
if (strlen("$item_title $options") < $max_line_length) {
$pdf->SetXY($item_col,$curr_row);
$pdf->Cell($title_width - 10,$incr,"$item_title $options",'0',1,'L',false,'',1);
}
else {
$pdf->SetXY($item_col,$curr_row);
$pdf->Cell($item_width,$incr,$item_title,'0',1,'L',false);
if (strlen($options)) {
$pdf->SetFont($document_font,"",$document_font_size - 1);
$curr_row += $incr;
$pdf->SetXY($item_col,$curr_row);
$pdf->Cell($title_width - 10,$incr,$options,'0',1,'L',false,'',1);
$pdf->SetFont($document_font,"",$document_font_size);
}
}
}
else {
if (strlen($options)) {
$pdf->SetFont($document_font,"",$document_font_size - 1);
$curr_row += $incr;
$pdf->SetXY($item_col,$curr_row);
$pdf->Cell($item_width,$incr,$options,'0',1,'L',false);
$pdf->SetFont($document_font,"",$document_font_size);
}
}
}
}
if (count($selected_items) > 1 || strlen($options)) $curr_row += $incr;
// Order notes
if (strlen($order_header['order_notes'])) {
$curr_row += $incr;
$pdf->SetXY($notes_col,$curr_row);
$pdf->SetFont($document_font,"",$document_font_size - 2);
$pdf->MultiCell($notes_width,$incr,$order_header['order_notes'],'1','L',false);
$curr_row = $pdf->GetY();
}
if (strlen($order_header['order_notes2'])) {
$curr_row += $incr;
$pdf->SetXY($notes_col,$curr_row);
$pdf->SetFont($document_font,"",$document_font_size - 2);
$pdf->MultiCell($notes_width,$incr,"(2) ".$order_header['order_notes2'],'1','L',false);
$curr_row = $pdf->GetY();
}
$curr_row += $incr;
if ($document_format == 'receipt') $curr_row += 20;
if ($document_format == 'page') {
$pdf->addPage();
$curr_row = $start_row + 2;
$new_page = true;
}
break;
case 'report':
$items_ordered = "";
$line = 1;
while ($row = db_fetch_array($ordered_items)) {
extract($row);
// Calculate the totals
if (array_key_exists($item_title,$totals)) $totals[$item_title] += $qty;
else $totals[$item_title] = $qty;
if (array_key_exists($item_title,$grand_totals)) $grand_totals[$item_title] += $qty;
else $grand_totals[$item_title] = $qty;
// Check for item options
$options = "";
$options_ordered = trim($options_ordered);
$options2_ordered = trim($options2_ordered);
$options3_ordered = trim($options3_ordered);
if (strlen($options_ordered)) $options = $options_ordered;
if (strlen($options2_ordered)) {
if (strlen($options)) $options .= "\n";
$options .= $options2_ordered;
}
if (strlen($options3_ordered)) {
if (strlen($options)) $options .= "\n";
$options .= $options3_ordered;
}
if (strlen($options) > 0) {
$options = trim(str_replace("\n",", ",trim($options)));
if (strlen($options) > 0) $options = " ($options)";
}
if (strlen($items_ordered) > 0) {
if ((strlen($items_ordered) + strlen("$item_title $options")) > (140 * $line)) {
$items_ordered .= "\n";
$line++;
}
else {
$items_ordered .= " // ";
}
}
if ($qty > 1) $items_ordered .= "$qty x ";
$items_ordered .= "$item_title $options";
}
$curr_row += $incr;
$pdf->SetFont($document_font,$font_parm,$document_font_size - 1);
$pdf->SetXY($items_col,$curr_row);
$pdf->MultiCell(0,$incr,$items_ordered,'0','L',false);
$pdf->SetFont($document_font,$font_parm,$document_font_size);
$curr_row = $pdf->GetY();
// Order notes
if (strlen($order_header['order_notes'])) {
$pdf->SetXY($notes_col,$curr_row);
$pdf->SetFont($document_font,"",$document_font_size - 2);
$pdf->MultiCell($notes_width,$incr,$order_header['order_notes'],'1','L',false);
$curr_row = $pdf->GetY();
}
if (strlen($order_header['order_notes2'])) {
if (strlen($order_header['order_notes'])) $curr_row += $incr;
$pdf->SetXY($notes_col,$curr_row);
$pdf->SetFont($document_font,"",$document_font_size - 2);
$pdf->MultiCell($notes_width,$incr,$order_header['order_notes2'],'1','L',false);
$curr_row = $pdf->GetY();
}
$curr_row += $incr - 2;
break;
}
}
// Print class totals
if ($printTotals == 'Y') {
$numTotals = count($totals);
if ($curr_row + $incr * $numTotals > $max_rows) {
$pdf->addPage();
$curr_row = $start_row + 2;
}
$curr_row += $incr;
$pdf->SetXY($left_col,$curr_row);
$pdf->SetFont($document_font,'B',$document_font_size);
$pdf->SetFillColor(hexdec("bb"),hexdec("bb"),hexdec("bb"));
$text = getLanguageText('TEXT-TOTAL');
if ($groupByClass) $text .= " - $class_info";
$text .= " ($total_orders)";
$fill = true;
if (isset($titleHighlights) && $titleHighlights == 'N') $fill = false;
$pdf->Cell($title_width,$incr,$text,'0',1,'L',$fill);
$pdf->SetFillColor(hexdec("dd"),hexdec("dd"),hexdec("dd"));
$curr_row += $incr + 1;
$pdf->SetFont($document_font,'',intval($document_font_size) - 1);
for ($t = 0; $t < count($selected_item_titles); $t++) {
$key = $selected_item_titles[$t];
if (isset($totals[$key]) && $totals[$key] > 0) {
$pdf->SetXY($left_col,$curr_row);
$pdf->Cell($title_width,$incr + 1,sprintf("%8d - %s",$totals[$key],$key),'0',1,'L',$fill);
$curr_row += $incr + 1;
}
}
}
$filename = "order-details.$mdate.pdf";
if ($siteType == 'registration') $filename = "registration-details.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=$filename");
header('Content-Transfer-Encoding: binary');
$pdf->Output($filename,"D");
?>