113 lines
2.6 KiB
JavaScript
Executable File
113 lines
2.6 KiB
JavaScript
Executable File
Event.observe(window, 'load', function() {
|
|
|
|
AddEditProductosListeners = function(e) {
|
|
|
|
var el = e.element();
|
|
var del = el.hasClassName('spanDelete');
|
|
var id = el.identify();
|
|
|
|
if(del == true){
|
|
DeleteProductoPopup(id);
|
|
return;
|
|
}
|
|
|
|
}
|
|
|
|
$('contenido').observe("click", AddEditProductosListeners);
|
|
|
|
});
|
|
|
|
function DeleteProductoPopup(id){
|
|
|
|
var message = "Realmente deseas eliminar este producto?";
|
|
|
|
if(!confirm(message)){
|
|
return;
|
|
}
|
|
|
|
new Ajax.Request(WEB_ROOT+'/ajax/productos.php',{
|
|
method:'post',
|
|
parameters: {type: "deleteProducto", productoId: id},
|
|
onSuccess: function(transport){
|
|
var response = transport.responseText || "no response text";
|
|
var splitResponse = response.split("[#]");
|
|
|
|
ShowStatus(splitResponse[1]);
|
|
$('contenido').innerHTML = splitResponse[2];
|
|
HideFview();
|
|
},
|
|
|
|
onFailure: function(){ alert('Something went wrong...') }
|
|
|
|
});
|
|
|
|
}//DeleteProductoPopup
|
|
|
|
function LoadSubcats(){
|
|
|
|
var catId = $("prodCatId").value;
|
|
|
|
$("enumSubcats").innerHTML = '';
|
|
$("txtSubcat").style.display = "none";
|
|
|
|
new Ajax.Request(WEB_ROOT+'/ajax/productos.php',{
|
|
method:'post',
|
|
parameters: {type:"loadSubcats", prodCatId:catId},
|
|
onLoading: function(){
|
|
$("loadSubcat").style.display = "";
|
|
$("loadSubcat").innerHTML = LOADER;
|
|
},
|
|
onSuccess: function(transport){
|
|
var response = transport.responseText || "no response text";
|
|
var splitResponse = response.split("[#]");
|
|
|
|
$("loadSubcat").innerHTML = "";
|
|
|
|
if(splitResponse[0] == "ok"){
|
|
$("txtSubcat").style.display = "";
|
|
$("enumSubcats").innerHTML = splitResponse[1];
|
|
}
|
|
|
|
},
|
|
onFailure: function(){ alert('Something went wrong...') }
|
|
});
|
|
|
|
}//LoadSubcats
|
|
|
|
function Search()
|
|
{
|
|
var vWord = $('word').value;
|
|
var codigoBarra = $('codigoBarra').value;
|
|
var vProdCatId = $("idProdCat").value;
|
|
var vProvId = $("proveedorId2").value;
|
|
var vNoProv = $("noProv").value;
|
|
|
|
new Ajax.Request(WEB_ROOT+'/ajax/productos.php',
|
|
{
|
|
method:'post',
|
|
parameters: {codigoBarra: codigoBarra, word: vWord, prodCatId: vProdCatId, proveedorId2:vProvId, noProveedor:vNoProv, type: "search"},
|
|
onLoading: function(){
|
|
$('loadBusqueda').show();
|
|
$('contenido').innerHTML = '';
|
|
},
|
|
onSuccess: function(transport){
|
|
var response = transport.responseText || "no response text";
|
|
|
|
$('loadBusqueda').hide();
|
|
$('contenido').innerHTML = response;
|
|
},
|
|
onFailure: function(){ alert('Something went wrong...') }
|
|
});
|
|
}
|
|
|
|
function CheckKey(e){
|
|
|
|
if(window.event)
|
|
keyCode = window.event.keyCode;
|
|
else if(e)
|
|
keyCode=e.which;
|
|
|
|
if(keyCode == 13)
|
|
Search();
|
|
|
|
}//CheckKey
|