Primer commit del sistema avantika sin cambios
This commit is contained in:
159
javascript/motivos.js
Executable file
159
javascript/motivos.js
Executable file
@@ -0,0 +1,159 @@
|
||||
Event.observe(window, 'load', function() {
|
||||
|
||||
AddEditProductosListeners = function(e) {
|
||||
|
||||
var el = e.element();
|
||||
var del = el.hasClassName('spanDelete');
|
||||
var id = el.identify();
|
||||
|
||||
if(del == true){
|
||||
DeleteMotivoPopup(id);
|
||||
return;
|
||||
}
|
||||
|
||||
del = el.hasClassName('spanEdit');
|
||||
|
||||
if(del == true)
|
||||
EditMotivoPopup(id);
|
||||
|
||||
}
|
||||
|
||||
if($('contenido')!= undefined)
|
||||
$('contenido').observe("click", AddEditProductosListeners);
|
||||
|
||||
if($("addMotivo") != undefined)
|
||||
$('addMotivo').observe("click", function(){ AddMotivoDiv(1); });
|
||||
|
||||
});
|
||||
|
||||
function AddMotivoDiv(id){
|
||||
|
||||
grayOut(true);
|
||||
|
||||
if(id == 0){
|
||||
$('fview').hide();
|
||||
grayOut(false);
|
||||
return;
|
||||
}
|
||||
$('fview').show();
|
||||
|
||||
new Ajax.Request(WEB_ROOT+'/ajax/motivos.php',{
|
||||
method:'post',
|
||||
parameters: {type: "addMotivo"},
|
||||
onSuccess: function(transport){
|
||||
var response = transport.responseText || "no response text";
|
||||
FViewOffSet(response);
|
||||
Event.observe($('btnSave'), "click", AddMotivo);
|
||||
Event.observe($('fviewclose'), "click", function(){ HideFview(); });
|
||||
},
|
||||
|
||||
onFailure: function(){ alert('Something went wrong...') }
|
||||
|
||||
});
|
||||
|
||||
}//AddMotivoDiv
|
||||
|
||||
function AddMotivo(){
|
||||
|
||||
new Ajax.Request(WEB_ROOT+'/ajax/motivos.php',
|
||||
{
|
||||
method:'post',
|
||||
parameters: $('frmAgregarMotivo').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...') }
|
||||
|
||||
});
|
||||
|
||||
}//AddMotivo
|
||||
|
||||
function EditMotivoPopup(id){
|
||||
|
||||
grayOut(true);
|
||||
$('fview').show();
|
||||
if(id == 0){
|
||||
$('fview').hide();
|
||||
grayOut(false);
|
||||
return;
|
||||
}
|
||||
|
||||
new Ajax.Request(WEB_ROOT+'/ajax/motivos.php',{
|
||||
method:'post',
|
||||
parameters: {type: "editMotivo", motivoId:id},
|
||||
onSuccess: function(transport){
|
||||
var response = transport.responseText || "no response text";
|
||||
|
||||
FViewOffSet(response);
|
||||
Event.observe($('closePopUpDiv'), "click", function(){ HideFview(); });
|
||||
Event.observe($('btnUpdate'), "click", EditMotivo);
|
||||
},
|
||||
|
||||
onFailure: function(){ alert('Something went wrong...') }
|
||||
|
||||
});
|
||||
|
||||
}//EditMotivoPopup
|
||||
|
||||
function EditMotivo(){
|
||||
|
||||
var form = $('frmEditarMotivo').serialize();
|
||||
|
||||
new Ajax.Request(WEB_ROOT+'/ajax/motivos.php', {
|
||||
method:'post',
|
||||
parameters: $('frmEditarMotivo').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...') }
|
||||
});
|
||||
|
||||
}//EditMotivo
|
||||
|
||||
function DeleteMotivoPopup(id){
|
||||
|
||||
var message = "Realmente deseas eliminar este motivo?";
|
||||
|
||||
if(!confirm(message)){
|
||||
return;
|
||||
}
|
||||
|
||||
new Ajax.Request(WEB_ROOT+'/ajax/motivos.php',{
|
||||
method:'post',
|
||||
parameters: {type: "deleteMotivo", motivoId: 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...') }
|
||||
|
||||
});
|
||||
|
||||
}//DeleteMotivoPopup
|
||||
Reference in New Issue
Block a user