306 lines
7.6 KiB
JavaScript
Executable File
306 lines
7.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){
|
|
DeleteAtributoPopup(id);
|
|
return;
|
|
}
|
|
|
|
del = el.hasClassName('spanEdit');
|
|
if(del == true)
|
|
EditAtributoPopup(id);
|
|
|
|
del = el.hasClassName('guardaStatus');
|
|
if(del == true)
|
|
cambiaStatus(id);
|
|
|
|
}
|
|
|
|
if($('contenido')!= undefined)
|
|
$('contenido').observe("click", AddEditProductosListeners);
|
|
|
|
if($("addPolitica") != undefined)
|
|
$('addPolitica').observe("click", function(){ AddPoliticaDiv(1); });
|
|
|
|
if($("search1") != undefined)
|
|
$('search1').observe("keyup", SearchBonificacion);
|
|
|
|
if($("search2") != undefined)
|
|
$('search2').observe("keyup", SearchBonificacion);
|
|
|
|
});
|
|
|
|
function aplicarBonifDev(id)
|
|
{
|
|
var totalBonificacion = $('totalBonificacion_'+id).value;
|
|
var totalDevolucion = $('totalDevolucion_'+id).value;
|
|
|
|
alert(totalBonificacion+" "+totalDevolucion);
|
|
var message = "Realmente deseas aplicar estas bonficaciones/devoluciones?";
|
|
|
|
if(!confirm(message)){
|
|
return;
|
|
}
|
|
|
|
new Ajax.Request(WEB_ROOT+'/ajax/evaluar-pedidos.php',
|
|
{
|
|
method:'post',
|
|
parameters: {type: "cambiarStatus", pedidoId: id, totalBonificacion: totalBonificacion, totalDevolucion: totalDevolucion},
|
|
onSuccess: function(transport){
|
|
var response = transport.responseText || "no response text";
|
|
var splitResponse = response.split("[#]");
|
|
if(splitResponse[0] == "Rechazo")
|
|
{
|
|
grayOut(true);
|
|
$('fview').show();
|
|
FViewOffSet(splitResponse[1]);
|
|
Event.observe($('agregarJustificante'), "click", SaveJustificante);
|
|
Event.observe($('fviewclose'), "click", function(){ HideFview(); });
|
|
}else{
|
|
if(splitResponse[0] == "fail"){
|
|
ShowStatusPopUp(splitResponse[1]);
|
|
}else{
|
|
ShowStatusPopUp(splitResponse[1]);
|
|
$('contenido').innerHTML = splitResponse[2];
|
|
HideFview();
|
|
}
|
|
}
|
|
},
|
|
|
|
onFailure: function(){ alert('Something went wrong...') }
|
|
|
|
});
|
|
}
|
|
|
|
function SearchBonificacion()
|
|
{
|
|
var pedidoId = $('search1').value;
|
|
var nombreProveedor = $('search2').value;
|
|
|
|
new Ajax.Request(WEB_ROOT+'/ajax/evaluar-pedidos.php',
|
|
{
|
|
method:'post',
|
|
parameters: $('filtraBonificacion').serialize()/*{type: "suggestBonificacion", pedidoId: pedidoId, nombreProveedor: nombreProveedor}*/,
|
|
onSuccess: function(transport){
|
|
var response = transport.responseText || "no response text";
|
|
var splitResponse = response.split("[#]");
|
|
if(splitResponse[0] == "fail"){
|
|
ShowStatusPopUp(splitResponse[1]);
|
|
}else{
|
|
$('contenido').innerHTML = splitResponse[1];
|
|
}
|
|
},
|
|
|
|
onFailure: function(){ alert('Something went wrong...') }
|
|
|
|
});
|
|
}
|
|
|
|
function SaveJustificante()
|
|
{
|
|
var status = $('status').value;
|
|
var bonificacionId = $('bonificacionId').value;
|
|
var justificante = $('justificante').value;
|
|
|
|
new Ajax.Request(WEB_ROOT+'/ajax/evaluar-pedidos.php',
|
|
{
|
|
method:'post',
|
|
parameters: {bonificacionId: bonificacionId, status: status, type: "cambiarStatus", aux: 0, justificante: justificante},
|
|
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]);
|
|
HideFview();
|
|
}
|
|
},
|
|
|
|
onFailure: function(){ alert('Something went wrong...') }
|
|
|
|
});
|
|
}
|
|
|
|
function cambiaStatus(id){
|
|
|
|
var totalBonificacion = $('totalBonificacion_'+id).value;
|
|
var aux = 0;
|
|
if(status == "Rechazado")
|
|
aux = 1;
|
|
new Ajax.Request(WEB_ROOT+'/ajax/evaluar-pedidos.php',
|
|
{
|
|
method:'post',
|
|
parameters: {bonificacionId: id, totalBonificacion: totalBonificacion, type: "cambiarStatus", aux: aux},
|
|
onSuccess: function(transport){
|
|
var response = transport.responseText || "no response text";
|
|
var splitResponse = response.split("[#]");
|
|
if(splitResponse[0] == "Rechazo")
|
|
{
|
|
grayOut(true);
|
|
$('fview').show();
|
|
FViewOffSet(splitResponse[1]);
|
|
Event.observe($('agregarJustificante'), "click", SaveJustificante);
|
|
Event.observe($('fviewclose'), "click", function(){ HideFview(); });
|
|
}else{
|
|
if(splitResponse[0] == "fail"){
|
|
ShowStatusPopUp(splitResponse[1]);
|
|
}else{
|
|
ShowStatusPopUp(splitResponse[1]);
|
|
$('contenido').innerHTML = splitResponse[2];
|
|
HideFview();
|
|
}
|
|
}
|
|
},
|
|
|
|
onFailure: function(){ alert('Something went wrong...') }
|
|
|
|
});
|
|
}
|
|
|
|
function AddPoliticaDiv(id){
|
|
|
|
grayOut(true);
|
|
|
|
if(id == 0){
|
|
$('fview').hide();
|
|
grayOut(false);
|
|
return;
|
|
}
|
|
$('fview').show();
|
|
|
|
new Ajax.Request(WEB_ROOT+'/ajax/politicas.php',{
|
|
method:'post',
|
|
parameters: {type: "addPolitica"},
|
|
onSuccess: function(transport){
|
|
var response = transport.responseText || "no response text";
|
|
FViewOffSet(response);
|
|
Event.observe($('btnSave'), "click", AddPolitica);
|
|
Event.observe($('fviewclose'), "click", function(){ HideFview(); });
|
|
},
|
|
|
|
onFailure: function(){ alert('Something went wrong...') }
|
|
|
|
});
|
|
|
|
}//AddAtributoDiv
|
|
|
|
function AddPolitica(){
|
|
|
|
new Ajax.Request(WEB_ROOT+'/ajax/politicas.php',
|
|
{
|
|
method:'post',
|
|
parameters: $('frmAgregarPolitica').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...') }
|
|
|
|
});
|
|
|
|
}
|
|
|
|
function EditAtributoPopup(id){
|
|
|
|
grayOut(true);
|
|
$('fview').show();
|
|
if(id == 0){
|
|
$('fview').hide();
|
|
grayOut(false);
|
|
return;
|
|
}
|
|
|
|
new Ajax.Request(WEB_ROOT+'/ajax/atributos.php',{
|
|
method:'post',
|
|
parameters: {type: "editAtributo", atributoId:id},
|
|
onSuccess: function(transport){
|
|
var response = transport.responseText || "no response text";
|
|
|
|
FViewOffSet(response);
|
|
Event.observe($('closePopUpDiv'), "click", function(){ HideFview(); });
|
|
Event.observe($('btnUpdate'), "click", EditAtributo);
|
|
},
|
|
|
|
onFailure: function(){ alert('Something went wrong...') }
|
|
|
|
});
|
|
|
|
}//EditAtributoPopup
|
|
|
|
function EditAtributo(){
|
|
|
|
var form = $('frmEditarAtributo').serialize();
|
|
|
|
new Ajax.Request(WEB_ROOT+'/ajax/atributos.php', {
|
|
method:'post',
|
|
parameters: $('frmEditarAtributo').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...') }
|
|
});
|
|
|
|
}//EditAtributo
|
|
|
|
function DeleteAtributoPopup(id){
|
|
|
|
var message = "Realmente deseas eliminar este atributo?";
|
|
|
|
if(!confirm(message)){
|
|
return;
|
|
}
|
|
|
|
new Ajax.Request(WEB_ROOT+'/ajax/atributos.php',{
|
|
method:'post',
|
|
parameters: {type: "deleteAtributo", atributoId: 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...') }
|
|
|
|
});
|
|
|
|
}//DeleteAtributoPopup
|
|
|
|
function ViewValores(id){
|
|
|
|
var obj = $('valores_'+id);
|
|
|
|
if(obj.style.display == "none")
|
|
obj.style.display = "";
|
|
else
|
|
obj.style.display = "none";
|
|
} |