diff --git a/classes/PaymentModule.php b/classes/PaymentModule.php index 4b06f7e89..f184a29a2 100644 --- a/classes/PaymentModule.php +++ b/classes/PaymentModule.php @@ -147,7 +147,6 @@ abstract class PaymentModuleCore extends Module $order->id_address_delivery = (int)$id_address; $order->id_currency = $id_currency; $order->id_lang = (int)($cart->id_lang); - $order->id_warehouse = $package_list[$id_address][$id_package]['id_warehouse']; $order->id_cart = (int)($cart->id); $order->reference = $reference; @@ -203,7 +202,7 @@ abstract class PaymentModuleCore extends Module // Insert new Order detail list using cart for the current order $order_detail = new OrderDetail(null, null, $this->context); - $order_detail->createList($order, $cart, $id_order_state, $product_list); + $order_detail->createList($order, $cart, $id_order_state, $product_list, 0, true, $package_list[$id_address][$id_package]['id_warehouse']); $order_detail_list[] = $order_detail; // Adding an entry in order_carrier table diff --git a/classes/order/Order.php b/classes/order/Order.php index f116d0351..b3fff4dc4 100644 --- a/classes/order/Order.php +++ b/classes/order/Order.php @@ -147,8 +147,6 @@ class OrderCore extends ObjectModel */ public $reference; - /** @var int Id warehouse */ - public $id_warehouse; protected $tables = array ('orders'); @@ -163,7 +161,6 @@ class OrderCore extends ObjectModel 'id_lang' => 'isUnsignedId', 'id_customer' => 'isUnsignedId', 'id_carrier' => 'isUnsignedId', - 'id_warehouse' => 'isUnsignedId', 'secure_key' => 'isMd5', 'payment' => 'isGenericName', 'recyclable' => 'isBool', @@ -280,7 +277,6 @@ class OrderCore extends ObjectModel $fields['date_add'] = pSQL($this->date_add); $fields['date_upd'] = pSQL($this->date_upd); $fields['reference'] = pSQL($this->reference); - $fields['id_warehouse'] = pSQL($this->id_warehouse); return $fields; } diff --git a/classes/order/OrderDetail.php b/classes/order/OrderDetail.php index ef604bdcc..4ba4c621f 100644 --- a/classes/order/OrderDetail.php +++ b/classes/order/OrderDetail.php @@ -125,11 +125,15 @@ class OrderDetailCore extends ObjectModel /** @var float $tax_rate **/ public $tax_rate; + + /** @var int Id warehouse */ + public $id_warehouse; protected $tables = array('order_detail'); protected $fieldsRequired = array( 'id_order', + 'id_warehouse', 'product_name', 'product_quantity', 'product_price'); @@ -137,6 +141,7 @@ class OrderDetailCore extends ObjectModel protected $fieldsValidate = array( 'id_order' => 'isUnsignedId', 'id_order_invoice' => 'isUnsignedId', + 'id_warehouse' => 'isUnsignedId', 'product_id' => 'isUnsignedId', 'product_attribute_id' => 'isUnsignedId', 'product_name' => 'isGenericName', @@ -218,6 +223,7 @@ class OrderDetailCore extends ObjectModel $fields['id_order'] = (int)$this->id_order; $fields['id_order_invoice'] = (int)$this->id_order_invoice; + $fields['id_warehouse'] = pSQL($this->id_warehouse); $fields['product_id'] = (int)$this->product_id; $fields['product_attribute_id'] = (int)$this->product_attribute_id; $fields['product_name'] = pSQL($this->product_name); @@ -410,11 +416,11 @@ class OrderDetailCore extends ObjectModel $this->tax_calculator = $tax_manager->getTaxCalculator(); } - $this->ecotax_tax_rate = 0; - if (!empty($product['ecotax'])) - $this->ecotax_tax_rate = Tax::getProductEcotaxRate($order->{Configuration::get('PS_TAX_ADDRESS_TYPE')}); + $this->ecotax_tax_rate = 0; + if (!empty($product['ecotax'])) + $this->ecotax_tax_rate = Tax::getProductEcotaxRate($order->{Configuration::get('PS_TAX_ADDRESS_TYPE')}); - $this->tax_computation_method = (int)$this->tax_calculator->computation_method; + $this->tax_computation_method = (int)$this->tax_calculator->computation_method; } /** @@ -447,11 +453,11 @@ class OrderDetailCore extends ObjectModel */ protected function setDetailProductPrice(Order $order, Cart $cart, $product) { - $customer = new Customer((int)$order->id_customer); - $customer_address = new Address((int)$order->{Configuration::get('PS_TAX_ADDRESS_TYPE')}); + $customer = new Customer((int)$order->id_customer); + $customer_address = new Address((int)$order->{Configuration::get('PS_TAX_ADDRESS_TYPE')}); - $this->specificPrice = SpecificPrice::getSpecificPrice( - (int)$product['id_product'], + $this->specificPrice = SpecificPrice::getSpecificPrice( + (int)$product['id_product'], (int)$order->id_shop, (int)$order->id_currency, (int)$customer_address->id_country, @@ -498,8 +504,8 @@ class OrderDetailCore extends ObjectModel * @param int $id_order_status * @param int $id_order_invoice * @param bool $use_taxes set to false if you don't want to use taxes - */ - protected function create(Order $order, Cart $cart, $product, $id_order_state, $id_order_invoice, $use_taxes = true) + */ + protected function create(Order $order, Cart $cart, $product, $id_order_state, $id_order_invoice, $use_taxes = true, $id_warehouse = 0) { if ($use_taxes) $this->tax_calculator = new TaxCalculator(); @@ -518,6 +524,7 @@ class OrderDetailCore extends ObjectModel $this->product_reference = empty($product['reference']) ? null : pSQL($product['reference']); $this->product_supplier_reference = empty($product['supplier_reference']) ? null : pSQL($product['supplier_reference']); $this->product_weight = (float)($product['id_product_attribute'] ? $product['weight_attribute'] : $product['weight']); + $this->id_warehouse = $id_warehouse; $productQuantity = (int)(Product::getQuantity($this->product_id, $this->product_attribute_id)); $this->product_quantity_in_stock = ($productQuantity - (int)($product['cart_quantity']) < 0) ? @@ -549,7 +556,7 @@ class OrderDetailCore extends ObjectModel * @param int $id_order_invoice * @param bool $use_taxes set to false if you don't want to use taxes */ - public function createList(Order $order, Cart $cart, $id_order_state, $product_list, $id_order_invoice = 0, $use_taxes = true) + public function createList(Order $order, Cart $cart, $id_order_state, $product_list, $id_order_invoice = 0, $use_taxes = true, $id_warehouse = 0) { $this->vat_address = new Address((int)($order->{Configuration::get('PS_TAX_ADDRESS_TYPE')})); $this->customer = new Customer((int)($order->id_customer)); @@ -558,7 +565,7 @@ class OrderDetailCore extends ObjectModel $this->outOfStock = false; foreach ($product_list as $product) - $this->create($order, $cart, $product, $id_order_state, $id_order_invoice, $use_taxes); + $this->create($order, $cart, $product, $id_order_state, $id_order_invoice, $use_taxes, $id_warehouse); unset($this->vat_address); unset($products); @@ -568,7 +575,7 @@ class OrderDetailCore extends ObjectModel /** * Get the state of the current stock product * @return array - */ + */ public function getStockState() { return $this->outOfStock; diff --git a/install-dev/sql/db.sql b/install-dev/sql/db.sql index 6e401a2e7..6ed2b060a 100644 --- a/install-dev/sql/db.sql +++ b/install-dev/sql/db.sql @@ -995,7 +995,6 @@ CREATE TABLE `PREFIX_orders` ( `id_group_shop` INT(11) UNSIGNED NOT NULL DEFAULT '1', `id_shop` INT(11) UNSIGNED NOT NULL DEFAULT '1', `id_carrier` int(10) unsigned NOT NULL, - `id_warehouse` int(10) unsigned DEFAULT 0, `id_lang` int(10) unsigned NOT NULL, `id_customer` int(10) unsigned NOT NULL, `id_cart` int(10) unsigned NOT NULL, @@ -1077,6 +1076,7 @@ CREATE TABLE `PREFIX_order_detail` ( `id_order_detail` int(10) unsigned NOT NULL auto_increment, `id_order` int(10) unsigned NOT NULL, `id_order_invoice` int(11) default NULL, + `id_warehouse` int(10) unsigned DEFAULT 0, `product_id` int(10) unsigned NOT NULL, `product_attribute_id` int(10) unsigned default NULL, `product_name` varchar(255) NOT NULL, diff --git a/install-dev/sql/upgrade/1.5.0.2.sql b/install-dev/sql/upgrade/1.5.0.2.sql index 2c5815907..340d6d453 100644 --- a/install-dev/sql/upgrade/1.5.0.2.sql +++ b/install-dev/sql/upgrade/1.5.0.2.sql @@ -4,4 +4,9 @@ INSERT INTO `PREFIX_access` (`id_profile`, `id_tab`, `view`, `add`, `edit`, `del INSERT INTO `PREFIX_access` (`id_profile`, `id_tab`, `view`, `add`, `edit`, `delete`) VALUES ('2', '108', '1', '1', '1', '1'); INSERT INTO `PREFIX_access` (`id_profile`, `id_tab`, `view`, `add`, `edit`, `delete`) VALUES ('3', '108', '1', '1', '1', '1'); INSERT INTO `PREFIX_access` (`id_profile`, `id_tab`, `view`, `add`, `edit`, `delete`) VALUES ('4', '108', '0', '0', '0', '0'); -INSERT INTO `PREFIX_access` (`id_profile`, `id_tab`, `view`, `add`, `edit`, `delete`) VALUES ('5', '108', '0', '0', '0', '0'); \ No newline at end of file +INSERT INTO `PREFIX_access` (`id_profile`, `id_tab`, `view`, `add`, `edit`, `delete`) VALUES ('5', '108', '0', '0', '0', '0'); + + + +ALTER TABLE `PREFIX_orders` DROP COLUMN `id_warehouse`; +ALTER TABLE `PREFIX_order_detail` ADD COLUMN `id_warehouse` int(10) unsigned DEFAULT 0 AFTER `id_order_invoice`; \ No newline at end of file diff --git a/themes/prestashop/js/cart-summary.js b/themes/prestashop/js/cart-summary.js index 078cd5cda..bb06677d8 100644 --- a/themes/prestashop/js/cart-summary.js +++ b/themes/prestashop/js/cart-summary.js @@ -639,4 +639,6 @@ $(document).ready(function() { } }); }); -}); \ No newline at end of file + + $('#gift').checkboxChange(function() { $('#gift_div').show('slow'); }, function() { $('#gift_div').hide('slow'); }); +}); diff --git a/themes/prestashop/js/order-opc.js b/themes/prestashop/js/order-opc.js index bb8a8c57d..fa54cc913 100755 --- a/themes/prestashop/js/order-opc.js +++ b/themes/prestashop/js/order-opc.js @@ -740,5 +740,4 @@ $(document).ready(function() { // If the multishipping mode is on, check the box "I want to specify a delivery address for each products I order.". if (typeof(multishipping_mode) != 'undefined' && multishipping_mode) $('#multishipping_mode_checkbox').click() - -}); \ No newline at end of file +}); diff --git a/themes/prestashop/js/tools.js b/themes/prestashop/js/tools.js index 04ee1ba7d..ab586fda2 100644 --- a/themes/prestashop/js/tools.js +++ b/themes/prestashop/js/tools.js @@ -224,3 +224,19 @@ function resizeAddressesBox(nameBox) }); $(nameBox).height(maxHeight); } + +$(document).ready(function() { + $.fn.checkboxChange = function(fnChecked, fnUnchecked) { + if ($(this).attr('checked') && fnChecked) + fnChecked.call(this); + else if(fnUnchecked) + fnUnchecked.call(this); + console.log('fff'); + + if (!$(this).attr('eventCheckboxChange')) + { + $(this).live('change', function() { $(this).checkboxChange(fnChecked, fnUnchecked) }); + $(this).attr('eventCheckboxChange', true); + } + } +}); \ No newline at end of file diff --git a/themes/prestashop/order-carrier.tpl b/themes/prestashop/order-carrier.tpl index 7689e93c3..61c96013a 100644 --- a/themes/prestashop/order-carrier.tpl +++ b/themes/prestashop/order-carrier.tpl @@ -196,7 +196,7 @@ {if $giftAllowed}
- gift == 1}checked="checked"{/if} onclick="$('#gift_div').toggle('slow');" />
+ gift == 1}checked="checked"{/if} />