SetFont($document_font,"B",$document_font_size + 1); $this->SetFillColor(hexdec("bb"),hexdec("bb"),hexdec("bb")); // Report title $this->SetXY($left_col,$start_row); $this->Cell($title_width,$incr,$report_title,'0',1,'L',true,'',1); $row = $start_row + $incr + 1; for ($i = 0; $i < count($headings); $i++) { $col = $columns[$i]; $width = $columns[$i + 1] - $col; $align = $alignment[$i]; $this->SetXY($col,$row); $this->Cell($width,$incr,' '.$headings[$i],'0',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',false,'',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',false,'',1); } } // 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); // 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); $curr_row = $max_rows; $school_name = $school_record['school_name']; // FIX: Initialize variables before use $count = 0; $swhere = ''; // FIX: Add proper SQL sanitization/prepared statement // Assuming $supplier_school_num comes from a trusted source, but should still be sanitized $supplier_school_num = isset($supplier_school_num) ? intval($supplier_school_num) : 0; if ($supplier_school_num === 0 && isset($school_num)) { $supplier_school_num = intval($school_num); } // Get suppliers $suppliers = db_query("SELECT * FROM suppliers WHERE school_num = $supplier_school_num AND status = 'Active' $swhere ORDER BY supplier_name"); $curr_page = 0; while ($row = db_fetch_array($suppliers)) { if ($curr_row > $max_rows - 5) { $pdf->addPage(); $curr_row = $start_row + $incr * 2 + 2; } extract($row); $supplier_num = $record_num; $pdf->SetFont($document_font,"",$document_font_size); $pdf->SetFillColor(hexdec("dd"),hexdec("dd"),hexdec("dd")); $bg = true; // if ($count % 2) $bg = false; if ($count % 2) $pdf->SetFillColor(hexdec("f8"),hexdec("f8"),hexdec("f8")); for ($i = 0; $i < count($fields); $i++) { $col = $columns[$i]; $align = $alignment[$i]; if ($columns[$i + 1] > $columns[$i]) $width = $columns[$i + 1] - $columns[$i]; else $width = $last_col - $columns[$i]; $pdf->SetXY($col,$curr_row); $pdf->Cell($width,$incr,sprintf($field_type[$i],$row[$fields[$i]]),'0',1,$align,$bg,'',1); if ($columns[$i + 1] < $columns[$i]) $curr_row += $incr; } $curr_row += $incr + 1; $count++; } // 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=suppliers.pdf"); header('Content-Transfer-Encoding: binary'); $pdf->Output("suppliers.pdf","D"); exit(); // Changed from return to exit() ?>