[*] PDF : Licenses + Hook in templates

This commit is contained in:
fBrignoli
2011-12-06 10:58:20 +00:00
parent 416aa938b1
commit 63822a2f34
11 changed files with 308 additions and 14 deletions
+35 -6
View File
@@ -260,7 +260,7 @@ class OrderInvoiceCore extends ObjectModel
* This method returns true if at least one order details uses the
* One After Another tax computation method.
*
* @since 1.5.0.1
* @since 1.5
* @return boolean
*/
public function useOneAfterAnotherTaxComputationMethod()
@@ -279,7 +279,7 @@ class OrderInvoiceCore extends ObjectModel
/**
* Returns the correct product taxes breakdown.
*
* @since 1.5.0.1
* @since 1.5
* @return array
*/
public function getProductTaxesBreakdown()
@@ -340,7 +340,7 @@ class OrderInvoiceCore extends ObjectModel
/**
* Returns the shipping taxes breakdown
*
* @since 1.5.0.1
* @since 1.5
* @return array
*/
public function getShippingTaxesBreakdown($order)
@@ -362,7 +362,7 @@ class OrderInvoiceCore extends ObjectModel
* Returns the wrapping taxes breakdown
* @todo
* @since 1.5.0.1
* @since 1.5
* @return array
*/
public function getWrappingTaxesBreakdown()
@@ -374,7 +374,7 @@ class OrderInvoiceCore extends ObjectModel
/**
* Returns the ecotax taxes breakdown
*
* @since 1.5.0.1
* @since 1.5
* @return array
*/
public function getEcoTaxTaxesBreakdown()
@@ -390,7 +390,7 @@ class OrderInvoiceCore extends ObjectModel
/**
* Returns all the order invoice that match the date interval
*
* @since 1.5.0.2
* @since 1.5
* @static
* @param $date_from
* @param $date_to
@@ -408,4 +408,33 @@ class OrderInvoiceCore extends ObjectModel
return ObjectModel::hydrateCollection('OrderInvoice', $order_invoice_list);
}
/**
* @since 1.5
* @static
* @param $id_order_invoice
*/
public static function getCarrier($id_order_invoice)
{
$carrier = false;
if ($id_carrier = OrderInvoice::getCarrierId($id_order_invoice))
$carrier = new Carrier((int)$id_carrier);
return $carrier;
}
/**
* @since 1.5
* @static
* @param $id_order_invoice
*/
public static function getCarrierId($id_order_invoice)
{
$sql = 'SELECT `id_carrier`
FROM `'._DB_PREFIX_.'order_carrier`
WHERE `id_order_invoice` = '.(int)$id_order_invoice;
return Db::getInstance()->getValue($sql);
}
}
+7 -1
View File
@@ -101,9 +101,15 @@ abstract class HTMLTemplateCore
$template = ucfirst(str_replace('HTMLTemplate', '', get_class($this)));
$hook_name = 'displayPDF'.$template;
// p('='.Hook::exec($hook_name, array('object' => $object)));
$this->smarty->assign(array(
'HOOK_DISPLAY_PDF' => Hook::exec($hook_name, array('object' => $object))
'HOOK_DISPLAY_PDF' => Hook::exec($hook_name, array('object' => $object)),
'kikoo' => 'lol'
));
}
/**
+1 -1
View File
@@ -2,7 +2,7 @@
<module>
<name>dateofdelivery</name>
<displayName><![CDATA[Date of delivery]]></displayName>
<version><![CDATA[1.0]]></version>
<version><![CDATA[1.1]]></version>
<description><![CDATA[Displays an approximate date of delivery]]></description>
<author><![CDATA[PrestaShop]]></author>
<tab><![CDATA[shipping_logistics]]></tab>
+43 -5
View File
@@ -36,7 +36,7 @@ class DateOfDelivery extends Module
{
$this->name = 'dateofdelivery';
$this->tab = 'shipping_logistics';
$this->version = '1.0';
$this->version = '1.1';
$this->author = 'PrestaShop';
$this->need_instance = 0;
@@ -48,8 +48,11 @@ class DateOfDelivery extends Module
public function install()
{
if (!parent::install() OR !$this->registerHook('beforeCarrier') OR !$this->registerHook('orderDetailDisplayed'))
return false;
if (!parent::install()
OR !$this->registerHook('beforeCarrier')
OR !$this->registerHook('orderDetailDisplayed')
OR !$this->registerHook('displayPDFInvoice'))
return false;
if (!Db::getInstance()->execute('
CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'dateofdelivery_carrier_rule` (
@@ -138,6 +141,34 @@ class DateOfDelivery extends Module
return $this->display(__FILE__, 'orderDetail.tpl');
}
/**
* Displays the delivery dates on the invoice
*
* @param $params contains an instance of OrderInvoice
* @return string
*
*/
public function hookDisplayPDFInvoice($params)
{
$order_invoice = $params['object'];
if (!($order_invoice instanceof OrderInvoice))
return;
$order = new Order((int)$order_invoice->id_order);
$oos = false; // For out of stock management
foreach ($order->getProducts() as $product)
if ($product['product_quantity_in_stock'] < 1)
$oos = true;
$id_carrier = (int)OrderInvoice::getCarrierId($order_invoice->id);
$return = '';
if ($datesDelivery = $this->_getDatesOfDelivery($id_carrier, $oos, $order_invoice->date_add))
$return = $this->l('Approximate date of delivery is between').' '.$datesDelivery[0].' '.$this->l('and').' '.$datesDelivery[1];
return $return;
}
private function _postProcess()
{
$errors = array();
@@ -428,7 +459,14 @@ class DateOfDelivery extends Module
WHERE `id_carrier` = '.(int)($id_carrier).'
'.((int)$id_carrier_rule != 0 ? 'AND `id_carrier_rule` != '.(int)($id_carrier_rule) : ''));
}
/**
* @param $id_carrier
* @param bool $product_oos
* @param null $date
*
* @return array|bool returns the min & max delivery date
*/
private function _getDatesOfDelivery($id_carrier, $product_oos = false, $date = null)
{
if (!(int)($id_carrier))
@@ -466,7 +504,7 @@ class DateOfDelivery extends Module
}
if (!$carrier_rule['delivery_sunday'] AND date('l', $date_maximal_time) == 'Sunday')
$date_maximal_time += 24 * 3600;
/*
$this->l('Sunday');
$this->l('Monday');
+37
View File
@@ -1,3 +1,28 @@
{*
* 2007-2011 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-2011 PrestaShop SA
* @version Release: $Revision: 6753 $
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
<div style="font-size: 9pt; color: #444">
<table>
@@ -91,5 +116,17 @@
<tr><td style="line-height: 8px">&nbsp;</td></tr>
</table>
{if isset($HOOK_DISPLAY_PDF)}
<div style="line-height: 1pt">&nbsp;</div>
<table style="width: 100%">
<tr>
<td style="width: 15%"></td>
<td style="width: 85%">
{$HOOK_DISPLAY_PDF}
</td>
</tr>
</table>
{/if}
</div>
+25
View File
@@ -1,3 +1,28 @@
{*
* 2007-2011 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-2011 PrestaShop SA
* @version Release: $Revision: 6753 $
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
<table>
<tr>
<td style="text-align: center; font-size: 6pt; color: #444">
+25
View File
@@ -1,3 +1,28 @@
{*
* 2007-2011 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-2011 PrestaShop SA
* @version Release: $Revision: 6753 $
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
<table style="width: 100%">
<tr>
<td style="width: 50%">
+25
View File
@@ -1,3 +1,28 @@
{*
* 2007-2011 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-2011 PrestaShop SA
* @version Release: $Revision: 6753 $
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
<!-- TAX DETAILS -->
<table style="width: 100%">
<tr>
+37 -1
View File
@@ -1,3 +1,28 @@
{*
* 2007-2011 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-2011 PrestaShop SA
* @version Release: $Revision: 6753 $
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
<div style="font-size: 8pt; color: #444">
<table>
@@ -202,5 +227,16 @@
{$tax_tab}
</div>
{if isset($HOOK_DISPLAY_PDF)}
<div style="line-height: 1pt">&nbsp;</div>
<table style="width: 100%">
<tr>
<td style="width: 15%"></td>
<td style="width: 85%">
{$HOOK_DISPLAY_PDF}
</td>
</tr>
</table>
{/if}
</div>
+36
View File
@@ -1,3 +1,28 @@
{*
* 2007-2011 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-2011 PrestaShop SA
* @version Release: $Revision: 6753 $
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
<div style="font-size: 9pt; color: #444">
<table>
@@ -124,6 +149,17 @@ Let us know if you have any questions' pdf='true'}
</tr>
</table>
{if isset($HOOK_DISPLAY_PDF)}
<div style="line-height: 1pt">&nbsp;</div>
<table style="width: 100%">
<tr>
<td style="width: 15%"></td>
<td style="width: 85%">
{$HOOK_DISPLAY_PDF}
</td>
</tr>
</table>
{/if}
</div>
+37
View File
@@ -1,3 +1,28 @@
{*
* 2007-2011 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-2011 PrestaShop SA
* @version Release: $Revision: 6753 $
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
<div style="font-size: 8pt; color: #444">
<table>
@@ -202,5 +227,17 @@
{$tax_tab}
{if isset($HOOK_DISPLAY_PDF)}
<div style="line-height: 1pt">&nbsp;</div>
<table style="width: 100%">
<tr>
<td style="width: 15%"></td>
<td style="width: 85%">
{$HOOK_DISPLAY_PDF}
</td>
</tr>
</table>
{/if}
</div>