diff --git a/src/js/controller.js b/src/js/controller.js index 234e005..d901670 100644 --- a/src/js/controller.js +++ b/src/js/controller.js @@ -310,6 +310,8 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', $scope.notaPedido = notaPedido; $scope.notaPedido.moneda = notaPedido.cotizacion.moneda; $scope.plazosPagos = notaPedido.notaPedidoPlazo; + $scope.notaPedido.puntosDescarga = + formatearPuntosDescarga(notaPedido.notaPedidoPuntoDescarga); addArrayCabecera(cabeceras); }, function() { @@ -372,6 +374,39 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', ); }; + $scope.seleccionarPuntosDeDescarga = function() { + if(!$scope.notaPedido.cliente.COD || !$scope.notaPedido.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: { + /*TODO: al traer nota de pedido ya creada + obtener idDomicilio correctamente*/ + idDomicilio: $scope.notaPedido.domicilio.id, + idCliente: $scope.notaPedido.cliente.COD, + articulos: $scope.articulosTabla, + puntosDescarga: $scope.notaPedido.puntosDescarga + } + } + } + ); + modalInstance.result.then( + function(puntosDescarga) { + $scope.notaPedido.puntosDescarga = puntosDescarga; + }, function() { + + } + ); + } + }; + $scope.seleccionarVendedor = function() { if(validarNotaRemitada()) { var modalInstance = $uibModal.open( @@ -452,7 +487,9 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', templateUrl: 'modal-domicilio.html', controller: 'focaModalDomicilioController', resolve: { - idCliente: function() { return cliente.cod; }, + idCliente: function() { + return cliente.cod; + }, esNuevo: function() { return cliente.esNuevo; }, articulos: function() { return $scope.articulosTabla; @@ -767,5 +804,41 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', return false; } } + + function formatearPuntosDescarga(notaPedidoPuntoDescarga) { + var result = []; + + notaPedidoPuntoDescarga.forEach(function(el) { + var puntoDescarga = result.filter(function(resultPunto) { + return resultPunto.id == el.idPuntoDescarga; + }); + + if(puntoDescarga.length) { + puntoDescarga[0].articulosAgregados.push({ + cantidad: el.cantidad, + descripcion: el.producto.descripcion, + id: el.producto.id + }); + }else { + result.push({ + id: el.puntoDescarga.id, + id_cliente: el.puntoDescarga.id_cliente, + id_da_config_0: el.puntoDescarga.id_da_config_0, + latitud: el.puntoDescarga.latitud, + longitud: el.puntoDescarga.longitud, + descripcion: el.puntoDescarga.descripcion, + articulosAgregados: [ + { + cantidad: el.cantidad, + descripcion: el.producto.descripcion, + id: el.producto.id + } + ] + }); + } + + }); + return result; + } } ]); diff --git a/src/js/service.js b/src/js/service.js index 3bce2cb..6130a83 100644 --- a/src/js/service.js +++ b/src/js/service.js @@ -56,8 +56,40 @@ angular.module('focaCrearNotaPedido') return $http.get(route + '/nota-pedido/numero-siguiente'); }, getBotonera: function() { - return ['Vendedor', 'Cliente', 'Proveedor', 'Moneda', - 'Precios y condiciones', 'Flete', 'Productos']; + return [ + { + label: 'Vendedor', + image: 'vendedor.png' + }, + { + label: 'Cliente', + image: 'cliente.png' + }, + { + label: 'Proveedor', + image: 'proveedor.png' + }, + { + label: 'Moneda', + image: 'moneda.png' + }, + { + label: 'Precios y condiciones', + image: 'precios-condiciones.png' + }, + { + label: 'Flete', + image: 'flete.png' + }, + { + label: 'Productos', + image: 'productos.png' + }, + { + label: 'Puntos de descarga', + image: 'seguimientoCobranza.png' + } + ]; }, crearPuntosDescarga: function(puntosDescarga) { return $http.post(route + '/puntos-descarga/nota-pedido', diff --git a/src/views/nota-pedido.html b/src/views/nota-pedido.html index 13dfdc6..e4c21da 100644 --- a/src/views/nota-pedido.html +++ b/src/views/nota-pedido.html @@ -11,7 +11,7 @@