// Fix some bug on advanced stock management

This commit is contained in:
rGaillard
2012-07-11 15:46:39 +00:00
parent 9195b74cb7
commit 3672b02c66
10 changed files with 66 additions and 41 deletions
+1 -1
View File
@@ -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');
}
+13 -11
View File
@@ -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];
+7 -4
View File
@@ -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',
+2
View File
@@ -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(),
);
+20 -3
View File
@@ -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);
@@ -273,6 +273,7 @@ class AdminWarehousesControllerCore extends AdminController
'label' => $this->l('Shops:'),
'name' => 'checkBoxShopAsso',
'desc' => $this->l('Associated shops'),
'disable_shared' => Shop::SHARE_STOCK
);
}
@@ -6,7 +6,7 @@
{/if}
{/if}
<form method="post" action="{$smarty.server.REQUEST_URI}">
<form method="post" action="{$smarty.server.REQUEST_URI|escape:'htmlall':'UTF-8'}">
<fieldset>
<legend>{l s='Global Configuration'}</legend>
+2 -2
View File
@@ -30,7 +30,7 @@
</div>
<div style="width: 800px; height: 250px; background-color: #EEEEEE; margin: 0 auto; font-family: arial;">
<div style="float:left; margin: 25px 0 0 50px;">
<form action="{$smarty.server.REQUEST_URI}" method="post">
<form action="{$smarty.server.REQUEST_URI|escape:'htmlall':'UTF-8'}" method="post">
<input type="submit" name="submitDateToday" class="button" value="{l s='Today' mod='trackingfront'}">
<input type="submit" name="submitDateMonth" class="button" value="{l s='Month' mod='trackingfront'}">
<input type="submit" name="submitDateYear" class="button" value="{l s='Year' mod='trackingfront'}">
@@ -67,4 +67,4 @@
</tr>
<tr id="trid_dummy"><td colspan="14" style="background: #567500;" /></tr>
</table>
*}
*}
+15 -15
View File
@@ -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}
<h3>{if isset($id_address)}{l s='Your address'}{else}{l s='New address'}{/if}</h3>
<p class="required text dni">
<label for="dni">{l s='Identification number'}</label>
<input type="text" class="text" name="dni" id="dni" value="{if isset($smarty.post.dni)}{$smarty.post.dni}{else}{if isset($address->dni)}{$address->dni|escape:'htmlall':'UTF-8'}{/if}{/if}" />
<input type="text" class="text" name="dni" id="dni" value="{if isset($smarty.post.dni)}{$smarty.post.dni|escape:'htmlall':'UTF-8'}{else}{if isset($address->dni)}{$address->dni|escape:'htmlall':'UTF-8'}{/if}{/if}" />
<span class="form_info">{l s='DNI / NIF / NIE'}</span>
<sup>*</sup>
</p>
@@ -108,7 +108,7 @@ $(function(){ldelim}
<div id="vat_number">
<p class="text">
<label for="vat_number">{l s='VAT number'}</label>
<input type="text" class="text" name="vat_number" value="{if isset($smarty.post.vat_number)}{$smarty.post.vat_number}{else}{if isset($address->vat_number)}{$address->vat_number|escape:'htmlall':'UTF-8'}{/if}{/if}" />
<input type="text" class="text" name="vat_number" value="{if isset($smarty.post.vat_number)}{$smarty.post.vat_number|escape:'htmlall':'UTF-8'}{else}{if isset($address->vat_number)}{$address->vat_number|escape:'htmlall':'UTF-8'}{/if}{/if}" />
</p>
</div>
</div>
@@ -118,43 +118,43 @@ $(function(){ldelim}
<p class="text">
<input type="hidden" name="token" value="{$token}" />
<label for="company">{l s='Company'}</label>
<input type="text" id="company" name="company" value="{if isset($smarty.post.company)}{$smarty.post.company}{else}{if isset($address->company)}{$address->company|escape:'htmlall':'UTF-8'}{/if}{/if}" />
<input type="text" id="company" name="company" value="{if isset($smarty.post.company)}{$smarty.post.company|escape:'htmlall':'UTF-8'}{else}{if isset($address->company)}{$address->company|escape:'htmlall':'UTF-8'}{/if}{/if}" />
</p>
{/if}
{if $field_name eq 'firstname'}
<p class="required text">
<label for="firstname">{l s='First name'} <sup>*</sup></label>
<input type="text" name="firstname" id="firstname" value="{if isset($smarty.post.firstname)}{$smarty.post.firstname}{else}{if isset($address->firstname)}{$address->firstname|escape:'htmlall':'UTF-8'}{/if}{/if}" />
<input type="text" name="firstname" id="firstname" value="{if isset($smarty.post.firstname)}{$smarty.post.firstname|escape:'htmlall':'UTF-8'}{else}{if isset($address->firstname)}{$address->firstname|escape:'htmlall':'UTF-8'}{/if}{/if}" />
</p>
{/if}
{if $field_name eq 'lastname'}
<p class="required text">
<label for="lastname">{l s='Last name'} <sup>*</sup></label>
<input type="text" id="lastname" name="lastname" value="{if isset($smarty.post.lastname)}{$smarty.post.lastname}{else}{if isset($address->lastname)}{$address->lastname|escape:'htmlall':'UTF-8'}{/if}{/if}" />
<input type="text" id="lastname" name="lastname" value="{if isset($smarty.post.lastname)}{$smarty.post.lastname|escape:'htmlall':'UTF-8'}{else}{if isset($address->lastname)}{$address->lastname|escape:'htmlall':'UTF-8'}{/if}{/if}" />
</p>
{/if}
{if $field_name eq 'address1'}
<p class="required text">
<label for="address1">{l s='Address'} <sup>*</sup></label>
<input type="text" id="address1" name="address1" value="{if isset($smarty.post.address1)}{$smarty.post.address1}{else}{if isset($address->address1)}{$address->address1|escape:'htmlall':'UTF-8'}{/if}{/if}" />
<input type="text" id="address1" name="address1" value="{if isset($smarty.post.address1)}{$smarty.post.address1|escape:'htmlall':'UTF-8'}{else}{if isset($address->address1)}{$address->address1|escape:'htmlall':'UTF-8'}{/if}{/if}" />
</p>
{/if}
{if $field_name eq 'address2'}
<p class="required text">
<label for="address2">{l s='Address (Line 2)'}</label>
<input type="text" id="address2" name="address2" value="{if isset($smarty.post.address2)}{$smarty.post.address2}{else}{if isset($address->address2)}{$address->address2|escape:'htmlall':'UTF-8'}{/if}{/if}" />
<input type="text" id="address2" name="address2" value="{if isset($smarty.post.address2)}{$smarty.post.address2|escape:'htmlall':'UTF-8'}{else}{if isset($address->address2)}{$address->address2|escape:'htmlall':'UTF-8'}{/if}{/if}" />
</p>
{/if}
{if $field_name eq 'postcode'}
<p class="required postcode text">
<label for="postcode">{l s='Zip / Postal Code'} <sup>*</sup></label>
<input type="text" id="postcode" name="postcode" value="{if isset($smarty.post.postcode)}{$smarty.post.postcode}{else}{if isset($address->postcode)}{$address->postcode|escape:'htmlall':'UTF-8'}{/if}{/if}" onkeyup="$('#postcode').val($('#postcode').val().toUpperCase());" />
<input type="text" id="postcode" name="postcode" value="{if isset($smarty.post.postcode)}{$smarty.post.postcode|escape:'htmlall':'UTF-8'}{else}{if isset($address->postcode)}{$address->postcode|escape:'htmlall':'UTF-8'}{/if}{/if}" onkeyup="$('#postcode').val($('#postcode').val().toUpperCase());" />
</p>
{/if}
{if $field_name eq 'city'}
<p class="required text">
<label for="city">{l s='City'} <sup>*</sup></label>
<input type="text" name="city" id="city" value="{if isset($smarty.post.city)}{$smarty.post.city}{else}{if isset($address->city)}{$address->city|escape:'htmlall':'UTF-8'}{/if}{/if}" maxlength="64" />
<input type="text" name="city" id="city" value="{if isset($smarty.post.city)}{$smarty.post.city|escape:'htmlall':'UTF-8'}{else}{if isset($address->city)}{$address->city|escape:'htmlall':'UTF-8'}{/if}{/if}" maxlength="64" />
</p>
{*
if customer hasn't update his layout address, country has to be verified
@@ -213,20 +213,20 @@ $(function(){ldelim}
{/if}
<p class="textarea">
<label for="other">{l s='Additional information'}</label>
<textarea id="other" name="other" cols="26" rows="3">{if isset($smarty.post.other)}{$smarty.post.other}{else}{if isset($address->other)}{$address->other|escape:'htmlall':'UTF-8'}{/if}{/if}</textarea>
<textarea id="other" name="other" cols="26" rows="3">{if isset($smarty.post.other)}{$smarty.post.other|escape:'htmlall':'UTF-8'}{else}{if isset($address->other)}{$address->other|escape:'htmlall':'UTF-8'}{/if}{/if}</textarea>
</p>
<p class="inline-infos required">{l s='You must register at least one phone number'} <sup class="required">*</sup></p>
<p class="text">
<label for="phone">{l s='Home phone'}</label>
<input type="text" id="phone" name="phone" value="{if isset($smarty.post.phone)}{$smarty.post.phone}{else}{if isset($address->phone)}{$address->phone|escape:'htmlall':'UTF-8'}{/if}{/if}" />
<input type="text" id="phone" name="phone" value="{if isset($smarty.post.phone)}{$smarty.post.phone|escape:'htmlall':'UTF-8'}{else}{if isset($address->phone)}{$address->phone|escape:'htmlall':'UTF-8'}{/if}{/if}" />
</p>
<p class="text">
<label for="phone_mobile">{l s='Mobile phone'}</label>
<input type="text" id="phone_mobile" name="phone_mobile" value="{if isset($smarty.post.phone_mobile)}{$smarty.post.phone_mobile}{else}{if isset($address->phone_mobile)}{$address->phone_mobile|escape:'htmlall':'UTF-8'}{/if}{/if}" />
<input type="text" id="phone_mobile" name="phone_mobile" value="{if isset($smarty.post.phone_mobile)}{$smarty.post.phone_mobile|escape:'htmlall':'UTF-8'}{else}{if isset($address->phone_mobile)}{$address->phone_mobile|escape:'htmlall':'UTF-8'}{/if}{/if}" />
</p>
<p class="required text" id="adress_alias">
<label for="alias">{l s='Assign an address title for future reference'} <sup>*</sup></label>
<input type="text" id="alias" name="alias" value="{if isset($smarty.post.alias)}{$smarty.post.alias}{else if isset($address->alias)}{$address->alias|escape:'htmlall':'UTF-8'}{else if isset($select_address)}{l s='My address'}{/if}" />
<input type="text" id="alias" name="alias" value="{if isset($smarty.post.alias)}{$smarty.post.alias|escape:'htmlall':'UTF-8'}{else if isset($address->alias)}{$address->alias|escape:'htmlall':'UTF-8'}{else if isset($select_address)}{l s='My address'}{/if}" />
</p>
</fieldset>
<p class="submit2">
+4 -4
View File
@@ -44,21 +44,21 @@
<p class="radio">
<span>{l s='Title'}</span>
{foreach from=$genders key=k item=gender}
<input type="radio" name="id_gender" id="id_gender{$gender->id}" value="{$gender->id}" {if isset($smarty.post.id_gender) && $smarty.post.id_gender == $gender->id}checked="checked"{/if} />
<input type="radio" name="id_gender" id="id_gender{$gender->id}" value="{$gender->id|intval}" {if isset($smarty.post.id_gender) && $smarty.post.id_gender == $gender->id}checked="checked"{/if} />
<label for="id_gender{$gender->id}" class="top">{$gender->name}</label>
{/foreach}
</p>
<p class="required text">
<label for="firstname">{l s='First name'} <sup>*</sup></label>
<input type="text" id="firstname" name="firstname" value="{$smarty.post.firstname}" />
<input type="text" id="firstname" name="firstname" value="{$smarty.post.firstname|escape:'htmlall':'UTF-8'}" />
</p>
<p class="required text">
<label for="lastname">{l s='Last name'} <sup>*</sup></label>
<input type="text" name="lastname" id="lastname" value="{$smarty.post.lastname}" />
<input type="text" name="lastname" id="lastname" value="{$smarty.post.lastname|escape:'htmlall':'UTF-8'}" />
</p>
<p class="required text">
<label for="email">{l s='E-mail'} <sup>*</sup></label>
<input type="text" name="email" id="email" value="{$smarty.post.email}" />
<input type="text" name="email" id="email" value="{$smarty.post.email|escape:'htmlall':'UTF-8'}" />
</p>
<p class="required text">
<label for="old_passwd">{l s='Current Password'} <sup>*</sup></label>