// added pack.tpl in AdminProductsController

This commit is contained in:
lLefevre
2011-12-16 13:57:27 +00:00
parent 6e3da1b627
commit b1a68fd7c8
7 changed files with 495 additions and 589 deletions
-158
View File
@@ -224,79 +224,6 @@ function displayTabProductById(el, id, selected)
});
}
function addPackItem()
{
if ($('#curPackItemId').val() == '' || $('#curPackItemName').val() == '')
{
alert(msg_select_one);
return false;
}
else if ($('#curPackItemId').val() == '' || $('#curPackItemQty').val() == '')
{
alert(msg_set_quantity);
return false;
}
var lineDisplay = $('#curPackItemQty').val()+ 'x ' +$('#curPackItemName').val();
var divContent = $('#divPackItems').html();
divContent += lineDisplay;
divContent += '<span onclick="delPackItem(' + $('#curPackItemId').val() + ');" style="cursor: pointer;"><img src="../img/admin/delete.gif" /></span><br />';
// QTYxID-QTYxID
var line = $('#curPackItemQty').val()+ 'x' +$('#curPackItemId').val();
$('#inputPackItems').val($('#inputPackItems').val() + line + '-');
$('#divPackItems').html(divContent);
$('#namePackItems').val($('#namePackItems').val() + lineDisplay + '¤');
$('#curPackItemId').val('');
$('#curPackItemName').val('');
$('#curPackItemName').setOptions({
extraParams: {
excludeIds : getSelectedIds()
}
});
}
function delPackItem(id)
{
var reg = new RegExp('-', 'g');
var regx = new RegExp('x', 'g');
var div = getE('divPackItems');
var input = getE('inputPackItems');
var name = getE('namePackItems');
var select = getE('curPackItemId');
var select_quantity = getE('curPackItemQty');
var inputCut = input.value.split(reg);
var nameCut = name.value.split(new RegExp('¤', 'g'));
input.value = '';
name.value = '';
div.innerHTML = '';
for (var i = 0; i < inputCut.length; ++i)
if (inputCut[i])
{
var inputQty = inputCut[i].split(regx);
if (inputQty[1] != id)
{
input.value += inputCut[i] + '-';
name.value += nameCut[i] + '¤';
div.innerHTML += nameCut[i] + ' <span onclick="delPackItem(' + inputQty[1] + ');" style="cursor: pointer;"><img src="../img/admin/delete.gif" /></span><br />';
}
}
$('#curPackItemName').setOptions({
extraParams: {
excludeIds : getSelectedIds()
}
});
}
/**
* Update the manufacturer select element with the list of existing manufacturers
*/
@@ -329,93 +256,8 @@ function getManufacturers()
/* function autocomplete */
urlToCall = null;
function getSelectedIds()
{
// input lines QTY x ID-
var ids = id_product + ',';
ids += $('#inputPackItems').val().replace(/\\d+x/g, '').replace(/\-/g,',');
ids = ids.replace(/\,$/,'');
return ids;
}
$(document).ready(function() {
updateCurrentText();
updateFriendlyURL();
$(function() {
$('#curPackItemName')
.autocomplete('ajax_products_list.php', {
delay: 100,
minChars: 1,
autoFill: true,
max:20,
matchContains: true,
mustMatch:true,
scroll:false,
cacheLength:0,
// param multipleSeparator:'||' ajouté à cause de bug dans lib autocomplete
multipleSeparator:'||',
formatItem: function(item) {
return item[1]+' - '+item[0];
}
}).result(function(event, item){
$('#curPackItemId').val(item[1]);
});
$('#curPackItemName').setOptions({
extraParams: {
excludeIds : getSelectedIds(), excludeVirtuals : 1
}
});
});
$("#is_virtual_good").change(function(e)
{
$("#virtual_good").toggle();
});
if ($("#is_virtual_good").attr("checked"))
{
$("#virtual_good").show();
$("#virtual_good_more").show();
}
if ( $("input[name=is_virtual_file]:checked").val() == 1)
{
$("#virtual_good_more").show();
$("#virtual_good_attributes").show();
$("#is_virtual_file_product").show();
}
else
{
$("#virtual_good_more").hide();
$("#virtual_good_attributes").hide();
$("#is_virtual_file_product").hide();
}
$("input[name=is_virtual_file]").live("change", function() {
if($(this).val() == "1")
{
$("#virtual_good_more").show();
$("#virtual_good_attributes").show();
$("#is_virtual_file_product").show();
}
else
{
$("#virtual_good_more").hide();
$("#virtual_good_attributes").hide();
$("#is_virtual_file_product").hide();
}
});
$("input[name=is_virtual_good]").live("change", function() {
if($(this).attr("checked"))
{
$("#is_virtual").val(1);
}
else
{
$("#is_virtual").val(0);
}
});
});