diff --git a/classes/Link.php b/classes/Link.php index 25853b103..70e1b501c 100644 --- a/classes/Link.php +++ b/classes/Link.php @@ -98,7 +98,7 @@ class LinkCore if (is_array($product) && isset($product['id_product'])) $product = new Product($product['id_product'], false, $id_lang); else if (is_numeric($product) || !$product) - $product = new Product($product, false, $id_lang); + $product = new Product($product, false, $id_lang); else throw new PrestaShopException('Invalid product vars'); } diff --git a/classes/Product.php b/classes/Product.php index 7b6f23ffd..42a50222a 100644 --- a/classes/Product.php +++ b/classes/Product.php @@ -2451,17 +2451,19 @@ class ProductCore extends ObjectModel } $res = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql); - foreach ($res as $row) - self::$_pricesLevel2[$cache_id_2][(int)$row['id_product_attribute']] = array( - 'price' => $row['price'], - 'ecotax' => $row['ecotax'], - 'attribute_price' => (isset($row['attribute_price']) ? $row['attribute_price'] : null) - ); - if ($default_on) - self::$_pricesLevel2[$cache_id_2][0] = array('price' => $row['price'], - 'ecotax' => $row['ecotax'], - 'attribute_price' => $row['attribute_price']); - + if ($res) + { + foreach ($res as $row) + self::$_pricesLevel2[$cache_id_2][(int)$row['id_product_attribute']] = array( + 'price' => $row['price'], + 'ecotax' => $row['ecotax'], + 'attribute_price' => (isset($row['attribute_price']) ? $row['attribute_price'] : null) + ); + if ($default_on) + self::$_pricesLevel2[$cache_id_2][0] = array('price' => $row['price'], + 'ecotax' => $row['ecotax'], + 'attribute_price' => $row['attribute_price']); + } } $result = self::$_pricesLevel2[$cache_id_2][(int)$id_product_attribute]; diff --git a/classes/helper/HelperForm.php b/classes/helper/HelperForm.php index b49c662c2..45e24be2b 100644 --- a/classes/helper/HelperForm.php +++ b/classes/helper/HelperForm.php @@ -137,8 +137,8 @@ class HelperFormCore extends Helper break; case 'shop' : - $params['html'] = $this->renderAssoShop($params['type']); - $shops = Shop::getShops(true, null, true); + $disable_shops = isset($params['disable_shared']) ? $params['disable_shared'] : false; + $params['html'] = $this->renderAssoShop($disable_shops); if (Shop::getTotalShops(false) == 1) unset($this->fields_form[$fieldset_key]['form']['input'][$key]); break; @@ -190,7 +190,7 @@ class HelperFormCore extends Helper * * @return string */ - public function renderAssoShop() + public function renderAssoShop($disable_shared = false) { if (!Shop::isFeatureActive()) return; @@ -228,8 +228,11 @@ class HelperFormCore extends Helper $tpl = $this->createTemplate('assoshop.tpl'); $tree = Shop::getTree(); $nb_shop = 0; - foreach ($tree as $value) + foreach ($tree as &$value) + { + $value['disable_shops'] = (isset($value[$disable_shared]) && $value[$disable_shared]); $nb_shop += count($value['shops']); + } $tpl->assign(array( 'input' => array( 'type' => 'shop', diff --git a/classes/shop/Shop.php b/classes/shop/Shop.php index 7b7e2f105..4dc82645b 100644 --- a/classes/shop/Shop.php +++ b/classes/shop/Shop.php @@ -117,6 +117,7 @@ class ShopCore extends ObjectModel */ const SHARE_CUSTOMER = 'share_customer'; const SHARE_ORDER = 'share_order'; + const SHARE_STOCK = 'share_stock'; /** * On shop instance, get its theme and URL data too @@ -574,6 +575,7 @@ class ShopCore extends ObjectModel 'name' => $row['group_name'], 'share_customer' => $row['share_customer'], 'share_order' => $row['share_order'], + 'share_stock' => $row['share_stock'], 'shops' => array(), ); diff --git a/classes/stock/Warehouse.php b/classes/stock/Warehouse.php index 6f635c469..aa77ea9e0 100644 --- a/classes/stock/Warehouse.php +++ b/classes/stock/Warehouse.php @@ -309,8 +309,6 @@ class WarehouseCore extends ObjectModel */ public static function getProductWarehouseList($id_product, $id_product_attribute = 0, $id_shop = null) { - if (is_null($id_shop)) - $id_shop = Context::getContext()->shop->id; // if it's a pack, returns warehouses if and only if some products use the advanced stock management if (Pack::isPack($id_product)) @@ -321,11 +319,30 @@ class WarehouseCore extends ObjectModel $res[]['id_warehouse'] = $warehouse; return $res; } + $share_stock = false; + if ($id_shop === null) + { + if (Shop::getContext() == Shop::CONTEXT_GROUP) + $shop_group = Shop::getContextShopGroup(); + else + $shop_group = Context::getContext()->shop->getGroup(); + $share_stock = $shop_group->share_stock; + } + else + { + $shop_group = Shop::getGroupFromShop($id_shop); + $share_stock = $shop_group['share_stock']; + } + + if ($share_stock) + $ids_shop = Shop::getShops(true, (int)$shop_group->id, true); + else + $ids_shop = array((int)Context::getContext()->shop->id); $query = new DbQuery(); $query->select('wpl.id_warehouse, CONCAT(w.reference, " - ", w.name) as name'); $query->from('warehouse_product_location', 'wpl'); - $query->innerJoin('warehouse_shop', 'ws', 'ws.id_warehouse = wpl.id_warehouse AND id_shop = '.(int)$id_shop); + $query->innerJoin('warehouse_shop', 'ws', 'ws.id_warehouse = wpl.id_warehouse AND id_shop IN ('.implode(',', array_map('intval', $ids_shop)).')'); $query->innerJoin('warehouse', 'w', 'ws.id_warehouse = w.id_warehouse'); $query->where('id_product = '.(int)$id_product); $query->where('id_product_attribute = '.(int)$id_product_attribute); diff --git a/controllers/admin/AdminWarehousesController.php b/controllers/admin/AdminWarehousesController.php index 91fe9323f..8b5a36730 100644 --- a/controllers/admin/AdminWarehousesController.php +++ b/controllers/admin/AdminWarehousesController.php @@ -273,6 +273,7 @@ class AdminWarehousesControllerCore extends AdminController 'label' => $this->l('Shops:'), 'name' => 'checkBoxShopAsso', 'desc' => $this->l('Associated shops'), + 'disable_shared' => Shop::SHARE_STOCK ); } diff --git a/modules/carriercompare/template/configuration.tpl b/modules/carriercompare/template/configuration.tpl index 132871ad4..f27cb18da 100644 --- a/modules/carriercompare/template/configuration.tpl +++ b/modules/carriercompare/template/configuration.tpl @@ -6,7 +6,7 @@ {/if} {/if} -
+
{l s='Global Configuration'} diff --git a/modules/trackingfront/account.tpl b/modules/trackingfront/account.tpl index 7c968d473..eeb4fa713 100644 --- a/modules/trackingfront/account.tpl +++ b/modules/trackingfront/account.tpl @@ -30,7 +30,7 @@
- + @@ -67,4 +67,4 @@ - *} \ No newline at end of file + *} diff --git a/themes/default/address.tpl b/themes/default/address.tpl index 034b140c6..5be3ad1c3 100644 --- a/themes/default/address.tpl +++ b/themes/default/address.tpl @@ -45,7 +45,7 @@ countriesNeedZipCode = new Array(); {/if} {/foreach} $(function(){ldelim} - $('.id_state option[value={if isset($smarty.post.id_state)}{$smarty.post.id_state}{else}{if isset($address->id_state)}{$address->id_state|escape:'htmlall':'UTF-8'}{/if}{/if}]').attr('selected', true); + $('.id_state option[value={if isset($smarty.post.id_state)}{$smarty.post.id_state|intval}{else}{if isset($address->id_state)}{$address->id_state|intval}{/if}{/if}]').attr('selected', true); {rdelim}); {if $vat_management} {literal} @@ -76,7 +76,7 @@ $(function(){ldelim} {if isset($id_address) && (isset($smarty.post.alias) || isset($address->alias))} {l s='Modify address'} {if isset($smarty.post.alias)} - "{$smarty.post.alias}" + "{$smarty.post.alias|escape:'htmlall':'UTF-8'}" {else} {if isset($address->alias)}"{$address->alias|escape:'htmlall':'UTF-8'}"{/if} {/if} @@ -94,7 +94,7 @@ $(function(){ldelim}

{if isset($id_address)}{l s='Your address'}{else}{l s='New address'}{/if}

- + {l s='DNI / NIF / NIE'} *

@@ -108,7 +108,7 @@ $(function(){ldelim}

- +

@@ -118,43 +118,43 @@ $(function(){ldelim}

- +

{/if} {if $field_name eq 'firstname'}

- +

{/if} {if $field_name eq 'lastname'}

- +

{/if} {if $field_name eq 'address1'}

- +

{/if} {if $field_name eq 'address2'}

- +

{/if} {if $field_name eq 'postcode'}

- +

{/if} {if $field_name eq 'city'}

- +

{* if customer hasn't update his layout address, country has to be verified @@ -213,20 +213,20 @@ $(function(){ldelim} {/if}

- +

{l s='You must register at least one phone number'} *

- +

- +

- +

diff --git a/themes/default/identity.tpl b/themes/default/identity.tpl index 9840124d7..deadcf8e7 100644 --- a/themes/default/identity.tpl +++ b/themes/default/identity.tpl @@ -44,21 +44,21 @@

{l s='Title'} {foreach from=$genders key=k item=gender} - id}checked="checked"{/if} /> + id}checked="checked"{/if} /> {/foreach}

- +

- +

- +