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 = 15; $max_rows = 750; $curr_row = $start_row; $new_page = true; $left_col = 15; $title_col = 200; $group_col = 50; $qty_col = 75; $item_col = 100; $max_line_length = 5; $pdf->SetFont("Arial",$font_parm,$document_font_size); $pdf->SetFillColor(hexdec("cc"),hexdec("cc"),hexdec("cc")); $prev_class_num = -1; // Process each record $page = 0; $pCount = 0; while ($person = db_fetch_array($people)) { extract($person); $person_num = $record_num; if ($curr_row >= $max_rows - $incr * 5) { // Add date to page $pdf->SetFont($document_font,"",$document_font_size - 1); $pdf->SetXY(200,$max_rows + 5); $date = date("F j, Y",time()); $pdf->Cell(350,$incr - 1,getLanguageText('TEXT-MENU-GROUPS-REPORT').": $date",'0',1,'R'); $pdf->SetFont($document_font,"",$document_font_size); $pdf->addPage(); $curr_row = $start_row; $new_page = true; } // Display titles in report format on each page if ($new_page) { $pdf->SetFillColor(hexdec("cc"),hexdec("cc"),hexdec("cc")); $pdf->SetFont("Arial",'B',$document_font_size + 1); $pdf->SetXY($left_col,$curr_row); $pdf->Cell(580,$incr + 2,$school_name,'0',1,'L',true); $pdf->SetFont("Arial",'B',$document_font_size); $pdf->SetXY($title_col + 100,$curr_row); $pdf->Cell(280,$incr + 2,"$menu_date - $menu_title",'0',1,'R',true); $curr_row += $incr + 2; $pdf->SetXY($left_col,$curr_row); $pdf->Cell(580,$incr + 2,getLanguageText('TEXT-MENU-GROUPS-REPORT')." - $groups",'0',1,'L',true); $new_page = false; $curr_row += $incr + 10; } // Determine if this person has an Active or Unpaid order for this schedule $oCount = db_getVal("SELECT count(*) FROM hotlunch_order_header WHERE school_num = $school_num AND ordered_by_num = $person_num AND schedule_num = $schedule_num AND status NOT IN ('Inactive','Deleted')"); if ($oCount == 0) continue; // Determine if this person has ordered items in selected group(s) $gCount = 0; for ($i = 0; $i < count($selected_groups); $i++) { $gCode = db_escape_string($selected_groups[$i]); $query = "SELECT count(*) FROM hotlunch_menu_items AS hlmi, hotlunch_order_items AS hloi " . "WHERE hlmi.school_num = $school_num " . "AND hlmi.menu_num = $menu_num " . "AND hlmi.menu_group = '$gCode' " . "AND hloi.school_num = $school_num " . "AND hloi.schedule_num = $schedule_num " . "AND hloi.menu_num = $menu_num " . "AND hloi.menu_item_num = hlmi.record_num " . "AND hloi.active != 'N' " . "AND hloi.ordered_by_num = $person_num"; $itemCount = db_getVal($query); if ($itemCount > 0) $gCount++; } if ($gCount < count($selected_groups)) continue; $pCount++; // Display name $pdf->SetFont("Arial",$font_parm,$document_font_size); $pdf->SetFillColor(hexdec("dd"),hexdec("dd"),hexdec("dd")); $name = trim($first_name . ' ' . $last_name); if (isset($ordered_by_type) && $ordered_by_type == 'Staff') $name .= " (Staff)"; $pdf->SetXY($left_col,$curr_row); $pdf->Cell(580,$incr,$name,'0',1,'L',true); $curr_row += $incr; // List items ordered for ($i = 0; $i < count($selected_groups); $i++) { $gCode = db_escape_string($selected_groups[$i]); $query = "SELECT * FROM hotlunch_menu_items AS hlmi, hotlunch_order_items AS hloi " . "WHERE hlmi.school_num = $school_num " . "AND hlmi.menu_num = $menu_num " . "AND hlmi.menu_group = '$gCode' " . "AND hloi.school_num = $school_num " . "AND hloi.schedule_num = $schedule_num " . "AND hloi.menu_num = $menu_num " . "AND hloi.menu_item_num = hlmi.record_num " . "AND hloi.active != 'N' " . "AND hloi.ordered_by_num = $person_num"; $results = db_query($query); // Print the quantity and item on the report if (db_num_rows($results) > 0) { while ($row = db_fetch_array($results)) { $pdf->SetXY($group_col,$curr_row); $pdf->Cell(20,$incr,$gCode,'0',1,'L',false); $pdf->SetXY($qty_col,$curr_row); $pdf->Cell(20,$incr,$row['qty'],'0',1,'L',false); $pdf->SetXY($item_col,$curr_row); $pdf->Cell(450,$incr,$row['item_title'],'0',1,'L',false); $curr_row += $incr; } } } $curr_row += $incr; } // Print total number of people $curr_row += $incr; $pdf->SetXY($qty_col,$curr_row); $pdf->Cell(450,$incr,getLanguageText('TEXT-ORDERS').": $pCount",'0',1,'L',false); // Add date to page $pdf->SetFont($document_font,"",$document_font_size - 1); $pdf->SetXY(200,$max_rows + 5); $date = date("F j, Y",time()); $pdf->Cell(350,$incr - 1,getLanguageText('TEXT-MENU-GROUPS-REPORT').": $date",'0',1,'R'); $pdf->SetFont($document_font,"",$document_font_size); 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=menu-groups.pdf"); header('Content-Transfer-Encoding: binary'); $pdf->Output("menu-groups.pdf","D"); ?>