380 lines
8.3 KiB
JavaScript
Executable File
380 lines
8.3 KiB
JavaScript
Executable File
function AddProduct(){
|
|
|
|
var prodItemId = jQ("#idProdItem").val();
|
|
var cantidad = jQ("#cantidad").val();
|
|
var ventaId = jQ("#ventaId").val();
|
|
|
|
var disponible = jQ("#disponible").val();
|
|
|
|
if(prodItemId == ""){
|
|
alert("Ningún producto seleccionado.");
|
|
jQ('#codigoBarra').focus();
|
|
return;
|
|
}else if(parseInt(cantidad) > parseInt(disponible)){
|
|
alert("La cantidad es mayor que el disponible. Por favor, verifique.");
|
|
jQ('#codigoBarra').focus();
|
|
return;
|
|
}
|
|
|
|
jQ.ajax({
|
|
type: "POST",
|
|
url: 'ajax/devoluciones.php',
|
|
data: "type=addProduct&prodItemId="+prodItemId+"&cantidad="+cantidad+"&ventaId="+ventaId,
|
|
success: function(data) {
|
|
var splitResponse = data.split("[#]");
|
|
|
|
if(splitResponse[0] == "ok"){
|
|
jQ('#tblConceptos').html(splitResponse[1]);
|
|
jQ('#txtTotal').html(splitResponse[2]);
|
|
jQ('#cantidad').focus();
|
|
|
|
//Actualizamos los Datos para obtener los roductos disponibles
|
|
UpdateInfoProd(prodItemId);
|
|
|
|
}
|
|
}
|
|
});
|
|
|
|
}
|
|
|
|
function DeleteProduct(k){
|
|
|
|
jQ.ajax({
|
|
type: "POST",
|
|
url: 'ajax/devoluciones.php',
|
|
data: "type=deleteProduct&k="+k,
|
|
beforeSend: function(){
|
|
//jQ("#tblConceptos").html(LOADER);
|
|
},
|
|
success: function(data) {
|
|
var splitResponse = data.split("[#]");
|
|
|
|
if(splitResponse[0] == "ok"){
|
|
jQ('#tblConceptos').html(splitResponse[1]);
|
|
jQ('#txtTotal').html(splitResponse[2]);
|
|
|
|
//Actualizamos los Datos para obtener los roductos disponibles
|
|
UpdateInfoProd(splitResponse[3]);
|
|
|
|
}
|
|
|
|
}
|
|
});
|
|
|
|
}
|
|
|
|
function SaveDevolucion(){
|
|
|
|
var ventaId = jQ("#ventaId").val();
|
|
var codigo = jQ("#codigo").val();
|
|
|
|
jQ.ajax({
|
|
type: "POST",
|
|
url: 'ajax/devoluciones.php',
|
|
data: "action=saveDevolucion&ventaId="+ventaId+"&codigo="+codigo,
|
|
success: function(data) {
|
|
var splitResponse = data.split("[#]");
|
|
|
|
if(splitResponse[0] == "ok"){
|
|
|
|
window.parent.HideFviewVta();
|
|
window.parent.AddVentaDiv();
|
|
|
|
alert("Para finalizar la devolucion, debe ingresar la nueva prenda a cobrar.");
|
|
|
|
/*
|
|
HideFviewCobro();
|
|
LimpiarFormulario();
|
|
PrintTicket(splitResponse[1]);
|
|
*/
|
|
|
|
}else if(splitResponse[0] == "fail"){
|
|
alert(splitResponse[1]);
|
|
}
|
|
|
|
}//success
|
|
});
|
|
|
|
}
|
|
|
|
function ProdSelected(event, ui){
|
|
|
|
var producto = ui.item.value;
|
|
var prodItemId = producto.prodItemId;
|
|
|
|
jQ("#codigoBarra").val(producto.codigoBarra);
|
|
jQ("#txtProducto").html(producto.descripcion);
|
|
event.preventDefault();
|
|
|
|
jQ("#cantidad").focus();
|
|
|
|
UpdateInfoProd(prodItemId);
|
|
|
|
}//ProdSelected
|
|
|
|
function UpdateInfoProd(prodItemId){
|
|
|
|
var ventaId = jQ("#ventaId").val();
|
|
|
|
//Recuperamos el Precio y la cantidad Disponible
|
|
|
|
jQ.ajax({
|
|
type: "POST",
|
|
url: 'ajax/devoluciones.php',
|
|
data: "type=getProdInfoDev&prodItemId=" + prodItemId + "&ventaId=" + ventaId,
|
|
success: function(data) {
|
|
var splitResponse = data.split("[#]");
|
|
|
|
if(splitResponse[0] == "ok"){
|
|
jQ('#txtPrecioUni').html(splitResponse[1]);
|
|
jQ('#txtDisp').html(splitResponse[2]);
|
|
jQ('#disponible').val(splitResponse[2]);
|
|
jQ('#idProdItem').val(prodItemId);
|
|
}
|
|
}
|
|
});
|
|
|
|
}
|
|
|
|
function UpdateInfoProdByCode(){
|
|
|
|
//Recuperamos el Precio y la cantidad Disponible
|
|
|
|
var ventaId = jQ("#ventaId").val();
|
|
var codigoBarra = jQ("#codigoBarra").val();
|
|
|
|
jQ.ajax({
|
|
type: "POST",
|
|
url: 'ajax/devoluciones.php',
|
|
data: "type=getProdInfoDevByCode&codigoBarra=" + codigoBarra + "&ventaId=" + ventaId,
|
|
beforeSend: function(){
|
|
jQ('#txtProducto').html(LOADER);
|
|
},
|
|
success: function(data) {
|
|
var splitResponse = data.split("[#]");
|
|
|
|
jQ('#txtProducto').html(' ');
|
|
|
|
if(splitResponse[0] == "ok"){
|
|
jQ('#txtPrecioUni').html(splitResponse[1]);
|
|
jQ('#txtDisp').html(splitResponse[2]);
|
|
jQ('#disponible').val(splitResponse[2]);
|
|
jQ('#txtProducto').html(splitResponse[3]);
|
|
jQ('#idProdItem').val(splitResponse[4]);
|
|
|
|
document.getElementById('cantidad').focus();
|
|
}else if(splitResponse[0] == "fail"){
|
|
alert(splitResponse[1]);
|
|
}
|
|
|
|
}
|
|
});
|
|
|
|
}
|
|
|
|
function UpdateInfoProdB(prodItemId){
|
|
|
|
//Recuperamos el Precio y la cantidad Disponible
|
|
|
|
jQ.ajax({
|
|
type: "POST",
|
|
url: 'ajax/ventas.php',
|
|
data: "type=getProdInfoVta&prodItemId="+prodItemId,
|
|
success: function(data) {
|
|
var splitResponse = data.split("[#]");
|
|
|
|
if(splitResponse[0] == "ok"){
|
|
jQ('#txtPrecioUni').html(splitResponse[1]);
|
|
jQ('#txtDisp').html(splitResponse[2]);
|
|
jQ('#disponible').val(splitResponse[2]);
|
|
jQ("#txtProducto").html(splitResponse[3]);
|
|
jQ('#idProdItem').val(prodItemId);
|
|
|
|
HideFviewCobro();
|
|
}
|
|
}
|
|
});
|
|
|
|
}
|
|
|
|
function ProdFocus(event, ui){
|
|
|
|
event.preventDefault();
|
|
|
|
}//ProdFocus
|
|
|
|
//Venta
|
|
|
|
/*
|
|
function CobrarDevolucionDiv(){
|
|
|
|
jQ.ajax({
|
|
type: "POST",
|
|
url: 'ajax/devoluciones.php',
|
|
data: 'type=cobrarDev',
|
|
success: function(data) {
|
|
var splitResponse = data.split("[#]");
|
|
|
|
if(splitResponse[0] == "ok"){
|
|
FViewOffSetCobro(splitResponse[1]);
|
|
jQ('#fviewCobro').show();
|
|
}else if(splitResponse[0] == "fail"){
|
|
alert(splitResponse[1]);
|
|
}
|
|
|
|
}
|
|
});
|
|
|
|
}//CobrarVentaDiv
|
|
*/
|
|
|
|
function CerrarVta(){
|
|
window.parent.HideFviewVta();
|
|
window.parent.location.reload();
|
|
}
|
|
|
|
function CancelarDevolucion(){
|
|
|
|
jQ.ajax({
|
|
type: "POST",
|
|
url: 'ajax/devoluciones.php',
|
|
data: "action=cancelarDevolucion",
|
|
success: function(data) {
|
|
var splitResponse = data.split("[#]");
|
|
|
|
if(splitResponse[0] == "ok")
|
|
|
|
jQ("#tblConceptos").html(splitResponse[1]);
|
|
|
|
LimpiarFormulario();
|
|
|
|
}
|
|
});
|
|
|
|
}//CancelarDevolucion
|
|
|
|
function LimpiarFormulario(){
|
|
|
|
jQ.ajax({
|
|
type: "POST",
|
|
url: 'ajax/devoluciones.php',
|
|
data: "action=limpiarForm",
|
|
success: function(data) {
|
|
var splitResponse = data.split("[#]");
|
|
|
|
if(splitResponse[0] == "ok")
|
|
|
|
jQ("#tblConceptos").html(splitResponse[1]);
|
|
|
|
jQ("#txtProducto").html(' ');
|
|
jQ("#txtPrecioUni").html('0.00');
|
|
jQ("#txtDisp").html('0');
|
|
jQ("#cantidad").val(1);
|
|
jQ("#codigoBarra").val('');
|
|
jQ("#disponible").val('');
|
|
jQ("#idProdItem").val('');
|
|
|
|
jQ('#ventaId').val('');
|
|
jQ('#txtTotal').html('0.00');
|
|
|
|
}
|
|
});
|
|
|
|
}
|
|
|
|
function BuscarProducto(){
|
|
|
|
jQ.ajax({
|
|
type: "POST",
|
|
url: 'ajax/ventas.php',
|
|
data: 'type=buscarProducto',
|
|
success: function(data) {
|
|
var splitResponse = data.split("[#]");
|
|
|
|
if(splitResponse[0] == "ok"){
|
|
FViewOffSetCobro(splitResponse[1]);
|
|
jQ('#fviewCobro').show();
|
|
}else if(splitResponse[0] == "fail"){
|
|
alert(splitResponse[1]);
|
|
}
|
|
|
|
}
|
|
});
|
|
|
|
}
|
|
|
|
function LoadSubcats(){
|
|
|
|
var catId = $("prodCatId2").value;
|
|
|
|
new Ajax.Request(WEB_ROOT+'/ajax/ventas.php',{
|
|
method:'post',
|
|
parameters: {type:"loadSubcats", prodCatId:catId},
|
|
onLoading: function(){
|
|
$("enumSubcats").innerHTML = LOADER;
|
|
},
|
|
onSuccess: function(transport){
|
|
var response = transport.responseText || "no response text";
|
|
var splitResponse = response.split("[#]");
|
|
|
|
if(splitResponse[0] == "ok")
|
|
$("enumSubcats").innerHTML = splitResponse[1];
|
|
|
|
},
|
|
onFailure: function(){ alert('Something went wrong...') }
|
|
});
|
|
|
|
}//LoadSubcats
|
|
|
|
function LoadProductos(){
|
|
|
|
var idProveedor = $("proveedorId2").value;
|
|
var idProdCat = $("prodCatId2").value;
|
|
var idProdSubcat = $("prodSubcatId2").value;
|
|
var vDisponible = 0;
|
|
|
|
if($("disponible2").checked)
|
|
vDisponible = 1;
|
|
|
|
new Ajax.Request(WEB_ROOT+'/ajax/ventas.php',{
|
|
method:'post',
|
|
parameters: {type:"loadProductos", prodCatId:idProdCat, prodSubcatId:idProdSubcat, proveedorId:idProveedor, disponible:vDisponible},
|
|
onLoading: function(){
|
|
$("enumProductos").innerHTML = LOADER;
|
|
},
|
|
onSuccess: function(transport){
|
|
var response = transport.responseText || "no response text";
|
|
var splitResponse = response.split("[#]");
|
|
|
|
if(splitResponse[0] == "ok")
|
|
$("enumProductos").innerHTML = splitResponse[1];
|
|
|
|
},
|
|
onFailure: function(){ alert('Something went wrong...') }
|
|
});
|
|
|
|
}//LoadProductos
|
|
|
|
function CheckKey(e){
|
|
|
|
if(window.event)
|
|
keyCode = window.event.keyCode;
|
|
else if(e)
|
|
keyCode=e.which;
|
|
|
|
if(keyCode == 13)
|
|
UpdateInfoProdByCode();
|
|
|
|
}//CheckKey
|
|
|
|
function PrintTicket(id){
|
|
|
|
window.open(WEB_ROOT + "/devoluciones-ticket/devolucionId/" + id , "Ticket Devolucion" , "width=350,height=300,scrollbars=YES")
|
|
|
|
}//PrintTicket
|
|
|
|
function PrintTicketVta(id){
|
|
|
|
window.open(WEB_ROOT + "/ventas-ticket/id/" + id , "Ticket Venta" , "width=350,height=300,scrollbars=YES")
|
|
|
|
}//PrintTicket
|