Current Module
This commit is contained in:
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
/**
|
||||
* Module allow edit existing orders and set rules for automatically generating numbers for orders and other documents
|
||||
*
|
||||
* @author Keshva <keshvathakur47@gmail.com>
|
||||
* @copyright 2021 Keshva
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_'))
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once(_PS_MODULE_DIR_.'modrefchange/classes/DocumentReferences.php');
|
||||
|
||||
class PDF extends PDFCore
|
||||
{
|
||||
public function render($display = true)
|
||||
{
|
||||
$render = false;
|
||||
$this->pdf_renderer->setFontForLang(Context::getContext()->language->iso_code);
|
||||
foreach ($this->objects as $object) {
|
||||
if (version_compare(_PS_VERSION_, '1.6.1.4', '>'))
|
||||
$this->pdf_renderer->startPageGroup();
|
||||
$template = $this->getTemplateObject($object);
|
||||
if (!$template) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (empty($this->filename)) {
|
||||
$this->filename = $template->getFilename();
|
||||
if ($template instanceof HTMLTemplateInvoice && $object instanceof OrderInvoice) {
|
||||
if ($result = DocumentReferences::getReference($object->id, 'invoice')) {
|
||||
$template->title = $result['reference'];
|
||||
$this->filename = $result['reference'].'.pdf';
|
||||
$orderNote = $this->getOrderNote($object->id_order);
|
||||
$template->order_invoice->note .= ($orderNote['show_on_invoice'] ? $orderNote['note'] : '');
|
||||
}
|
||||
} else if ($template instanceof HTMLTemplateDeliverySlip && $object instanceof OrderInvoice) {
|
||||
if ($result = DocumentReferences::getReference($object->id, 'delivery_slip')) {
|
||||
$template->title = $result['reference'];
|
||||
$this->filename = $result['reference'].'.pdf';
|
||||
}
|
||||
} else if ($object instanceof OrderSlip) {
|
||||
if ($result = DocumentReferences::getReference($object->id, 'credit_slip')) {
|
||||
$template->title = $result['reference'];
|
||||
$this->filename = $result['reference'].'.pdf';
|
||||
}
|
||||
}
|
||||
if (count($this->objects) > 1) {
|
||||
$this->filename = $template->getBulkFilename();
|
||||
}
|
||||
}
|
||||
|
||||
if ($result = DocumentReferences::getReference($object->id, 'credit_slip')) {
|
||||
$template->title = $result['reference'];
|
||||
$this->filename = $result['reference'].'.pdf';
|
||||
}
|
||||
|
||||
|
||||
$template->assignHookData($object);
|
||||
|
||||
$this->pdf_renderer->createHeader($template->getHeader());
|
||||
$this->pdf_renderer->createFooter($template->getFooter());
|
||||
if (version_compare(_PS_VERSION_, '1.6.1.4', '>'))
|
||||
$this->pdf_renderer->createPagination($template->getPagination());
|
||||
$this->pdf_renderer->createContent($template->getContent());
|
||||
$this->pdf_renderer->writePage();
|
||||
$render = true;
|
||||
|
||||
unset($template);
|
||||
}
|
||||
|
||||
if ($render) {
|
||||
// clean the output buffer
|
||||
if (ob_get_level() && ob_get_length() > 0) {
|
||||
ob_clean();
|
||||
}
|
||||
return $this->pdf_renderer->render($this->filename, $display);
|
||||
}
|
||||
}
|
||||
|
||||
private function getOrderNote($idOrder) {
|
||||
$orderNote = array(
|
||||
'note' => '',
|
||||
'show_on_invoice' => false
|
||||
);
|
||||
if ($row = Db::getInstance()->getRow('SELECT * FROM '._DB_PREFIX_.'order_note WHERE id_order = '.(int)$idOrder)) {
|
||||
$orderNote = array(
|
||||
'note' => $row['note'],
|
||||
'show_on_invoice' => ((int)$row['show_on_invoice'] == 1)
|
||||
);
|
||||
}
|
||||
return $orderNote;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2014 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/afl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2014 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
|
||||
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
|
||||
header('Location: ../');
|
||||
exit;
|
||||
Reference in New Issue
Block a user