From fd6a74cee345e8efab4adfa0afd7dd5beec13ab0 Mon Sep 17 00:00:00 2001 From: bMancone Date: Tue, 22 Nov 2011 14:37:36 +0000 Subject: [PATCH] // Update Supply Order Form (PDF) --- classes/pdf/HTMLTemplateSupplyOrderForm.php | 81 ++++++++++++++++--- themes/prestashop/pdf/supply-order-footer.tpl | 53 ++++++++++++ themes/prestashop/pdf/supply-order.tpl | 40 ++++----- 3 files changed, 143 insertions(+), 31 deletions(-) create mode 100755 themes/prestashop/pdf/supply-order-footer.tpl diff --git a/classes/pdf/HTMLTemplateSupplyOrderForm.php b/classes/pdf/HTMLTemplateSupplyOrderForm.php index 80f617625..7326b506c 100644 --- a/classes/pdf/HTMLTemplateSupplyOrderForm.php +++ b/classes/pdf/HTMLTemplateSupplyOrderForm.php @@ -44,20 +44,20 @@ class HTMLTemplateSupplyOrderForm extends HTMLTemplate $this->address_warehouse = new Address($this->warehouse->id_address); // header informations - $this->date = Tools::displayDate($supply_order->date_add, (int)$this->context->language->id); + $this->date = Tools::displayDate($supply_order->date_add, (int)$this->supply_order->id_lang); $this->title = self::l('Supply order form').sprintf(' #%s', $supply_order->reference); - - // footer informations : displays the address of the warehouse - $this->address = $this->address_warehouse; } /** - * Returns the template's HTML content - * @return string HTML content + * @see HTMLTemplate::getContent() */ public function getContent() { - $supply_order_details = $this->supply_order->getEntriesCollection($this->context->language->id); + $supply_order_details = $this->supply_order->getEntriesCollection($this->supply_order->id_lang); + $this->roundSupplyOrderDetails($supply_order_details); + + $this->roundSupplyOrder($this->supply_order); + $tax_order_summary = $this->getTaxOrderSummary(); $currency = new Currency($this->supply_order->id_currency); @@ -73,8 +73,7 @@ class HTMLTemplateSupplyOrderForm extends HTMLTemplate } /** - * Returns the template filename when using bulk rendering - * @return string filename + * @see HTMLTemplate::getBulkFilename() */ public function getBulkFilename() { @@ -82,8 +81,7 @@ class HTMLTemplateSupplyOrderForm extends HTMLTemplate } /** - * Returns the template filename - * @return string filename + * @see HTMLTemplate::getFileName() */ public function getFilename() { @@ -103,6 +101,67 @@ class HTMLTemplateSupplyOrderForm extends HTMLTemplate $query->groupBy('tax_rate'); $results = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query); + + foreach ($results as &$result) + { + $result['base_te'] = Tools::ps_round($result['base_te'], 2); + $result['tax_rate'] = Tools::ps_round($result['tax_rate'], 2); + $result['total_tax_value'] = Tools::ps_round($result['total_tax_value'], 2); + } + return $results; } + + /** + * @see HTMLTemplate::getFooter() + */ + public function getFooter() + { + $this->address = $this->address_warehouse; + $shop_address = ''; + if (isset($this->address) && $this->address instanceof Address) + $shop_address = AddressFormat::generateAddress($this->address, array(), ' - ', ' '); + + $free_text = $this->l('DE: Discount excluded '); + $free_text .= $this->l(' DI: Discount included'); + + $this->smarty->assign(array( + 'shop_address' => $shop_address, + 'shop_fax' => Configuration::get('PS_SHOP_FAX'), + 'shop_phone' => Configuration::get('PS_SHOP_PHONE'), + 'shop_details' => Configuration::get('PS_SHOP_DETAILS'), + 'free_text' => $free_text, + )); + return $this->smarty->fetch(_PS_THEME_DIR_.'/pdf/supply-order-footer.tpl'); + } + + /** + * Rounds values of a SupplyOrderDetail object + * @param array $collection + */ + protected function roundSupplyOrderDetails(&$collection) + { + foreach ($collection as $supply_order_detail) + { + $supply_order_detail->unit_price_te = Tools::ps_round($supply_order_detail->unit_price_te, 2); + $supply_order_detail->price_te = Tools::ps_round($supply_order_detail->price_te, 2); + $supply_order_detail->discount_rate = Tools::ps_round($supply_order_detail->discount_rate, 2); + $supply_order_detail->price_with_discount_te = Tools::ps_round($supply_order_detail->price_with_discount_te, 2); + $supply_order_detail->tax_rate = Tools::ps_round($supply_order_detail->tax_rate, 2); + $supply_order_detail->price_ti = Tools::ps_round($supply_order_detail->price_ti, 2); + } + } + + /** + * Rounds values of a SupplyOrder object + * @param SupplyOrder $supply_order + */ + protected function roundSupplyOrder(SupplyOrder &$supply_order) + { + $supply_order->total_te = Tools::ps_round($supply_order->total_te, 2); + $supply_order->discount_value_te = Tools::ps_round($supply_order->discount_value_te, 2); + $supply_order->total_with_discount_te = Tools::ps_round($supply_order->total_with_discount_te, 2); + $supply_order->total_tax = Tools::ps_round($supply_order->total_tax, 2); + $supply_order->total_ti = Tools::ps_round($supply_order->total_ti, 2); + } } diff --git a/themes/prestashop/pdf/supply-order-footer.tpl b/themes/prestashop/pdf/supply-order-footer.tpl new file mode 100755 index 000000000..5712f163c --- /dev/null +++ b/themes/prestashop/pdf/supply-order-footer.tpl @@ -0,0 +1,53 @@ +{* +* 2007-2011 PrestaShop +* +* NOTICE OF LICENSE +* +* This source file is subject to the Open Software License (OSL 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/osl-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$ +* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*} + + + + +
+ {$shop_address|escape:'htmlall':'UTF-8'}
+ + {if !empty($shop_phone) OR !empty($shop_fax)} + {l s='For more assistance, contact Support:' pdf='true'}
+ {if !empty($shop_phone)} + Tel: {$shop_phone|escape:'htmlall':'UTF-8'} + {/if} + + {if !empty($shop_fax)} + Fax: {$shop_fax|escape:'htmlall':'UTF-8'} + {/if} +
+ {/if} + + {if isset($shop_details)} + {$shop_details|escape:'htmlall':'UTF-8'}
+ {/if} + + {if isset($free_text)} + {$free_text|escape:'htmlall':'UTF-8'}
+ {/if} +
+ diff --git a/themes/prestashop/pdf/supply-order.tpl b/themes/prestashop/pdf/supply-order.tpl index 9df0e3957..d835323ea 100644 --- a/themes/prestashop/pdf/supply-order.tpl +++ b/themes/prestashop/pdf/supply-order.tpl @@ -61,19 +61,19 @@   - {l s='Products to order:'} + {l s='Products ordered:'}
- - - + + + - + - - + + {* for each product ordered *} @@ -82,12 +82,12 @@ - - + + - + - + {/foreach}
{l s='Reference'}{l s='Designation'}{l s='Qty'}{l s='Reference'}{l s='Designation'}{l s='Qty'} {l s='Unit Price TE'}{l s='Total TE BD'}{l s='Total TE (DE)'} {l s='Discount Rate'}{l s='Total TE AD'}{l s='Tax rate'}{l s='Total TE (DI)'}{l s='Tax rate'} {l s='Total TI'}
{$supply_order_detail->supplier_reference} {$supply_order_detail->name} {$supply_order_detail->quantity_expected}{$supply_order_detail->unit_price_te}{$supply_order_detail->price_te}{$currency->prefix} {$supply_order_detail->unit_price_te} {$currency->suffix}{$currency->prefix} {$supply_order_detail->price_te} {$currency->suffix} {$supply_order_detail->discount_rate}{$supply_order_detail->price_with_discount_te}{$currency->prefix} {$supply_order_detail->price_with_discount_te} {$currency->suffix} {$supply_order_detail->tax_rate}{$supply_order_detail->price_ti}{$currency->prefix} {$supply_order_detail->price_ti} {$currency->suffix}
@@ -109,9 +109,9 @@ {foreach $tax_order_summary as $entry} - {$entry['base_te']} + {$currency->prefix} {$entry['base_te']} {$currency->suffix} {$entry['tax_rate']} - {$entry['total_tax_value']} + {$currency->prefix} {$entry['total_tax_value']} {$currency->suffix} {/foreach} @@ -127,24 +127,24 @@
- - + + - + - - + + - + - +
{l s='Total TE'}{$supply_order->total_te}{l s='Total TE (DE)'}{$currency->prefix} {$supply_order->total_te} {$currency->suffix}
{l s='Order Discount'}{$supply_order->discount_value_te}{$currency->prefix} {$supply_order->discount_value_te} {$currency->suffix}
{l s='Total AD TE'}{$supply_order->total_with_discount_te}{l s='Total TE (DI)'}{$currency->prefix} {$supply_order->total_with_discount_te} {$currency->suffix}
{l s='Tax value'}{$supply_order->total_tax}{$currency->prefix} {$supply_order->total_tax} {$currency->suffix}
{l s='Total TI'}{$supply_order->total_ti}{$currency->prefix} {$supply_order->total_ti} {$currency->suffix}
{l s='TOTAL TO PAY'}