Files
ventas_php/javascript/descuentos-nuevo.js

104 lines
2.5 KiB
JavaScript
Executable File

function SaveDescuentos(k){
var descTipo = $("tipoDescGral").value;
var descVal = $("valDescGral").value;
var idVenta = $("ventaId").value;
new Ajax.Request(WEB_ROOT+'/ajax/descuentos.php',{
method:'post',
parameters: {type: "saveDescuentos", tipoDesc:descTipo, valDesc:descVal, ventaId:idVenta},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
console.log(response);
if(splitResponse[0] == "ok"){
alert("El descuento fue aplicado correctamente.");
CerrarDesc();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function UpdatePrecios(k){
var descTipo = $("tipoDesc_"+k).value;
var descVal = $("valDesc_"+k).value;
var idVenta = $("ventaId").value;
new Ajax.Request(WEB_ROOT+'/ajax/descuentos.php',{
method:'post',
parameters: {type: "updatePrecios", k:k, tipoDesc:descTipo, valDesc:descVal, ventaId:idVenta},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
console.log(response);
if(splitResponse[0] == "ok"){
$("txtTotalProd_"+k).innerHTML = splitResponse[1];
UpdateTotales();
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function UpdateTotales(){
var descTipo = $("tipoDescGral").value;
var descVal = $("valDescGral").value;
var idVenta = $("ventaId").value;
new Ajax.Request(WEB_ROOT+'/ajax/descuentos.php',{
method:'post',
parameters: {type: "updateTotales", tipoDesc:descTipo, valDesc:descVal, ventaId:idVenta},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
console.log(response);
if(splitResponse[0] == "ok"){
$("txtSubtotal").innerHTML = splitResponse[1];
$("txtIva").innerHTML = splitResponse[2];
$("txtTotal").innerHTML = splitResponse[3];
}
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function CancelarDescuentos(){
new Ajax.Request(WEB_ROOT+'/ajax/descuentos.php',{
method:'post',
parameters: {type: "cancelarDescuentos"},
onSuccess: function(transport){
var response = transport.responseText || "no response text";
var splitResponse = response.split("[#]");
if(splitResponse[0] == "ok")
CerrarDesc();
},
onFailure: function(){ alert('Something went wrong...') }
});
}//CancelarDescuento
function CerrarDesc(){
window.parent.HideFviewVta();
window.parent.location.reload();
}