diff --git a/classes/order/OrderInvoice.php b/classes/order/OrderInvoice.php index c9d4b6e11..ad42f0f35 100644 --- a/classes/order/OrderInvoice.php +++ b/classes/order/OrderInvoice.php @@ -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); + } } \ No newline at end of file diff --git a/classes/pdf/HTMLTemplate.php b/classes/pdf/HTMLTemplate.php index 3ccafedf4..15edfac47 100755 --- a/classes/pdf/HTMLTemplate.php +++ b/classes/pdf/HTMLTemplate.php @@ -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' )); + + + } /** diff --git a/modules/dateofdelivery/config.xml b/modules/dateofdelivery/config.xml index 3a7570dc9..3a5b35773 100755 --- a/modules/dateofdelivery/config.xml +++ b/modules/dateofdelivery/config.xml @@ -2,7 +2,7 @@ dateofdelivery - + diff --git a/modules/dateofdelivery/dateofdelivery.php b/modules/dateofdelivery/dateofdelivery.php index e740e3bbb..170f1baa9 100644 --- a/modules/dateofdelivery/dateofdelivery.php +++ b/modules/dateofdelivery/dateofdelivery.php @@ -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'); diff --git a/themes/default/pdf/delivery-slip.tpl b/themes/default/pdf/delivery-slip.tpl index ee578491d..2435e9b48 100755 --- a/themes/default/pdf/delivery-slip.tpl +++ b/themes/default/pdf/delivery-slip.tpl @@ -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 +* @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 +*}
@@ -91,5 +116,17 @@
 
+{if isset($HOOK_DISPLAY_PDF)} +
 
+ + + + + +
+ {$HOOK_DISPLAY_PDF} +
+{/if} +
diff --git a/themes/default/pdf/footer.tpl b/themes/default/pdf/footer.tpl index 3e0f0ea3c..2bcb2f7e2 100755 --- a/themes/default/pdf/footer.tpl +++ b/themes/default/pdf/footer.tpl @@ -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 +* @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 +*}
diff --git a/themes/default/pdf/header.tpl b/themes/default/pdf/header.tpl index d43d836a2..ad04d3dc9 100755 --- a/themes/default/pdf/header.tpl +++ b/themes/default/pdf/header.tpl @@ -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 +* @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 +*}
diff --git a/themes/default/pdf/invoice.tax-tab.tpl b/themes/default/pdf/invoice.tax-tab.tpl index 57ec1fb10..f365aa6f9 100755 --- a/themes/default/pdf/invoice.tax-tab.tpl +++ b/themes/default/pdf/invoice.tax-tab.tpl @@ -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 +* @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 +*} diff --git a/themes/default/pdf/invoice.tpl b/themes/default/pdf/invoice.tpl index aecab1fa0..6c157ceb0 100755 --- a/themes/default/pdf/invoice.tpl +++ b/themes/default/pdf/invoice.tpl @@ -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 +* @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 +*}
@@ -202,5 +227,16 @@ {$tax_tab} - +{if isset($HOOK_DISPLAY_PDF)} +
 
+
+ + + + +
+ {$HOOK_DISPLAY_PDF} +
+{/if} + \ No newline at end of file diff --git a/themes/default/pdf/order-return.tpl b/themes/default/pdf/order-return.tpl index bf943ab6d..53f5e41f8 100755 --- a/themes/default/pdf/order-return.tpl +++ b/themes/default/pdf/order-return.tpl @@ -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 +* @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 +*}
@@ -124,6 +149,17 @@ Let us know if you have any questions' pdf='true'}
+{if isset($HOOK_DISPLAY_PDF)} +
 
+ + + + + +
+ {$HOOK_DISPLAY_PDF} +
+{/if}
diff --git a/themes/default/pdf/order-slip.tpl b/themes/default/pdf/order-slip.tpl index 8f44c0067..ce13ef25b 100755 --- a/themes/default/pdf/order-slip.tpl +++ b/themes/default/pdf/order-slip.tpl @@ -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 +* @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 +*}
@@ -202,5 +227,17 @@ {$tax_tab} +{if isset($HOOK_DISPLAY_PDF)} +
 
+
+ + + + +
+ {$HOOK_DISPLAY_PDF} +
+{/if} +