From 1e642e9f73c067c864c9b906aed1ba5818d14cbb Mon Sep 17 00:00:00 2001 From: Jose Pinto Date: Tue, 19 Feb 2019 11:58:42 -0300 Subject: [PATCH] fix modal puntos descarga --- src/js/controller.js | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/js/service.js | 4 ++++ 2 files changed, 59 insertions(+) diff --git a/src/js/controller.js b/src/js/controller.js index 49b98d6..c068b7a 100644 --- a/src/js/controller.js +++ b/src/js/controller.js @@ -468,6 +468,49 @@ angular.module('focaCrearRemito') .controller('remitoController', ); }; + $scope.seleccionarPuntosDeDescarga = function() { + if(!$scope.remito.cliente.COD || !$scope.remito.domicilio.id) { + focaModalService.alert('Primero seleccione un cliente y un domicilio'); + return; + }else { + var modalInstance = $uibModal.open( + { + ariaLabelledBy: 'Búsqueda de Puntos de descarga', + templateUrl: 'modal-punto-descarga.html', + controller: 'focaModalPuntoDescargaController', + size: 'lg', + resolve: { + filters: { + idDomicilio: $scope.remito.domicilio.id, + idCliente: $scope.remito.cliente.COD, + articulos: $scope.articulosTabla, + puntosDescarga: $scope.remito.domicilio.puntosDescarga + } + } + } + ); + modalInstance.result.then( + function(puntosDescarga) { + $scope.remito.puntosDescarga = puntosDescarga; + + //AGREGO PUNTOS DE DESCARGA A CABECERA + var puntosStamp = ''; + puntosDescarga.forEach(function(punto, idx, arr) { + puntosStamp += punto.descripcion; + if((idx + 1) !== arr.length) puntosStamp += ', '; + }); + + $scope.$broadcast('addCabecera', { + label: 'Puntos de descarga:', + valor: puntosStamp + }); + }, function() { + $scope.abrirModalDomicilios($scope.cliente); + } + ); + } + }; + $scope.seleccionarVendedor = function() { if(varlidarRemitoFacturado()) { var parametrosModal = { @@ -567,6 +610,7 @@ angular.module('focaCrearRemito') .controller('remitoController', modalInstance.result.then( function(cliente) { $scope.abrirModalDomicilios(cliente); + $scope.cliente = cliente; }, function() { } @@ -610,6 +654,17 @@ angular.module('focaCrearRemito') .controller('remitoController', label: 'Domicilio:', valor: domicilioStamp }); + + if(domicilio.verPuntos) { + delete $scope.remito.domicilio.verPuntos; + $scope.seleccionarPuntosDeDescarga(); + }else { + crearRemitoService + .getPuntosDescargaByClienDom(domicilio.id, cliente.cod) + .then(function(res) { + if(res.data.length) $scope.seleccionarPuntosDeDescarga(); + }); + } }, function() { $scope.seleccionarCliente(); return; diff --git a/src/js/service.js b/src/js/service.js index 5fa36ce..dd18b96 100644 --- a/src/js/service.js +++ b/src/js/service.js @@ -56,6 +56,10 @@ angular.module('focaCrearRemito') getNumeroRemito: function() { return $http.get(route + '/remito/numero-siguiente'); }, + getPuntosDescargaByClienDom: function(idDomicilio, idCliente) { + return $http.get(API_ENDPOINT.URL + '/punto-descarga/' + + idDomicilio + '/' + idCliente); + }, getBotonera: function() { return [ { -- 1.9.1