diff --git a/admin-dev/themes/default/template/controllers/products/combinations.tpl b/admin-dev/themes/default/template/controllers/products/combinations.tpl
index 57665673b..248e76182 100644
--- a/admin-dev/themes/default/template/controllers/products/combinations.tpl
+++ b/admin-dev/themes/default/template/controllers/products/combinations.tpl
@@ -307,7 +307,7 @@
|
-
+
|
diff --git a/js/admin-products.js b/js/admin-products.js
index 30a0e8d1d..1b5c55d1f 100644
--- a/js/admin-products.js
+++ b/js/admin-products.js
@@ -94,7 +94,7 @@ product_tabs['Combinations'] = new function(){
$("#attribute_wholesale_price_full").hide();
$("#attribute_wholesale_price_blank").show();
}
- fillCombination(
+ self.fillCombination(
wholesale_price,
price,
weight,
@@ -223,6 +223,176 @@ product_tabs['Combinations'] = new function(){
});
};
+ this.fillCombination = function(wholesale_price, price_impact, weight_impact, unit_impact, reference,
+ ean, quantity, image, old_attr, id_product_attribute, default_attribute, eco_tax, upc, minimal_quantity, available_date,
+ virtual_product_name_attribute, virtual_product_filename_attribute, virtual_product_nb_downloable, virtual_product_expiration_date_attribute,
+ virtual_product_nb_days, is_shareable)
+ {
+ var link = '';
+ self.init_elems();
+ $('#stock_mvt_attribute').show();
+ $('#initial_stock_attribute').hide();
+ $('#attribute_quantity').html(quantity);
+ $('#attribute_quantity').show();
+ $('#attr_qty_stock').show();
+
+ $('#attribute_minimal_quantity').val(minimal_quantity);
+
+ getE('attribute_reference').value = reference;
+
+ getE('virtual_product_name_attribute').value = virtual_product_name_attribute;
+ getE('virtual_product_nb_downloable_attribute').value = virtual_product_nb_downloable;
+ getE('virtual_product_expiration_date_attribute').value = virtual_product_nb_downloable;
+ getE('virtual_product_expiration_date_attribute').value = virtual_product_expiration_date_attribute;
+ getE('virtual_product_nb_days_attribute').value = virtual_product_nb_days;
+
+ getE('attribute_ean13').value = ean;
+ getE('attribute_upc').value = upc;
+ getE('attribute_wholesale_price').value = Math.abs(wholesale_price);
+ getE('attribute_price').value = ps_round(Math.abs(price_impact), 2);
+ getE('attribute_priceTEReal').value = Math.abs(price_impact);
+ getE('attribute_weight').value = Math.abs(weight_impact);
+ getE('attribute_unity').value = Math.abs(unit_impact);
+ if ($('#attribute_ecotax').length != 0)
+ getE('attribute_ecotax').value = eco_tax;
+
+ if (default_attribute == 1)
+ getE('attribute_default').checked = true;
+ else
+ getE('attribute_default').checked = false;
+
+ if (price_impact < 0)
+ {
+ getE('attribute_price_impact').options[getE('attribute_price_impact').selectedIndex].value = -1;
+ getE('attribute_price_impact').selectedIndex = 2;
+ }
+ else if (!price_impact)
+ {
+ getE('attribute_price_impact').options[getE('attribute_price_impact').selectedIndex].value = 0;
+ getE('attribute_price_impact').selectedIndex = 0;
+ }
+ else if (price_impact > 0)
+ {
+ getE('attribute_price_impact').options[getE('attribute_price_impact').selectedIndex].value = 1;
+ getE('attribute_price_impact').selectedIndex = 1;
+ }
+ if (weight_impact < 0)
+ {
+ getE('attribute_weight_impact').options[getE('attribute_weight_impact').selectedIndex].value = -1;
+ getE('attribute_weight_impact').selectedIndex = 2;
+ }
+ else if (!weight_impact)
+ {
+ getE('attribute_weight_impact').options[getE('attribute_weight_impact').selectedIndex].value = 0;
+ getE('attribute_weight_impact').selectedIndex = 0;
+ }
+ else if (weight_impact > 0)
+ {
+ getE('attribute_weight_impact').options[getE('attribute_weight_impact').selectedIndex].value = 1;
+ getE('attribute_weight_impact').selectedIndex = 1;
+ }
+ if (unit_impact < 0)
+ {
+ getE('attribute_unit_impact').options[getE('attribute_unit_impact').selectedIndex].value = -1;
+ getE('attribute_unit_impact').selectedIndex = 2;
+ }
+ else if (!unit_impact)
+ {
+ getE('attribute_unit_impact').options[getE('attribute_unit_impact').selectedIndex].value = 0;
+ getE('attribute_unit_impact').selectedIndex = 0;
+ }
+ else if (unit_impact > 0)
+ {
+ getE('attribute_unit_impact').options[getE('attribute_unit_impact').selectedIndex].value = 1;
+ getE('attribute_unit_impact').selectedIndex = 1;
+ }
+
+ if (is_shareable > 0)
+ $("#virtual_product_is_shareable_attribute").attr("checked", "checked");
+
+ if (id_product_attribute != '' && virtual_product_filename_attribute != '')
+ $("#gethtmlink").show();
+ link = $("#make_downloadable_product_attribute").attr('href');
+ $("#make_downloadable_product_attribute").attr('href', link+"&id_product_attribute="+id_product_attribute);
+
+ $("#virtual_product_filename_attribute").val(virtual_product_filename_attribute);
+ $("#add_new_combination").show();
+
+ /* Reset all combination images */
+ combinationImages = $('#id_image_attr').find("input[id^=id_image_attr_]");
+ combinationImages.each(function() {
+ this.checked = false;
+ });
+
+ /* Check combination images */
+ if (typeof(combination_images[id_product_attribute]) != 'undefined')
+ for (i = 0; i < combination_images[id_product_attribute].length; i++)
+ $('#id_image_attr_' + combination_images[id_product_attribute][i]).attr('checked', 'checked');
+ check_impact();
+ check_weight_impact();
+ check_unit_impact();
+
+ var elem = getE('product_att_list');
+
+ for (var i = 0; i < old_attr.length; i++)
+ {
+ var opt = document.createElement('option');
+ opt.text = old_attr[i++];
+ opt.value = old_attr[i];
+ try {
+ elem.add(opt, null);
+ }
+ catch(ex) {
+ elem.add(opt);
+ }
+ }
+ getE('id_product_attribute').value = id_product_attribute;
+
+ $('#available_date_attribute').val(available_date);
+ };
+
+ this.init_elems = function()
+ {
+ var impact = getE('attribute_price_impact');
+ var impact2 = getE('attribute_weight_impact');
+ var elem = getE('product_att_list');
+
+ if (elem.length)
+ for (i = elem.length - 1; i >= 0; i--)
+ if (elem[i])
+ elem.remove(i);
+
+ $('input[name="id_image_attr[]"]').each(function (){
+ $(this).attr('checked', false);
+ });
+
+ $('#attribute_default').attr('checked', false);
+
+ getE('attribute_price_impact').selectedIndex = 0;
+ getE('attribute_weight_impact').selectedIndex = 0;
+ getE('attribute_unit_impact').selectedIndex = 0;
+ $('#span_unit_impact').hide();
+ $('#unity_third').html($('#unity_second').html());
+
+ if ($('#unity').is())
+ if ($('#unity').get(0).value.length > 0)
+ $('#tr_unit_impact').show();
+ else
+ $('#tr_unit_impact').hide();
+ try
+ {
+ if (impact.options[impact.selectedIndex].value == 0)
+ $('#span_impact').hide();
+ if (impact2.options[impact.selectedIndex].value == 0)
+ getE('span_weight_impact').style.display = 'none';
+ }
+ catch (e)
+ {
+ $('#span_impact').hide();
+ getE('span_weight_impact').style.display = 'none';
+ }
+ };
+
this.onReady = function(){
self.bindEdit();
self.bindDefault();
diff --git a/js/attributesBack.js b/js/attributesBack.js
index 600a55fdc..7499856ec 100644
--- a/js/attributesBack.js
+++ b/js/attributesBack.js
@@ -26,133 +26,6 @@
var storeUsedGroups = {};
-function fillCombination(wholesale_price, price_impact, weight_impact, unit_impact, reference,
-ean, quantity, image, old_attr, id_product_attribute, default_attribute, eco_tax, upc, minimal_quantity, available_date,
-virtual_product_name_attribute, virtual_product_filename_attribute, virtual_product_nb_downloable, virtual_product_expiration_date_attribute,
-virtual_product_nb_days, is_shareable)
-{
- var link = '';
- init_elems();
- $('#stock_mvt_attribute').show();
- $('#initial_stock_attribute').hide();
- $('#attribute_quantity').html(quantity);
- $('#attribute_quantity').show();
- $('#attr_qty_stock').show();
-
- $('#attribute_minimal_quantity').val(minimal_quantity);
-
- getE('attribute_reference').value = reference;
-
- getE('virtual_product_name_attribute').value = virtual_product_name_attribute;
- getE('virtual_product_nb_downloable_attribute').value = virtual_product_nb_downloable;
- getE('virtual_product_expiration_date_attribute').value = virtual_product_nb_downloable;
- getE('virtual_product_expiration_date_attribute').value = virtual_product_expiration_date_attribute;
- getE('virtual_product_nb_days_attribute').value = virtual_product_nb_days;
-
- getE('attribute_ean13').value = ean;
- getE('attribute_upc').value = upc;
- getE('attribute_wholesale_price').value = Math.abs(wholesale_price);
- getE('attribute_price').value = ps_round(Math.abs(price_impact), 2);
- getE('attribute_priceTEReal').value = Math.abs(price_impact);
- getE('attribute_weight').value = Math.abs(weight_impact);
- getE('attribute_unity').value = Math.abs(unit_impact);
- if ($('#attribute_ecotax').length != 0)
- getE('attribute_ecotax').value = eco_tax;
-
- if (default_attribute == 1)
- getE('attribute_default').checked = true;
- else
- getE('attribute_default').checked = false;
-
- if (price_impact < 0)
- {
- getE('attribute_price_impact').options[getE('attribute_price_impact').selectedIndex].value = -1;
- getE('attribute_price_impact').selectedIndex = 2;
- }
- else if (!price_impact)
- {
- getE('attribute_price_impact').options[getE('attribute_price_impact').selectedIndex].value = 0;
- getE('attribute_price_impact').selectedIndex = 0;
- }
- else if (price_impact > 0)
- {
- getE('attribute_price_impact').options[getE('attribute_price_impact').selectedIndex].value = 1;
- getE('attribute_price_impact').selectedIndex = 1;
- }
- if (weight_impact < 0)
- {
- getE('attribute_weight_impact').options[getE('attribute_weight_impact').selectedIndex].value = -1;
- getE('attribute_weight_impact').selectedIndex = 2;
- }
- else if (!weight_impact)
- {
- getE('attribute_weight_impact').options[getE('attribute_weight_impact').selectedIndex].value = 0;
- getE('attribute_weight_impact').selectedIndex = 0;
- }
- else if (weight_impact > 0)
- {
- getE('attribute_weight_impact').options[getE('attribute_weight_impact').selectedIndex].value = 1;
- getE('attribute_weight_impact').selectedIndex = 1;
- }
- if (unit_impact < 0)
- {
- getE('attribute_unit_impact').options[getE('attribute_unit_impact').selectedIndex].value = -1;
- getE('attribute_unit_impact').selectedIndex = 2;
- }
- else if (!unit_impact)
- {
- getE('attribute_unit_impact').options[getE('attribute_unit_impact').selectedIndex].value = 0;
- getE('attribute_unit_impact').selectedIndex = 0;
- }
- else if (unit_impact > 0)
- {
- getE('attribute_unit_impact').options[getE('attribute_unit_impact').selectedIndex].value = 1;
- getE('attribute_unit_impact').selectedIndex = 1;
- }
-
- if (is_shareable > 0)
- $("#virtual_product_is_shareable_attribute").attr("checked", "checked");
-
- if (id_product_attribute != '' && virtual_product_filename_attribute != '')
- $("#gethtmlink").show();
- link = $("#make_downloadable_product_attribute").attr('href');
- $("#make_downloadable_product_attribute").attr('href', link+"&id_product_attribute="+id_product_attribute);
-
- $("#virtual_product_filename_attribute").val(virtual_product_filename_attribute);
- $("#add_new_combination").show();
-
- /* Reset all combination images */
- combinationImages = $('#id_image_attr').find("input[id^=id_image_attr_]");
- combinationImages.each(function() {
- this.checked = false;
- });
-
- /* Check combination images */
- if (typeof(combination_images[id_product_attribute]) != 'undefined')
- for (i = 0; i < combination_images[id_product_attribute].length; i++)
- $('#id_image_attr_' + combination_images[id_product_attribute][i]).attr('checked', 'checked');
- check_impact();
- check_weight_impact();
- check_unit_impact();
-
- var elem = getE('product_att_list');
-
- for (var i = 0; i < old_attr.length; i++)
- {
- var opt = document.createElement('option');
- opt.text = old_attr[i++];
- opt.value = old_attr[i];
- try {
- elem.add(opt, null);
- }
- catch(ex) {
- elem.add(opt);
- }
- }
- getE('id_product_attribute').value = id_product_attribute;
-
- $('#available_date_attribute').val(available_date);
-}
function populate_attrs()
{
@@ -209,48 +82,6 @@ function check_unit_impact()
$('#span_unit_impact').show();
}
-function init_elems()
-{
- var impact = getE('attribute_price_impact');
- var impact2 = getE('attribute_weight_impact');
- var elem = getE('product_att_list');
-
- if (elem.length)
- for (i = elem.length - 1; i >= 0; i--)
- if (elem[i])
- elem.remove(i);
-
- $('input[name="id_image_attr[]"]').each(function (){
- $(this).attr('checked', false);
- });
-
- $('#attribute_default').attr('checked', false);
-
- getE('attribute_price_impact').selectedIndex = 0;
- getE('attribute_weight_impact').selectedIndex = 0;
- getE('attribute_unit_impact').selectedIndex = 0;
- $('#span_unit_impact').hide();
- $('#unity_third').html($('#unity_second').html());
-
- if ($('#unity').is())
- if ($('#unity').get(0).value.length > 0)
- $('#tr_unit_impact').show();
- else
- $('#tr_unit_impact').hide();
- try
- {
- if (impact.options[impact.selectedIndex].value == 0)
- $('#span_impact').hide();
- if (impact2.options[impact.selectedIndex].value == 0)
- getE('span_weight_impact').style.display = 'none';
- }
- catch (e)
- {
- $('#span_impact').hide();
- getE('span_weight_impact').style.display = 'none';
- }
-}
-
function attr_selectall()
{
var elem = getE('product_att_list');