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