コード例 #1
0
ファイル: ExportPdf.php プロジェクト: grlf/eyedock
 public function run()
 {
     $this->grid->getDi()->plugins_payment->loadEnabled()->getAllEnabled();
     $ds = $this->grid->getDataSource();
     $fn = tempnam(DATA_DIR, 'zip_');
     $zip = new ZipArchive();
     $zip->open($fn, ZipArchive::OVERWRITE);
     $st = $ds->query();
     while ($iprec = $this->grid->getDi()->db->fetchRow($st)) {
         $ip = $ds->getDataSourceQuery()->getTable()->createRecord($iprec);
         $pdf = Am_Pdf_Invoice::create($ip);
         $zip->addFromString($pdf->getFileName(), $pdf->render());
     }
     $zip->close();
     register_shutdown_function(array($this, 'cleanup'), $fn);
     $helper = new Am_Controller_Action_Helper_SendFile();
     $helper->sendFile($fn, 'application/octet-stream', array('filename' => sprintf('invoices-%s.zip', sqlDate('now'))));
 }
コード例 #2
0
 static function onPaymentAfterInsert(Am_Event_PaymentAfterInsert $event)
 {
     /**
      * This e-mail is sent for first payment in invoice only
      * another template must be used for the following payments
      */
     if ($event->getInvoice()->getPaymentsCount() != 1) {
         return;
     }
     if ($event->getDi()->config->get('send_payment_mail')) {
         $et = Am_Mail_Template::load('send_payment_mail', $event->getUser()->lang);
         if ($et) {
             $et->setUser($event->getUser())->setInvoice($event->getInvoice())->setPayment($event->getPayment())->setInvoice_text($event->getInvoice()->render());
             if (Am_Di::getInstance()->config->get('send_pdf_invoice', false)) {
                 try {
                     $invoice = new Am_Pdf_Invoice($event->getInvoice());
                     $et->getMail()->createAttachment($invoice->render(), 'application/pdf', Zend_Mime::DISPOSITION_ATTACHMENT, Zend_Mime::ENCODING_BASE64, $invoice->getFileName());
                 } catch (Exception $e) {
                     $this->getDi()->errorLogTable->logException($e);
                 }
             }
             $et->send($event->getUser());
         }
     }
     if ($event->getDi()->config->get('send_payment_admin')) {
         $et = Am_Mail_Template::load('send_payment_admin', $event->getUser()->lang);
         if ($et) {
             $et->setUser($event->getUser())->setInvoice($event->getInvoice())->setPayment($event->getPayment())->setInvoice_text($event->getInvoice()->render());
             $et->send(Am_Mail_Template::TO_ADMIN);
         }
     }
 }
コード例 #3
0
 function getInvoiceAction()
 {
     $id = $this->getFiltered('id');
     if (!$id) {
         throw new Am_Exception_InputError("Wrong invoice# passed");
     }
     $invoice = $this->getDi()->invoiceTable->findFirstByPublicId($id);
     if (!$invoice) {
         throw new Am_Exception(___("Invoice not found"));
     }
     if ($invoice->user_id != $this->user->user_id) {
         throw new Am_Exception_Security("Foreign invoice requested : [{$id}] for {$this->user->user_id}");
     }
     $pdfInvoice = new Am_Pdf_Invoice($invoice);
     $pdfInvoice->setDi($this->getDi());
     $pdfInvoiceRendered = $pdfInvoice->render();
     $this->noCache();
     header("Content-type: application/pdf");
     header("Content-Length: " . strlen($pdfInvoiceRendered));
     header("Content-Disposition: attachment; filename={$pdfInvoice->getFileName()}");
     echo $pdfInvoiceRendered;
 }
コード例 #4
0
 function invoiceAction()
 {
     $this->getDi()->authAdmin->getUser()->checkPermission('grid_invoice', 'browse');
     if ($payment_id = $this->_request->getInt('payment_id')) {
         $payment = $this->getDi()->invoicePaymentTable->load($this->_request->getInt('payment_id'));
     } else {
         if ($refund_id = $this->_request->getInt('refund_id')) {
             $payment = $this->getDi()->invoiceRefundTable->load($this->_request->getInt('refund_id'));
         }
     }
     $this->getDi()->plugins_payment->loadEnabled()->getAllEnabled();
     $pdfInvoice = Am_Pdf_Invoice::create($payment);
     $pdfInvoice->setDi($this->getDi());
     $this->_helper->sendFile->sendData($pdfInvoice->render(), 'application/pdf', $pdfInvoice->getFileName());
 }
コード例 #5
0
 function getInvoiceAction()
 {
     $id = $this->getDi()->app->reveal($this->getParam('id'));
     if (!$id) {
         throw new Am_Exception_InputError("Wrong invoice# passed");
     }
     $payment = $this->getDi()->invoicePaymentTable->load($id);
     if (!$payment) {
         throw new Am_Exception(___("Invoice not found"));
     }
     if ($payment->user_id != $this->user->user_id) {
         throw new Am_Exception_Security("Foreign invoice requested : [{$id}] for {$this->user->user_id}");
     }
     $this->getDi()->plugins_payment->loadEnabled()->getAllEnabled();
     $pdfInvoice = Am_Pdf_Invoice::create($payment);
     $pdfInvoice->setDi($this->getDi());
     $this->_helper->sendFile->sendData($pdfInvoice->render(), 'application/pdf', $pdfInvoice->getFileName());
 }