From 22d96be9f2d2cedff84ccebf9bc0efb59d0f0b45 Mon Sep 17 00:00:00 2001 From: Luigi Date: Fri, 12 Apr 2019 09:19:37 -0300 Subject: [PATCH] Alerta al cambiar precio y condicion --- src/js/controller.js | 101 +++++++++++++++++++++++++-------------------------- 1 file changed, 50 insertions(+), 51 deletions(-) diff --git a/src/js/controller.js b/src/js/controller.js index a1fd248..be9a001 100644 --- a/src/js/controller.js +++ b/src/js/controller.js @@ -574,63 +574,13 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', } }; - function abrirModal() { - var modalInstance = $uibModal.open( - { - ariaLabelledBy: 'Busqueda de Precio Condición', - templateUrl: 'modal-precio-condicion.html', - controller: 'focaModalPrecioCondicionController', - size: 'lg', - resolve: { - idListaPrecio: function() { - return $scope.notaPedido.cliente.MOD || null; - } - } - } - ); - - modalInstance.result.then( - function(precioCondicion) { - var cabecera = ''; - var plazosConcat = ''; - if (!Array.isArray(precioCondicion)) { - $scope.notaPedido.notaPedidoPlazo = precioCondicion.plazoPago; - $scope.notaPedido.precioCondicion = precioCondicion; - $scope.notaPedido.idPrecioCondicion = precioCondicion.id; - $scope.idLista = precioCondicion.idListaPrecio; - for (var i = 0; i < precioCondicion.plazoPago.length; i++) { - plazosConcat += precioCondicion.plazoPago[i].dias + ' '; - } - cabecera = $filter('rellenarDigitos')(precioCondicion.id, 4) + - ' - ' + precioCondicion.nombre + ' ' + plazosConcat.trim(); - } else { //Cuando se ingresan los plazos manualmente - $scope.notaPedido.idPrecioCondicion = 0; - //-1, el modal productos busca todos los productos - $scope.idLista = -1; - $scope.notaPedido.notaPedidoPlazo = precioCondicion; - for (var j = 0; j < precioCondicion.length; j++) { - plazosConcat += precioCondicion[j].dias + ' '; - } - cabecera = 'Ingreso manual ' + plazosConcat.trim(); - } - $scope.notaPedido.articulosNotaPedido = []; - $scope.$broadcast('addCabecera', { - label: 'Precios y condiciones:', - valor: cabecera - }); - }, function() { - - } - ); - } - $scope.seleccionarPreciosYCondiciones = function() { if (!$scope.notaPedido.cliente.COD) { focaModalService.alert('Primero seleccione un cliente'); return; } if ($scope.notaPedido.articulosNotaPedido.length !== 0) { - focaModalService.confirm('Se perderan los datos ingresados').then(function(data) { + focaModalService.confirm('Se perderan los productos ingresados').then(function(data) { if (data) { abrirModal(); } @@ -638,6 +588,55 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', } else if (validarNotaRemitada()) { abrirModal(); } + function abrirModal() { + var modalInstance = $uibModal.open( + { + ariaLabelledBy: 'Busqueda de Precio Condición', + templateUrl: 'modal-precio-condicion.html', + controller: 'focaModalPrecioCondicionController', + size: 'lg', + resolve: { + idListaPrecio: function() { + return $scope.notaPedido.cliente.MOD || null; + } + } + } + ); + + modalInstance.result.then( + function(precioCondicion) { + var cabecera = ''; + var plazosConcat = ''; + if (!Array.isArray(precioCondicion)) { + $scope.notaPedido.notaPedidoPlazo = precioCondicion.plazoPago; + $scope.notaPedido.precioCondicion = precioCondicion; + $scope.notaPedido.idPrecioCondicion = precioCondicion.id; + $scope.idLista = precioCondicion.idListaPrecio; + for (var i = 0; i < precioCondicion.plazoPago.length; i++) { + plazosConcat += precioCondicion.plazoPago[i].dias + ' '; + } + cabecera = $filter('rellenarDigitos')(precioCondicion.id, 4) + + ' - ' + precioCondicion.nombre + ' ' + plazosConcat.trim(); + } else { //Cuando se ingresan los plazos manualmente + $scope.notaPedido.idPrecioCondicion = 0; + //-1, el modal productos busca todos los productos + $scope.idLista = -1; + $scope.notaPedido.notaPedidoPlazo = precioCondicion; + for (var j = 0; j < precioCondicion.length; j++) { + plazosConcat += precioCondicion[j].dias + ' '; + } + cabecera = 'Ingreso manual ' + plazosConcat.trim(); + } + $scope.notaPedido.articulosNotaPedido = []; + $scope.$broadcast('addCabecera', { + label: 'Precios y condiciones:', + valor: cabecera + }); + }, function() { + + } + ); + } }; $scope.seleccionarMoneda = function() { -- 1.9.1