Commit f30854747ebde9844db4b7ba179b2885fd3c7b81
1 parent
ef25294933
Exists in
master
and in
2 other branches
cerrar ventana al aceptar alerta
Showing
1 changed file
with
5 additions
and
1 deletions
Show diff stats
src/js/controllerCerrarVehiculo.js
1 | angular.module('focaLogisticaPedidoRuta') | 1 | angular.module('focaLogisticaPedidoRuta') |
2 | .controller('focaModalCerrarVehiculo', [ | 2 | .controller('focaModalCerrarVehiculo', [ |
3 | '$scope', | 3 | '$scope', |
4 | '$uibModalInstance', | 4 | '$uibModalInstance', |
5 | '$uibModal', | 5 | '$uibModal', |
6 | 'focaLogisticaPedidoRutaService', | 6 | 'focaLogisticaPedidoRutaService', |
7 | 'idVehiculo', | 7 | 'idVehiculo', |
8 | 'focaModalService', | 8 | 'focaModalService', |
9 | '$filter', | 9 | '$filter', |
10 | 'fechaReparto', | 10 | 'fechaReparto', |
11 | 'cerrar', | 11 | 'cerrar', |
12 | function($scope, $uibModalInstance, $uibModal, focaLogisticaPedidoRutaService, | 12 | function($scope, $uibModalInstance, $uibModal, focaLogisticaPedidoRutaService, |
13 | idVehiculo, focaModalService, $filter, fechaReparto, cerrar) { | 13 | idVehiculo, focaModalService, $filter, fechaReparto, cerrar) { |
14 | $scope.cerrar = cerrar; | 14 | $scope.cerrar = cerrar; |
15 | $scope.vehiculo = {}; | 15 | $scope.vehiculo = {}; |
16 | $scope.remitos = []; | 16 | $scope.remitos = []; |
17 | $scope.now = fechaReparto; | 17 | $scope.now = fechaReparto; |
18 | focaLogisticaPedidoRutaService.obtenerVehiculoById(idVehiculo).then(function(res) { | 18 | focaLogisticaPedidoRutaService.obtenerVehiculoById(idVehiculo).then(function(res) { |
19 | $scope.vehiculo = res.data; | 19 | $scope.vehiculo = res.data; |
20 | }); | 20 | }); |
21 | focaLogisticaPedidoRutaService.getRemitosByIdVehiculo(idVehiculo, 1, 1).then( | 21 | focaLogisticaPedidoRutaService.getRemitosByIdVehiculo(idVehiculo, 1, 1).then( |
22 | function(res) { | 22 | function(res) { |
23 | $scope.remitos = res.data; | 23 | $scope.remitos = res.data; |
24 | }); | 24 | }); |
25 | focaLogisticaPedidoRutaService.numeroHojaRuta().then(function(res) { | 25 | focaLogisticaPedidoRutaService.numeroHojaRuta().then(function(res) { |
26 | $scope.sucursal = res.data.sucursal; | 26 | $scope.sucursal = res.data.sucursal; |
27 | $scope.numero = res.data.numeroHojaRuta; | 27 | $scope.numero = res.data.numeroHojaRuta; |
28 | }); | 28 | }); |
29 | $scope.cancelar = function() { | 29 | $scope.cancelar = function() { |
30 | $uibModalInstance.close(); | 30 | $uibModalInstance.close(); |
31 | }; | 31 | }; |
32 | $scope.aceptar = function() { | 32 | $scope.aceptar = function() { |
33 | var idsRemito = []; | 33 | var idsRemito = []; |
34 | $scope.remitos.forEach(function(remito) { | 34 | $scope.remitos.forEach(function(remito) { |
35 | idsRemito.push(remito.id); | 35 | idsRemito.push(remito.id); |
36 | }); | 36 | }); |
37 | var cierreDistribuicion = { | 37 | var cierreDistribuicion = { |
38 | idsRemito: idsRemito, | 38 | idsRemito: idsRemito, |
39 | fechaReparto: focaLogisticaPedidoRutaService.fecha | 39 | fechaReparto: focaLogisticaPedidoRutaService.fecha |
40 | }; | 40 | }; |
41 | focaLogisticaPedidoRutaService.cerrarDistribuicion(cierreDistribuicion) | 41 | focaLogisticaPedidoRutaService.cerrarDistribuicion(cierreDistribuicion) |
42 | .then(function() { | 42 | .then(function() { |
43 | focaModalService.alert('Vehículo cerrado con éxito'); | 43 | focaModalService |
44 | .alert('Vehículo cerrado con éxito') | ||
45 | .then(function() { | ||
46 | $scope.cancelar(); | ||
47 | }); | ||
44 | } | 48 | } |
45 | ); | 49 | ); |
46 | }; | 50 | }; |
47 | $scope.eliminarRemitos = function() { | 51 | $scope.eliminarRemitos = function() { |
48 | var remitosDel = $filter('filter')($scope.remitos, {checked: true}); | 52 | var remitosDel = $filter('filter')($scope.remitos, {checked: true}); |
49 | focaModalService.alert('¿Seguro que desea desasociar estos remitos del vehículo?') | 53 | focaModalService.alert('¿Seguro que desea desasociar estos remitos del vehículo?') |
50 | .then(function() { | 54 | .then(function() { |
51 | eliminarRemitos(remitosDel); | 55 | eliminarRemitos(remitosDel); |
52 | } | 56 | } |
53 | ); | 57 | ); |
54 | }; | 58 | }; |
55 | $scope.minimoUnoChecked = function() { | 59 | $scope.minimoUnoChecked = function() { |
56 | var remitosChequeados = $filter('filter')($scope.remitos, {checked: true}); | 60 | var remitosChequeados = $filter('filter')($scope.remitos, {checked: true}); |
57 | return !remitosChequeados.length; | 61 | return !remitosChequeados.length; |
58 | }; | 62 | }; |
59 | function eliminarRemitos(remitosDel) { | 63 | function eliminarRemitos(remitosDel) { |
60 | var nuevosRemitos = $filter('filter')($scope.remitos, {checked: !true}); | 64 | var nuevosRemitos = $filter('filter')($scope.remitos, {checked: !true}); |
61 | focaLogisticaPedidoRutaService.desasociarRemitos(remitosDel, $scope.vehiculo.id, | 65 | focaLogisticaPedidoRutaService.desasociarRemitos(remitosDel, $scope.vehiculo.id, |
62 | nuevosRemitos ? true : false).then(function() { | 66 | nuevosRemitos ? true : false).then(function() { |
63 | $scope.remitos = nuevosRemitos; | 67 | $scope.remitos = nuevosRemitos; |
64 | }); | 68 | }); |
65 | } | 69 | } |
66 | }]); | 70 | }]); |
67 | 71 |