[-] BO : Bug fixed related to #PSCFV-1354 - Specific price with multishop, groups/currencies/countries should vary in function of the selected shop

This commit is contained in:
fBrignoli
2012-05-16 15:51:22 +00:00
parent 604b572ed2
commit bf66f03fd7
5 changed files with 57 additions and 6 deletions

View File

@@ -25,6 +25,9 @@
*}
<script type="text/javascript">
var product_url = '{$link->getAdminLink('AdminProducts', true)}';
var Customer = {
"hiddenField": jQuery('#id_customer'),
"field": jQuery('#customer'),
@@ -257,7 +260,7 @@ jQuery(document).ready(Customer.init);
<input type="hidden" name="sp_id_shop" value="0" />
{else}
<div class="margin-form">
<select name="sp_id_shop">
<select name="sp_id_shop" id="sp_id_shop">
{if !$admin_one_shop}<option value="0">{l s='All shops'}</option>{/if}
{foreach from=$shops item=shop}
<option value="{$shop.id_shop}">{$shop.name|htmlentitiesUTF8}</option>
@@ -272,14 +275,14 @@ jQuery(document).ready(Customer.init);
{/foreach}
</select>
&gt;
<select name="sp_id_country">
<select name="sp_id_country" id="sp_id_country">
<option value="0">{l s='All countries'}</option>
{foreach from=$countries item=country}
<option value="{$country.id_country}">{$country.name|htmlentitiesUTF8}</option>
{/foreach}
</select>
&gt;
<select name="sp_id_group">
<select name="sp_id_group" id="sp_id_group">
<option value="0">{l s='All groups'}</option>
{foreach from=$groups item=group}
<option value="{$group.id_group}">{$group.name}</option>

View File

@@ -147,6 +147,17 @@ class CountryCore extends ObjectModel
return $countries;
}
public static function getCountriesByIdShop($id_shop, $id_lang)
{
$sql = 'SELECT *
FROM `'._DB_PREFIX_.'country` c
LEFT JOIN `'._DB_PREFIX_.'country_shop` cs ON (cs.`id_country`= c.`id_country`)
LEFT JOIN `'._DB_PREFIX_.'country_lang` cl ON (c.`id_country` = cl.`id_country` AND cl.`id_lang` = '.(int)$id_lang.')
WHERE `id_shop` = '.(int)$id_shop;
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
}
/**
* Get a country ID with its iso code
*

View File

@@ -212,6 +212,19 @@ class CurrencyCore extends ObjectModel
return $tab;
}
public static function getCurrenciesByIdShop($id_shop = 0)
{
$sql = 'SELECT *
FROM `'._DB_PREFIX_.'currency` c
LEFT JOIN `'._DB_PREFIX_.'currency_shop` cs ON (cs.`id_currency` = c.`id_currency`)
'.($id_shop != 0 ? ' WHERE cs.`id_shop` = '.(int)$id_shop : '').'
GROUP BY c.id_currency
ORDER BY `name` ASC';
return Db::getInstance()->executeS($sql);
}
public static function getPaymentCurrenciesSpecial($id_module, $id_shop = null)
{
if (is_null($id_shop))

View File

@@ -71,12 +71,18 @@ class GroupCore extends ObjectModel
protected $webserviceParameters = array();
public static function getGroups($id_lang)
public static function getGroups($id_lang, $id_shop = false)
{
$shop_criteria = '';
if ($id_shop)
$shop_criteria = 'LEFT JOIN `'._DB_PREFIX_.'group_shop` gs ON (gs.`id_group` = g.`id_group`)
WHERE `id_shop` = '.(int)$id_shop;
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT g.`id_group`, g.`reduction`, g.`price_display_method`, gl.`name`
FROM `'._DB_PREFIX_.'group` g
LEFT JOIN `'._DB_PREFIX_.'group_lang` AS gl ON (g.`id_group` = gl.`id_group` AND gl.`id_lang` = '.(int)$id_lang.')
'.$shop_criteria.'
ORDER BY g.`id_group` ASC');
}

View File

@@ -377,7 +377,7 @@ product_tabs['Combinations'] = new function(){
/**
* hide save and save-and-stay buttons
*
*
* @access public
* @return void
*/
@@ -410,7 +410,7 @@ function handleSaveButtons(e)
msg[i++] = handleSaveButtonsForVirtual();
else
msg[i++] = handleSaveButtonsForSimple();
// common for all products
$("#disableSaveMessage").remove();
if ($("#name_"+defaultLanguage).val() == "" && (!display_multishop_checkboxes || $('input[name=\'multishop_check[name]['+defaultLanguage+']\']').prop('checked')))
@@ -546,11 +546,28 @@ product_tabs['Prices'] = new function(){
})
};
this.loadInformations = function(select_id, action)
{
id_shop = $('#sp_id_shop').val();
$.ajax({
url: product_url + '&action='+action+'&ajax=true&id_shop='+id_shop,
success: function(data) {
$(select_id + ' option').not(':first').remove();
$(select_id).append(data);
}
});
}
this.onReady = function(){
self.toggleSpecificPrice();
self.deleteSpecificPrice();
self.bindDelete();
$('#sp_id_shop').change(function() {
self.loadInformations('#sp_id_group','getGroupsOptions');
self.loadInformations('#spm_currency_0', 'getCurrenciesOptions');
self.loadInformations('#sp_id_country', 'getCountriesOptions');
});
if (display_multishop_checkboxes)
ProductMultishop.checkAllPrices();
};
@@ -1564,3 +1581,4 @@ $(document).ready(function() {
return (code == 13) ? false : true;
});
});