if (isset($_REQUEST['go'])) { $invoice = module_invoice::get_invoice($invoice_id); // confirm customer access. if (!$invoice || $invoice['invoice_id'] != $invoice_id) { echo 'invalid invoice id'; exit; } if ($invoice && $invoice['customer_id']) { $customer_test = module_customer::get_customer($invoice['customer_id']); if (!$customer_test || $customer_test['customer_id'] != $invoice['customer_id']) { echo 'invalid customer id'; exit; } } if (isset($_REQUEST['htmlonly'])) { echo module_invoice::invoice_html($invoice_id, $invoice, 'pdf'); exit; } // send the actual invoice. // step1, generate the PDF for the invoice... $pdf_file = module_invoice::generate_pdf($invoice_id); if ($pdf_file && is_file($pdf_file)) { // copied from public_print hook @ob_end_clean(); @ob_end_clean(); // send pdf headers and prompt the user to download the 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");