addPage(); $pdf->SetAutoPageBreak(true,10); $font_parm = $document_font_weight; $font_red = hexdec(substr(str_replace("#","",$document_text_color),0,2)); $font_green = hexdec(substr(str_replace("#","",$document_text_color),2,2)); $font_blue = hexdec(substr(str_replace("#","",$document_text_color),4,2)); $pdf->SetTextColor($font_red,$font_green,$font_blue); // Set parameters for this document $start_row = 10; $max_rows = 700; $curr_row = $start_row; $new_page = true; $left_col = 10; $title_col = 200; $qty_col = 50; $item_col = 75; $items_col = 20; $pdf->SetFont("Arial",$font_parm,$document_font_size); $pdf->SetFillColor(hexdec("cc"),hexdec("cc"),hexdec("cc")); $fill = true; if ($document_format == 'report') $fill = false; $prev_div = -1; // Process each record while ($entry = db_fetch_array($orders)) { extract($entry); if ($division != $prev_div) { $class_info = "Staff"; if (isset($class_num) && $class_num > 0) $class_info = getClassInfo($class_num,'external',0); $prev_div = $division; if ($curr_row != $start_row) $curr_row = $max_rows; } if ($curr_row >= $max_rows - $incr * 2) { $pdf->addPage(); $curr_row = $start_row; $new_page = true; } // Display titles in report format on each page if ($new_page && $document_format == 'report') { $pdf->SetFont("Arial",'B',$document_font_size + 1); $pdf->SetXY($left_col,$curr_row); $pdf->Cell(200,$incr + 2,$school_name,'0',1,'L',true); $pdf->SetXY($title_col,$curr_row); $pdf->Cell(400,$incr + 2,"$class_info $menu_title, $menu_date",'0',1,'R',true); $new_page = false; $curr_row += $incr + 10; $pdf->SetFont("Arial",$font_parm,$document_font_size); } // Display student name $name = trim($name); $pdf->SetXY($left_col,$curr_row); $pdf->Cell(200,$incr,$name,'0',1,'L',$fill); if ($document_format == 'receipt') { $pdf->SetXY($title_col,$curr_row); $pdf->Cell(400,$incr,"$class_info $menu_title, $menu_date",'0',1,'R',$fill); } // 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.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); // Display the items switch ($document_format) { case 'receipt': while ($row = db_fetch_array($ordered_items)) { extract($row); // Check for item options $options = ""; $options_ordered = trim($options_ordered); $options2_ordered = trim($options2_ordered); $options3_ordered = trim($options3_ordered); if (strlen($options2_ordered)) $options_ordered .= "\n$options2_ordered"; if (strlen($options3_ordered)) $options_ordered .= "\n$options3_ordered"; if (strlen($options_ordered) > 0) { $options = trim(str_replace("\n",", ",trim($options_ordered))); if (strlen($options) > 0) $options = " ($options)"; } $curr_row += $incr; $pdf->SetXY($qty_col,$curr_row); $pdf->Cell(20,$incr,$qty,'0',1,'R',false); $pdf->SetXY($item_col,$curr_row); $pdf->Cell(200,$incr,"$item_title $options",'0',1,'L',false); } $curr_row += 30; break; case 'report': $items_ordered = ""; $line = 1; while ($row = db_fetch_array($ordered_items)) { extract($row); // Check for item options $options = ""; $options_ordered = trim($options_ordered); $options2_ordered = trim($options2_ordered); $options3_ordered = trim($options3_ordered); if (strlen($options2_ordered)) $options_ordered .= "\n$options2_ordered"; if (strlen($options3_ordered)) $options_ordered .= "\n$options3_ordered"; if (strlen($options_ordered) > 0) { $options = trim(str_replace("\n",", ",trim($options_ordered))); 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("Arial",$font_parm,$document_font_size - 1); $pdf->SetXY($items_col,$curr_row); $pdf->MultiCell(0,$incr,$items_ordered,'0','L',false); $pdf->SetFont("Arial",$font_parm,$document_font_size); $curr_row = $pdf->GetY(); break; } $curr_row += $incr; } 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=order-details-summary.pdf"); header('Content-Transfer-Encoding: binary'); $pdf->Output("order-details-summary.pdf","D"); ?>