Example #1
0
<?php

define('FPDF_FONTPATH', dirname(__FILE__) . '/fpdf17/font/');
require dirname(__FILE__) . '/fpdf17/fpdf.php';
require 'InvoiceAllMCPDF.class.php';
$pdf = new InvoicePDF();
$pdf->Output();
 /**
  * Page is displayed when issued invoice is edited
  * 
  * @param void
  * @return null
  */
 function notify()
 {
     $this->wireframe->print_button = false;
     if ($this->active_invoice->isNew()) {
         $this->httpError(HTTP_ERR_NOT_FOUND);
     }
     // if
     if (!$this->active_invoice->canEdit($this->logged_user)) {
         $this->httpError(HTTP_ERR_FORBIDDEN);
     }
     // if
     $company = $this->active_invoice->getCompany();
     if (!instance_of($company, 'Company')) {
         $this->httpError(HTTP_ERR_CONFLICT);
     }
     // if
     if (!$company->hasManagers()) {
         flash_error("Sorry, there's nobody in :company_name to whom we can email the invoice", array('company_name' => $company->getName()));
         $this->redirectToUrl($this->active_invoice->getViewUrl());
     }
     // if
     $notify_url = assemble_url('invoice_notify', array('invoice_id' => $this->active_invoice->getId()));
     $users = $company->getUsers();
     $this->smarty->assign(array('users' => $users, 'company' => $company, 'notify_url' => $notify_url));
     $issue_data = $this->request->post('issue');
     if ($this->request->isSubmitted()) {
         if (isset($issue_data['send_emails']) && $issue_data['send_emails']) {
             $issue_to = Users::findById($issue_data['user_id']);
             if (instance_of($issue_to, 'User')) {
                 $filename_name = 'invoice_' . $this->active_invoice->getId() . '.pdf';
                 $filename = WORK_PATH . '/' . $filename_name;
                 require_once INVOICING_MODULE_PATH . '/models/InvoicePdf.class.php';
                 InvoicePDF::save($this->active_invoice, $filename);
                 ApplicationMailer::send($issue_to, 'invoicing/issue', array('issued_by_name' => $this->logged_user->getDisplayName(), 'issued_by_url' => $this->logged_user->getViewUrl(), 'invoice_number' => $this->active_invoice->getNumber(), 'invoice_url' => $this->active_invoice->getCompanyViewUrl(), 'pdf_url' => $this->active_invoice->getCompanyPdfUrl()), null, array(array('path' => $filename)));
                 @unlink($filename);
                 flash_success('Email sent successfully');
             } else {
                 flash_error('User does not exists');
                 $this->redirectToUrl($notify_url);
             }
             // if
         }
         // if
         $this->redirectToUrl($this->active_invoice->getViewUrl());
     }
     // if
 }
 /**
  * Render invoice PDF
  *
  * @param void
  * @return null
  */
 function pdf()
 {
     if ($this->active_invoice->isNew()) {
         $this->httpError(HTTP_ERR_NOT_FOUND);
     }
     // if
     if ($this->active_invoice->getStatus() == INVOICE_STATUS_DRAFT) {
         $this->httpError(HTTP_ERR_NOT_FOUND);
     }
     // if
     require_once INVOICING_MODULE_PATH . '/models/InvoicePdf.class.php';
     InvoicePDF::download($this->active_invoice, lang('#:invoice_id.pdf', array('invoice_id' => $this->active_invoice->getName())));
     die;
 }
 /**
  * Serve PDF inline
  *
  * @param Invoice $invoice
  * @param string  $filename
  * @return boolean
  */
 function inline(&$invoice, $filename)
 {
     $generator =& InvoicePDF::preparePDF($invoice);
     return $generator->inline($filename);
 }