[*] PDF : PDF is now rendered by TCPDF throught HTML template

This commit is contained in:
fBrignoli
2011-11-17 17:15:23 +00:00
parent 73e98a4f56
commit fddc403a09
33 changed files with 1917 additions and 213 deletions
+44 -7
View File
@@ -25,29 +25,66 @@
* International Registered Trademark & Property of PrestaShop SA
*/
class PdfInvoiceControllerCore extends FrontController
{
protected $display_header = false;
protected $display_footer = false;
public $content_only = true;
protected $template;
public $filename;
public function postProcess()
{
$id_order = (int)Tools::getValue('id_order');
if (!$this->context->customer->isLogged() && !Tools::getValue('secure_key'))
Tools::redirect('index.php?controller=authentication&back=pdf-invoice');
if (!(int)Configuration::get('PS_INVOICE'))
die(Tools::displayError('Invoices are disabled in this shop.'));
if (isset($_GET['id_order']) && Validate::isUnsignedId($_GET['id_order']))
$order = new Order($_GET['id_order']);
if (isset($id_order) && Validate::isUnsignedId($id_order))
$order = new Order($id_order);
if (!isset($order) || !Validate::isLoadedObject($order))
die(Tools::displayError('Invoice not found'));
else if ((isset($this->context->customer->id) && $order->id_customer != $this->context->customer->id) || (Tools::isSubmit('secure_key') && $order->secure_key != Tools::getValue('secure_key')))
if ((isset($this->context->customer->id) && $order->id_customer != $this->context->customer->id) || (Tools::isSubmit('secure_key') && $order->secure_key != Tools::getValue('secure_key')))
die(Tools::displayError('Invoice not found'));
else if (!OrderState::invoiceAvailable($order->getCurrentState()) && !$order->invoice_number)
if (!OrderState::invoiceAvailable($order->getCurrentState()) && !$order->invoice_number)
die(Tools::displayError('No invoice available'));
else
PDF::invoice($order);
// assignments
$country = new Country((int)$order->id_address_invoice);
$this->order = $order;
}
}
public function display()
{
$pdf = new PDF($this->order, PDF::TEMPLATE_INVOICE, $this->context->smarty, $this->context->language->id);
$pdf->render();
}
/**
* Returns the invoice template associated to the country iso_code
* @param string $iso_user
*/
public function getTemplate($iso_country)
{
$template = _PS_THEME_PDF_DIR_.'/invoice.tpl';
$iso_template = _PS_THEME_PDF_DIR_.'/invoice.'.$iso_country.'.tpl';
if (file_exists($iso_template))
$template = $iso_template;
return $template;
}
}