SetFillColor(hexdec("cc"),hexdec("cc"),hexdec("cc")); $this->SetFont($document_font,"B",$document_font_size + 1); $this->SetXY($left_col,$row); $this->Cell($title_width,$incr + 1,$report_title,'0',1,'L',true,'',1); $this->SetFont($document_font,"B",$document_font_size); if (isset($report_subtitle) && strlen($report_subtitle) > 0) { $row = $row + $incr + 2; $this->SetXY($left_col,$row); $this->Cell($title_width,$incr + 1,$report_subtitle,'0',1,'L',true,'',1); } $this->SetFillColor(hexdec("dd"),hexdec("dd"),hexdec("dd")); if (isset($headings) && is_array($headings) && count($headings)) { $row += $incr * 2; for ($i = 0; $i < count($headings); $i++) { $col = $cols[$i]; $width = $widths[$i]; $align = $alignment[$i]; $this->SetXY($col,$row); $this->Cell($width,$incr + 1,' ' . $headings[$i] . ' ','1',1,$align,true,'',1); } } } function Footer() { global $incr, $left_col, $title_width, $max_rows, $document_font, $document_font_size, $document_name, $logo_image, $logo_url, $logo_row, $school_name; // Print the date $this->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','',1); $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','',1); } } $pdf= new PDF('P', 'mm', 'Letter', 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->SetTextColor($font_red,$font_green,$font_blue); $pdf->SetFont($document_font,"",$document_font_size); $pdf->addPage(); // // Get set of records // $query = "SELECT 'hotlunch' AS code, system_configuration AS category, count(*) as number FROM schools WHERE status = 'Active' AND reseller = 'hotlunch' GROUP BY 1,2 " . "UNION " . "SELECT 'resellers', reseller, count(*) as number FROM schools WHERE status = 'Active' AND reseller != 'hotlunch' GROUP BY 1,2 " . "ORDER BY 1,2"; $reportData = db_query($query); // // Generate the report // $curr_row = $start_row + 3 * $incr + 1; $count = 0; $grand_total = 0; $disc_total = 0; $count_total = 0; while ($row = db_fetch_assoc($reportData)) { // New page if current page is full if ($curr_row > $max_rows - $incr - 2) { $pdf->addPage(); $curr_row = $start_row + 5 * $incr; $count = 0; } extract($row); $pdf->SetFont($document_font,"",$document_font_size); $pdf->SetFillColor(hexdec("ee"),hexdec("ee"),hexdec("ee")); $fill = true; if ($count % 2) $fill = false; $count++; // Format report line $data = array(); if ($code == 'hotlunch') { $rate = 300; $disc = 250; if ($category == 'Full') { $rate = 400; $disc = 350; } $data = array($category,$number,'$'.number_format($rate,2),'$'.number_format($number * $rate,2),'$'.number_format($disc,2),'$'.number_format($number*$disc,2)); $grand_total += $number * $rate; $disc_total += $number * $disc; } else { $reseller = $category; $rate = db_getVal("SELECT annual_rate FROM resellers WHERE reseller_code = '$reseller'"); $data = array(strtoupper($category),$number,'$'.number_format($rate,2),'$'.number_format($number * $rate,2),'$'.number_format($rate,2),'$'.number_format($number*$rate,2)); $grand_total += $number * $rate; $disc_total += $number * $rate; } $count_total += $number; for ($i = 0; $i < count($headings); $i++) { $col = $cols[$i]; $width = $widths[$i]; $align = $alignment[$i]; $pdf->SetXY($col,$curr_row); $pdf->Cell($width,$incr,' ' . $data[$i] . ' ','1',1,$align,$fill,'',1); } $curr_row += $incr; } // Output the completed 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=$file_name"); $pdf->Output($file_name,"D"); ?>