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'); $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'); } } // Force exact physical size for Letter: 8.5 x 11 inches => 279.4mm x 215.9mm (landscape) $pageFormat = array(279.4, 215.9); $pdf= new PDF('L', 'mm', $pageFormat, true, 'UTF-8', false); $pdf->addPage(); $font_red = hexdec("00"); $font_green = hexdec("00"); $font_blue = hexdec("00"); $pdf->SetTextColor($font_red,$font_green,$font_blue); $school_name = $school_record['school_name']; $document_name = getLanguageText('TEXT-ORDERS-SUMMARY'); // Set the report parameters $ReportTitle = getLanguageText('TEXT-SPECIAL-PRICE-ORDERS') . " (" . $GlobalText['Student'] . ") - $schedule_name"; $orderby = "ORDER BY last_name, first_name"; $mode = "student"; // Recalculate all orders in schedule $query = "SELECT record_num FROM hotlunch_order_header WHERE school_num = $school_num AND schedule_num = $schedule_num"; $results = db_query($query); while ($row = db_fetch_assoc($results)) { $order_num = $row['record_num']; $orderData = calcOrderTotal($order_num,$schedule_num,'N'); } // Get orders for this schedule $query = "SELECT p.last_name,p.first_name,class_num,sequence,people_type,hloh.price_category,hloh.order_total,hloh.status,p.user_num,hloh.record_num,userid,hloh.payment_method," . "hloh.order_cost,hloh.category_savings,hloh.added_date,sum(ua.transaction_amount) as balance,delivered " . "FROM people AS p LEFT JOIN classes AS c ON p.class_num = c.record_num, hotlunch_order_header AS hloh, " . "users AS u LEFT JOIN user_account AS ua ON ua.school_num = $school_num AND ua.user_num = u.record_num AND (ua.deleted != 'Y' OR ua.deleted IS NULL) " . "WHERE p.school_num = $base_school_num " . "AND hloh.school_num = $school_num " . "AND hloh.status NOT IN ('Inactive','Deleted') " . "AND p.record_num = hloh.ordered_by_num " . "AND hloh.schedule_num = $schedule_num " . "AND p.user_num = u.record_num " . "AND hloh.price_category != 'Regular' " . "GROUP BY 1,2,3,4,5,6,7,8,9,10,11 " . $orderby; $results = db_query($query); if (db_num_rows($results) == 0) { header("Location: /?action=schedule-reports&schedule_num=$schedule_num&error_code=NOORDERS"); exit(); } $total = 0; $savings = 0; $costs = 0; $curr_row = $max_rows + 1; $page = 1; // Process all the orders found for this page while ($row = db_fetch_array($results)) { if ($curr_row > $max_rows) { if ($page > 1) $pdf->addPage(); $curr_row = $start_row; $pdf->SetFillColor(hexdec("cc"),hexdec("cc"),hexdec("cc")); $pdf->SetFont($document_font,"B",$document_font_size + 1); $pdf->SetXY($title_col,$curr_row); $pdf->Cell(260,$incr,$ReportTitle,'0',1,'L',true,'',1); $curr_row += $incr + 2; $page++; $count = 0; $pdf->SetXY($title_col,$curr_row); $pdf->SetFont($document_font,"B",$document_font_size); // Titles for ($cnum = 0; $cnum < count($titles); $cnum++) { $curr_col = $columns[$cnum]; $title = $titles[$cnum]; $align = $alignment[$cnum]; $width = $columns[$cnum + 1] - $columns[$cnum]; $pdf->SetXY($curr_col,$curr_row); $pdf->Cell($width,$incr,$title,'0',1,$align,true,'',1); } $pdf->SetFont($document_font,"",$document_font_size); $curr_row += $incr; } $name = $row['last_name'] . ', ' . $row['first_name']; $pdf->SetFillColor(hexdec("ee"),hexdec("ee"),hexdec("ee")); $bg = true; if ($count % 2) $bg = false; $cnum = 0; $curr_col = $columns[$cnum]; $width = $columns[$cnum + 1] - $columns[$cnum]; $pdf->SetXY($curr_col,$curr_row); $pdf->Cell($width,$incr,$name,'0',1,'L',$bg,'',1); $cnum++; $curr_col = $columns[$cnum]; $width = $columns[$cnum + 1] - $columns[$cnum]; $pdf->SetXY($curr_col,$curr_row); $pdf->Cell($width,$incr,$row['people_type'],'0',1,'L',$bg,'',1); $cnum++; $curr_col = $columns[$cnum]; $width = $columns[$cnum + 1] - $columns[$cnum]; $pdf->SetXY($curr_col,$curr_row); $pdf->Cell($width,$incr,$school_record['currency_symbol'] . number_format($row['order_cost'],2) . " ",'0',1,'R',$bg,'',1); $costs += $row['order_cost']; $cnum++; $curr_col = $columns[$cnum]; $width = $columns[$cnum + 1] - $columns[$cnum]; $pdf->SetXY($curr_col,$curr_row); $pdf->Cell($width,$incr,$school_record['currency_symbol'] . number_format($row['order_total'],2) . " ",'0',1,'R',$bg,'',1); $total += $row['order_total']; $cnum++; $curr_col = $columns[$cnum]; $width = $columns[$cnum + 1] - $columns[$cnum]; $pdf->SetXY($curr_col,$curr_row); $pdf->Cell($width,$incr,'-'.$school_record['currency_symbol'] . number_format($row['category_savings'],2) . " ",'0',1,'R',$bg,'',1); $savings += $row['category_savings']; // Get the name on this account $unum = $row['user_num']; $uname = db_getVal("select concat(first_name,' ',last_name) from users where school_num = $base_school_num and record_num = $unum"); $cnum++; $curr_col = $columns[$cnum]; $width = $columns[$cnum + 1] - $columns[$cnum]; $pdf->SetXY($curr_col,$curr_row); $pdf->Cell($width,$incr,$uname,'0',1,'L',$bg,'',1); $cnum++; $curr_col = $columns[$cnum]; $width = $columns[$cnum + 1] - $columns[$cnum]; $pdf->SetXY($curr_col,$curr_row); $pdf->Cell($width,$incr,$row['price_category'],'0',1,'L',$bg,'',1); $dtext = ""; if (isset($hotlunch_schedule['schedule_type']) && $hotlunch_schedule['schedule_type'] != 'Hot Lunch' && in_array($siteType,array('hotlunch','yearbook','tickets','fundraising'))) { $dtext = " (" . $row['delivered'] . ")"; } $cnum++; $curr_col = $columns[$cnum]; $width = $columns[$cnum + 1] - $columns[$cnum]; $pdf->SetXY($curr_col,$curr_row); $pdf->Cell($width,$incr,$row['status'].' - '.$row['payment_method'] . $dtext,'0',1,'L',$bg,'',1); $cnum++; $curr_col = $columns[$cnum]; $width = $columns[$cnum + 1] - $columns[$cnum]; $pdf->SetXY($curr_col,$curr_row); $pdf->Cell($width,$incr,dateString('date',strtotime($row['added_date'])),'0',1,'L',$bg,'',1); $curr_row += $incr; $count++; } // Total $pdf->SetFillColor(hexdec("cc"),hexdec("cc"),hexdec("cc")); $pdf->SetFont($document_font,"B",$document_font_size); $pdf->SetXY($title_col,$curr_row); $pdf->Cell(260,$incr," ",'0',1,'L',true,'',1); $width = $columns[1] - $columns[0]; $curr_col = $columns[0]; $pdf->SetXY($curr_col,$curr_row); $pdf->Cell($width,$incr,"Total:",'0',1,'R',true,'',1); $width = $columns[3] - $columns[2]; $curr_col = $columns[2]; $pdf->SetXY($curr_col,$curr_row); $pdf->Cell($width,$incr,$school_record['currency_symbol'] . number_format($costs,2) . " ",'0',1,'R',true,'',1); $width = $columns[4] - $columns[3]; $curr_col = $columns[3]; $pdf->SetXY($curr_col,$curr_row); $pdf->Cell($width,$incr,$school_record['currency_symbol'] . number_format($total,2) . " ",'0',1,'R',true,'',1); $width = $columns[5] - $columns[4]; $curr_col = $columns[4]; $pdf->SetXY($curr_col,$curr_row); $pdf->Cell($width,$incr,'-'.$school_record['currency_symbol'] . number_format($savings,2) . " ",'0',1,'R',true,'',1); // Output the completed PDF $filename = "order-summary.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"); ?>