[*] PDF : PDF is now rendered by TCPDF throught HTML template
This commit is contained in:
@@ -104,3 +104,4 @@ class OrderFollowControllerCore extends FrontController
|
||||
$this->addJS(_THEME_JS_DIR_.'history.js');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -84,5 +84,10 @@ class OrderReturnControllerCore extends FrontController
|
||||
));
|
||||
$this->setTemplate(_PS_THEME_DIR_.'order-return.tpl');
|
||||
}
|
||||
|
||||
public function displayAjax()
|
||||
{
|
||||
$this->context->smarty->display($this->template);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -35,16 +35,22 @@ class PdfOrderReturnControllerCore extends FrontController
|
||||
if (!$this->context->customer->isLogged())
|
||||
Tools::redirect('index.php?controller=authentication&back=order-follow');
|
||||
|
||||
if (isset($_GET['id_order_return']) && Validate::isUnsignedId($_GET['id_order_return']))
|
||||
$orderReturn = new OrderReturn($_GET['id_order_return']);
|
||||
if (isset(Tools::getValue('id_order_return')) && Validate::isUnsignedId(Tools::getValue('id_order_return')))
|
||||
$this->orderReturn = new OrderReturn(Tools::getValue('id_order_return'));
|
||||
|
||||
if (!isset($orderReturn) || !Validate::isLoadedObject($orderReturn))
|
||||
if (!isset($this->orderReturn) || !Validate::isLoadedObject($this->orderReturn))
|
||||
die(Tools::displayError('Order return not found'));
|
||||
else if ($orderReturn->id_customer != $this->context->customer->id)
|
||||
else if ($this->orderReturn->id_customer != $this->context->customer->id)
|
||||
die(Tools::displayError('Order return not found'));
|
||||
else if ($orderReturn->state < 2)
|
||||
else if ($this->orderReturn->state < 2)
|
||||
die(Tools::displayError('Order return not confirmed'));
|
||||
else
|
||||
PDF::orderReturn($orderReturn);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function display()
|
||||
{
|
||||
$pdf = new PDF($this->orderReturn, PDF::TEMPLATE_ORDER_RETURN, $this->context->smarty);
|
||||
$pdf->render();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,25 +30,29 @@ class PdfOrderSlipControllerCore extends FrontController
|
||||
protected $display_header = false;
|
||||
protected $display_footer = false;
|
||||
|
||||
protected $order_slip;
|
||||
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
if (!$this->context->customer->isLogged())
|
||||
Tools::redirect('index.php?controller=authentication&back=order-follow');
|
||||
|
||||
if (isset($_GET['id_order_slip']) && Validate::isUnsignedId($_GET['id_order_slip']))
|
||||
$orderSlip = new OrderSlip($_GET['id_order_slip']);
|
||||
$this->order_slip = new OrderSlip($_GET['id_order_slip']);
|
||||
|
||||
if (!isset($orderSlip) || !Validate::isLoadedObject($orderSlip))
|
||||
die(Tools::displayError('Order return not found'));
|
||||
else if ($orderSlip->id_customer != $this->context->customer->id)
|
||||
if (!isset($this->order_slip) || !Validate::isLoadedObject($this->order_slip))
|
||||
die(Tools::displayError('Order return not found'));
|
||||
|
||||
$order = new Order($orderSlip->id_order);
|
||||
if (!Validate::isLoadedObject($order))
|
||||
die(Tools::displayError('Order not found'));
|
||||
else if ($this->order_slip->id_customer != $this->context->customer->id)
|
||||
die(Tools::displayError('Order return not found'));
|
||||
|
||||
$order->products = OrderSlip::getOrdersSlipProducts((int)$orderSlip->id, $order);
|
||||
$ref = null;
|
||||
PDF::invoice($order, 'D', false, $ref, $orderSlip);
|
||||
}
|
||||
|
||||
public function display()
|
||||
{
|
||||
$pdf = new PDF($this->order_slip, PDF::TEMPLATE_ORDER_SLIP, $this->context->smarty);
|
||||
$pdf->render();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user