Commit 2f3f3916b610e4c3a148a59e4bf292a2f7aeb633
Exists in
develop
Merge branch 'develop' into 'develop'
Develop See merge request !56
Showing
1 changed file
Show diff stats
src/js/controller.js
1 | angular.module('focaLogisticaPedidoRuta').controller('focaLogisticaPedidoRutaController', [ | 1 | angular.module('focaLogisticaPedidoRuta').controller('focaLogisticaPedidoRutaController', [ |
2 | '$scope', 'focaLogisticaPedidoRutaService', '$location', '$uibModal', '$filter', | 2 | '$scope', 'focaLogisticaPedidoRutaService', '$location', '$uibModal', '$filter', |
3 | 'focaModalService', 'focaBotoneraLateralService', '$interval', | 3 | 'focaModalService', 'focaBotoneraLateralService', '$interval', |
4 | function ($scope, focaLogisticaPedidoRutaService, $location, $uibModal, $filter, | 4 | function ($scope, focaLogisticaPedidoRutaService, $location, $uibModal, $filter, |
5 | focaModalService, focaBotoneraLateralService, $interval | 5 | focaModalService, focaBotoneraLateralService, $interval |
6 | ) { | 6 | ) { |
7 | $scope.actividad = 'Logistica'; | 7 | $scope.actividad = 'Logistica'; |
8 | //Datos Pantalla | 8 | //Datos Pantalla |
9 | $scope.titulo = 'Logistica de Pedidos'; | 9 | $scope.titulo = 'Logistica de Pedidos'; |
10 | 10 | ||
11 | var transportista = { label: 'Vehículo', image: 'abmChofer.png' }; | 11 | var transportista = { label: 'Vehículo', image: 'abmChofer.png' }; |
12 | var fecha = { label: 'Fecha Reparto', image: 'FechaEntrega.png' }; | 12 | var fecha = { label: 'Fecha Reparto', image: 'FechaEntrega.png' }; |
13 | $scope.botonera = [fecha, transportista]; | 13 | $scope.botonera = [fecha, transportista]; |
14 | var cabecera = ''; | 14 | var cabecera = ''; |
15 | $scope.now = new Date(); | 15 | $scope.now = new Date(); |
16 | $scope.idVendedor = 0; | 16 | $scope.idVendedor = 0; |
17 | $scope.marcadores = []; | 17 | $scope.marcadores = []; |
18 | $scope.vehiculos = []; | 18 | $scope.vehiculos = []; |
19 | getSeguimiento(); | 19 | getSeguimiento(); |
20 | $scope.arrastrando = false; | 20 | $scope.arrastrando = false; |
21 | $scope.general = function () { | 21 | $scope.general = function () { |
22 | $scope.idVendedor = 0; | 22 | $scope.idVendedor = 0; |
23 | getSeguimiento(); | 23 | getSeguimiento(); |
24 | }; | 24 | }; |
25 | 25 | ||
26 | setearFecha(new Date()); | 26 | setearFecha(new Date()); |
27 | 27 | ||
28 | //SETEO BOTONERA LATERAL | 28 | //SETEO BOTONERA LATERAL |
29 | focaBotoneraLateralService.showSalir(true); | 29 | focaBotoneraLateralService.showSalir(true); |
30 | focaBotoneraLateralService.showPausar(false); | 30 | focaBotoneraLateralService.showPausar(false); |
31 | focaBotoneraLateralService.showGuardar(false); | 31 | focaBotoneraLateralService.showGuardar(false); |
32 | 32 | ||
33 | $scope.general = function () { | 33 | $scope.general = function () { |
34 | $scope.idVendedor = 0; | 34 | $scope.idVendedor = 0; |
35 | getSeguimiento(); | 35 | getSeguimiento(); |
36 | $scope.$broadcast('removeCabecera', cabecera); | 36 | $scope.$broadcast('removeCabecera', cabecera); |
37 | $scope.$broadcast('addCabecera', { | 37 | $scope.$broadcast('addCabecera', { |
38 | label: 'General', | 38 | label: 'General', |
39 | valor: '' | 39 | valor: '' |
40 | }); | 40 | }); |
41 | }; | 41 | }; |
42 | 42 | ||
43 | $scope.cargar = function (idVehiculo, punto) { | 43 | $scope.cargar = function (idVehiculo, punto) { |
44 | if (!eligioFecha()) return; | 44 | if (!eligioFecha()) return; |
45 | var idRemito; | 45 | var idRemito; |
46 | if (punto === -1) { | 46 | if (punto === -1) { |
47 | idRemito = -1; | 47 | idRemito = -1; |
48 | } else { | 48 | } else { |
49 | idRemito = JSON.parse(punto).notaPedido.remito.id; | 49 | idRemito = JSON.parse(punto).notaPedido.remito.id; |
50 | } | 50 | } |
51 | 51 | ||
52 | $uibModal.open( | 52 | $uibModal.open( |
53 | { | 53 | { |
54 | ariaLabelledBy: 'Busqueda de Vehiculo', | 54 | ariaLabelledBy: 'Busqueda de Vehiculo', |
55 | templateUrl: 'foca-detalle-vehiculo.html', | 55 | templateUrl: 'foca-detalle-vehiculo.html', |
56 | controller: 'focaDetalleVehiculo', | 56 | controller: 'focaDetalleVehiculo', |
57 | size: 'lg', | 57 | size: 'lg', |
58 | resolve: { | 58 | resolve: { |
59 | idVehiculo: function () { return idVehiculo; }, | 59 | idVehiculo: function () { return idVehiculo; }, |
60 | idRemito: function () { return idRemito; }, | 60 | idRemito: function () { return idRemito; }, |
61 | fechaReparto: function () { return $scope.fechaReparto; } | 61 | fechaReparto: function () { return $scope.fechaReparto; }, |
62 | orden: function () { return null; } | ||
62 | } | 63 | } |
63 | } | 64 | } |
64 | ); | 65 | ); |
65 | }; | 66 | }; |
66 | 67 | ||
67 | $scope.quitarVehiculo = function (vehiculo) { | 68 | $scope.quitarVehiculo = function (vehiculo) { |
68 | if (!eligioFecha() || vehiculoEnUso(vehiculo)) return; | 69 | if (!eligioFecha() || vehiculoEnUso(vehiculo)) return; |
69 | focaModalService.confirm('Esta seguro que desea eliminar el vehículo ' + | 70 | focaModalService.confirm('Esta seguro que desea eliminar el vehículo ' + |
70 | vehiculo.codigo + ' de ' + vehiculo.transportista.NOM + '?').then(function () { | 71 | vehiculo.codigo + ' de ' + vehiculo.transportista.NOM + '?').then(function () { |
71 | eliminarVehiculo(vehiculo); | 72 | eliminarVehiculo(vehiculo); |
72 | }); | 73 | }); |
73 | }; | 74 | }; |
74 | 75 | ||
75 | $scope.hacerHojaRuta = function (vehiculo, cerrar) { | 76 | $scope.hacerHojaRuta = function (vehiculo, cerrar) { |
76 | if (!eligioFecha() || vehiculoEnUso(vehiculo)) return; | 77 | if (!eligioFecha() || vehiculoEnUso(vehiculo)) return; |
77 | var modalInstance = $uibModal.open( | 78 | var modalInstance = $uibModal.open( |
78 | { | 79 | { |
79 | ariaLabelledBy: 'Creación hoja ruta', | 80 | ariaLabelledBy: 'Creación hoja ruta', |
80 | templateUrl: 'foca-modal-cerrar-vehiculo.html', | 81 | templateUrl: 'foca-modal-cerrar-vehiculo.html', |
81 | controller: 'focaModalCerrarVehiculo', | 82 | controller: 'focaModalCerrarVehiculo', |
82 | size: 'lg', | 83 | size: 'lg', |
83 | resolve: { | 84 | resolve: { |
84 | idVehiculo: function () { return vehiculo.id; }, | 85 | idVehiculo: function () { return vehiculo.id; }, |
85 | fechaReparto: function () { return $scope.fechaReparto; }, | 86 | fechaReparto: function () { return $scope.fechaReparto; }, |
86 | cerrar: function () { return cerrar; } | 87 | cerrar: function () { return cerrar; } |
87 | } | 88 | } |
88 | } | 89 | } |
89 | ); | 90 | ); |
90 | modalInstance.result | 91 | modalInstance.result |
91 | .then(function () { }, function () { }); | 92 | .then(function () { }, function () { }); |
92 | }; | 93 | }; |
93 | 94 | ||
94 | $scope.arrastra = function () { | 95 | $scope.arrastra = function () { |
95 | $scope.arrastrando = true; | 96 | $scope.arrastrando = true; |
96 | $scope.$digest(); | 97 | $scope.$digest(); |
97 | }; | 98 | }; |
98 | 99 | ||
99 | $scope.noArrastra = function () { | 100 | $scope.noArrastra = function () { |
100 | $scope.arrastrando = false; | 101 | $scope.arrastrando = false; |
101 | $scope.$digest(); | 102 | $scope.$digest(); |
102 | }; | 103 | }; |
103 | 104 | ||
104 | $scope.individual = function () { | 105 | $scope.individual = function () { |
105 | $scope.idVendedor = -1; | 106 | $scope.idVendedor = -1; |
106 | }; | 107 | }; |
107 | 108 | ||
108 | $scope.mostrarDetalle = function () { | 109 | $scope.mostrarDetalle = function () { |
109 | $scope.detalle = true; | 110 | $scope.detalle = true; |
110 | }; | 111 | }; |
111 | 112 | ||
112 | $scope.salir = function () { | 113 | $scope.salir = function () { |
113 | $location.path('/'); | 114 | $location.path('/'); |
114 | }; | 115 | }; |
115 | 116 | ||
116 | $scope.search = function () { | 117 | $scope.search = function () { |
117 | getSeguimiento(); | 118 | getSeguimiento(); |
118 | }; | 119 | }; |
119 | 120 | ||
120 | $scope.fecha = function () { | 121 | $scope.fecha = function () { |
121 | getSeguimiento(); | 122 | getSeguimiento(); |
122 | }; | 123 | }; |
123 | 124 | ||
124 | $scope.seleccionarVehiculo = function () { | 125 | $scope.seleccionarVehiculo = function () { |
125 | var parametrosModal = { | 126 | var parametrosModal = { |
126 | titulo: 'Búsqueda de Transportista', | 127 | titulo: 'Búsqueda de Transportista', |
127 | query: '/transportista', | 128 | query: '/transportista', |
128 | columnas: [ | 129 | columnas: [ |
129 | { | 130 | { |
130 | nombre: 'Código', | 131 | nombre: 'Código', |
131 | propiedad: 'COD' | 132 | propiedad: 'COD' |
132 | }, | 133 | }, |
133 | { | 134 | { |
134 | nombre: 'Nombre', | 135 | nombre: 'Nombre', |
135 | propiedad: 'NOM' | 136 | propiedad: 'NOM' |
136 | }, | 137 | }, |
137 | { | 138 | { |
138 | nombre: 'CUIT', | 139 | nombre: 'CUIT', |
139 | propiedad: 'CUIT' | 140 | propiedad: 'CUIT' |
140 | } | 141 | } |
141 | ] | 142 | ] |
142 | }; | 143 | }; |
143 | focaModalService.modal(parametrosModal) | 144 | focaModalService.modal(parametrosModal) |
144 | .then(function (transportista) { | 145 | .then(function (transportista) { |
145 | $scope.selectVehiculo(transportista.COD, transportista.NOM); | 146 | $scope.selectVehiculo(transportista.COD, transportista.NOM); |
146 | }); | 147 | }); |
147 | }; | 148 | }; |
148 | 149 | ||
149 | $scope.seleccionarRemito = function () { | 150 | $scope.seleccionarRemito = function () { |
150 | var modalInstance = $uibModal.open( | 151 | var modalInstance = $uibModal.open( |
151 | { | 152 | { |
152 | ariaLabelledBy: 'Busqueda de Remito', | 153 | ariaLabelledBy: 'Busqueda de Remito', |
153 | templateUrl: 'foca-modal-remito.html', | 154 | templateUrl: 'foca-modal-remito.html', |
154 | controller: 'focaModalRemitoController', | 155 | controller: 'focaModalRemitoController', |
155 | size: 'lg', | 156 | size: 'lg', |
156 | resolve: { usadoPor: function () { return 'remito'; } } | 157 | resolve: { usadoPor: function () { return 'remito'; } } |
157 | } | 158 | } |
158 | ); | 159 | ); |
159 | modalInstance.result | 160 | modalInstance.result |
160 | .then(function (remito) { | 161 | .then(function (remito) { |
161 | $scope.remito = remito; | 162 | $scope.remito = remito; |
162 | $scope.remito.numero = $filter('rellenarDigitos')(remito.lugar, 4) + '-' + | 163 | $scope.remito.numero = $filter('rellenarDigitos')(remito.lugar, 4) + '-' + |
163 | $filter('rellenarDigitos')(remito.numeroRemito, 6); | 164 | $filter('rellenarDigitos')(remito.numeroRemito, 6); |
164 | $scope.cliente = remito.cliente.NOM; | 165 | $scope.cliente = remito.cliente.NOM; |
165 | }, function () { }); | 166 | }, function () { }); |
166 | }; | 167 | }; |
167 | 168 | ||
168 | $scope.selectVehiculo = function (idTransportista, nombreTransportista) { | 169 | $scope.selectVehiculo = function (idTransportista, nombreTransportista) { |
169 | var parametrosModal = { | 170 | var parametrosModal = { |
170 | columnas: [ | 171 | columnas: [ |
171 | { | 172 | { |
172 | propiedad: 'codigo', | 173 | propiedad: 'codigo', |
173 | nombre: 'Código' | 174 | nombre: 'Código' |
174 | }, | 175 | }, |
175 | { | 176 | { |
176 | propiedad: 'tractor', | 177 | propiedad: 'tractor', |
177 | nombre: 'tractor' | 178 | nombre: 'tractor' |
178 | }, | 179 | }, |
179 | { | 180 | { |
180 | propiedad: 'semi', | 181 | propiedad: 'semi', |
181 | nombre: 'Semi' | 182 | nombre: 'Semi' |
182 | }, | 183 | }, |
183 | { | 184 | { |
184 | propiedad: 'capacidadTotalCisternas', | 185 | propiedad: 'capacidadTotalCisternas', |
185 | nombre: 'Capacidad' | 186 | nombre: 'Capacidad' |
186 | } | 187 | } |
187 | ], | 188 | ], |
188 | query: '/vehiculo/transportista/' + idTransportista, | 189 | query: '/vehiculo/transportista/' + idTransportista, |
189 | titulo: 'Búsqueda de vehiculos', | 190 | titulo: 'Búsqueda de vehiculos', |
190 | subTitulo: idTransportista + '-' + nombreTransportista | 191 | subTitulo: idTransportista + '-' + nombreTransportista |
191 | }; | 192 | }; |
192 | focaModalService.modal(parametrosModal) | 193 | focaModalService.modal(parametrosModal) |
193 | .then( | 194 | .then( |
194 | function (vehiculo) { | 195 | function (vehiculo) { |
195 | var existe = $filter('filter')($scope.vehiculos, { id: vehiculo.id }); | 196 | var existe = $filter('filter')($scope.vehiculos, { id: vehiculo.id }); |
196 | if (existe.length) { | 197 | if (existe.length) { |
197 | focaModalService.alert('El vehiculo ya ha sido cargado'); | 198 | focaModalService.alert('El vehiculo ya ha sido cargado'); |
198 | return; | 199 | return; |
199 | } | 200 | } |
200 | if (!vehiculo.cisternas.length) { | 201 | if (!vehiculo.cisternas.length) { |
201 | focaModalService.alert('El vehiculo no tiene cisternas'); | 202 | focaModalService.alert('El vehiculo no tiene cisternas'); |
202 | return; | 203 | return; |
203 | } | 204 | } |
204 | $scope.vehiculos.push(vehiculo); | 205 | $scope.vehiculos.push(vehiculo); |
205 | }, function () { }); | 206 | }, function () { }); |
206 | }; | 207 | }; |
207 | 208 | ||
208 | $scope.seleccionarFechaReparto = function () { | 209 | $scope.seleccionarFechaReparto = function () { |
209 | focaModalService.modalFecha('Fecha de reparto') | 210 | focaModalService.modalFecha('Fecha de reparto') |
210 | .then(function (fecha) { | 211 | .then(function (fecha) { |
211 | setearFecha(fecha); | 212 | setearFecha(fecha); |
212 | }); | 213 | }); |
213 | }; | 214 | }; |
214 | 215 | ||
215 | function actualizarMarcadores(filtros) { | 216 | function actualizarMarcadores(filtros) { |
216 | var marcadores = []; | 217 | var marcadores = []; |
217 | if (filtros.cliente && filtros.remito === undefined) { | 218 | if (filtros.cliente && filtros.remito === undefined) { |
218 | 219 | ||
219 | $scope.marcadores.forEach(function (marcador) { | 220 | $scope.marcadores.forEach(function (marcador) { |
220 | if (marcador.notaPedido.cliente.NOM === filtros.cliente) { | 221 | if (marcador.notaPedido.cliente.NOM === filtros.cliente) { |
221 | marcadores.push(marcador); | 222 | marcadores.push(marcador); |
222 | } | 223 | } |
223 | }); | 224 | }); |
224 | 225 | ||
225 | if (marcadores.length === 0) { | 226 | if (marcadores.length === 0) { |
226 | focaModalService.alert('No se encontraron coincidencias en la busqueda') | 227 | focaModalService.alert('No se encontraron coincidencias en la busqueda') |
227 | .then(function (data) { | 228 | .then(function (data) { |
228 | if (data) $scope.marcadoresFiltro = marcadores; | 229 | if (data) $scope.marcadoresFiltro = marcadores; |
229 | }); | 230 | }); |
230 | $scope.$broadcast('cleanCabecera'); | 231 | $scope.$broadcast('cleanCabecera'); |
231 | setearFecha(new Date()); | 232 | setearFecha(new Date()); |
232 | return; | 233 | return; |
233 | } else { | 234 | } else { |
234 | $scope.marcadoresFiltro = marcadores; | 235 | $scope.marcadoresFiltro = marcadores; |
235 | $scope.$broadcast('addCabecera', { | 236 | $scope.$broadcast('addCabecera', { |
236 | label: 'Cliente:', | 237 | label: 'Cliente:', |
237 | valor: filtros.cliente | 238 | valor: filtros.cliente |
238 | }); | 239 | }); |
239 | } | 240 | } |
240 | } else { | 241 | } else { |
241 | $scope.marcadores.forEach(function (marcador) { | 242 | $scope.marcadores.forEach(function (marcador) { |
242 | if (filtros.remito.id === marcador.notaPedido.remito.id) marcadores.push(marcador); | 243 | if (filtros.remito.id === marcador.notaPedido.remito.id) marcadores.push(marcador); |
243 | }); | 244 | }); |
244 | if (marcadores.length === 0) { | 245 | if (marcadores.length === 0) { |
245 | focaModalService.alert('No se encontraron coincidencias en la busqueda') | 246 | focaModalService.alert('No se encontraron coincidencias en la busqueda') |
246 | .then(function (data) { | 247 | .then(function (data) { |
247 | if (data) $scope.marcadoresFiltro = marcadores; | 248 | if (data) $scope.marcadoresFiltro = marcadores; |
248 | }); | 249 | }); |
249 | $scope.$broadcast('cleanCabecera'); | 250 | $scope.$broadcast('cleanCabecera'); |
250 | setearFecha(new Date()); | 251 | setearFecha(new Date()); |
251 | return; | 252 | return; |
252 | } else { | 253 | } else { |
253 | $scope.marcadoresFiltro = marcadores; | 254 | $scope.marcadoresFiltro = marcadores; |
254 | $scope.$broadcast('addCabecera', { | 255 | $scope.$broadcast('addCabecera', { |
255 | label: 'Cliente:', | 256 | label: 'Cliente:', |
256 | valor: filtros.cliente | 257 | valor: filtros.cliente |
257 | }); | 258 | }); |
258 | } | 259 | } |
259 | } | 260 | } |
260 | } | 261 | } |
261 | 262 | ||
262 | function setearFecha(fecha) { | 263 | function setearFecha(fecha) { |
263 | $scope.fechaReparto = fecha; | 264 | $scope.fechaReparto = fecha; |
264 | focaLogisticaPedidoRutaService.setFechaReparto(fecha); | 265 | focaLogisticaPedidoRutaService.setFechaReparto(fecha); |
265 | focaLogisticaPedidoRutaService.getUnidadesByFecha(fecha).then(function (res) { | 266 | focaLogisticaPedidoRutaService.getUnidadesByFecha(fecha).then(function (res) { |
266 | $scope.vehiculos = res.data; | 267 | $scope.vehiculos = res.data; |
267 | $scope.$broadcast('addCabecera', { | 268 | $scope.$broadcast('addCabecera', { |
268 | label: 'Fecha:', | 269 | label: 'Fecha:', |
269 | valor: fecha.toLocaleDateString() | 270 | valor: fecha.toLocaleDateString() |
270 | }); | 271 | }); |
271 | }); | 272 | }); |
272 | } | 273 | } |
273 | 274 | ||
274 | function getSeguimiento() { | 275 | function getSeguimiento() { |
275 | var desde = new Date('1900/01/01'); | 276 | var desde = new Date('1900/01/01'); |
276 | var hasta = new Date('2099/01/01'); | 277 | var hasta = new Date('2099/01/01'); |
277 | if ($scope.fechaDesde) { | 278 | if ($scope.fechaDesde) { |
278 | var fechaDesde = $scope.fechaDesde; | 279 | var fechaDesde = $scope.fechaDesde; |
279 | desde = new Date(new Date(fechaDesde.setHours(0)).setMinutes(0)); | 280 | desde = new Date(new Date(fechaDesde.setHours(0)).setMinutes(0)); |
280 | desde = new Date(desde); | 281 | desde = new Date(desde); |
281 | } | 282 | } |
282 | if ($scope.fechaHasta) { | 283 | if ($scope.fechaHasta) { |
283 | var fechaHasta = $scope.fechaHasta; | 284 | var fechaHasta = $scope.fechaHasta; |
284 | hasta = new Date(new Date(fechaHasta.setHours(0)).setMinutes(0)); | 285 | hasta = new Date(new Date(fechaHasta.setHours(0)).setMinutes(0)); |
285 | hasta = hasta.setDate(hasta.getDate() + 1); | 286 | hasta = hasta.setDate(hasta.getDate() + 1); |
286 | hasta = new Date(hasta); | 287 | hasta = new Date(hasta); |
287 | } | 288 | } |
288 | var datos = { | 289 | var datos = { |
289 | actividad: $scope.actividad, | 290 | actividad: $scope.actividad, |
290 | idUsuario: $scope.idVendedor, | 291 | idUsuario: $scope.idVendedor, |
291 | fechaDesde: desde, | 292 | fechaDesde: desde, |
292 | fechaHasta: hasta, | 293 | fechaHasta: hasta, |
293 | asignacion: $scope.filtroEstado ? true : ($scope.filtroEstado !== undefined ? | 294 | asignacion: $scope.filtroEstado ? true : ($scope.filtroEstado !== undefined ? |
294 | false : undefined) | 295 | false : undefined) |
295 | }; | 296 | }; |
296 | 297 | ||
297 | $scope.datosBuscados = { | 298 | $scope.datosBuscados = { |
298 | actividad: $scope.actividad, | 299 | actividad: $scope.actividad, |
299 | individual: $scope.idVendedor ? true : false | 300 | individual: $scope.idVendedor ? true : false |
300 | }; | 301 | }; |
301 | 302 | ||
302 | focaLogisticaPedidoRutaService.obtenerActividad(datos).then(function (datos) { | 303 | focaLogisticaPedidoRutaService.obtenerActividad(datos).then(function (datos) { |
303 | if (!angular.equals($scope.marcadores, datos.data)) { | 304 | if (!angular.equals($scope.marcadores, datos.data)) { |
304 | $scope.marcadores = datos.data; | 305 | $scope.marcadores = datos.data; |
305 | $scope.marcadoresFiltro = $scope.marcadores; | 306 | $scope.marcadoresFiltro = $scope.marcadores; |
306 | } | 307 | } |
307 | }); | 308 | }); |
308 | } | 309 | } |
309 | 310 | ||
310 | function eliminarVehiculo(vehiculo) { | 311 | function eliminarVehiculo(vehiculo) { |
311 | focaLogisticaPedidoRutaService.getRemitosByIdVehiculo(vehiculo.id).then(function (res) { | 312 | focaLogisticaPedidoRutaService.getRemitosByIdVehiculo(vehiculo.id).then(function (res) { |
312 | if (!res.data.length) { | 313 | if (!res.data.length) { |
313 | $scope.vehiculos.splice($scope.vehiculos.indexOf(vehiculo), 1); | 314 | $scope.vehiculos.splice($scope.vehiculos.indexOf(vehiculo), 1); |
314 | } else { | 315 | } else { |
315 | focaModalService.alert('No ha sido posible eliminar el vehiculo porque ' + | 316 | focaModalService.alert('No ha sido posible eliminar el vehiculo porque ' + |
316 | 'tiene remitos asociados').then(function () { | 317 | 'tiene remitos asociados').then(function () { |
317 | $scope.hacerHojaRuta(vehiculo, true); | 318 | $scope.hacerHojaRuta(vehiculo, true); |
318 | }); | 319 | }); |
319 | } | 320 | } |
320 | }); | 321 | }); |
321 | } | 322 | } |
322 | 323 | ||
323 | function eligioFecha() { | 324 | function eligioFecha() { |
324 | if (!$scope.fechaReparto) { | 325 | if (!$scope.fechaReparto) { |
325 | focaModalService.alert('Primero seleccione fecha de reparto'); | 326 | focaModalService.alert('Primero seleccione fecha de reparto'); |
326 | return false; | 327 | return false; |
327 | } | 328 | } |
328 | return true; | 329 | return true; |
329 | } | 330 | } |
330 | 331 | ||
331 | function vehiculoEnUso(vehiculo) { | 332 | function vehiculoEnUso(vehiculo) { |
332 | var idUsuario = focaLogisticaPedidoRutaService.idUsuario; | 333 | var idUsuario = focaLogisticaPedidoRutaService.idUsuario; |
333 | for (var i = 0; i < vehiculo.cisternas.length; i++) { | 334 | for (var i = 0; i < vehiculo.cisternas.length; i++) { |
334 | for (var j = 0; j < vehiculo.cisternas[i].cisternasCarga.length; j++) { | 335 | for (var j = 0; j < vehiculo.cisternas[i].cisternasCarga.length; j++) { |
335 | var cisternaCarga = vehiculo.cisternas[i].cisternasCarga[j]; | 336 | var cisternaCarga = vehiculo.cisternas[i].cisternasCarga[j]; |
336 | if (cisternaCarga.fechaReparto.substring(0, 10) === $scope.fechaReparto | 337 | if (cisternaCarga.fechaReparto.substring(0, 10) === $scope.fechaReparto |
337 | .toISOString().substring(0, 10) && cisternaCarga.idUsuarioProceso && | 338 | .toISOString().substring(0, 10) && cisternaCarga.idUsuarioProceso && |
338 | cisternaCarga.idUsuarioProceso !== idUsuario) { | 339 | cisternaCarga.idUsuarioProceso !== idUsuario) { |
339 | focaModalService.alert('El vehículo está siendo usado por otro usuario'); | 340 | focaModalService.alert('El vehículo está siendo usado por otro usuario'); |
340 | return true; | 341 | return true; |
341 | } | 342 | } |
342 | } | 343 | } |
343 | } | 344 | } |
344 | return false; | 345 | return false; |
345 | } | 346 | } |
346 | // $interval(function() { | 347 | // $interval(function() { |
347 | // getSeguimiento(); | 348 | // getSeguimiento(); |
348 | // }, 5000); | 349 | // }, 5000); |
349 | } | 350 | } |
350 | ]); | 351 | ]); |
351 | 352 |