diff --git a/src/js/controller.js b/src/js/controller.js index 679858e..f2a3343 100644 --- a/src/js/controller.js +++ b/src/js/controller.js @@ -90,8 +90,8 @@ angular.module('focaLogisticaPedidoRuta') .controller('focaLogisticaPedidoRutaCo var modalInstance = $uibModal.open( { ariaLabelledBy: 'Creación hoja ruta', - templateUrl: 'foca-modal-crear-hoja-ruta.html', - controller: 'focaModalCrearHojaRuta', + templateUrl: 'foca-modal-cerrar-vehiculo.html', + controller: 'focaModalCerrarVehiculo', size: 'lg', resolve: { idVehiculo: function() {return vehiculo.id;} diff --git a/src/js/controllerCerrarVehiculo.js b/src/js/controllerCerrarVehiculo.js new file mode 100644 index 0000000..dd36ef7 --- /dev/null +++ b/src/js/controllerCerrarVehiculo.js @@ -0,0 +1,86 @@ +angular.module('focaLogisticaPedidoRuta') + .controller('focaModalCerrarVehiculo', [ + '$scope', + '$uibModalInstance', + '$uibModal', + 'focaLogisticaPedidoRutaService', + 'idVehiculo', + 'focaModalService', + '$filter', + function($scope, $uibModalInstance, $uibModal, focaLogisticaPedidoRutaService, + idVehiculo, focaModalService, $filter) { + $scope.vehiculo = {}; + $scope.remitos = []; + $scope.now = new Date(); + focaLogisticaPedidoRutaService.obtenerVehiculoById(idVehiculo).then(function(res) { + $scope.vehiculo = res.data; + }); + //TODO: refactor código esta rre feo + focaLogisticaPedidoRutaService.getRemitos(idVehiculo).then(function(res) { + $scope.remitos = focaLogisticaPedidoRutaService.obtenerRemitosDeCarga(res.data); + }); + + focaLogisticaPedidoRutaService.numeroHojaRuta().then(function(res) { + $scope.sucursal = res.data.sucursal; + $scope.numero = res.data.numeroHojaRuta; + }); + $scope.cancelar = function() { + $uibModalInstance.close(); + }; + $scope.aceptar = function() { + var save = { + hojaRuta: { + id: 0, + fechaCreacion: $scope.now.toISOString().slice(0, 19).replace('T', ' '), + idTransportista: $scope.vehiculo.idTransportista, + idChofer: $scope.chofer.id, + idVehiculo: $scope.vehiculo.id, + tarifaFlete: $scope.tarifaFlete + }, + remitos: $scope.remitos, + idVehiculo: $scope.vehiculo.id + }; + focaLogisticaPedidoRutaService.crearHojaRuta(save).then(function() { + $uibModalInstance.close(); + focaModalService.alert('Hoja de ruta guardada con éxito'); + }); + }; + $scope.seleccionarChofer = function() { + var modalInstance = $uibModal.open( + { + ariaLabelledBy: 'Busqueda de Chofer', + templateUrl: 'modal-chofer.html', + controller: 'focaModalChoferController', + size: 'lg' + } + ); + + modalInstance.result.then( + function(chofer) { + $scope.chofer = chofer; + }, function() { + // funcion ejecutada cuando se cancela el modal + } + ); + }; + $scope.eliminarRemitos = function() { + var remitosDel = $filter('filter')($scope.remitos, {checked: true}); + focaModalService.alert('¿Seguro que desea desasociar estos remitos del vehículo?') + .then(function() { + eliminarRemitos(remitosDel); + } + ); + }; + $scope.minimoUnoChecked = function() { + var remitosChequeados = $filter('filter')($scope.remitos, {checked: true}); + return !remitosChequeados.length; + }; + function eliminarRemitos(remitosDel) { + var nuevosRemitos = $filter('filter')($scope.remitos, {checked: !true}); + focaLogisticaPedidoRutaService.desasociarRemitos(remitosDel, $scope.vehiculo.id, + nuevosRemitos ? true : false).then(function() { + focaModalService.alert('Remitos desasociados con éxito'); + $scope.remitos = nuevosRemitos; + }); + } + }]); diff --git a/src/js/controllerHojaRuta.js b/src/js/controllerHojaRuta.js deleted file mode 100644 index e88f993..0000000 --- a/src/js/controllerHojaRuta.js +++ /dev/null @@ -1,86 +0,0 @@ -angular.module('focaLogisticaPedidoRuta') - .controller('focaModalCrearHojaRuta', [ - '$scope', - '$uibModalInstance', - '$uibModal', - 'focaLogisticaPedidoRutaService', - 'idVehiculo', - 'focaModalService', - '$filter', - function($scope, $uibModalInstance, $uibModal, focaLogisticaPedidoRutaService, - idVehiculo, focaModalService, $filter) { - $scope.vehiculo = {}; - $scope.remitos = []; - $scope.now = new Date(); - focaLogisticaPedidoRutaService.obtenerVehiculoById(idVehiculo).then(function(res) { - $scope.vehiculo = res.data; - }); - //TODO: refactor código esta rre feo - focaLogisticaPedidoRutaService.getRemitos(idVehiculo).then(function(res) { - $scope.remitos = focaLogisticaPedidoRutaService.obtenerRemitosDeCarga(res.data); - }); - - focaLogisticaPedidoRutaService.numeroHojaRuta().then(function(res) { - $scope.sucursal = res.data.sucursal; - $scope.numero = res.data.numeroHojaRuta; - }); - $scope.cancelar = function() { - $uibModalInstance.close(); - }; - $scope.aceptar = function() { - var save = { - hojaRuta: { - id: 0, - fechaCreacion: $scope.now.toISOString().slice(0, 19).replace('T', ' '), - idTransportista: $scope.vehiculo.idTransportista, - idChofer: $scope.chofer.id, - idVehiculo: $scope.vehiculo.id, - tarifaFlete: $scope.tarifaFlete - }, - remitos: $scope.remitos, - idVehiculo: $scope.vehiculo.id - }; - focaLogisticaPedidoRutaService.crearHojaRuta(save).then(function() { - $uibModalInstance.close(); - focaModalService.alert('Hoja de ruta guardada con éxito'); - }); - }; - $scope.seleccionarChofer = function() { - var modalInstance = $uibModal.open( - { - ariaLabelledBy: 'Busqueda de Chofer', - templateUrl: 'modal-chofer.html', - controller: 'focaModalChoferController', - size: 'lg' - } - ); - - modalInstance.result.then( - function(chofer) { - $scope.chofer = chofer; - }, function() { - // funcion ejecutada cuando se cancela el modal - } - ); - }; - $scope.eliminarRemitos = function() { - var remitosDel = $filter('filter')($scope.remitos, {checked: true}); - focaModalService.alert('¿Seguro que desea desasociar estos remitos del vehículo?') - .then(function() { - eliminarRemitos(remitosDel); - } - ); - }; - $scope.minimoUnoChecked = function() { - var remitosChequeados = $filter('filter')($scope.remitos, {checked: true}); - return !remitosChequeados.length; - }; - function eliminarRemitos(remitosDel) { - var nuevosRemitos = $filter('filter')($scope.remitos, {checked: !true}); - focaLogisticaPedidoRutaService.desasociarRemitos(remitosDel, $scope.vehiculo.id, - nuevosRemitos ? true : false).then(function() { - focaModalService.alert('Remitos desasociados con éxito'); - $scope.remitos = nuevosRemitos; - }); - } - }]); diff --git a/src/views/foca-logistica-pedido-ruta.html b/src/views/foca-logistica-pedido-ruta.html index 139e370..fe947d6 100644 --- a/src/views/foca-logistica-pedido-ruta.html +++ b/src/views/foca-logistica-pedido-ruta.html @@ -138,7 +138,7 @@ width="100%">
Remito Nº | +Cliente | +Domicilio de entrega | +|
---|---|---|---|
+ No se han encontrado remitos. + | +|||
+ | + | + |
+
+
+
+
+ |
+
Remito Nº | -Cliente | -Domicilio de entrega | -|
---|---|---|---|
- No se han encontrado remitos. - | -|||
- | - | - |
-
-
-
-
- |
-