Exemple #1
0
 public function executeInvoice($request)
 {
     $order = $this->getRoute()->getObject();
     if (!file_exists($order->getInvoiceAbsolutePath('pdf'))) {
         // init invoice generation task
         $arguments = array('orderID' => $order['id']);
         $options = array('host' => $request->getHost(), 'culture' => $this->getUser()->getCulture(), 'application' => 'backend');
         $invoiceGenTask = new sfInvoiceGenerationTask(sfContext::getInstance()->getEventDispatcher(), new sfFormatter());
         chdir(sfConfig::get('sf_root_dir'));
         // hack to start task from Action
         $invoiceGenTask->run($arguments, $options);
     }
     // We'll be outputting a PDF
     header('Content-type: application/pdf');
     // It will be called
     header('Content-Disposition: attachment; filename="' . $order->getInvoiceFilename('pdf') . '"');
     // The PDF source
     readfile($order->getInvoiceAbsolutePath('pdf'));
     return sfView::NONE;
 }
Exemple #2
0
 public function executeInvoice($request)
 {
     $order = Doctrine::getTable('ProductOrder')->find($this->getRequestParameter('invoiceID'));
     $this->forward404Unless($this->getUser()->isMyOrder($order));
     if (!file_exists($order->getInvoiceAbsolutePath('pdf'))) {
         // init invoice generation task
         $arguments = array('orderID' => $this->getRequestParameter('invoiceID'));
         $options = array('host' => $request->getHost(), 'culture' => $this->getUser()->getCulture());
         $invoiceGenTask = new sfInvoiceGenerationTask(sfContext::getInstance()->getEventDispatcher(), new sfFormatter());
         chdir(sfConfig::get('sf_root_dir'));
         // hack to start task from Action
         $invoiceGenTask->run($arguments, $options);
     }
     # We'll be outputting a PDF
     header('Content-type: application/pdf');
     # It will be called
     header('Content-Disposition: attachment; filename="' . $order->getInvoiceFilename('pdf') . '"');
     # The PDF source
     readfile($order->getInvoiceAbsolutePath('pdf'));
     return sfView::NONE;
 }