diff --git a/src/js/controller.js b/src/js/controller.js index 6369868..414079e 100644 --- a/src/js/controller.js +++ b/src/js/controller.js @@ -156,8 +156,8 @@ angular.module('focaModalDetalleHojaRuta') templateUrl: 'modal-actualizar-punto-descarga.html', controller: 'focaModalActualizarPuntoDescargaController', resolve: { - puntosDescarga: function() { - return $scope.remito.notaPedido.notaPedidoPuntoDescarga; + notaPedido: function() { + return $scope.remito.notaPedido; } }, size: 'lg' @@ -207,33 +207,59 @@ angular.module('focaModalDetalleHojaRuta') '$uibModalInstance', 'focaSeguimientoService', 'focaModalService', - 'puntosDescarga', + 'notaPedido', 'focaModalDetalleHojaRutaService', function($scope, $uibModalInstance, focaSeguimientoService, - focaModalService, puntosDescarga, focaModalDetalleHojaRutaService) + focaModalService, notaPedido, focaModalDetalleHojaRutaService) { - $scope.puntosDescarga = puntosDescarga; + $scope.notaPedido = notaPedido; + $scope.descripcion = ''; focaSeguimientoService.obtenerPosicion(function(res) { $scope.posicion = res.coords; }); $scope.cancel = function() { - $uibModalInstance.dismiss(); + if ($scope.ingreso) { + $scope.ingreso = false; + } else { + $uibModalInstance.dismiss(); + } }; $scope.select = function(puntoDescarga) { - if(!$scope.posicion){ - focaModalService.alert('No se pudo obtener la ubicacion'); + if (!$scope.posicion) { + focaModalService.alert('No se pudo obtener la ubicación'); return; } puntoDescarga.latitud = $scope.posicion.latitude; puntoDescarga.longitud = $scope.posicion.longitude; focaModalDetalleHojaRutaService - .updatePuntoDescarga(puntoDescarga) + .guardarPuntoDescarga(puntoDescarga) + .then(function(res) { + $uibModalInstance.close(res.data); + }); + }; + + $scope.guardar = function() { + if (!$scope.posicion) { + focaModalService.alert('No se pudo obtener la ubicación'); + return; + } + focaModalDetalleHojaRutaService + .guardarPuntoDescarga({ + id: 0, + id_cliente: $scope.notaPedido.idCliente, + id_da_config_0: $scope.notaPedido.idDomicilio, + descripcion: $scope.descripcion, + latitud: $scope.posicion.latitude, + longitud: $scope.posicion.longitude + }) .then(function(res) { $uibModalInstance.close(res.data); }); + }; + } ] ); diff --git a/src/js/service.js b/src/js/service.js index 91b5999..96eae19 100644 --- a/src/js/service.js +++ b/src/js/service.js @@ -19,7 +19,7 @@ angular.module('focaModalDetalleHojaRuta') rechazarRemito: function(remito) { return $http.post(API_ENDPOINT.URL + '/remito/update', {remito: remito}); }, - updatePuntoDescarga: function(puntoDescarga) { + guardarPuntoDescarga: function(puntoDescarga) { return $http.post(API_ENDPOINT.URL + '/punto-descarga', {puntoDescarga: puntoDescarga}); } diff --git a/src/views/modal-actualizar-punto-descarga.html b/src/views/modal-actualizar-punto-descarga.html index feb20a7..7fad1c4 100644 --- a/src/views/modal-actualizar-punto-descarga.html +++ b/src/views/modal-actualizar-punto-descarga.html @@ -1,10 +1,18 @@ -