Commit 22d96be9f2d2cedff84ccebf9bc0efb59d0f0b45
1 parent
9e8fab2220
Exists in
master
and in
1 other branch
Alerta al cambiar precio y condicion
Showing
1 changed file
with
50 additions
and
51 deletions
Show diff stats
src/js/controller.js
... | ... | @@ -574,63 +574,13 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
574 | 574 | } |
575 | 575 | }; |
576 | 576 | |
577 | - function abrirModal() { | |
578 | - var modalInstance = $uibModal.open( | |
579 | - { | |
580 | - ariaLabelledBy: 'Busqueda de Precio Condición', | |
581 | - templateUrl: 'modal-precio-condicion.html', | |
582 | - controller: 'focaModalPrecioCondicionController', | |
583 | - size: 'lg', | |
584 | - resolve: { | |
585 | - idListaPrecio: function() { | |
586 | - return $scope.notaPedido.cliente.MOD || null; | |
587 | - } | |
588 | - } | |
589 | - } | |
590 | - ); | |
591 | - | |
592 | - modalInstance.result.then( | |
593 | - function(precioCondicion) { | |
594 | - var cabecera = ''; | |
595 | - var plazosConcat = ''; | |
596 | - if (!Array.isArray(precioCondicion)) { | |
597 | - $scope.notaPedido.notaPedidoPlazo = precioCondicion.plazoPago; | |
598 | - $scope.notaPedido.precioCondicion = precioCondicion; | |
599 | - $scope.notaPedido.idPrecioCondicion = precioCondicion.id; | |
600 | - $scope.idLista = precioCondicion.idListaPrecio; | |
601 | - for (var i = 0; i < precioCondicion.plazoPago.length; i++) { | |
602 | - plazosConcat += precioCondicion.plazoPago[i].dias + ' '; | |
603 | - } | |
604 | - cabecera = $filter('rellenarDigitos')(precioCondicion.id, 4) + | |
605 | - ' - ' + precioCondicion.nombre + ' ' + plazosConcat.trim(); | |
606 | - } else { //Cuando se ingresan los plazos manualmente | |
607 | - $scope.notaPedido.idPrecioCondicion = 0; | |
608 | - //-1, el modal productos busca todos los productos | |
609 | - $scope.idLista = -1; | |
610 | - $scope.notaPedido.notaPedidoPlazo = precioCondicion; | |
611 | - for (var j = 0; j < precioCondicion.length; j++) { | |
612 | - plazosConcat += precioCondicion[j].dias + ' '; | |
613 | - } | |
614 | - cabecera = 'Ingreso manual ' + plazosConcat.trim(); | |
615 | - } | |
616 | - $scope.notaPedido.articulosNotaPedido = []; | |
617 | - $scope.$broadcast('addCabecera', { | |
618 | - label: 'Precios y condiciones:', | |
619 | - valor: cabecera | |
620 | - }); | |
621 | - }, function() { | |
622 | - | |
623 | - } | |
624 | - ); | |
625 | - } | |
626 | - | |
627 | 577 | $scope.seleccionarPreciosYCondiciones = function() { |
628 | 578 | if (!$scope.notaPedido.cliente.COD) { |
629 | 579 | focaModalService.alert('Primero seleccione un cliente'); |
630 | 580 | return; |
631 | 581 | } |
632 | 582 | if ($scope.notaPedido.articulosNotaPedido.length !== 0) { |
633 | - focaModalService.confirm('Se perderan los datos ingresados').then(function(data) { | |
583 | + focaModalService.confirm('Se perderan los productos ingresados').then(function(data) { | |
634 | 584 | if (data) { |
635 | 585 | abrirModal(); |
636 | 586 | } |
... | ... | @@ -638,6 +588,55 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
638 | 588 | } else if (validarNotaRemitada()) { |
639 | 589 | abrirModal(); |
640 | 590 | } |
591 | + function abrirModal() { | |
592 | + var modalInstance = $uibModal.open( | |
593 | + { | |
594 | + ariaLabelledBy: 'Busqueda de Precio Condición', | |
595 | + templateUrl: 'modal-precio-condicion.html', | |
596 | + controller: 'focaModalPrecioCondicionController', | |
597 | + size: 'lg', | |
598 | + resolve: { | |
599 | + idListaPrecio: function() { | |
600 | + return $scope.notaPedido.cliente.MOD || null; | |
601 | + } | |
602 | + } | |
603 | + } | |
604 | + ); | |
605 | + | |
606 | + modalInstance.result.then( | |
607 | + function(precioCondicion) { | |
608 | + var cabecera = ''; | |
609 | + var plazosConcat = ''; | |
610 | + if (!Array.isArray(precioCondicion)) { | |
611 | + $scope.notaPedido.notaPedidoPlazo = precioCondicion.plazoPago; | |
612 | + $scope.notaPedido.precioCondicion = precioCondicion; | |
613 | + $scope.notaPedido.idPrecioCondicion = precioCondicion.id; | |
614 | + $scope.idLista = precioCondicion.idListaPrecio; | |
615 | + for (var i = 0; i < precioCondicion.plazoPago.length; i++) { | |
616 | + plazosConcat += precioCondicion.plazoPago[i].dias + ' '; | |
617 | + } | |
618 | + cabecera = $filter('rellenarDigitos')(precioCondicion.id, 4) + | |
619 | + ' - ' + precioCondicion.nombre + ' ' + plazosConcat.trim(); | |
620 | + } else { //Cuando se ingresan los plazos manualmente | |
621 | + $scope.notaPedido.idPrecioCondicion = 0; | |
622 | + //-1, el modal productos busca todos los productos | |
623 | + $scope.idLista = -1; | |
624 | + $scope.notaPedido.notaPedidoPlazo = precioCondicion; | |
625 | + for (var j = 0; j < precioCondicion.length; j++) { | |
626 | + plazosConcat += precioCondicion[j].dias + ' '; | |
627 | + } | |
628 | + cabecera = 'Ingreso manual ' + plazosConcat.trim(); | |
629 | + } | |
630 | + $scope.notaPedido.articulosNotaPedido = []; | |
631 | + $scope.$broadcast('addCabecera', { | |
632 | + label: 'Precios y condiciones:', | |
633 | + valor: cabecera | |
634 | + }); | |
635 | + }, function() { | |
636 | + | |
637 | + } | |
638 | + ); | |
639 | + } | |
641 | 640 | }; |
642 | 641 | |
643 | 642 | $scope.seleccionarMoneda = function() { |