diff --git a/src/js/controller.js b/src/js/controller.js index a10b785..5d40b6e 100644 --- a/src/js/controller.js +++ b/src/js/controller.js @@ -519,11 +519,17 @@ angular.module('focaCrearFactura').controller('facturaController', [ crearFuncionesProductos(producto); }); + + $scope.botoneraProductos.push({ + label: 'Ultimos despachos', + image: 'ultimos-despachos.png', + imageDefault: 'productoDefault.png' + }); }); } $scope.seleccionarBusquedaProductos = function () { - + if (angular.equals({}, $scope.factura.vendedor)) { focaModalService.alert('Seleccione Vendedor'); @@ -593,6 +599,89 @@ angular.module('focaCrearFactura').controller('facturaController', [ .catch(function (e) { console.error(e); }); }; + $scope.seleccionarUltimosDespachos = function () { + + if (angular.equals($scope.factura.cliente, {})) { + focaModalService.alert('Seleccione cliente'); + return; + } + + var modalInstance = $uibModal.open( + { + templateUrl: 'modal-ultimos-despachos.html', + controller: 'ultimosDespachosController', + resolve: { + parametros: function () { + return { + planilla: $scope.factura.vendedor.NplVen, + }; + } + }, + size: 'md' + } + ); + + modalInstance.result.then(function (despacho) { + + var articulo = { + TIP: $scope.factura.cliente.tipoFactura, + TCO: 'FT', + SUC: parseInt($scope.puntoVenta), + ORD: $scope.articulosFiltro().length + 1, + SEC: despacho.SEC, + ART: despacho.PRO, + RUB: producto.CodRub, + DES: producto.DetArt, + CAN: despacho.LTS, + PUN: producto.PreVen, + IVA: producto.IMPIVA, + NET: producto.IvaCO != 0 ? producto.PreNet : 0, + NEX: producto.IvaCO == 0 ? producto.PreNet : 0, + IMI: producto.ImpInt, + IMI2: producto.ImpInt2, + IMI3: producto.ImpInt3, + PUT: producto.PreVen, + SUR: despacho.SUR, + PLA: despacho.PLA, + LUG: despacho.LUG, + LEG: $scope.factura.vendedor.CodVen, + TUR: $scope.factura.vendedor.TurVen, + ORDEN_PRECOMPRA: '', + ESC: producto.tipoFactura === 'L' ? 1 : 0, + CMF: 0, + PTA: 0, + IVS: 0, + TIVA: 21, // TODO traer POR de la tabla ACODIVA where ID = IvaCO + CON: 0, + SINO: '', + ORD_TRA: 0, + IMP_DESP: 0, + PCD: 0, + RTO: '', + }; + + crearFacturaService.setearDespachoOcupado({ + surtidor: despacho.SUR, + producto: despacho.PRO, + carga: despacho.CAR + }) + .then(function () { + $scope.factura.articulosFactura.push(articulo); + $scope.factura.despachos.push(despacho); + }) + .catch(function (err) { + + console.error(err); + focaModalService.alert('El despacho esta en uso'); + }); + + }) + .catch(function (err) { + console.error(err); + }); + + }; + function crearFuncionesProductos(producto) { $scope[nombreFuncion(producto.DetArt)] = function () { diff --git a/src/js/controllerUltimosDespachos.js b/src/js/controllerUltimosDespachos.js new file mode 100644 index 0000000..f7d8fb7 --- /dev/null +++ b/src/js/controllerUltimosDespachos.js @@ -0,0 +1,52 @@ +angular.module('focaCrearFactura') + .controller('ultimosDespachosController', [ + '$filter', + '$scope', + '$uibModalInstance', + 'crearFacturaService', + 'parametros', + function ($filter, $scope, $uibModalInstance, crearFacturaService, parametros) { + + $scope.colorTexto = { color: 'black' }; + + config(); + + function config() { + + crearFacturaService.getUltimosDespachos(parametros.planilla).then(function (res) { + $scope.productos = res.data; + }); + } + + $scope.aceptar = function (despacho) { + $uibModalInstance.close(despacho); + }; + + $scope.cancel = function () { + $uibModalInstance.dismiss('cancel'); + }; + + //TODO: Cambiar switch case con los casos de nombres de productos axion + function setColorNombreProducto() { + + // Diesel #FF852E | Euro+Diesel #6C389A | Premium #00A857 | Super #175AA5 + switch ($scope.nombreProducto) { + case 'NAFTA SUPER XXI': + $scope.colorTexto = { color: '#FF852E' }; + break; + case 'GO-INFINIA DIESEL': + $scope.colorTexto = { color: '#6C389A' }; + break; + case 'ULTRADIESEL XXI - RED': + $scope.colorTexto = { color: '#00A857' }; + break; + case 'NAFTA INFINIA': + $scope.colorTexto = { color: '#175AA5' }; + break; + default: + $scope.colorTexto = { color: 'black' }; + break; + } + } + } + ]); diff --git a/src/js/service.js b/src/js/service.js index dbd0dd4..aeea056 100644 --- a/src/js/service.js +++ b/src/js/service.js @@ -15,6 +15,9 @@ angular.module('focaCrearFactura') getProductosByPlanilla: function (numeroPlanilla) { return $http.get(route + '/turnos/productos/' + numeroPlanilla); }, + getUltimosDespachos: function (numeroPlanilla) { + return $http.get(route + '/turnos/productos/' + numeroPlanilla + '/true'); + }, setearDespachoOcupado: function (parametros) { return $http.post(route + '/turnos/despacho-en-uso', parametros); }, diff --git a/src/views/modal-ultimos-despachos.html b/src/views/modal-ultimos-despachos.html new file mode 100644 index 0000000..b6ad51b --- /dev/null +++ b/src/views/modal-ultimos-despachos.html @@ -0,0 +1,76 @@ +
+ | + | + | + + | +