Event.observe(window, 'load', function() { AddEditProductosListeners = function(e) { var el = e.element(); var del = el.hasClassName('spanDelete'); var id = el.identify(); if(del == true){ DeleteConjuntoPopup(id); return; } del = el.hasClassName('spanEdit'); if(del == true) EditConjuntoPopup(id); } if($('contenido')!= undefined) $('contenido').observe("click", AddEditProductosListeners); if($("addConjunto") != undefined) $('addConjunto').observe("click", function(){ AddConjuntoDiv(1); }); }); function AddConjuntoDiv(id){ grayOut(true); if(id == 0){ $('fview').hide(); grayOut(false); return; } $('fview').show(); new Ajax.Request(WEB_ROOT+'/ajax/conjunto-tallas.php',{ method:'post', parameters: {type: "addConjunto"}, onSuccess: function(transport){ var response = transport.responseText || "no response text"; FViewOffSet(response); Event.observe($('btnSave'), "click", AddConjunto); Event.observe($('fviewclose'), "click", function(){ HideFview(); }); }, onFailure: function(){ alert('Something went wrong...') } }); }//AddConjuntoDiv function AddConjunto(){ $("type").value = "saveConjunto"; new Ajax.Request(WEB_ROOT+'/ajax/conjunto-tallas.php', { method:'post', parameters: $('frmAgregarConjunto').serialize(), onSuccess: function(transport){ var response = transport.responseText || "no response text"; var splitResponse = response.split("[#]"); if(splitResponse[0] == "fail"){ ShowStatusPopUp(splitResponse[1]); }else{ ShowStatusPopUp(splitResponse[1]); $('contenido').innerHTML = splitResponse[2]; HideFview(); } }, onFailure: function(){ alert('Something went wrong...') } }); }//AddConjunto function EditConjuntoPopup(id){ grayOut(true); $('fview').show(); if(id == 0){ $('fview').hide(); grayOut(false); return; } new Ajax.Request(WEB_ROOT+'/ajax/conjunto-tallas.php',{ method:'post', parameters: {type: "editConjunto", conTallaId:id}, onSuccess: function(transport){ var response = transport.responseText || "no response text"; FViewOffSet(response); Event.observe($('closePopUpDiv'), "click", function(){ HideFview(); }); Event.observe($('btnUpdate'), "click", EditConjunto); }, onFailure: function(){ alert('Something went wrong...') } }); }//EditConjuntoPopup function EditConjunto(){ $("type").value = "saveEditConjunto"; new Ajax.Request(WEB_ROOT+'/ajax/conjunto-tallas.php', { method:'post', parameters: $('frmEditarConjunto').serialize(), onSuccess: function(transport){ var response = transport.responseText || "no response text"; var splitResponse = response.split("[#]"); if(splitResponse[0] == "fail") { ShowStatusPopUp(splitResponse[1]) } else { ShowStatusPopUp(splitResponse[1]) $('contenido').innerHTML = splitResponse[2]; HideFview(); } }, onFailure: function(){ alert('Something went wrong...') } }); }//EditConjunto function DeleteConjuntoPopup(id){ var message = "Realmente deseas eliminar este conjunto?"; if(!confirm(message)){ return; } new Ajax.Request(WEB_ROOT+'/ajax/conjunto-tallas.php',{ method:'post', parameters: {type: "deleteConjunto", conTallaId: 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...') } }); }//DeleteConjuntoPopup /*** TALLAS ***/ function AddTalla() { var form = $("formName").value; $("type").value = "saveTallas"; new Ajax.Request(WEB_ROOT+'/ajax/conjunto-tallas.php', { method:'post', parameters: $(form).serialize(true), onSuccess: function(transport){ var response = transport.responseText || "no response text"; var splitResponse = response.split("[#]"); AddTalla2(); }, onFailure: function(){ alert('Something went wrong...') } }); } function AddTalla2() { new Ajax.Request(WEB_ROOT+'/ajax/conjunto-tallas.php', { method:'post', parameters: {type:"addTalla"}, onSuccess: function(transport){ var response = transport.responseText || "no response text"; var splitResponse = response.split("[#]"); if(splitResponse[0] == "ok") { $('listTallas').innerHTML = splitResponse[1]; } else { alert("Ocurrio un error al agregar la talla"); } }, onFailure: function(){ alert('Something went wrong...') } }); } function DelTalla(id) { var form = $("formName").value; $("type").value = "saveTallas"; new Ajax.Request(WEB_ROOT+'/ajax/conjunto-tallas.php', { method:'post', parameters: $(form).serialize(true), onSuccess: function(transport){ var response = transport.responseText || "no response text"; var splitResponse = response.split("[#]"); DelTalla2(id); }, onFailure: function(){ alert('Something went wrong...') } }); } function DelTalla2(id) { new Ajax.Request(WEB_ROOT+'/ajax/conjunto-tallas.php', { method:'post', parameters: {type:"delTalla", k:id}, onSuccess: function(transport){ var response = transport.responseText || "no response text"; var splitResponse = response.split("[#]"); if(splitResponse[0] == "ok") { $('listTallas').innerHTML = splitResponse[1]; } else { alert("Ocurrio un error al agregar la talla"); } }, onFailure: function(){ alert('Something went wrong...') } }); }