Commit aaecbd022e08c0a856bf45f674947332a479d735
1 parent
4aa8f26e93
Exists in
master
Mejora logistica de pedidos
Showing
5 changed files
with
256 additions
and
10 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 | |||
157 | $scope.selectVehiculo = function(idTransportista, nombreTransportista) { | 180 | $scope.selectVehiculo = function(idTransportista, nombreTransportista) { |
158 | var parametrosModal = { | 181 | var parametrosModal = { |
159 | columnas: [ | 182 | columnas: [ |
160 | { | 183 | { |
161 | propiedad: 'codigo', | 184 | propiedad: 'codigo', |
162 | nombre: 'Código' | 185 | nombre: 'Código' |
163 | }, | 186 | }, |
164 | { | 187 | { |
165 | propiedad: 'tractor', | 188 | propiedad: 'tractor', |
166 | nombre: 'tractor' | 189 | nombre: 'tractor' |
167 | }, | 190 | }, |
168 | { | 191 | { |
169 | propiedad: 'semi', | 192 | propiedad: 'semi', |
170 | nombre: 'Semi' | 193 | nombre: 'Semi' |
171 | }, | 194 | }, |
172 | { | 195 | { |
173 | propiedad: 'capacidadTotalCisternas', | 196 | propiedad: 'capacidadTotalCisternas', |
174 | nombre: 'Capacidad' | 197 | nombre: 'Capacidad' |
175 | } | 198 | } |
176 | ], | 199 | ], |
177 | query: '/vehiculo/transportista/' + idTransportista, | 200 | query: '/vehiculo/transportista/' + idTransportista, |
178 | titulo: 'Búsqueda de vehiculos', | 201 | titulo: 'Búsqueda de vehiculos', |
179 | subTitulo: idTransportista + '-' + nombreTransportista | 202 | subTitulo: idTransportista + '-' + nombreTransportista |
180 | }; | 203 | }; |
181 | focaModalService.modal(parametrosModal).then( | 204 | focaModalService.modal(parametrosModal).then( |
182 | function(vehiculo) { | 205 | function(vehiculo) { |
183 | var existe = $filter('filter')($scope.vehiculos, {id: vehiculo.id}); | 206 | var existe = $filter('filter')($scope.vehiculos, {id: vehiculo.id}); |
184 | if (existe.length) { | 207 | if (existe.length) { |
185 | focaModalService.alert('El vehiculo ya ha sido cargado'); | 208 | focaModalService.alert('El vehiculo ya ha sido cargado'); |
186 | return; | 209 | return; |
187 | } | 210 | } |
188 | if (!vehiculo.cisternas.length) { | 211 | if (!vehiculo.cisternas.length) { |
189 | focaModalService.alert('El vehiculo no tiene cisternas'); | 212 | focaModalService.alert('El vehiculo no tiene cisternas'); |
190 | return; | 213 | return; |
191 | } | 214 | } |
192 | $scope.vehiculos.push(vehiculo); | 215 | $scope.vehiculos.push(vehiculo); |
193 | }, function() { | 216 | }, function() { |
194 | // funcion ejecutada cuando se cancela el modal | 217 | // funcion ejecutada cuando se cancela el modal |
195 | }); | 218 | }); |
196 | }; | 219 | }; |
197 | |||
198 | $scope.seleccionarFechaReparto = function() { | 220 | $scope.seleccionarFechaReparto = function() { |
199 | focaModalService.modalFecha('Fecha de reparto').then(function(fecha) { | 221 | focaModalService.modalFecha('Fecha de reparto').then(function(fecha) { |
200 | setearFecha(fecha); | 222 | setearFecha(fecha); |
201 | }); | 223 | }); |
202 | }; | 224 | }; |
203 | 225 | ||
226 | function actualizarMarcadores (filtros) { | ||
227 | var marcadores = []; | ||
228 | if (filtros.cliente && filtros.remito === undefined) { | ||
229 | |||
230 | $scope.marcadores.forEach( function (marcador) { | ||
231 | if (marcador.notaPedido.cliente.NOM === filtros.cliente) { | ||
232 | marcadores.push(marcador); | ||
233 | } | ||
234 | }); | ||
235 | |||
236 | if (marcadores.length === 0) { | ||
237 | focaModalService.alert('No se encontraron coincidencias en la busqueda') | ||
238 | .then(function (data) { | ||
239 | if (data) { | ||
240 | $scope.marcadoresFiltro = marcadores; | ||
241 | } | ||
242 | }); | ||
243 | $scope.$broadcast('cleanCabecera'); | ||
244 | setearFecha(new Date()); | ||
245 | return; | ||
246 | } else { | ||
247 | $scope.marcadoresFiltro = marcadores; | ||
248 | $scope.$broadcast('addCabecera', { | ||
249 | label: 'Cliente:', | ||
250 | valor: filtros.cliente | ||
251 | }); | ||
252 | } | ||
253 | } else { | ||
254 | $scope.marcadores.forEach( function (marcador) { | ||
255 | if (filtros.remito.id === marcador.notaPedido.remito.id) { | ||
256 | marcadores.push(marcador); | ||
257 | } | ||
258 | }); | ||
259 | if (marcadores.length === 0) { | ||
260 | focaModalService.alert('No se encontraron coincidencias en la busqueda') | ||
261 | .then(function (data) { | ||
262 | if (data) { | ||
263 | $scope.marcadoresFiltro = marcadores; | ||
264 | } | ||
265 | }); | ||
266 | $scope.$broadcast('cleanCabecera'); | ||
267 | setearFecha(new Date()); | ||
268 | return; | ||
269 | } else { | ||
270 | $scope.marcadoresFiltro = marcadores; | ||
271 | $scope.$broadcast('addCabecera', { | ||
272 | label: 'Cliente:', | ||
273 | valor: filtros.cliente | ||
274 | }); | ||
275 | } | ||
276 | } | ||
277 | } | ||
278 | |||
204 | function setearFecha(fecha) { | 279 | function setearFecha(fecha) { |
205 | $scope.fechaReparto = fecha; | 280 | $scope.fechaReparto = fecha; |
206 | focaLogisticaPedidoRutaService.setFechaReparto(fecha); | 281 | focaLogisticaPedidoRutaService.setFechaReparto(fecha); |
207 | focaLogisticaPedidoRutaService.getUnidadesByFecha(fecha).then(function(res){ | 282 | focaLogisticaPedidoRutaService.getUnidadesByFecha(fecha).then(function(res){ |
208 | $scope.vehiculos = res.data; | 283 | $scope.vehiculos = res.data; |
209 | $scope.$broadcast('addCabecera', { | 284 | $scope.$broadcast('addCabecera', { |
210 | label: 'Fecha:', | 285 | label: 'Fecha:', |
211 | valor: fecha.toLocaleDateString() | 286 | valor: fecha.toLocaleDateString() |
212 | }); | 287 | }); |
213 | }); | 288 | }); |
214 | } | 289 | } |
215 | 290 | ||
216 | function getSeguimiento() { | 291 | function getSeguimiento() { |
217 | var desde = new Date('1900/01/01'); | 292 | var desde = new Date('1900/01/01'); |
218 | var hasta = new Date('2099/01/01'); | 293 | var hasta = new Date('2099/01/01'); |
219 | if ($scope.fechaDesde) { | 294 | if ($scope.fechaDesde) { |
220 | var fechaDesde = $scope.fechaDesde; | 295 | var fechaDesde = $scope.fechaDesde; |
221 | desde = new Date(new Date(fechaDesde.setHours(0)).setMinutes(0)); | 296 | desde = new Date(new Date(fechaDesde.setHours(0)).setMinutes(0)); |
222 | desde = new Date(desde); | 297 | desde = new Date(desde); |
223 | } | 298 | } |
224 | if ($scope.fechaHasta) { | 299 | if ($scope.fechaHasta) { |
225 | var fechaHasta = $scope.fechaHasta; | 300 | var fechaHasta = $scope.fechaHasta; |
226 | hasta = new Date(new Date(fechaHasta.setHours(0)).setMinutes(0)); | 301 | hasta = new Date(new Date(fechaHasta.setHours(0)).setMinutes(0)); |
227 | hasta = hasta.setDate(hasta.getDate() + 1); | 302 | hasta = hasta.setDate(hasta.getDate() + 1); |
228 | hasta = new Date(hasta); | 303 | hasta = new Date(hasta); |
229 | } | 304 | } |
230 | var datos = { | 305 | var datos = { |
231 | actividad: $scope.actividad, | 306 | actividad: $scope.actividad, |
232 | idUsuario: $scope.idVendedor, | 307 | idUsuario: $scope.idVendedor, |
233 | fechaDesde: desde, | 308 | fechaDesde: desde, |
234 | fechaHasta: hasta, | 309 | fechaHasta: hasta, |
235 | asignacion: $scope.filtroEstado ? true : ($scope.filtroEstado !== undefined ? | 310 | asignacion: $scope.filtroEstado ? true : ($scope.filtroEstado !== undefined ? |
236 | false : undefined) | 311 | false : undefined) |
237 | }; | 312 | }; |
238 | 313 | ||
239 | $scope.datosBuscados = { | 314 | $scope.datosBuscados = { |
240 | actividad: $scope.actividad, | 315 | actividad: $scope.actividad, |
241 | individual: $scope.idVendedor ? true : false | 316 | individual: $scope.idVendedor ? true : false |
242 | }; | 317 | }; |
243 | 318 | ||
244 | focaLogisticaPedidoRutaService.obtenerActividad(datos).then(function(datos) { | 319 | focaLogisticaPedidoRutaService.obtenerActividad(datos).then(function(datos) { |
245 | if (JSON.stringify(datos.data) !== JSON.stringify($scope.marcadores)) { | 320 | if (!angular.equals($scope.marcadores, datos.data)) { |
246 | $scope.marcadores = datos.data; | 321 | $scope.marcadores = datos.data; |
322 | $scope.marcadoresFiltro = $scope.marcadores; | ||
247 | } | 323 | } |
248 | }); | 324 | }); |
249 | } | 325 | } |
250 | 326 | ||
251 | function eliminarVehiculo(vehiculo) { | 327 | function eliminarVehiculo(vehiculo) { |
252 | focaLogisticaPedidoRutaService.getRemitosByIdVehiculo(vehiculo.id).then(function(res) { | 328 | focaLogisticaPedidoRutaService.getRemitosByIdVehiculo(vehiculo.id).then(function(res) { |
253 | if (!res.data.length) { | 329 | if (!res.data.length) { |
254 | $scope.vehiculos.splice($scope.vehiculos.indexOf(vehiculo), 1); | 330 | $scope.vehiculos.splice($scope.vehiculos.indexOf(vehiculo), 1); |
255 | } else { | 331 | } else { |
256 | focaModalService.alert('No ha sido posible eliminar el vehiculo porque ' + | 332 | focaModalService.alert('No ha sido posible eliminar el vehiculo porque ' + |
257 | 'tiene remitos asociados').then(function() { | 333 | 'tiene remitos asociados').then(function() { |
258 | $scope.hacerHojaRuta(vehiculo, true); | 334 | $scope.hacerHojaRuta(vehiculo, true); |
259 | }); | 335 | }); |
260 | } | 336 | } |
261 | }); | 337 | }); |
262 | } | 338 | } |
263 | 339 | ||
264 | function eligioFecha() { | 340 | function eligioFecha() { |
265 | if (!$scope.fechaReparto) { | 341 | if (!$scope.fechaReparto) { |
266 | focaModalService.alert('Primero seleccione fecha de reparto'); | 342 | focaModalService.alert('Primero seleccione fecha de reparto'); |
267 | return false; | 343 | return false; |
268 | } | 344 | } |
269 | return true; | 345 | return true; |
270 | } | 346 | } |
271 | 347 | ||
272 | function vehiculoEnUso(vehiculo) { | 348 | function vehiculoEnUso(vehiculo) { |
273 | var idUsuario = focaLogisticaPedidoRutaService.idUsuario; | 349 | var idUsuario = focaLogisticaPedidoRutaService.idUsuario; |
274 | for(var i = 0; i < vehiculo.cisternas.length; i++) { | 350 | for(var i = 0; i < vehiculo.cisternas.length; i++) { |
275 | for(var j = 0; j < vehiculo.cisternas[i].cisternasCarga.length; j++) { | 351 | for(var j = 0; j < vehiculo.cisternas[i].cisternasCarga.length; j++) { |
276 | var cisternaCarga = vehiculo.cisternas[i].cisternasCarga[j]; | 352 | var cisternaCarga = vehiculo.cisternas[i].cisternasCarga[j]; |
277 | if (cisternaCarga.fechaReparto.substring(0, 10) === $scope.fechaReparto | 353 | if (cisternaCarga.fechaReparto.substring(0, 10) === $scope.fechaReparto |
278 | .toISOString().substring(0, 10) && cisternaCarga.idUsuarioProceso && | 354 | .toISOString().substring(0, 10) && cisternaCarga.idUsuarioProceso && |
279 | cisternaCarga.idUsuarioProceso !== idUsuario) | 355 | cisternaCarga.idUsuarioProceso !== idUsuario) |
280 | { | 356 | { |
281 | focaModalService.alert('El vehículo está siendo usado por otro usuario'); | 357 | focaModalService.alert('El vehículo está siendo usado por otro usuario'); |
282 | return true; | 358 | return true; |
283 | } | 359 | } |
284 | } | 360 | } |
285 | } | 361 | } |
286 | return false; | 362 | return false; |
287 | } | 363 | } |
288 | $interval(function() { | 364 | // $interval(function() { |
289 | getSeguimiento(); | 365 | // getSeguimiento(); |
290 | }, 5000); | 366 | // }, 5000); |
291 | } | 367 | } |
292 | ]); | 368 | ]); |
src/js/controllerBusquedaAvanzada.js
File was created | 1 | angular.module('focaLogisticaPedidoRuta') .controller('focaModalBusquedaAvanzadaController', [ | |
2 | '$scope', 'focaLogisticaPedidoRutaService', '$uibModal', '$filter', | ||
3 | 'focaModalService', '$uibModalInstance', 'parametrosModal', | ||
4 | function($scope, focaLogisticaPedidoRutaService, $uibModal, $filter, | ||
5 | focaModalService, $uibModalInstance, parametrosModal | ||
6 | ) { | ||
7 | $scope.cliente = ''; | ||
8 | $scope.seleccionarCliente = function (key) { | ||
9 | if (key !== 13) { | ||
10 | return; | ||
11 | } | ||
12 | focaModalService.modal({ | ||
13 | titulo: 'Clientes', | ||
14 | searchText: $scope.cliente, | ||
15 | query: '/cliente', | ||
16 | size: 'md', | ||
17 | columnas: [ | ||
18 | { | ||
19 | propiedad: 'COD', | ||
20 | nombre: 'Codigo' | ||
21 | }, | ||
22 | { | ||
23 | propiedad: 'NOM', | ||
24 | nombre: 'Nombre' | ||
25 | }, | ||
26 | { | ||
27 | propiedad: 'CUIT', | ||
28 | nombre: 'CUIT' | ||
29 | } | ||
30 | ], | ||
31 | }).then(function (res) { | ||
32 | $scope.cliente = res.NOM; | ||
33 | }).catch(function (e) { | ||
34 | console.log(e); | ||
35 | }); | ||
36 | }; | ||
37 | |||
38 | $scope.seleccionarRemito = function () { | ||
39 | var modalInstance = $uibModal.open( | ||
40 | { | ||
41 | ariaLabelledBy: 'Busqueda de Remito', | ||
42 | templateUrl: 'foca-modal-remito.html', | ||
43 | controller: 'focaModalRemitoController', | ||
44 | size: 'lg', | ||
45 | resolve: { usadoPor: function () { return 'remito'; } } | ||
46 | } | ||
47 | ); | ||
48 | modalInstance.result.then(function(remito) { | ||
49 | $scope.remito = remito; | ||
50 | $scope.remito.numero = $filter('rellenarDigitos')(remito.lugar, 4) + '-' + | ||
51 | $filter('rellenarDigitos')(remito.numeroRemito, 6); | ||
52 | $scope.cliente = remito.cliente.NOM; | ||
53 | }, function () { | ||
54 | // funcion ejecutada cuando se cancela el modal | ||
55 | } | ||
56 | ); | ||
57 | }; | ||
58 | |||
59 | $scope.cancel = function () { | ||
60 | $uibModalInstance.dismiss('close'); | ||
61 | }; | ||
62 | |||
63 | $scope.buscar = function () { | ||
64 | $uibModalInstance.close(datos()); | ||
65 | }; | ||
66 | |||
67 | function datos () { | ||
68 | var datos = { | ||
69 | cliente: $scope.cliente, | ||
70 | remito: $scope.remito | ||
71 | }; | ||
72 | return datos; | ||
73 | } | ||
74 | } | ||
75 | ]); | ||
76 |
src/js/service.js
1 | angular.module('focaLogisticaPedidoRuta') | 1 | angular.module('focaLogisticaPedidoRuta') |
2 | .factory( | 2 | .factory( |
3 | 'focaLogisticaPedidoRutaService', [ | 3 | 'focaLogisticaPedidoRutaService', [ |
4 | '$http', | 4 | '$http', |
5 | '$cookies', | 5 | '$cookies', |
6 | 'API_ENDPOINT', | 6 | 'API_ENDPOINT', |
7 | '$filter', | 7 | '$filter', |
8 | function($http, $cookies, API_ENDPOINT, $filter) { | 8 | function($http, $cookies, API_ENDPOINT, $filter) { |
9 | var url = API_ENDPOINT.URL; | 9 | var url = API_ENDPOINT.URL; |
10 | return { | 10 | return { |
11 | idUsuario: $cookies.get('vendedorCobrador'), | 11 | idUsuario: $cookies.get('vendedorCobrador'), |
12 | obtenerActividad: function(parametros) { | 12 | obtenerActividad: function(parametros) { |
13 | return $http.post(url + '/seguimiento/filtros', parametros); | 13 | return $http.post(url + '/seguimiento/filtros', parametros); |
14 | }, | 14 | }, |
15 | numeroHojaRuta: function() { | 15 | numeroHojaRuta: function() { |
16 | return $http.get(url + '/hoja-ruta/numero-siguiente'); | 16 | return $http.get(url + '/hoja-ruta/numero-siguiente'); |
17 | }, | 17 | }, |
18 | getRemitos: function(idVehiculo) { | 18 | getRemitos: function(idVehiculo) { |
19 | return $http.get(url + '/remito/sin-hoja-ruta/' + idVehiculo); | 19 | return $http.get(url + '/remito/sin-hoja-ruta/' + idVehiculo); |
20 | }, | 20 | }, |
21 | cerrarDistribuicion: function(remitos) { | 21 | cerrarDistribuicion: function(remitos) { |
22 | return $http.post(url + '/vehiculo/cierre-distribuicion', remitos); | 22 | return $http.post(url + '/vehiculo/cierre-distribuicion', remitos); |
23 | }, | 23 | }, |
24 | getArticulos: function () { | ||
25 | return $http.get(url + '/articulos'); | ||
26 | }, | ||
27 | getAllClientes: function () { | ||
28 | return $http.get(url + '/cliente'); | ||
29 | }, | ||
24 | desasociarRemitos: function(remitos, idVehiculo, sinRemitos) { | 30 | desasociarRemitos: function(remitos, idVehiculo, sinRemitos) { |
25 | var idsRemitos = []; | 31 | var idsRemitos = []; |
26 | for (var i = 0; i < remitos.length; i++) { | 32 | for (var i = 0; i < remitos.length; i++) { |
27 | idsRemitos.push(remitos[i].id); | 33 | idsRemitos.push(remitos[i].id); |
28 | } | 34 | } |
29 | return $http.post(url + '/vehiculo/desasociar-remitos', | 35 | return $http.post(url + '/vehiculo/desasociar-remitos', |
30 | { | 36 | { |
31 | idsRemitos: idsRemitos, | 37 | idsRemitos: idsRemitos, |
32 | idVehiculo: idVehiculo, | 38 | idVehiculo: idVehiculo, |
33 | vehiculoSinRemitos: sinRemitos | 39 | vehiculoSinRemitos: sinRemitos |
34 | }); | 40 | }); |
35 | }, | 41 | }, |
36 | getRemitosByIdVehiculo: function(idVehiculo, sinConfirmar, sinHojaRuta) { | 42 | getRemitosByIdVehiculo: function(idVehiculo, sinConfirmar, sinHojaRuta) { |
37 | var sinHoja = sinHojaRuta ? '/sinHojaRuta' : ''; | 43 | var sinHoja = sinHojaRuta ? '/sinHojaRuta' : ''; |
38 | return $http.get(url + '/vehiculo/obtener/remitos/' + | 44 | return $http.get(url + '/vehiculo/obtener/remitos/' + |
39 | idVehiculo + '/' + this.fecha.toISOString().substring(0, 10) + | 45 | idVehiculo + '/' + this.fecha.toISOString().substring(0, 10) + |
40 | '/' + sinConfirmar + sinHoja); | 46 | '/' + sinConfirmar + sinHoja); |
41 | }, | 47 | }, |
42 | getVehiculosByIdUsuario: function() { | 48 | getVehiculosByIdUsuario: function() { |
43 | return $http.get(url + '/vehiculo/usuario/' + this.idUsuario); | 49 | return $http.get(url + '/vehiculo/usuario/' + this.idUsuario); |
44 | }, | 50 | }, |
45 | getUnidadesByFecha: function() { | 51 | getUnidadesByFecha: function() { |
46 | return $http.post(url + '/vehiculo/listar/fecha', | 52 | return $http.post(url + '/vehiculo/listar/fecha', |
47 | {fecha: this.fecha}); | 53 | {fecha: this.fecha}); |
48 | }, | 54 | }, |
49 | setFechaReparto: function(fechaReparto) { | 55 | setFechaReparto: function(fechaReparto) { |
50 | this.fecha = fechaReparto; | 56 | this.fecha = fechaReparto; |
51 | }, | 57 | }, |
52 | obtenerVehiculoById: function(idVehiculo) { | 58 | obtenerVehiculoById: function(idVehiculo) { |
53 | return $http.get(url + '/vehiculo/' + idVehiculo); | 59 | return $http.get(url + '/vehiculo/' + idVehiculo); |
54 | } | 60 | } |
55 | }; | 61 | }; |
56 | }]); | 62 | }]); |
57 | 63 |
src/views/foca-logistica-pedido-ruta.html
1 | <div class="foca-logistica-pedido-ruta" id="scope"> | 1 | <div class="foca-logistica-pedido-ruta" id="scope"> |
2 | <div class="row"> | 2 | <div class="row"> |
3 | <foca-cabecera-facturador | 3 | <foca-cabecera-facturador |
4 | titulo="titulo" | 4 | titulo="titulo" |
5 | fecha="now" | 5 | fecha="now" |
6 | class="mb-0 col-lg-12" | 6 | class="mb-0 col-lg-12" |
7 | ></foca-cabecera-facturador> | 7 | ></foca-cabecera-facturador> |
8 | </div> | 8 | </div> |
9 | <div class="row px-5 py-2 botonera-secundaria position-relative"> | 9 | <div class="row px-5 py-2 botonera-secundaria position-relative"> |
10 | <div class="col-10"> | 10 | <div class="col-10"> |
11 | <foca-botonera-facturador botones="botonera" max="6" class="row"></foca-botonera-facturador> | 11 | <foca-botonera-facturador botones="botonera" max="6" class="row"></foca-botonera-facturador> |
12 | </div> | 12 | </div> |
13 | <div class="col-2 pl-0 position-absolute right-0"> | 13 | <div class="col-2 px-0 position-absolute right-0"> |
14 | <strong>Ver Remitos</strong> | 14 | <strong>Ver Remitos</strong> |
15 | <br> | 15 | <br> |
16 | <span>Fecha Desde</span> | 16 | <span>Fecha Desde</span> |
17 | <input | 17 | <input |
18 | type="text" | 18 | type="text" |
19 | readonly | 19 | readonly |
20 | ng-model="fechaDesde" | 20 | ng-model="fechaDesde" |
21 | class="form-control form-control-sm" | 21 | class="form-control form-control-sm" |
22 | uib-datepicker-popup="dd/MM/yyyy" | 22 | uib-datepicker-popup="dd/MM/yyyy" |
23 | show-button-bar="false" | 23 | show-button-bar="false" |
24 | is-open="fechaDesdeOpen" | 24 | is-open="fechaDesdeOpen" |
25 | on-open-focus="false" | 25 | on-open-focus="false" |
26 | ng-focus="fechaDesdeOpen = true" | 26 | ng-focus="fechaDesdeOpen = true" |
27 | ng-change="search()" | 27 | ng-change="search()" |
28 | /> | 28 | /> |
29 | <span>Fecha Hasta</span> | 29 | <span>Fecha Hasta</span> |
30 | <input | 30 | <input |
31 | type="text" | 31 | type="text" |
32 | readonly | 32 | readonly |
33 | ng-model="fechaHasta" | 33 | ng-model="fechaHasta" |
34 | class="form-control form-control-sm" | 34 | class="form-control form-control-sm" |
35 | uib-datepicker-popup="dd/MM/yyyy" | 35 | uib-datepicker-popup="dd/MM/yyyy" |
36 | show-button-bar="false" | 36 | show-button-bar="false" |
37 | is-open="fechaHastaOpen" | 37 | is-open="fechaHastaOpen" |
38 | on-open-focus="false" | 38 | on-open-focus="false" |
39 | ng-focus="fechaHastaOpen = true" | 39 | ng-focus="fechaHastaOpen = true" |
40 | ng-change="search()" | 40 | ng-change="search()" |
41 | /> | 41 | /> |
42 | <div class="custom-control custom-radio pt-4"> | 42 | <div class="custom-control custom-radio pt-4"> |
43 | <input | 43 | <input |
44 | type="radio" | 44 | type="radio" |
45 | class="custom-control-input" | 45 | class="custom-control-input" |
46 | id="idTodos" | 46 | id="idTodos" |
47 | name="filtro" | 47 | name="filtro" |
48 | ng-model="filtroEstado" | 48 | ng-model="filtroEstado" |
49 | ng-change="search()" | 49 | ng-change="search()" |
50 | checked> | 50 | checked> |
51 | <label class="custom-control-label pb-3" for="idTodos"></label> | 51 | <label class="custom-control-label pb-3" for="idTodos"></label> |
52 | <img src="img/marker-icon-grey.png"> | 52 | <img src="img/marker-icon-grey.png"> |
53 | <strong>Todos</strong> | 53 | <strong>Todos</strong> |
54 | </div> | 54 | </div> |
55 | <div class="custom-control custom-radio"> | 55 | <div class="custom-control custom-radio"> |
56 | <input | 56 | <input |
57 | type="radio" | 57 | type="radio" |
58 | class="custom-control-input" | 58 | class="custom-control-input" |
59 | id="idSinAsignar" | 59 | id="idSinAsignar" |
60 | name="filtro" | 60 | name="filtro" |
61 | ng-model="filtroEstado" | 61 | ng-model="filtroEstado" |
62 | ng-change="search()" | 62 | ng-change="search()" |
63 | ng-value="false"> | 63 | ng-value="false"> |
64 | <label class="custom-control-label pb-3" for="idSinAsignar"></label> | 64 | <label class="custom-control-label pb-3" for="idSinAsignar"></label> |
65 | <img src="img/marker-icon-green.png"> | 65 | <img src="img/marker-icon-green.png"> |
66 | <strong>Sin asignar</strong> | 66 | <strong>Sin asignar</strong> |
67 | </div> | 67 | </div> |
68 | <div class="custom-control custom-radio"> | 68 | <div class="custom-control custom-radio"> |
69 | <input | 69 | <input |
70 | type="radio" | 70 | type="radio" |
71 | class="custom-control-input" | 71 | class="custom-control-input" |
72 | id="idAsignado" | 72 | id="idAsignado" |
73 | name="filtro" | 73 | name="filtro" |
74 | ng-model="filtroEstado" | 74 | ng-model="filtroEstado" |
75 | ng-change="search()" | 75 | ng-change="search()" |
76 | ng-value="true"> | 76 | ng-value="true"> |
77 | <label class="custom-control-label pb-3" for="idAsignado"></label> | 77 | <label class="custom-control-label pb-3" for="idAsignado"></label> |
78 | <img src="img/marker-icon-red.png"> | 78 | <img src="img/marker-icon-red.png"> |
79 | <strong>Asignado</strong> | 79 | <strong>Asignado</strong> |
80 | </div> | 80 | </div> |
81 | <div class="pt-4"> | ||
82 | <button | ||
83 | ladda="searchLoading" | ||
84 | class="btn btn-outline-light" | ||
85 | type="button" | ||
86 | ng-click="busquedaAvanzada()" | ||
87 | > | ||
88 | <span class="text-dark text-truncate"> | ||
89 | Búsqueda Avanzada | ||
90 | <i class="fa fa-search" aria-hidden="true"></i> | ||
91 | </span> | ||
92 | </button> | ||
93 | </div> | ||
81 | </div> | 94 | </div> |
82 | </div> | 95 | </div> |
83 | <div class="row px-5"> | 96 | <div class="row px-5"> |
84 | <div class="col-10"> | 97 | <div class="col-10"> |
85 | <foca-logistica | 98 | <foca-logistica |
86 | latitud="-34.7152975" | 99 | latitud="-34.7152975" |
87 | longitud="-65.9053867" | 100 | longitud="-65.9053867" |
88 | zoom="5" | 101 | zoom="5" |
89 | marcadores="marcadores" | 102 | marcadores="marcadoresFiltro" |
90 | parametros= "datosBuscados" | 103 | parametros= "datosBuscados" |
91 | /> | 104 | /> |
92 | </div> | 105 | </div> |
93 | <div class="col-12 p-0"> | 106 | <div class="col-12 p-0"> |
94 | <div class="py-2 row"> | 107 | <div class="py-2 row"> |
95 | <div class="col-sm-3" ng-repeat="vehiculo in vehiculos"> | 108 | <div class="col-sm-3" ng-repeat="vehiculo in vehiculos"> |
96 | <div | 109 | <div |
97 | style="width: 15rem;" | 110 | style="width: 15rem;" |
98 | class="card bg-secondary text-white m-2"> | 111 | class="card bg-secondary text-white m-2"> |
99 | <div class="card-body text-center"> | 112 | <div class="card-body text-center"> |
100 | <p class="card-text">{{vehiculo.transportista.NOM.trim()}}</p> | 113 | <p class="card-text">{{vehiculo.transportista.NOM.trim()}}</p> |
101 | <p class="card-text"></p> | 114 | <p class="card-text"></p> |
102 | <p class="card-text">{{vehiculo.codigo}}</p> | 115 | <p class="card-text">{{vehiculo.codigo}}</p> |
103 | </div> | 116 | </div> |
104 | <div class="card-footer" ng-hide="arrastrando"> | 117 | <div class="card-footer" ng-hide="arrastrando"> |
105 | <div class="row justify-content-around"> | 118 | <div class="row justify-content-around"> |
106 | <div class="col-3 ml-2"> | 119 | <div class="col-3 ml-2"> |
107 | <i | 120 | <i |
108 | class="fa fa-trash fa-2x" | 121 | class="fa fa-trash fa-lg" |
109 | uib-tooltip="Eliminar vehiculo" | 122 | uib-tooltip="Eliminar vehiculo" |
110 | ng-click="quitarVehiculo(vehiculo)"> | 123 | ng-click="quitarVehiculo(vehiculo)"> |
111 | </i> | 124 | </i> |
112 | </div> | 125 | </div> |
113 | <div class="col-3"> | 126 | <div class="col-3"> |
114 | <i | 127 | <i |
115 | class="fa fa-eye fa-2x" | 128 | class="fa fa-eye fa-lg" |
116 | uib-tooltip="Ver cisternas" | 129 | uib-tooltip="Ver cisternas" |
117 | ng-click="cargar(vehiculo.id, -1)"> | 130 | ng-click="cargar(vehiculo.id, -1)"> |
118 | </i> | 131 | </i> |
119 | </div> | 132 | </div> |
120 | <div class="col-3"> | 133 | <div class="col-3"> |
121 | <i | 134 | <i |
122 | class="fa fa-save fa-2x" | 135 | class="fa fa-save fa-lg" |
123 | uib-tooltip="Confirmar distribuición" | 136 | uib-tooltip="Confirmar distribuición" |
124 | ng-click="hacerHojaRuta(vehiculo)"> | 137 | ng-click="hacerHojaRuta(vehiculo)"> |
125 | </i> | 138 | </i> |
126 | </div> | 139 | </div> |
127 | </div> | 140 | </div> |
128 | </div> | 141 | </div> |
129 | <div class="card-footer text-center" ng-show="arrastrando"> | 142 | <div class="card-footer text-center" ng-show="arrastrando"> |
130 | <button | 143 | <button |
131 | class="btn flashit btn-block btn-dashed text-dark" | 144 | class="btn flashit btn-block btn-dashed text-dark" |
132 | id="{{vehiculo.id}}" | 145 | id="{{vehiculo.id}}" |
133 | ondrop="drop(event)" | 146 | ondrop="drop(event)" |
134 | ondragover="allowDrop(event)"> | 147 | ondragover="allowDrop(event)"> |
135 | Arrastrar aquí | 148 | Arrastrar aquí |
136 | </button> | 149 | </button> |
137 | </div> | 150 | </div> |
138 | </div> | 151 | </div> |
139 | </div> | 152 | </div> |
140 | </div> | 153 | </div> |
141 | </div> | 154 | </div> |
142 | </div> | 155 | </div> |
143 | </div> | 156 | </div> |
144 | 157 |
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 | </div> | ||
6 | </div> | ||
7 | </div> | ||
8 | <div class="modal-body"> | ||
9 | <div class="row"> | ||
10 | <div class="col-12"> | ||
11 | <h6>Remitos del cliente:</h6> | ||
12 | </div> | ||
13 | <div class="col-12"> | ||
14 | <div class="input-group"> | ||
15 | <input | ||
16 | class="form-control" | ||
17 | ng-model="cliente" | ||
18 | ng-keypress="seleccionarCliente($event.keyCode)" | ||
19 | placeholder="Ingrese un cliente" | ||
20 | /> | ||
21 | <button | ||
22 | ng-show="cliente !== ''" | ||
23 | type="button" | ||
24 | class="clear-input" | ||
25 | ng-click="cliente = '';" | ||
26 | ><i class="fa fa-times"></i> | ||
27 | </button> | ||
28 | <div class="input-group-append"> | ||
29 | <button | ||
30 | ladda="searchLoading" | ||
31 | class="btn btn-outline-secondary form-control" | ||
32 | type="button" | ||
33 | ng-click="seleccionarCliente(13)"> | ||
34 | <i class="fa fa-search" aria-hidden="true"></i> | ||
35 | </button> | ||
36 | </div> | ||
37 | </div> | ||
38 | </div> | ||
39 | </div> | ||
40 | <div class="row pt-3"> | ||
41 | <div class="col-12"> | ||
42 | <h6>Remito Nº</h6> | ||
43 | </div> | ||
44 | <div class="col-12"> | ||
45 | <div class="input-group"> | ||
46 | <input | ||
47 | class="form-control" | ||
48 | ng-model="remito.numero" | ||
49 | ng-click="seleccionarRemito()" | ||
50 | readonly/> | ||
51 | <div class="input-group-append"> | ||
52 | <button | ||
53 | ladda="searchLoading" | ||
54 | class="btn btn-outline-secondary form-control" | ||
55 | type="button" | ||
56 | ng-click="seleccionarRemito()"> | ||
57 | <i class="fa fa-search" aria-hidden="true"></i> | ||
58 | </button> | ||
59 | </div> | ||
60 | </div> | ||
61 | </div> | ||
62 | </div> | ||
63 | </div> | ||
64 | <div class="modal-footer py-1"> | ||
65 | <button | ||
66 | class="btn btn-sm btn-secondary" | ||
67 | type="button" | ||
68 | data-dismiss="modal" | ||
69 | ng-click="cancel()">Cancelar | ||
70 | </button> | ||
71 | <button | ||
72 | class="btn btn-sm btn-primary" | ||
73 | type="button" | ||
74 | ng-click="buscar()">Buscar | ||
75 | </button> | ||
76 | </div> |