/** * Generate one or multiple PDFs by order ID * @param array * @return void */ public function generateInvoices(array $arrIds) { $this->import('Isotope'); if (!count($arrIds)) { $this->log('No order IDs passed to method.', __METHOD__, TL_ERROR); $this->redirect($this->Environment->script . '?act=error'); } $pdf = null; foreach ($arrIds as $intId) { $objOrder = new IsotopeOrder(); if ($objOrder->findBy('id', $intId)) { $pdf = $objOrder->generatePDF(null, $pdf, false); } } if (!$pdf) { $this->log('No order IDs passed to method.', __METHOD__, TL_ERROR); $this->redirect($this->Environment->script . '?act=error'); } // Close and output PDF document $pdf->lastPage(); // @todo make things like this configurable in a further version of Isotope $strInvoiceTitle = 'invoice_' . $objOrder->order_id; $pdf->Output(standardize(ampersand($strInvoiceTitle, false), true) . '.pdf', 'D'); // Set config back to default // @todo do we need that? The PHP session is ended anyway... $this->Isotope->resetConfig(true); // Stop script execution exit; }