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"); ?>