Commit 70e8a0267fb4fe3fc527d3d055b4e3b1b0456ace

Authored by Marcelo Puebla
Exists in develop

Merge branch 'develop' into 'develop'

Develop

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