From ca0d0ad645594fc94fb11b75a77581e3fc320ddf Mon Sep 17 00:00:00 2001 From: fSerny Date: Wed, 23 Nov 2011 22:42:17 +0000 Subject: [PATCH] [-] BO : Partial refund - part 4 --- admin-dev/themes/template/orders/_new_product.tpl | 2 +- admin-dev/themes/template/orders/_product_line.tpl | 1 + admin-dev/themes/template/orders/view.tpl | 14 ++++++++------ classes/order/OrderSlip.php | 6 ++++++ controllers/admin/AdminOrdersController.php | 12 +++++++----- install-dev/sql/db.sql | 1 + install-dev/sql/upgrade/1.5.0.1.sql | 1 + js/admin_order.js | 10 ++++++++-- modules/homeslider/config.xml | 2 +- 9 files changed, 34 insertions(+), 15 deletions(-) diff --git a/admin-dev/themes/template/orders/_new_product.tpl b/admin-dev/themes/template/orders/_new_product.tpl index 6a35b8c22..b8f62abba 100644 --- a/admin-dev/themes/template/orders/_new_product.tpl +++ b/admin-dev/themes/template/orders/_new_product.tpl @@ -46,4 +46,4 @@

{l s='If you don\'t select the "Free shipping", the normal shipping cost will be applied'}

