// Combination multishop

This commit is contained in:
rMalie
2012-04-20 10:01:05 +00:00
parent f5fc3769a9
commit 84d1e57ad9
12 changed files with 213 additions and 138 deletions
@@ -55,13 +55,18 @@
<h4>{l s='Add or modify combinations for this product'}</h4>
<div class="separation"></div> {l s='or go to'}
&nbsp;<a class="button bt-icon confirm_leave" href="index.php?tab=AdminAttributeGenerator&id_product={$product->id}&attributegenerator&token={$token_generator}"><img src="../img/admin/appearance.gif" alt="combinations_generator" class="middle" title="{l s='Product combinations generator'}" /><span>{l s='Product combinations generator'}</span></a>
{if isset($display_multishop_checkboxes) && $display_multishop_checkboxes}
<br />
{include file="controllers/products/multishop/check_fields.tpl" product_tab="Combinations"}
{/if}
<div class="separation"></div>
<div id="add_new_combination" style="display: none;">
<table cellpadding="5" style="width:100%">
<tr>
<td style="width:150px;vertical-align:top;text-align:right;padding-right:10px;font-weight:bold;" valign="top">
{l s='Attribute:'}
<label>{l s='Attribute:'}</label>
</td>
<td style="padding-bottom:5px;">
<select name="attribute_group" id="attribute_group" style="width: 200px;" onchange="populate_attrs();">
@@ -75,7 +80,7 @@
</tr>
<tr>
<td style="width:150px;vertical-align:top;text-align:right;padding-right:10px;font-weight:bold;" valign="top">
{l s='Value:'}
<label>{l s='Value:'}</label>
</td>
<td style="padding-bottom:5px;">
<select name="attribute" id="attribute" style="width: 200px;">
@@ -102,7 +107,7 @@
</td>
</tr>
<tr>
<td style="width:150px;vertical-align:top;text-align:right;padding-right:10px;font-weight:bold;">{l s='Reference:'}</td>
<td style="width:150px;vertical-align:top;text-align:right;padding-right:10px;"><label>{l s='Reference:'}</label></td>
<td style="padding-bottom:5px;">
<input size="55" type="text" id="attribute_reference" name="attribute_reference" value="" style="width: 130px; margin-right: 44px;" />
{l s='EAN13:'}<input size="55" maxlength="13" type="text" id="attribute_ean13" name="attribute_ean13" value="" style="width: 110px; margin-left: 10px; margin-right: 44px;" />
@@ -175,7 +180,8 @@
<table>
<tr>
<td style="width:150px;vertical-align:top;text-align:right;padding-right:10px;font-weight:bold;">
{l s='Wholesale price:'}
{include file="controllers/products/multishop/checkbox.tpl" field="attribute_wholesale_price" type="default"}
<label>{l s='Wholesale price:'}</label>
</td>
<td style="padding-bottom:5px;">
{if $currency->format % 2 != 0}{$currency->sign}{/if}
@@ -185,7 +191,10 @@
</td>
</tr>
<tr>
<td style="width:150px;vertical-align:top;text-align:right;padding-right:10px;font-weight:bold;">{l s='Impact on price:'}</td>
<td style="width:150px;vertical-align:top;text-align:right;padding-right:10px;font-weight:bold;">
{include file="controllers/products/multishop/checkbox.tpl" field="attribute_price_impact" type="attribute_price_impact"}
<label>{l s='Impact on price:'}</label>
</td>
<td colspan="2" style="padding-bottom:5px;">
<select name="attribute_price_impact" id="attribute_price_impact" style="width: 140px;" onchange="check_impact(); calcImpactPriceTI();">
<option value="0">{l s='None'}</option>
@@ -210,7 +219,10 @@
</td>
</tr>
<tr>
<td style="width:150px;vertical-align:top;text-align:right;padding-right:10px;font-weight:bold;">{l s='Impact on weight:'}</td>
<td style="width:150px;vertical-align:top;text-align:right;padding-right:10px;font-weight:bold;">
{include file="controllers/products/multishop/checkbox.tpl" field="attribute_weight_impact" type="attribute_weight_impact"}
<label>{l s='Impact on weight:'}</label>
</td>
<td colspan="2" style="padding-bottom:5px;">
<select name="attribute_weight_impact" id="attribute_weight_impact" style="width: 140px;" onchange="check_weight_impact();">
<option value="0">{l s='None'}</option>
@@ -224,7 +236,10 @@
</td>
</tr>
<tr id="tr_unit_impact">
<td style="width:150px;vertical-align:top;text-align:right;padding-right:10px;font-weight:bold;">{l s='Impact on unit price :'}</td>
<td style="width:150px;vertical-align:top;text-align:right;padding-right:10px;font-weight:bold;">
{include file="controllers/products/multishop/checkbox.tpl" field="attribute_unit_impact" type="attribute_unit_impact"}
<label style="width: 100px; float: right">{l s='Impact on unit price :'}</label>
</td>
<td colspan="2" style="padding-bottom:5px;">
<select name="attribute_unit_impact" id="attribute_unit_impact" style="width: 140px;" onchange="check_unit_impact();">
<option value="0">{l s='None'}</option>
@@ -240,7 +255,8 @@
{if $ps_use_ecotax}
<tr>
<td style="width:150px;vertical-align:top;text-align:right;padding-right:10px;font-weight:bold;">
{l s='Eco-tax:'}
{include file="controllers/products/multishop/checkbox.tpl" field="attribute_ecotax" type="default"}
<label>{l s='Eco-tax:'}</label>
</td>
<td style="padding-bottom:5px;">{if $currency->format % 2 != 0}{$currency->sign}{/if}
<input type="text" size="3" name="attribute_ecotax" id="attribute_ecotax" value="0.00" onKeyUp="if (isArrowKey(event)) return ;this.value = this.value.replace(/,/g, '.');" />
@@ -251,6 +267,7 @@
{/if}
<tr>
<td style="width:150px;vertical-align:top;text-align:right;padding-right:10px;font-weight:bold;" class="col-left">
{include file="controllers/products/multishop/checkbox.tpl" field="attribute_minimal_quantity" type="default"}
<label>{l s='Minimum quantity:'}</label>
</td>
<td style="padding-bottom:5px;">
@@ -259,7 +276,8 @@
</td>
</tr>
<tr>
<td style="width:150px;vertical-align:top;text-align:right;padding-right:10px;font-weight:bold;" class="col-left" style="width:150px">
<td style="width:150px;vertical-align:top;text-align:right;padding-right:10px;font-weight:bold;" class="col-left">
{include file="controllers/products/multishop/checkbox.tpl" field="available_date_attribute" type="default"}
<label>{l s='Available date:'}</label>
</td>
<td style="padding-bottom:5px;">
@@ -282,7 +300,7 @@
</td>
</tr>
<tr>
<td style="width:150px">{l s='Image:'}</td>
<td style="width:150px"><label>{l s='Image:'}</label></td>
<td style="padding-bottom:5px;">
<ul id="id_image_attr">
{foreach from=$images key=k item=image}
@@ -298,7 +316,10 @@
</td>
</tr>
<tr>
<td style="width:150px">{l s='Default:'}<br /><br /></td>
<td style="width:150px">
{include file="controllers/products/multishop/checkbox.tpl" field="attribute_default" type="attribute_default"}
<label>{l s='Default:'}</label><br /><br />
</td>
<td style="padding-bottom:5px;">
<input type="checkbox" name="attribute_default" id="attribute_default" value="1" />
&nbsp;{l s='Make this the default combination for this product'}<br /><br />
@@ -44,9 +44,9 @@
ed.onInit.add(function(ed)
{
if (typeof load_tinymce_multishop[ed.id] != 'undefined')
if (typeof ProductMultishop.load_tinymce[ed.id] != 'undefined')
{
if (typeof load_tinymce_multishop[ed.id])
if (typeof ProductMultishop.load_tinymce[ed.id])
ed.hide();
else
ed.show();
@@ -26,7 +26,7 @@
{if isset($display_multishop_checkboxes) && $display_multishop_checkboxes}
<label style="float: none">
<input type="checkbox" style="vertical-align: text-bottom" onclick="$('input[name^=\'multishop_check[\']').attr('checked', this.checked); multishopCheckAllProductFields{$product_tab}()" />
<input type="checkbox" style="vertical-align: text-bottom" onclick="$('input[name^=\'multishop_check[\']').attr('checked', this.checked); ProductMultishop.checkAll{$product_tab}()" />
{l s='Check / uncheck all (you are editing this page for several shops, some fields like "name" or "price" are disabled, you have to check these fields in order to edit them for these shops)'}
</label>
{/if}
@@ -28,23 +28,23 @@
{if isset($multilang) && $multilang}
{if isset($only_checkbox)}
{foreach from=$languages item=language}
<input type="checkbox" name="multishop_check[{$field}][{$language.id_lang}]" value="1" onclick="multishopCheckProductField(this.checked, '{$field}_{$language.id_lang}', '{$type}')" {if !empty($multishop_check[$field][$language.id_lang])}checked="checked"{/if} />
<input type="checkbox" name="multishop_check[{$field}][{$language.id_lang}]" value="1" onclick="ProductMultishop.checkField(this.checked, '{$field}_{$language.id_lang}', '{$type}')" {if !empty($multishop_check[$field][$language.id_lang])}checked="checked"{/if} />
{/foreach}
{else}
<div class="multishop_product_checkbox">
{foreach from=$languages item=language}
<div class="multishop_lang_{$language.id_lang}" style="{if !$language.is_default}display: none;{/if}">
<input type="checkbox" name="multishop_check[{$field}][{$language.id_lang}]" value="1" onclick="multishopCheckProductField(this.checked, '{$field}_{$language.id_lang}', '{$type}')" {if !empty($multishop_check[$field][$language.id_lang])}checked="checked"{/if} />
<input type="checkbox" name="multishop_check[{$field}][{$language.id_lang}]" value="1" onclick="ProductMultishop.checkField(this.checked, '{$field}_{$language.id_lang}', '{$type}')" {if !empty($multishop_check[$field][$language.id_lang])}checked="checked"{/if} />
</div>
{/foreach}
</div>
{/if}
{else}
{if isset($only_checkbox)}
<input type="checkbox" name="multishop_check[{$field}]" value="1" onclick="multishopCheckProductField(this.checked, '{$field}', '{$type}')" {if !empty($multishop_check[$field])}checked="checked"{/if} />
<input type="checkbox" name="multishop_check[{$field}]" value="1" onclick="ProductMultishop.checkField(this.checked, '{$field}', '{$type}')" {if !empty($multishop_check[$field])}checked="checked"{/if} />
{else}
<div class="multishop_product_checkbox">
<input type="checkbox" name="multishop_check[{$field}]" value="1" onclick="multishopCheckProductField(this.checked, '{$field}', '{$type}')" {if !empty($multishop_check[$field])}checked="checked"{/if} />
<input type="checkbox" name="multishop_check[{$field}]" value="1" onclick="ProductMultishop.checkField(this.checked, '{$field}', '{$type}')" {if !empty($multishop_check[$field])}checked="checked"{/if} />
</div>
{/if}
{/if}
@@ -174,7 +174,10 @@ jQuery(document).ready(Customer.init);
</tr>
{if $ps_use_ecotax}
<tr>
<td class="col-left"><label>{l s='Eco-tax (tax incl.):'}</label></td>
<td class="col-left">
{include file="controllers/products/multishop/checkbox.tpl" field="ecot" type="default"}
<label>{l s='Eco-tax (tax incl.):'}</label>
</td>
<td>
{$currency->prefix}<input size="11" maxlength="14" id="ecotax" name="ecotax" type="text" value="{$product->ecotax|string_format:'%.2f'}" onkeyup="$('#priceType').val('TI');if (isArrowKey(event))return; calcPriceTE(); this.value = this.value.replace(/,/g, '.'); if (parseInt(this.value) > getE('priceTE').value) this.value = getE('priceTE').value; if (isNaN(this.value)) this.value = 0;" />{$currency->suffix}
<span style="margin-left:10px">({l s='already included in price'})</span>
+1 -1
View File
@@ -70,7 +70,6 @@ class CombinationCore extends ObjectModel
'ean13' => array('type' => self::TYPE_STRING, 'validate' => 'isEan13', 'size' => 13),
'upc' => array('type' => self::TYPE_STRING, 'validate' => 'isUpc', 'size' => 12),
'quantity' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'size' => 10),
'weight' => array('type' => self::TYPE_INT, 'validate' => 'isFloat'),
'reference' => array('type' => self::TYPE_STRING, 'size' => 32),
'supplier_reference' => array('type' => self::TYPE_STRING, 'size' => 32),
@@ -78,6 +77,7 @@ class CombinationCore extends ObjectModel
'wholesale_price' => array('type' => self::TYPE_FLOAT, 'shop' => true, 'validate' => 'isPrice', 'size' => 27),
'price' => array('type' => self::TYPE_FLOAT, 'shop' => true, 'validate' => 'isNegativePrice', 'size' => 20),
'ecotax' => array('type' => self::TYPE_FLOAT, 'shop' => true, 'validate' => 'isPrice', 'size' => 20),
'weight' => array('type' => self::TYPE_FLOAT, 'shop' => true, 'validate' => 'isFloat'),
'unit_price_impact' => array('type' => self::TYPE_FLOAT, 'shop' => true, 'validate' => 'isPrice', 'size' => 20),
'minimal_quantity' => array('type' => self::TYPE_INT, 'shop' => true, 'validate' => 'isUnsignedId', 'required' => true),
'default_on' => array('type' => self::TYPE_INT, 'shop' => true, 'validate' => 'isBool'),
+19 -19
View File
@@ -339,8 +339,9 @@ abstract class ObjectModelCore
|| ($type == self::FORMAT_COMMON && (!empty($data['shop']) || !empty($data['lang']))))
continue;
if (is_array($this->update_fields) && (empty($this->update_fields[$field]) || ($type == self::FORMAT_LANG && empty($this->update_fields[$field][$id_lang]))))
continue;
if (is_array($this->update_fields))
if ((!empty($data['lang']) || !empty($data['shop'])) && (empty($this->update_fields[$field]) || ($type == self::FORMAT_LANG && empty($this->update_fields[$field][$id_lang]))))
continue;
// Get field value, if value is multilang and field is empty, use value from default lang
$value = $this->$field;
@@ -433,12 +434,7 @@ abstract class ObjectModelCore
$this->date_upd = date('Y-m-d H:i:s');
// Database insertion
if ($null_values)
$result = Db::getInstance()->insert($this->def['table'], $this->getFields(), true);
else
$result = Db::getInstance()->insert($this->def['table'], $this->getFields());
if (!$result)
if (!$result = Db::getInstance()->insert($this->def['table'], $this->getFields(), $null_values))
return false;
// Get object id in database
@@ -450,10 +446,7 @@ abstract class ObjectModelCore
$fields = $this->getFieldsShop();
$fields[$this->def['primary']] = (int)$this->id;
$fields['id_shop'] = (int)$this->id_shop;
if ($null_values)
$result &= Db::getInstance()->insert($this->def['table'].'_shop', $fields, true);
else
$result &= Db::getInstance()->insert($this->def['table'].'_shop', $fields);
$result &= Db::getInstance()->insert($this->def['table'].'_shop', $fields, $null_values);
}
else if (!Shop::isFeatureActive() && Shop::isTableAssociated($this->def['table']))
$result &= $this->associateTo(Context::getContext()->shop->id);
@@ -515,12 +508,7 @@ abstract class ObjectModelCore
$this->date_upd = date('Y-m-d H:i:s');
// Database update
if ($null_values)
$result = Db::getInstance()->update($this->def['table'], $this->getFields(), '`'.pSQL($this->def['primary']).'` = '.(int)$this->id, 0, true);
else
$result = Db::getInstance()->update($this->def['table'], $this->getFields(), '`'.pSQL($this->def['primary']).'` = '.(int)$this->id);
if (!$result)
if (!$result = Db::getInstance()->update($this->def['table'], $this->getFields(), '`'.pSQL($this->def['primary']).'` = '.(int)$this->id, 0, $null_values))
return false;
// Database insertion for multishop fields related to the object
@@ -528,14 +516,26 @@ abstract class ObjectModelCore
{
$fields = $this->getFieldsShop();
$fields[$this->def['primary']] = (int)$this->id;
if (is_array($this->update_fields))
{
$update_fields = $this->update_fields;
$this->update_fields = null;
$all_fields = $this->getFieldsShop();
$all_fields[$this->def['primary']] = (int)$this->id;
$this->update_fields = $update_fields;
}
else
$all_fields = $fields;
foreach (Shop::getContextListShopID() as $id_shop)
{
$fields['id_shop'] = $id_shop;
$all_fields['id_shop'] = $id_shop;
$where = $this->def['primary'].' = '.(int)$this->id.' AND id_shop = '.(int)$id_shop;
if (Db::getInstance()->getValue('SELECT '.$this->def['primary'].' FROM '._DB_PREFIX_.$this->def['table'].'_shop WHERE '.$where))
$result &= Db::getInstance()->update($this->def['table'].'_shop', $fields, $where, 0, $null_values);
else
$result &= Db::getInstance()->insert($this->def['table'].'_shop', $fields, $null_values);
$result &= Db::getInstance()->insert($this->def['table'].'_shop', $all_fields, $null_values);
}
}
+17 -3
View File
@@ -1231,12 +1231,25 @@ class ProductCore extends ObjectModel
* @return array Update result
*/
public function updateAttribute($id_product_attribute, $wholesale_price, $price, $weight, $unit, $ecotax,
$id_images, $reference, $ean13, $default, $location = null, $upc = null, $minimal_quantity, $available_date)
$id_images, $reference, $ean13, $default, $location = null, $upc = null, $minimal_quantity = null, $available_date = null, $update_all_fields = true)
{
$combination = new Combination($id_product_attribute);
if (!$update_all_fields)
$combination->setFieldsToUpdate(array(
'price' => !is_null($price),
'wholesale_price' => !is_null($wholesale_price),
'ecotax' => !is_null($ecotax),
'weight' => !is_null($weight),
'unit_price_impact' => !is_null($unit),
'default_on' => !is_null($ecotax),
'minimal_quantity' => !is_null($minimal_quantity),
'available_date' => !is_null($available_date),
));
$price = str_replace(',', '.', $price);
$weight = str_replace(',', '.', $weight);
$combination = new Combination($id_product_attribute);
$combination->price = (float)$price;
$combination->wholesale_price = (float)$wholesale_price;
$combination->ecotax = (float)$ecotax;
@@ -1248,7 +1261,8 @@ class ProductCore extends ObjectModel
$combination->upc = pSQL($upc);
$combination->default_on = (int)$default;
$combination->minimal_quantity = (int)$minimal_quantity;
$combination->available_date = pSQL($available_date);
$combination->available_date = $available_date ? pSQL($available_date) : '0000-00-00';
$combination->save();
if (!empty($id_images))
+14 -15
View File
@@ -583,7 +583,7 @@ class AdminProductsControllerCore extends AdminController
if (Validate::isLoadedObject($product = $this->object))
{
if (!Tools::getIsset('attribute_price') || Tools::getIsset('attribute_price') == null)
if ($this->isProductFieldUpdated('attribute_price') && (!Tools::getIsset('attribute_price') || Tools::getIsset('attribute_price') == null))
$this->errors[] = Tools::displayError('Attribute price required.');
if (!Tools::getIsset('attribute_combination_list') || Tools::isEmpty(Tools::getValue('attribute_combination_list')))
$this->errors[] = Tools::displayError('You must add at least one attribute.');
@@ -605,28 +605,29 @@ class AdminProductsControllerCore extends AdminController
$this->errors[] = Tools::displayError('This attribute already exists.');
else
{
if (Validate::isDateFormat(Tools::getValue('available_date_attribute')))
if ($this->isProductFieldUpdated('available_date_attribute') && !Validate::isDateFormat(Tools::getValue('available_date_attribute')))
$this->errors[] = Tools::displayError('Invalid date format.');
else
{
$product->updateAttribute((int)$id_product_attribute,
Tools::getValue('attribute_wholesale_price'),
Tools::getValue('attribute_price') * Tools::getValue('attribute_price_impact'),
Tools::getValue('attribute_weight') * Tools::getValue('attribute_weight_impact'),
Tools::getValue('attribute_unity') * Tools::getValue('attribute_unit_impact'),
Tools::getValue('attribute_ecotax'),
$this->isProductFieldUpdated('attribute_wholesale_price') ? Tools::getValue('attribute_wholesale_price') : null,
$this->isProductFieldUpdated('attribute_price_impact') ? Tools::getValue('attribute_price') * Tools::getValue('attribute_price_impact') : null,
$this->isProductFieldUpdated('attribute_weight_impact') ? Tools::getValue('attribute_weight') * Tools::getValue('attribute_weight_impact') : null,
$this->isProductFieldUpdated('attribute_unit_impact') ? Tools::getValue('attribute_unity') * Tools::getValue('attribute_unit_impact') : null,
$this->isProductFieldUpdated('attribute_ecotax') ? Tools::getValue('attribute_ecotax') : null,
Tools::getValue('id_image_attr'),
Tools::getValue('attribute_reference'),
Tools::getValue('attribute_ean13'),
Tools::getValue('attribute_default'),
$this->isProductFieldUpdated('attribute_default') ? Tools::getValue('attribute_default') : null,
Tools::getValue('attribute_location'),
Tools::getValue('attribute_upc'),
Tools::getValue('attribute_minimal_quantity'),
Tools::getValue('available_date_attribute'));
$this->isProductFieldUpdated('attribute_minimal_quantity') ? Tools::getValue('attribute_minimal_quantity') : null,
$this->isProductFieldUpdated('available_date_attribute') ? Tools::getValue('available_date_attribute') : null,
false);
Hook::exec('actionProductAttributeUpdate', array('id_product_attribute' => (int)$id_product_attribute));
$this->updateDownloadProduct($product, 1, $id_product_attribute);
}
else
$this->errors[] = Tools::displayError('Invalid date format.');
}
}
else
@@ -1552,9 +1553,7 @@ class AdminProductsControllerCore extends AdminController
if ($this->isTabSubmitted('Shipping'))
$this->addCarriers();
if ($this->isTabSubmitted('Associations'))
{
$this->updateAccessories($object);
}
if ($this->isTabSubmitted('Accounting'))
$this->processAccounting();
@@ -1727,7 +1726,7 @@ class AdminProductsControllerCore extends AdminController
// Cache this condition to improve performances
static $is_activated = null;
if (is_null($is_activated))
$is_activated = Shop::isFeatureActive() && Shop::getContext() != Shop::CONTEXT_SHOP;
$is_activated = Shop::isFeatureActive() && Shop::getContext() != Shop::CONTEXT_SHOP && $this->id_object;
if (!$is_activated)
return true;
+1
View File
@@ -1447,6 +1447,7 @@ CREATE TABLE `PREFIX_product_attribute_shop` (
`wholesale_price` decimal(20,6) NOT NULL default '0.000000',
`price` decimal(20,6) NOT NULL default '0.000000',
`ecotax` decimal(17,6) NOT NULL default '0.00',
`weight` float NOT NULL default '0',
`unit_price_impact` decimal(17,2) NOT NULL default '0.00',
`default_on` tinyint(1) unsigned NOT NULL default '0',
`minimal_quantity` int(10) unsigned NOT NULL DEFAULT '1',
+2 -1
View File
@@ -61,13 +61,14 @@ CREATE TABLE `PREFIX_product_attribute_shop` (
`wholesale_price` decimal(20,6) NOT NULL default '0.000000',
`price` decimal(20,6) NOT NULL default '0.000000',
`ecotax` decimal(17,6) NOT NULL default '0.00',
`weight` float NOT NULL default '0',
`unit_price_impact` decimal(17,2) NOT NULL default '0.00',
`default_on` tinyint(1) unsigned NOT NULL default '0',
`minimal_quantity` int(10) unsigned NOT NULL DEFAULT '1',
`available_date` date NOT NULL,
PRIMARY KEY (`id_product_attribute`, `id_shop`)
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
INSERT INTO `PREFIX_product_attribute_shop` (`id_product_attribute`, `id_shop`, `wholesale_price`, `price`, `ecotax`, `unit_price_impact`, `default_on`, `minimal_quantity`, `available_date`) (SELECT `id_product_attribute`, (SELECT `value` FROM `PREFIX_configuration` WHERE `name` = 'PS_SHOP_DEFAULT'), `wholesale_price`, `price`, `ecotax`, `unit_price_impact`, `default_on`, `minimal_quantity`, `available_date` FROM `PREFIX_product_attribute`);
INSERT INTO `PREFIX_product_attribute_shop` (`id_product_attribute`, `id_shop`, `wholesale_price`, `price`, `ecotax`, `weight`, `unit_price_impact`, `default_on`, `minimal_quantity`, `available_date`) (SELECT `id_product_attribute`, (SELECT `value` FROM `PREFIX_configuration` WHERE `name` = 'PS_SHOP_DEFAULT'), `wholesale_price`, `price`, `ecotax`, `weight`, `unit_price_impact`, `default_on`, `minimal_quantity`, `available_date` FROM `PREFIX_product_attribute`);
INSERT INTO `PREFIX_attribute_shop` (`id_attribute`, `id_shop`) (SELECT a.id_attribute, c.id_shop FROM PREFIX_attribute_group_shop a LEFT JOIN PREFIX_shop_group b ON a.id_group_shop = b.id_shop_group INNER JOIN PREFIX_shop c ON b.id_shop_group = c.id_shop_group);
CREATE TABLE `PREFIX_attribute_shop` (
+116 -80
View File
@@ -398,6 +398,8 @@ product_tabs['Combinations'] = new function(){
self.bindDefault();
self.bindDelete();
self.bindToggleAddCombination();
if (display_multishop_checkboxes)
ProductMultishop.checkAllCombinations();
};
}
@@ -507,7 +509,7 @@ product_tabs['Seo'] = new function(){
displayFlags(languages, id_language, allowEmployeeFormLang);
if (display_multishop_checkboxes)
multishopCheckAllProductFieldsSeo();
ProductMultishop.checkAllSeo();
};
}
@@ -580,7 +582,7 @@ product_tabs['Prices'] = new function(){
self.bindDelete();
if (display_multishop_checkboxes)
multishopCheckAllProductFieldsPrice();
ProductMultishop.checkAllPrice();
};
}
@@ -716,7 +718,7 @@ product_tabs['Associations'] = new function(){
});
if (display_multishop_checkboxes)
multishopCheckAllProductFieldsAssociations();
ProductMultishop.checkAllAssociations();
};
}
@@ -931,7 +933,7 @@ product_tabs['Informations'] = new function(){
if (display_multishop_checkboxes)
{
multishopCheckAllProductFieldsInformations();
ProductMultishop.checkAllInformations();
var active_click = function()
{
if (!$('input[name=\'multishop_check[active]\']').attr('checked'))
@@ -1461,96 +1463,130 @@ function ajaxAction (url, action, success_callback, failure_callback){
});
};
var load_tinymce_multishop = {};
function multishopCheckProductField(checked, id, type)
var ProductMultishop = new function()
{
checked = !checked;
switch (type)
var self = this;
this.load_tinymce = {};
this.checkField = function(checked, id, type)
{
case 'tinymce' :
$('#'+id).attr('disabled', checked);
if (typeof load_tinymce_multishop[id] == 'undefined')
load_tinymce_multishop[id] = checked;
else
{
if (checked)
tinyMCE.get(id).hide();
checked = !checked;
switch (type)
{
case 'tinymce' :
$('#'+id).attr('disabled', checked);
if (typeof self.load_tinymce[id] == 'undefined')
self.load_tinymce[id] = checked;
else
tinyMCE.get(id).show();
}
break;
{
if (checked)
tinyMCE.get(id).hide();
else
tinyMCE.get(id).show();
}
break;
case 'radio' :
$('input[name=\''+id+'\']').attr('disabled', checked);
break;
case 'radio' :
$('input[name=\''+id+'\']').attr('disabled', checked);
break;
case 'show_price' :
if ($('input[name=\'available_for_order\']').attr('checked'))
checked = true;
$('input[name=\''+id+'\']').attr('disabled', checked);
break;
case 'show_price' :
if ($('input[name=\'available_for_order\']').attr('checked'))
checked = true;
$('input[name=\''+id+'\']').attr('disabled', checked);
break;
case 'price' :
$('#priceTE').attr('disabled', checked);
$('#priceTI').attr('disabled', checked);
break;
case 'price' :
$('#priceTE').attr('disabled', checked);
$('#priceTI').attr('disabled', checked);
break;
case 'unit_price' :
$('#unit_price').attr('disabled', checked);
$('#unity').attr('disabled', checked);
break;
case 'unit_price' :
$('#unit_price').attr('disabled', checked);
$('#unity').attr('disabled', checked);
break;
case 'category_box' :
$('#categories-treeview input[type=checkbox]').attr('disabled', checked);
break;
case 'attribute_price_impact' :
$('#attribute_price_impact').attr('disabled', checked);
$('#attribute_price').attr('disabled', checked);
$('#attribute_priceTI').attr('disabled', checked);
break;
default :
$('#'+id).attr('disabled', checked);
break;
}
}
case 'category_box' :
$('#categories-treeview input[type=checkbox]').attr('disabled', checked);
break;
function multishopCheckAllProductFieldsInformations()
{
multishopCheckProductField($('input[name=\'multishop_check[active]\']').attr('checked'), 'active', 'radio');
multishopCheckProductField($('input[name=\'multishop_check[visibility]\']').attr('checked'), 'visibility');
multishopCheckProductField($('input[name=\'multishop_check[available_for_order]\']').attr('checked'), 'available_for_order');
multishopCheckProductField($('input[name=\'multishop_check[show_price]\']').attr('checked'), 'show_price', 'show_price');
multishopCheckProductField($('input[name=\'multishop_check[online_only]\']').attr('checked'), 'online_only');
multishopCheckProductField($('input[name=\'multishop_check[condition]\']').attr('checked'), 'condition');
$.each(languages, function(k, v)
case 'attribute_weight_impact' :
$('#attribute_weight_impact').attr('disabled', checked);
$('#attribute_weight').attr('disabled', checked);
break;
case 'attribute_unit_impact' :
$('#attribute_unit_impact').attr('disabled', checked);
$('#attribute_unity').attr('disabled', checked);
break;
default :
$('#'+id).attr('disabled', checked);
break;
}
};
this.checkAllInformations = function()
{
multishopCheckProductField($('input[name=\'multishop_check[name]['+v.id_lang+']\']').attr('checked'), 'name_'+v.id_lang);
multishopCheckProductField($('input[name=\'multishop_check[description_short]['+v.id_lang+']\']').attr('checked'), 'description_short_'+v.id_lang, 'tinymce');
multishopCheckProductField($('input[name=\'multishop_check[description]['+v.id_lang+']\']').attr('checked'), 'description_'+v.id_lang, 'tinymce');
});
}
ProductMultishop.checkField($('input[name=\'multishop_check[active]\']').attr('checked'), 'active', 'radio');
ProductMultishop.checkField($('input[name=\'multishop_check[visibility]\']').attr('checked'), 'visibility');
ProductMultishop.checkField($('input[name=\'multishop_check[available_for_order]\']').attr('checked'), 'available_for_order');
ProductMultishop.checkField($('input[name=\'multishop_check[show_price]\']').attr('checked'), 'show_price', 'show_price');
ProductMultishop.checkField($('input[name=\'multishop_check[online_only]\']').attr('checked'), 'online_only');
ProductMultishop.checkField($('input[name=\'multishop_check[condition]\']').attr('checked'), 'condition');
$.each(languages, function(k, v)
{
ProductMultishop.checkField($('input[name=\'multishop_check[name]['+v.id_lang+']\']').attr('checked'), 'name_'+v.id_lang);
ProductMultishop.checkField($('input[name=\'multishop_check[description_short]['+v.id_lang+']\']').attr('checked'), 'description_short_'+v.id_lang, 'tinymce');
ProductMultishop.checkField($('input[name=\'multishop_check[description]['+v.id_lang+']\']').attr('checked'), 'description_'+v.id_lang, 'tinymce');
});
};
function multishopCheckAllProductFieldsPrice(checked)
{
multishopCheckProductField($('input[name=\'multishop_check[wholesale_price]\']').attr('checked'), 'wholesale_price');
multishopCheckProductField($('input[name=\'multishop_check[price]\']').attr('checked'), 'price', 'price');
multishopCheckProductField($('input[name=\'multishop_check[id_tax_rules_group]\']').attr('checked'), 'id_tax_rules_group');
multishopCheckProductField($('input[name=\'multishop_check[unit_price]\']').attr('checked'), 'unit_price', 'unit_price');
multishopCheckProductField($('input[name=\'multishop_check[on_sale]\']').attr('checked'), 'on_sale');
}
function multishopCheckAllProductFieldsSeo(checked)
{
$.each(languages, function(k, v)
this.checkAllPrice = function()
{
multishopCheckProductField($('input[name=\'multishop_check[meta_title]['+v.id_lang+']\']').attr('checked'), 'meta_title_'+v.id_lang);
multishopCheckProductField($('input[name=\'multishop_check[meta_description]['+v.id_lang+']\']').attr('checked'), 'meta_description_'+v.id_lang);
multishopCheckProductField($('input[name=\'multishop_check[meta_keywords]['+v.id_lang+']\']').attr('checked'), 'meta_keywords_'+v.id_lang);
multishopCheckProductField($('input[name=\'multishop_check[link_rewrite]['+v.id_lang+']\']').attr('checked'), 'link_rewrite_'+v.id_lang);
});
}
ProductMultishop.checkField($('input[name=\'multishop_check[wholesale_price]\']').attr('checked'), 'wholesale_price');
ProductMultishop.checkField($('input[name=\'multishop_check[price]\']').attr('checked'), 'price', 'price');
ProductMultishop.checkField($('input[name=\'multishop_check[id_tax_rules_group]\']').attr('checked'), 'id_tax_rules_group');
ProductMultishop.checkField($('input[name=\'multishop_check[unit_price]\']').attr('checked'), 'unit_price', 'unit_price');
ProductMultishop.checkField($('input[name=\'multishop_check[on_sale]\']').attr('checked'), 'on_sale');
ProductMultishop.checkField($('input[name=\'multishop_check[on_sale]\']').attr('checked'), 'ecotax');
};
function multishopCheckAllProductFieldsAssociations(checked)
{
multishopCheckProductField($('input[name=\'multishop_check[id_category_default]\']').attr('checked'), 'id_category_default');
multishopCheckProductField($('input[name=\'multishop_check[category_box]\']').attr('checked'), 'categories-treeview', 'category_box');
}
this.checkAllSeo = function()
{
$.each(languages, function(k, v)
{
ProductMultishop.checkField($('input[name=\'multishop_check[meta_title]['+v.id_lang+']\']').attr('checked'), 'meta_title_'+v.id_lang);
ProductMultishop.checkField($('input[name=\'multishop_check[meta_description]['+v.id_lang+']\']').attr('checked'), 'meta_description_'+v.id_lang);
ProductMultishop.checkField($('input[name=\'multishop_check[meta_keywords]['+v.id_lang+']\']').attr('checked'), 'meta_keywords_'+v.id_lang);
ProductMultishop.checkField($('input[name=\'multishop_check[link_rewrite]['+v.id_lang+']\']').attr('checked'), 'link_rewrite_'+v.id_lang);
});
};
this.checkAllAssociations = function()
{
ProductMultishop.checkField($('input[name=\'multishop_check[id_category_default]\']').attr('checked'), 'id_category_default');
ProductMultishop.checkField($('input[name=\'multishop_check[id_category_default]\']').attr('checked'), 'categories-treeview', 'category_box');
};
this.checkAllCombinations = function()
{
ProductMultishop.checkField($('input[name=\'multishop_check[attribute_wholesale_price]\']').attr('checked'), 'attribute_wholesale_price');
ProductMultishop.checkField($('input[name=\'multishop_check[attribute_price_impact]\']').attr('checked'), 'attribute_price_impact', 'attribute_price_impact');
ProductMultishop.checkField($('input[name=\'multishop_check[attribute_weight_impact]\']').attr('checked'), 'attribute_weight_impact', 'attribute_weight_impact');
ProductMultishop.checkField($('input[name=\'multishop_check[attribute_unit_impact]\']').attr('checked'), 'attribute_unit_impact', 'attribute_unit_impact');
ProductMultishop.checkField($('input[name=\'multishop_check[attribute_ecotax]\']').attr('checked'), 'attribute_ecotax');
ProductMultishop.checkField($('input[name=\'multishop_check[attribute_minimal_quantity]\']').attr('checked'), 'attribute_minimal_quantity');
ProductMultishop.checkField($('input[name=\'multishop_check[available_date_attribute]\']').attr('checked'), 'available_date_attribute');
ProductMultishop.checkField($('input[name=\'multishop_check[attribute_default]\']').attr('checked'), 'attribute_default');
};
};
var tabs_manager = new ProductTabsManager();
tabs_manager.setTabs(product_tabs);