Commit 579ff5c308837696dce6a00337589fbdb3269f6e
1 parent
38888beffc
Exists in
master
Codigo identado.
Showing
1 changed file
with
46 additions
and
46 deletions
Show diff stats
src/js/controller.js
1 | -angular.module('focaLogisticaPedidoRuta') .controller('focaLogisticaPedidoRutaController', [ | |
1 | +angular.module('focaLogisticaPedidoRuta').controller('focaLogisticaPedidoRutaController', [ | |
2 | 2 | '$scope', 'focaLogisticaPedidoRutaService', '$location', '$uibModal', '$filter', |
3 | - 'focaModalService', 'focaBotoneraLateralService', '$interval', | |
4 | - function($scope, focaLogisticaPedidoRutaService, $location, $uibModal, $filter, | |
3 | + 'focaModalService', 'focaBotoneraLateralService', '$interval', | |
4 | + function ($scope, focaLogisticaPedidoRutaService, $location, $uibModal, $filter, | |
5 | 5 | focaModalService, focaBotoneraLateralService, $interval |
6 | 6 | ) { |
7 | 7 | $scope.actividad = 'Logistica'; |
... | ... | @@ -24,7 +24,7 @@ angular.module('focaLogisticaPedidoRuta') .controller('focaLogisticaPedidoRutaCo |
24 | 24 | $scope.vehiculos = []; |
25 | 25 | getSeguimiento(); |
26 | 26 | $scope.arrastrando = false; |
27 | - $scope.general = function() { | |
27 | + $scope.general = function () { | |
28 | 28 | $scope.idVendedor = 0; |
29 | 29 | getSeguimiento(); |
30 | 30 | }; |
... | ... | @@ -36,7 +36,7 @@ angular.module('focaLogisticaPedidoRuta') .controller('focaLogisticaPedidoRutaCo |
36 | 36 | focaBotoneraLateralService.showPausar(false); |
37 | 37 | focaBotoneraLateralService.showGuardar(false); |
38 | 38 | |
39 | - $scope.general = function() { | |
39 | + $scope.general = function () { | |
40 | 40 | $scope.idVendedor = 0; |
41 | 41 | getSeguimiento(); |
42 | 42 | $scope.$broadcast('removeCabecera', cabecera); |
... | ... | @@ -46,7 +46,7 @@ angular.module('focaLogisticaPedidoRuta') .controller('focaLogisticaPedidoRutaCo |
46 | 46 | }); |
47 | 47 | }; |
48 | 48 | |
49 | - $scope.cargar = function(idVehiculo, punto) { | |
49 | + $scope.cargar = function (idVehiculo, punto) { | |
50 | 50 | if (!eligioFecha()) return; |
51 | 51 | var idRemito; |
52 | 52 | if (punto === -1) { |
... | ... | @@ -61,24 +61,24 @@ angular.module('focaLogisticaPedidoRuta') .controller('focaLogisticaPedidoRutaCo |
61 | 61 | controller: 'focaDetalleVehiculo', |
62 | 62 | size: 'lg', |
63 | 63 | resolve: { |
64 | - idVehiculo: function() {return idVehiculo;}, | |
65 | - idRemito: function() {return idRemito;}, | |
66 | - fechaReparto: function() {return $scope.fechaReparto;} | |
64 | + idVehiculo: function () { return idVehiculo; }, | |
65 | + idRemito: function () { return idRemito; }, | |
66 | + fechaReparto: function () { return $scope.fechaReparto; } | |
67 | 67 | } |
68 | 68 | } |
69 | 69 | ); |
70 | 70 | }; |
71 | 71 | |
72 | - $scope.quitarVehiculo = function(vehiculo) { | |
72 | + $scope.quitarVehiculo = function (vehiculo) { | |
73 | 73 | if (!eligioFecha() || vehiculoEnUso(vehiculo)) return; |
74 | 74 | |
75 | 75 | focaModalService.confirm('Esta seguro que desea eliminar el vehículo ' + |
76 | - vehiculo.codigo + ' de ' + vehiculo.transportista.NOM + '?').then(function() { | |
76 | + vehiculo.codigo + ' de ' + vehiculo.transportista.NOM + '?').then(function () { | |
77 | 77 | eliminarVehiculo(vehiculo); |
78 | 78 | }); |
79 | 79 | }; |
80 | 80 | |
81 | - $scope.hacerHojaRuta = function(vehiculo, cerrar) { | |
81 | + $scope.hacerHojaRuta = function (vehiculo, cerrar) { | |
82 | 82 | if (!eligioFecha() || vehiculoEnUso(vehiculo)) return; |
83 | 83 | var modalInstance = $uibModal.open( |
84 | 84 | { |
... | ... | @@ -87,50 +87,50 @@ angular.module('focaLogisticaPedidoRuta') .controller('focaLogisticaPedidoRutaCo |
87 | 87 | controller: 'focaModalCerrarVehiculo', |
88 | 88 | size: 'lg', |
89 | 89 | resolve: { |
90 | - idVehiculo: function() {return vehiculo.id;}, | |
91 | - fechaReparto: function() {return $scope.fechaReparto;}, | |
92 | - cerrar: function() {return cerrar;} | |
90 | + idVehiculo: function () { return vehiculo.id; }, | |
91 | + fechaReparto: function () { return $scope.fechaReparto; }, | |
92 | + cerrar: function () { return cerrar; } | |
93 | 93 | } |
94 | 94 | } |
95 | 95 | ); |
96 | - modalInstance.result.then(function() { | |
97 | - | |
98 | - }, function() { | |
96 | + modalInstance.result.then(function () { | |
97 | + | |
98 | + }, function () { | |
99 | 99 | //usar cuando se cancela el modal |
100 | 100 | }); |
101 | 101 | }; |
102 | 102 | |
103 | - $scope.arrastra = function() { | |
103 | + $scope.arrastra = function () { | |
104 | 104 | $scope.arrastrando = true; |
105 | 105 | $scope.$digest(); |
106 | 106 | }; |
107 | 107 | |
108 | - $scope.noArrastra = function() { | |
108 | + $scope.noArrastra = function () { | |
109 | 109 | $scope.arrastrando = false; |
110 | 110 | $scope.$digest(); |
111 | 111 | }; |
112 | 112 | |
113 | - $scope.individual = function() { | |
113 | + $scope.individual = function () { | |
114 | 114 | $scope.idVendedor = -1; |
115 | 115 | }; |
116 | 116 | |
117 | - $scope.mostrarDetalle = function() { | |
117 | + $scope.mostrarDetalle = function () { | |
118 | 118 | $scope.detalle = true; |
119 | 119 | }; |
120 | 120 | |
121 | - $scope.salir = function() { | |
121 | + $scope.salir = function () { | |
122 | 122 | $location.path('/'); |
123 | 123 | }; |
124 | 124 | |
125 | - $scope.search = function() { | |
125 | + $scope.search = function () { | |
126 | 126 | getSeguimiento(); |
127 | 127 | }; |
128 | 128 | |
129 | - $scope.fecha = function() { | |
129 | + $scope.fecha = function () { | |
130 | 130 | getSeguimiento(); |
131 | 131 | }; |
132 | 132 | |
133 | - $scope.seleccionarVehículo = function() { | |
133 | + $scope.seleccionarVehículo = function () { | |
134 | 134 | var parametrosModal = { |
135 | 135 | titulo: 'Búsqueda de Transportista', |
136 | 136 | query: '/transportista', |
... | ... | @@ -149,12 +149,12 @@ angular.module('focaLogisticaPedidoRuta') .controller('focaLogisticaPedidoRutaCo |
149 | 149 | } |
150 | 150 | ] |
151 | 151 | }; |
152 | - focaModalService.modal(parametrosModal).then(function(transportista) { | |
152 | + focaModalService.modal(parametrosModal).then(function (transportista) { | |
153 | 153 | $scope.selectVehiculo(transportista.COD, transportista.NOM); |
154 | 154 | }); |
155 | 155 | }; |
156 | 156 | |
157 | - $scope.selectVehiculo = function(idTransportista, nombreTransportista) { | |
157 | + $scope.selectVehiculo = function (idTransportista, nombreTransportista) { | |
158 | 158 | var parametrosModal = { |
159 | 159 | columnas: [ |
160 | 160 | { |
... | ... | @@ -179,8 +179,8 @@ angular.module('focaLogisticaPedidoRuta') .controller('focaLogisticaPedidoRutaCo |
179 | 179 | subTitulo: idTransportista + '-' + nombreTransportista |
180 | 180 | }; |
181 | 181 | focaModalService.modal(parametrosModal).then( |
182 | - function(vehiculo) { | |
183 | - var existe = $filter('filter')($scope.vehiculos, {id: vehiculo.id}); | |
182 | + function (vehiculo) { | |
183 | + var existe = $filter('filter')($scope.vehiculos, { id: vehiculo.id }); | |
184 | 184 | if (existe.length) { |
185 | 185 | focaModalService.alert('El vehiculo ya ha sido cargado'); |
186 | 186 | return; |
... | ... | @@ -190,13 +190,13 @@ angular.module('focaLogisticaPedidoRuta') .controller('focaLogisticaPedidoRutaCo |
190 | 190 | return; |
191 | 191 | } |
192 | 192 | $scope.vehiculos.push(vehiculo); |
193 | - }, function() { | |
193 | + }, function () { | |
194 | 194 | // funcion ejecutada cuando se cancela el modal |
195 | 195 | }); |
196 | 196 | }; |
197 | 197 | |
198 | - $scope.seleccionarFechaReparto = function() { | |
199 | - focaModalService.modalFecha('Fecha de reparto').then(function(fecha) { | |
198 | + $scope.seleccionarFechaReparto = function () { | |
199 | + focaModalService.modalFecha('Fecha de reparto').then(function (fecha) { | |
200 | 200 | setearFecha(fecha); |
201 | 201 | }); |
202 | 202 | }; |
... | ... | @@ -204,7 +204,7 @@ angular.module('focaLogisticaPedidoRuta') .controller('focaLogisticaPedidoRutaCo |
204 | 204 | function setearFecha(fecha) { |
205 | 205 | $scope.fechaReparto = fecha; |
206 | 206 | focaLogisticaPedidoRutaService.setFechaReparto(fecha); |
207 | - focaLogisticaPedidoRutaService.getUnidadesByFecha(fecha).then(function(res){ | |
207 | + focaLogisticaPedidoRutaService.getUnidadesByFecha(fecha).then(function (res) { | |
208 | 208 | $scope.vehiculos = res.data; |
209 | 209 | $scope.$broadcast('addCabecera', { |
210 | 210 | label: 'Fecha:', |
... | ... | @@ -241,20 +241,21 @@ angular.module('focaLogisticaPedidoRuta') .controller('focaLogisticaPedidoRutaCo |
241 | 241 | individual: $scope.idVendedor ? true : false |
242 | 242 | }; |
243 | 243 | |
244 | - focaLogisticaPedidoRutaService.obtenerActividad(datos).then(function(datos) { | |
245 | - if (JSON.stringify(datos.data) !== JSON.stringify($scope.marcadores)) { | |
246 | - $scope.marcadores = datos.data; | |
247 | - } | |
248 | - }); | |
244 | + focaLogisticaPedidoRutaService.obtenerActividad(datos) | |
245 | + .then(function (datos) { | |
246 | + if (JSON.stringify(datos.data) !== JSON.stringify($scope.marcadores)) { | |
247 | + $scope.marcadores = datos.data; | |
248 | + } | |
249 | + }); | |
249 | 250 | } |
250 | 251 | |
251 | 252 | function eliminarVehiculo(vehiculo) { |
252 | - focaLogisticaPedidoRutaService.getRemitosByIdVehiculo(vehiculo.id).then(function(res) { | |
253 | + focaLogisticaPedidoRutaService.getRemitosByIdVehiculo(vehiculo.id).then(function (res) { | |
253 | 254 | if (!res.data.length) { |
254 | 255 | $scope.vehiculos.splice($scope.vehiculos.indexOf(vehiculo), 1); |
255 | 256 | } else { |
256 | 257 | focaModalService.alert('No ha sido posible eliminar el vehiculo porque ' + |
257 | - 'tiene remitos asociados').then(function() { | |
258 | + 'tiene remitos asociados').then(function () { | |
258 | 259 | $scope.hacerHojaRuta(vehiculo, true); |
259 | 260 | }); |
260 | 261 | } |
... | ... | @@ -271,13 +272,12 @@ angular.module('focaLogisticaPedidoRuta') .controller('focaLogisticaPedidoRutaCo |
271 | 272 | |
272 | 273 | function vehiculoEnUso(vehiculo) { |
273 | 274 | var idUsuario = focaLogisticaPedidoRutaService.idUsuario; |
274 | - for(var i = 0; i < vehiculo.cisternas.length; i++) { | |
275 | - for(var j = 0; j < vehiculo.cisternas[i].cisternasCarga.length; j++) { | |
275 | + for (var i = 0; i < vehiculo.cisternas.length; i++) { | |
276 | + for (var j = 0; j < vehiculo.cisternas[i].cisternasCarga.length; j++) { | |
276 | 277 | var cisternaCarga = vehiculo.cisternas[i].cisternasCarga[j]; |
277 | 278 | if (cisternaCarga.fechaReparto.substring(0, 10) === $scope.fechaReparto |
278 | 279 | .toISOString().substring(0, 10) && cisternaCarga.idUsuarioProceso && |
279 | - cisternaCarga.idUsuarioProceso !== idUsuario) | |
280 | - { | |
280 | + cisternaCarga.idUsuarioProceso !== idUsuario) { | |
281 | 281 | focaModalService.alert('El vehículo está siendo usado por otro usuario'); |
282 | 282 | return true; |
283 | 283 | } |
... | ... | @@ -285,7 +285,7 @@ angular.module('focaLogisticaPedidoRuta') .controller('focaLogisticaPedidoRutaCo |
285 | 285 | } |
286 | 286 | return false; |
287 | 287 | } |
288 | - $interval(function() { | |
288 | + $interval(function () { | |
289 | 289 | getSeguimiento(); |
290 | 290 | }, 5000); |
291 | 291 | } |