- \ No newline at end of file + diff --git a/admin-dev/themes/template/orders/_product_line.tpl b/admin-dev/themes/template/orders/_product_line.tpl index 200be6ef1..b429fc90a 100755 --- a/admin-dev/themes/template/orders/_product_line.tpl +++ b/admin-dev/themes/template/orders/_product_line.tpl @@ -63,6 +63,7 @@ {displayPrice price=(Tools::ps_round($product_price, 2) * ($product['product_quantity'] - $product['customizationQuantityTotal'])) currency=$currency->id} +   diff --git a/admin-dev/themes/template/orders/view.tpl b/admin-dev/themes/template/orders/view.tpl index e52405f72..ef5027ddf 100755 --- a/admin-dev/themes/template/orders/view.tpl +++ b/admin-dev/themes/template/orders/view.tpl @@ -504,7 +504,9 @@ {if ($order->hasBeenDelivered())}{l s='Returned'}{/if} {l s='Stock'} {l s='Total'} * - {l s='Products'} +   +   + {l s='Products'} {if ($order->hasBeenDelivered())} {l s='Return'} {elseif ($order->hasBeenPaid())} @@ -551,29 +553,29 @@ {l s='Products'} {displayPrice price=$order->total_products_wt currency=$currency->id} -   +   total_discounts_tax_incl == 0}style="display: none;"{/if}> {l s='Discounts'} -{displayPrice price=$order->total_discounts_tax_incl currency=$currency->id} -   +   total_wrapping_tax_incl == 0}style="display: none;"{/if}> {l s='Wrapping'} {displayPrice price=$order->total_wrapping_tax_incl currency=$currency->id} -   +   {l s='Shipping'} {displayPrice price=$order->total_shipping_tax_incl currency=$currency->id} - € + € {l s='Total'} {displayPrice price=$order->total_paid_tax_incl currency=$currency->id} -   +   diff --git a/classes/order/OrderSlip.php b/classes/order/OrderSlip.php index 8e1059454..5e9e28a7e 100644 --- a/classes/order/OrderSlip.php +++ b/classes/order/OrderSlip.php @@ -48,6 +48,9 @@ class OrderSlipCore extends ObjectModel /** @var integer */ public $shipping_cost_amount; + /** @var integer */ + public $partial; + /** @var string Object creation date */ public $date_add; @@ -72,6 +75,7 @@ class OrderSlipCore extends ObjectModel $fields['amount'] = (int)($this->amount); $fields['shipping_cost'] = (int)($this->shipping_cost); $fields['shipping_cost_amount'] = (float)($this->shipping_cost_amount); + $fields['partial'] = (int)($this->partial); $fields['date_add'] = pSQL($this->date_add); $fields['date_upd'] = pSQL($this->date_upd); return $fields; @@ -179,6 +183,7 @@ class OrderSlipCore extends ObjectModel $orderSlip->id_order = (int)($order->id); $orderSlip->shipping_cost = (int)($shipping_cost); $orderSlip->conversion_rate = $currency->conversion_rate; + $orderSlip->partial = 0; if (!$orderSlip->add()) return false; @@ -196,6 +201,7 @@ class OrderSlipCore extends ObjectModel $orderSlip->shipping_cost = false; $orderSlip->shipping_cost_amount = (float)($shipping_cost_amount); $orderSlip->conversion_rate = $currency->conversion_rate; + $orderSlip->partial = 1; if (!$orderSlip->add()) return false; diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index ac12515f2..abc788917 100755 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -106,9 +106,9 @@ class AdminOrdersControllerCore extends AdminController if ($this->display == 'view') { $order = new Order((int)Tools::getValue('id_order')); - if ($order->hasBeenDelivered()) $type = $this->l('Return'); - elseif ($order->hasBeenPaid()) $type = $this->l('Refund'); - else $type = $this->l('Cancel'); + if ($order->hasBeenDelivered()) $type = $this->l('Return products'); + elseif ($order->hasBeenPaid()) $type = $this->l('Standard refund'); + else $type = $this->l('Cancel products'); $this->toolbar_btn['new'] = array( 'short' => 'Create', @@ -119,7 +119,7 @@ class AdminOrdersControllerCore extends AdminController $this->toolbar_btn['standard_refund'] = array( 'short' => 'Create', 'href' => '', - 'desc' => $type.' '.$this->l('refund'), + 'desc' => $type, 'class' => 'process-icon-new standard_refund' ); $this->toolbar_btn['partial_refund'] = array( @@ -345,8 +345,10 @@ class AdminOrdersControllerCore extends AdminController $order_detail_list[$id_order_detail] = $amount_detail; } $shipping_cost_amount = (float)(Tools::getValue('partialRefundShippingCost')); + if ($shipping_cost_amount > 0) + $amount += $shipping_cost_amount; - if ($shipping_cost_amount > 0 OR $amount > 0) + if ($amount > 0) { if (!OrderSlip::createPartialOrderSlip($order, $amount, $shipping_cost_amount, $order_detail_list)) $this->_errors[] = Tools::displayError('Cannot generate partial credit slip'); diff --git a/install-dev/sql/db.sql b/install-dev/sql/db.sql index 1773292be..9cc4b16a0 100644 --- a/install-dev/sql/db.sql +++ b/install-dev/sql/db.sql @@ -1205,6 +1205,7 @@ CREATE TABLE `PREFIX_order_slip` ( `shipping_cost` tinyint(3) unsigned NOT NULL default '0', `amount` DECIMAL(10,2) NOT NULL, `shipping_cost_amount` DECIMAL(10,2) NOT NULL, + `partial` TINYINT(1) NOT NULL, `date_add` datetime NOT NULL, `date_upd` datetime NOT NULL, PRIMARY KEY (`id_order_slip`), diff --git a/install-dev/sql/upgrade/1.5.0.1.sql b/install-dev/sql/upgrade/1.5.0.1.sql index 4d3d2acaf..d99ff2c3e 100644 --- a/install-dev/sql/upgrade/1.5.0.1.sql +++ b/install-dev/sql/upgrade/1.5.0.1.sql @@ -625,4 +625,5 @@ CREATE TABLE `PREFIX_order_carrier` ( ALTER TABLE `PREFIX_order_slip` ADD COLUMN `amount` DECIMAL(10,2) NOT NULL AFTER `shipping_cost`; ALTER TABLE `PREFIX_order_slip` ADD COLUMN `shipping_cost_amount` DECIMAL(10,2) NOT NULL AFTER `amount`; +ALTER TABLE `PREFIX_order_slip` ADD COLUMN `partial` TINYINT(1) NOT NULL AFTER `shipping_cost_amount`; ALTER TABLE `PREFIX_order_slip_detail` ADD COLUMN `amount` DECIMAL(10,2) NOT NULL AFTER `product_quantity`; diff --git a/js/admin_order.js b/js/admin_order.js index ce9a3390a..8484566f8 100644 --- a/js/admin_order.js +++ b/js/admin_order.js @@ -29,6 +29,9 @@ var current_product = null; $(document).ready(function() { $('.add_product').click(function() { $('.cancel_product_change_link:visible').trigger('click'); + $('.add_product_fields').show(); + $('.edit_product_fields').hide(); + $('.standard_refund_fields').hide(); $('tr#new_product').slideDown('fast', function () { $('tr#new_product td').fadeIn('fast'); }); @@ -263,6 +266,9 @@ $(document).ready(function() { }); $('.edit_product_change_link').click(function() { + $('.add_product_fields').hide(); + $('.standard_refund_fields').hide(); + $('.edit_product_fields').show(); $('.cancel_product_change_link:visible').trigger('click'); closeAddProduct(); @@ -307,7 +313,7 @@ $(document).ready(function() { $('.cancel_product_change_link').click(function() { current_product = null; - + $('.edit_product_fields').show(); $(this).parent().parent().css('background-color', '#FFF'); $(this).parent().parent().find('td .product_price_show').show(); @@ -324,7 +330,7 @@ $(document).ready(function() { $(this).parent().children('.edit_product_change_link').show(); $(this).parent().children('input[name=submitProductChange]').hide(); $(this).parent().children('.cancel_product_change_link').hide(); - + $('.standard_refund_fields').hide(); return false; }); diff --git a/modules/homeslider/config.xml b/modules/homeslider/config.xml index a9e9c5440..2e1e7a56e 100644 --- a/modules/homeslider/config.xml +++ b/modules/homeslider/config.xml @@ -2,7 +2,7 @@ homeslider - +