Commit 60f20692e0fb41cb9599375a1818cba49c153a65
1 parent
cde896c9ee
Exists in
master
validaciones
Showing
3 changed files
with
9 additions
and
7 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 | 8 | ||
9 | //Datos Pantalla | 9 | //Datos Pantalla |
10 | $scope.titulo = 'Logistica de Pedidos'; | 10 | $scope.titulo = 'Logistica de Pedidos'; |
11 | var transportista = { | 11 | var transportista = { |
12 | label: 'Unidad', | 12 | label: 'Unidad', |
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: 'fechaDeReparto.png' | 17 | image: 'fechaDeReparto.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 | //SETEO BOTONERA LATERAL | 32 | //SETEO BOTONERA LATERAL |
33 | focaBotoneraLateralService.showSalir(true); | 33 | focaBotoneraLateralService.showSalir(true); |
34 | focaBotoneraLateralService.showPausar(false); | 34 | focaBotoneraLateralService.showPausar(false); |
35 | focaBotoneraLateralService.showGuardar(false); | 35 | focaBotoneraLateralService.showGuardar(false); |
36 | 36 | ||
37 | 37 | ||
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(!$scope.fechaReparto) { | 50 | if(!$scope.fechaReparto) { |
51 | focaModalService.alert('Primero seleccione fecha de reparto'); | 51 | focaModalService.alert('Primero seleccione fecha de reparto'); |
52 | return; | 52 | return; |
53 | } | 53 | } |
54 | var idRemito; | 54 | var idRemito; |
55 | if(punto === -1) { | 55 | if(punto === -1) { |
56 | idRemito = -1; | 56 | idRemito = -1; |
57 | }else { | 57 | }else { |
58 | idRemito = JSON.parse(punto).notaPedido.remito.id; | 58 | idRemito = JSON.parse(punto).notaPedido.remito.id; |
59 | } | 59 | } |
60 | var modalInstance = $uibModal.open( | 60 | var modalInstance = $uibModal.open( |
61 | { | 61 | { |
62 | ariaLabelledBy: 'Busqueda de Vehiculo', | 62 | ariaLabelledBy: 'Busqueda de Vehiculo', |
63 | templateUrl: 'foca-detalle-vehiculo.html', | 63 | templateUrl: 'foca-detalle-vehiculo.html', |
64 | controller: 'focaDetalleVehiculo', | 64 | controller: 'focaDetalleVehiculo', |
65 | size: 'lg', | 65 | size: 'lg', |
66 | resolve: { | 66 | resolve: { |
67 | idVehiculo: function() {return idVehiculo;}, | 67 | idVehiculo: function() {return idVehiculo;}, |
68 | idRemito: function() {return idRemito;}, | 68 | idRemito: function() {return idRemito;}, |
69 | fechaReparto: function() {return $scope.fechaReparto;} | 69 | fechaReparto: function() {return $scope.fechaReparto;} |
70 | } | 70 | } |
71 | } | 71 | } |
72 | ); | 72 | ); |
73 | modalInstance.result.then(function() { | 73 | modalInstance.result.then(function() { |
74 | }, function() { | 74 | }, function() { |
75 | }); | 75 | }); |
76 | }; | 76 | }; |
77 | 77 | ||
78 | $scope.quitarVehiculo = function(vehiculo) { | 78 | $scope.quitarVehiculo = function(vehiculo) { |
79 | //TODO: Pasar validación a función | 79 | //TODO: Pasar validación a función |
80 | $scope.fechaReparto.setHours(0, 0, 0, 0); | 80 | $scope.fechaReparto.setHours(0, 0, 0, 0); |
81 | var idUsuario = focaLogisticaPedidoRutaService.idUsuario; | 81 | var idUsuario = focaLogisticaPedidoRutaService.idUsuario; |
82 | for(var i = 0; i < vehiculo.cisternas.length; i++) { | 82 | for(var i = 0; i < vehiculo.cisternas.length; i++) { |
83 | for(var j = 0; j < vehiculo.cisternas[i].cisternasCarga.length; j++) { | 83 | for(var j = 0; j < vehiculo.cisternas[i].cisternasCarga.length; j++) { |
84 | var cisternaCarga = vehiculo.cisternas[i].cisternasCarga[j]; | 84 | var cisternaCarga = vehiculo.cisternas[i].cisternasCarga[j]; |
85 | if(cisternaCarga.fechaReparto.substring(0, 10) === $scope.fechaReparto | 85 | if(cisternaCarga.fechaReparto.substring(0, 10) === $scope.fechaReparto |
86 | .toISOString().substring(0, 10) && cisternaCarga.idUsuarioProceso !== | 86 | .toISOString().substring(0, 10) && cisternaCarga.idUsuarioProceso !== |
87 | idUsuario) | 87 | idUsuario) |
88 | { | 88 | { |
89 | focaModalService.alert('El vehículo está siendo usado por otro usuario'); | 89 | focaModalService.alert('El vehículo está siendo usado por otro usuario'); |
90 | return; | 90 | return; |
91 | } | 91 | } |
92 | } | 92 | } |
93 | } | 93 | } |
94 | focaModalService.confirm('Esta seguro que desea eliminar el vehículo ' + | 94 | focaModalService.confirm('Esta seguro que desea eliminar el vehículo ' + |
95 | vehiculo.codigo + '?').then(function() { | 95 | vehiculo.codigo + '?').then(function() { |
96 | eliminarVehiculo(vehiculo); | 96 | eliminarVehiculo(vehiculo); |
97 | }); | 97 | }); |
98 | }; | 98 | }; |
99 | 99 | ||
100 | $scope.hacerHojaRuta = function(vehiculo) { | 100 | $scope.hacerHojaRuta = function(vehiculo) { |
101 | if(!$scope.fechaReparto) { | 101 | if(!$scope.fechaReparto) { |
102 | focaModalService.alert('Primero seleccione fecha de reparto'); | 102 | focaModalService.alert('Primero seleccione fecha de reparto'); |
103 | return; | 103 | return; |
104 | } | 104 | } |
105 | //TODO: Pasar validación a función | 105 | //TODO: Pasar validación a función |
106 | $scope.fechaReparto.setHours(0, 0, 0, 0); | 106 | $scope.fechaReparto.setHours(0, 0, 0, 0); |
107 | var idUsuario = focaLogisticaPedidoRutaService.idUsuario; | 107 | var idUsuario = focaLogisticaPedidoRutaService.idUsuario; |
108 | for(var i = 0; i < vehiculo.cisternas.length; i++) { | 108 | for(var i = 0; i < vehiculo.cisternas.length; i++) { |
109 | for(var j = 0; j < vehiculo.cisternas[i].cisternasCarga.length; j++) { | 109 | for(var j = 0; j < vehiculo.cisternas[i].cisternasCarga.length; j++) { |
110 | var cisternaCarga = vehiculo.cisternas[i].cisternasCarga[j]; | 110 | var cisternaCarga = vehiculo.cisternas[i].cisternasCarga[j]; |
111 | if(cisternaCarga.fechaReparto.substring(0, 10) === $scope.fechaReparto | 111 | if(cisternaCarga.fechaReparto.substring(0, 10) === $scope.fechaReparto |
112 | .toISOString().substring(0, 10) && cisternaCarga.idUsuarioProceso !== | 112 | .toISOString().substring(0, 10) && cisternaCarga.idUsuarioProceso !== |
113 | idUsuario) | 113 | idUsuario) |
114 | { | 114 | { |
115 | focaModalService.alert('El vehículo está siendo usado por otro usuario'); | 115 | focaModalService.alert('El vehículo está siendo usado por otro usuario'); |
116 | return; | 116 | return; |
117 | } | 117 | } |
118 | } | 118 | } |
119 | } | 119 | } |
120 | var modalInstance = $uibModal.open( | 120 | var modalInstance = $uibModal.open( |
121 | { | 121 | { |
122 | ariaLabelledBy: 'Creación hoja ruta', | 122 | ariaLabelledBy: 'Creación hoja ruta', |
123 | templateUrl: 'foca-modal-cerrar-vehiculo.html', | 123 | templateUrl: 'foca-modal-cerrar-vehiculo.html', |
124 | controller: 'focaModalCerrarVehiculo', | 124 | controller: 'focaModalCerrarVehiculo', |
125 | size: 'lg', | 125 | size: 'lg', |
126 | resolve: { | 126 | resolve: { |
127 | idVehiculo: function() {return vehiculo.id;} | 127 | idVehiculo: function() {return vehiculo.id;} |
128 | } | 128 | } |
129 | } | 129 | } |
130 | ); | 130 | ); |
131 | modalInstance.result.then(function() { | 131 | modalInstance.result.then(function() { |
132 | 132 | ||
133 | }, function() { | 133 | }, function() { |
134 | //usar cuando se cancela el modal | 134 | //usar cuando se cancela el modal |
135 | }); | 135 | }); |
136 | }; | 136 | }; |
137 | 137 | ||
138 | $scope.arrastra = function() { | 138 | $scope.arrastra = function() { |
139 | $scope.arrastrando = true; | 139 | $scope.arrastrando = true; |
140 | $scope.$digest(); | 140 | $scope.$digest(); |
141 | }; | 141 | }; |
142 | 142 | ||
143 | $scope.noArrastra = function() { | 143 | $scope.noArrastra = function() { |
144 | $scope.arrastrando = false; | 144 | $scope.arrastrando = false; |
145 | $scope.$digest(); | 145 | $scope.$digest(); |
146 | }; | 146 | }; |
147 | 147 | ||
148 | $scope.individual = function() { | 148 | $scope.individual = function() { |
149 | $scope.idVendedor = -1; | 149 | $scope.idVendedor = -1; |
150 | }; | 150 | }; |
151 | 151 | ||
152 | $scope.mostrarDetalle = function() { | 152 | $scope.mostrarDetalle = function() { |
153 | $scope.detalle = true; | 153 | $scope.detalle = true; |
154 | }; | 154 | }; |
155 | 155 | ||
156 | $scope.salir = function() { | 156 | $scope.salir = function() { |
157 | $location.path('/'); | 157 | $location.path('/'); |
158 | }; | 158 | }; |
159 | 159 | ||
160 | $scope.search = function() { | 160 | $scope.search = function() { |
161 | getSeguimiento(); | 161 | getSeguimiento(); |
162 | }; | 162 | }; |
163 | 163 | ||
164 | $scope.fecha = function() { | 164 | $scope.fecha = function() { |
165 | getSeguimiento(); | 165 | getSeguimiento(); |
166 | }; | 166 | }; |
167 | 167 | ||
168 | $scope.seleccionarUnidad = function() { | 168 | $scope.seleccionarUnidad = function() { |
169 | var modalInstance = $uibModal.open( | 169 | var modalInstance = $uibModal.open( |
170 | { | 170 | { |
171 | ariaLabelledBy: 'Busqueda de Transportista', | 171 | ariaLabelledBy: 'Busqueda de Transportista', |
172 | templateUrl: 'modal-proveedor.html', | 172 | templateUrl: 'modal-proveedor.html', |
173 | controller: 'focaModalProveedorCtrl', | 173 | controller: 'focaModalProveedorCtrl', |
174 | size: 'lg', | 174 | size: 'lg', |
175 | resolve: { | 175 | resolve: { |
176 | transportista: function() { | 176 | transportista: function() { |
177 | return true; | 177 | return true; |
178 | } | 178 | } |
179 | } | 179 | } |
180 | } | 180 | } |
181 | ); | 181 | ); |
182 | modalInstance.result.then(function(transportista) { | 182 | modalInstance.result.then(function(transportista) { |
183 | $scope.seleccionarVehiculo(transportista.COD); | 183 | $scope.seleccionarVehiculo(transportista.COD); |
184 | }); | 184 | }); |
185 | }; | 185 | }; |
186 | 186 | ||
187 | $scope.seleccionarVehiculo = function(idTransportista) { | 187 | $scope.seleccionarVehiculo = function(idTransportista) { |
188 | var query = '/vehiculo/transportista/' + idTransportista; | 188 | var query = '/vehiculo/transportista/' + idTransportista; |
189 | var columnas = { | 189 | var columnas = { |
190 | nombre: ['Código', 'tractor', 'Semi', 'Capacidad'], | 190 | nombre: ['Código', 'tractor', 'Semi', 'Capacidad'], |
191 | propiedad: ['codigo', 'tractor', 'semi', 'capacidadTotalCisternas'] | 191 | propiedad: ['codigo', 'tractor', 'semi', 'capacidadTotalCisternas'] |
192 | }; | 192 | }; |
193 | var titulo = 'Búsqueda de vehiculos'; | 193 | var titulo = 'Búsqueda de vehiculos'; |
194 | focaModalService.modal(columnas, query, titulo).then( | 194 | focaModalService.modal(columnas, query, titulo).then( |
195 | function(vehiculo) { | 195 | function(vehiculo) { |
196 | var existe = $filter('filter')($scope.vehiculos, {id: vehiculo.id}); | 196 | var existe = $filter('filter')($scope.vehiculos, {id: vehiculo.id}); |
197 | if(existe.length) { | 197 | if(existe.length) { |
198 | focaModalService.alert('El vehiculo ya ha sido cargado'); | 198 | focaModalService.alert('El vehiculo ya ha sido cargado'); |
199 | return; | 199 | return; |
200 | } | 200 | } |
201 | if(!vehiculo.cisternas.length) { | 201 | if(!vehiculo.cisternas.length) { |
202 | focaModalService.alert('El vehiculo no tiene cisternas'); | 202 | focaModalService.alert('El vehiculo no tiene cisternas'); |
203 | return; | 203 | return; |
204 | } | 204 | } |
205 | $scope.vehiculos.push(vehiculo); | 205 | $scope.vehiculos.push(vehiculo); |
206 | }, function() { | 206 | }, function() { |
207 | // funcion ejecutada cuando se cancela el modal | 207 | // funcion ejecutada cuando se cancela el modal |
208 | }); | 208 | }); |
209 | }; | 209 | }; |
210 | 210 | ||
211 | $scope.seleccionarFechaReparto = function() { | 211 | $scope.seleccionarFechaReparto = function() { |
212 | focaModalService.modalFecha('Fecha de reparto').then(function(fecha) { | 212 | focaModalService.modalFecha('Fecha de reparto').then(function(fecha) { |
213 | $scope.$broadcast('addCabecera',{ | 213 | $scope.$broadcast('addCabecera',{ |
214 | label: 'Fecha:', | 214 | label: 'Fecha:', |
215 | valor: fecha.toLocaleDateString() | 215 | valor: fecha.toLocaleDateString() |
216 | }); | 216 | }); |
217 | $scope.fechaReparto = fecha; | 217 | $scope.fechaReparto = fecha; |
218 | focaLogisticaPedidoRutaService.setFechaReparto(fecha); | 218 | focaLogisticaPedidoRutaService.setFechaReparto(fecha); |
219 | focaLogisticaPedidoRutaService.getUnidadesByFecha(fecha).then(function(res) { | 219 | focaLogisticaPedidoRutaService.getUnidadesByFecha(fecha).then(function(res) { |
220 | $scope.vehiculos = res.data; | 220 | $scope.vehiculos = res.data; |
221 | }); | 221 | }); |
222 | }); | 222 | }); |
223 | }; | 223 | }; |
224 | 224 | ||
225 | function getSeguimiento() { | 225 | function getSeguimiento() { |
226 | var desde = new Date('1900/01/01'); | 226 | var desde = new Date('1900/01/01'); |
227 | var hasta = new Date('2099/01/01'); | 227 | var hasta = new Date('2099/01/01'); |
228 | if($scope.fechaDesde) { | 228 | if($scope.fechaDesde) { |
229 | var fechaDesde = $scope.fechaDesde; | 229 | var fechaDesde = $scope.fechaDesde; |
230 | desde = new Date(new Date(fechaDesde.setHours(0)).setMinutes(0)); | 230 | desde = new Date(new Date(fechaDesde.setHours(0)).setMinutes(0)); |
231 | desde = new Date(desde); | 231 | desde = new Date(desde); |
232 | } | 232 | } |
233 | if($scope.fechaHasta) { | 233 | if($scope.fechaHasta) { |
234 | var fechaHasta = $scope.fechaHasta; | 234 | var fechaHasta = $scope.fechaHasta; |
235 | hasta = new Date(new Date(fechaHasta.setHours(0)).setMinutes(0)); | 235 | hasta = new Date(new Date(fechaHasta.setHours(0)).setMinutes(0)); |
236 | hasta = hasta.setDate(hasta.getDate() + 1); | 236 | hasta = hasta.setDate(hasta.getDate() + 1); |
237 | hasta = new Date(hasta); | 237 | hasta = new Date(hasta); |
238 | } | 238 | } |
239 | var datos = { | 239 | var datos = { |
240 | actividad: $scope.actividad, | 240 | actividad: $scope.actividad, |
241 | idUsuario: $scope.idVendedor, | 241 | idUsuario: $scope.idVendedor, |
242 | fechaDesde: desde, | 242 | fechaDesde: desde, |
243 | fechaHasta: hasta, | 243 | fechaHasta: hasta, |
244 | asignacion: $scope.filtroEstado ? true : ($scope.filtroEstado !== undefined ? | 244 | asignacion: $scope.filtroEstado ? true : ($scope.filtroEstado !== undefined ? |
245 | false : undefined) | 245 | false : undefined) |
246 | }; | 246 | }; |
247 | 247 | ||
248 | $scope.datosBuscados = { | 248 | $scope.datosBuscados = { |
249 | actividad: $scope.actividad, | 249 | actividad: $scope.actividad, |
250 | individual: $scope.idVendedor ? true : false | 250 | individual: $scope.idVendedor ? true : false |
251 | }; | 251 | }; |
252 | 252 | ||
253 | focaLogisticaPedidoRutaService.obtenerActividad(datos).then(function(datos) { | 253 | focaLogisticaPedidoRutaService.obtenerActividad(datos).then(function(datos) { |
254 | if(JSON.stringify(datos.data) !== JSON.stringify($scope.marcadores)) { | 254 | if(JSON.stringify(datos.data) !== JSON.stringify($scope.marcadores)) { |
255 | $scope.marcadores = datos.data; | 255 | $scope.marcadores = datos.data; |
256 | } | 256 | } |
257 | }); | 257 | }); |
258 | } | 258 | } |
259 | 259 | ||
260 | function eliminarVehiculo(vehiculo) { | 260 | function eliminarVehiculo(vehiculo) { |
261 | focaLogisticaPedidoRutaService.getRemitos(vehiculo.id).then(function(res) { | 261 | focaLogisticaPedidoRutaService.getRemitos(vehiculo.id).then(function(res) { |
262 | if(!focaLogisticaPedidoRutaService.obtenerRemitosDeCarga(res.data).length) { | 262 | if(!focaLogisticaPedidoRutaService.obtenerRemitosDeCarga(res.data).length) { |
263 | $scope.vehiculos.splice($scope.vehiculos.indexOf(vehiculo), 1); | 263 | $scope.vehiculos.splice($scope.vehiculos.indexOf(vehiculo), 1); |
264 | }else { | 264 | }else { |
265 | focaModalService.alert('No ha sido posible eliminar el vehiculo porque ' + | 265 | focaModalService.alert('No ha sido posible eliminar el vehiculo porque ' + |
266 | 'tiene remitos asociados').then(function() { | 266 | 'tiene remitos asociados').then(function() { |
267 | $scope.hacerHojaRuta(vehiculo); | 267 | $scope.hacerHojaRuta(vehiculo); |
268 | }); | 268 | }); |
269 | } | 269 | } |
270 | }); | 270 | }); |
271 | } | 271 | } |
272 | $interval(function() { | 272 | // TODO: descomentar en produccion |
273 | getSeguimiento(); | 273 | // $interval(function() { |
274 | }, 5000); | 274 | // getSeguimiento(); |
275 | // }, 5000); | ||
275 | } | 276 | } |
276 | ]); | 277 | ]); |
277 | 278 |
src/js/osm-directive.js
1 | angular.module('focaLogisticaPedidoRuta').directive('focaLogistica', function() { | 1 | angular.module('focaLogisticaPedidoRuta').directive('focaLogistica', function() { |
2 | return { | 2 | return { |
3 | restrict: 'E', | 3 | restrict: 'E', |
4 | link: function(scope, el, attrs) { | 4 | link: function(scope, el, attrs) { |
5 | var contenedor = document.createElement('div'); | 5 | var contenedor = document.createElement('div'); |
6 | contenedor.className = 'border border-light rounded'; | 6 | contenedor.className = 'border border-light rounded'; |
7 | el.append(contenedor); | 7 | el.append(contenedor); |
8 | scope.map = L.map(contenedor).setView([attrs.latitud, attrs.longitud], attrs.zoom); | 8 | scope.map = L.map(contenedor).setView([attrs.latitud, attrs.longitud], attrs.zoom); |
9 | L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(scope.map); | 9 | L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(scope.map); |
10 | }, | 10 | }, |
11 | controller: ['$scope', '$filter', function($scope, $filter) { | 11 | controller: ['$scope', '$filter', function($scope, $filter) { |
12 | $scope.markers = []; | 12 | $scope.markers = []; |
13 | $scope.$watch('marcadores', function() { | 13 | $scope.$watch('marcadores', function() { |
14 | for(var i in $scope.markers) { | 14 | for(var i in $scope.markers) { |
15 | $scope.map.removeLayer($scope.markers[i]); | 15 | $scope.map.removeLayer($scope.markers[i]); |
16 | } | 16 | } |
17 | $scope.markers = []; | 17 | $scope.markers = []; |
18 | 18 | ||
19 | angular.forEach($scope.marcadores, function(marcador) { | 19 | angular.forEach($scope.marcadores, function(marcador) { |
20 | var observacion = | 20 | var observacion = |
21 | 'Vendedor: ' + marcador.notaPedido.idVendedor + ' - ' + | 21 | 'Vendedor: ' + marcador.notaPedido.idVendedor + ' - ' + |
22 | ( | 22 | ( |
23 | marcador.notaPedido.vendedor ? | 23 | marcador.notaPedido.vendedor ? |
24 | marcador.notaPedido.vendedor.NomVen : | 24 | marcador.notaPedido.vendedor.NomVen : |
25 | '' | 25 | '' |
26 | ) + '<br/>'; | 26 | ) + '<br/>'; |
27 | observacion += 'Fecha: ' + | 27 | observacion += 'Fecha: ' + |
28 | $filter('date')(marcador.fecha.slice(0,10), 'dd/MM/yyyy') + ' ' + | 28 | $filter('date')(marcador.fecha.slice(0,10), 'dd/MM/yyyy') + ' ' + |
29 | marcador.fecha.slice(11,19) + '<br/>'; | 29 | marcador.fecha.slice(11,19) + '<br/>'; |
30 | observacion += 'Remito Nº: ' + $filter('comprobante')([ | 30 | observacion += 'Remito Nº: ' + $filter('comprobante')([ |
31 | marcador.notaPedido.remito.sucursal, | 31 | marcador.notaPedido.remito.sucursal, |
32 | marcador.notaPedido.remito.numeroRemito | 32 | marcador.notaPedido.remito.numeroRemito |
33 | ]) + '<br/>'; | 33 | ]) + '<br/>'; |
34 | observacion += 'Cliente: ' + | 34 | observacion += 'Cliente: ' + |
35 | marcador.notaPedido.cliente.NOM + '<br/>'; | 35 | marcador.notaPedido.cliente.NOM + '<br/>'; |
36 | 36 | ||
37 | // if($scope.parametros.individual) { | 37 | // if($scope.parametros.individual) { |
38 | observacion += | 38 | observacion += |
39 | 'Total: ' + $filter('currency')(marcador.notaPedido.remito.total, '$'); | 39 | 'Total: ' + $filter('currency')(marcador.notaPedido.remito.total, '$'); |
40 | observacion = 'Orden: ' + marcador.orden + '<br/>' + observacion; | 40 | observacion = 'Orden: ' + marcador.orden + '<br/>' + observacion; |
41 | 41 | ||
42 | if(marcador.distancia) { | 42 | if(marcador.distancia) { |
43 | observacion += '<br/>Distancia a casa central: ' + | 43 | observacion += '<br/>Distancia a casa central: ' + |
44 | marcador.distancia + 'km'; | 44 | marcador.distancia + 'km'; |
45 | } | 45 | } |
46 | observacion += '<br/>'; | 46 | observacion += '<br/>'; |
47 | observacion += '<i class="fa fa-map-marker fa-3x" aria-hidden="true"'+ | 47 | observacion += '<i class="fa fa-map-marker fa-3x" aria-hidden="true"'+ |
48 | 'class="form-control" ondragend="dropEnd()" ondragstart=\'drag(event, '+ | 48 | 'class="form-control" ondragend="dropEnd()" ondragstart=\'drag(event, '+ |
49 | JSON.stringify(marcador)+')\' draggable="true"></i>(Arrastrar icono)'; | 49 | JSON.stringify(marcador)+')\' draggable="true"></i>(Arrastrar icono)'; |
50 | var icon; | 50 | var icon; |
51 | if(marcador.notaPedido.remito.idUsuarioProceso) { | 51 | if(marcador.notaPedido.remito.idUsuarioProceso) { |
52 | //Asignado ROJO | 52 | //Asignado ROJO |
53 | icon = new L.Icon({ | 53 | icon = new L.Icon({ |
54 | iconUrl: 'img/marker-icon-2x-red.png', | 54 | iconUrl: 'img/marker-icon-2x-red.png', |
55 | shadowUrl: 'img/marker-shadow.png', | 55 | shadowUrl: 'img/marker-shadow.png', |
56 | iconSize: [25, 41], | 56 | iconSize: [25, 41], |
57 | iconAnchor: [12, 41], | 57 | iconAnchor: [12, 41], |
58 | popupAnchor: [1, -34], | 58 | popupAnchor: [1, -34], |
59 | shadowSize: [41, 41] | 59 | shadowSize: [41, 41] |
60 | }); | 60 | }); |
61 | }else { | 61 | }else { |
62 | //Sin asignar VERDE | 62 | //Sin asignar VERDE |
63 | icon = new L.Icon({ | 63 | icon = new L.Icon({ |
64 | iconUrl: 'img/marker-icon-2x-green.png', | 64 | iconUrl: 'img/marker-icon-2x-green.png', |
65 | shadowUrl: 'img/marker-shadow.png', | 65 | shadowUrl: 'img/marker-shadow.png', |
66 | iconSize: [25, 41], | 66 | iconSize: [25, 41], |
67 | iconAnchor: [12, 41], | 67 | iconAnchor: [12, 41], |
68 | popupAnchor: [1, -34], | 68 | popupAnchor: [1, -34], |
69 | shadowSize: [41, 41] | 69 | shadowSize: [41, 41] |
70 | }); | 70 | }); |
71 | } | 71 | } |
72 | $scope.markers.push( | 72 | $scope.markers.push( |
73 | L.marker([marcador.latitud, marcador.longitud], {icon: icon}) | 73 | L.marker( |
74 | [marcador.latitud, marcador.longitud], | ||
75 | {icon: icon, draggable: true}) | ||
74 | .addTo($scope.map) | 76 | .addTo($scope.map) |
75 | .bindPopup(observacion) | 77 | .bindPopup(observacion) |
76 | ); | 78 | ); |
77 | //abre marcador del primer punto | 79 | //abre marcador del primer punto |
78 | //$scope.markers[0].openPopup(); | 80 | //$scope.markers[0].openPopup(); |
79 | }); | 81 | }); |
80 | }); | 82 | }); |
81 | }], | 83 | }], |
82 | scope: { | 84 | scope: { |
83 | latitud: '=', | 85 | latitud: '=', |
84 | longitud: '=', | 86 | longitud: '=', |
85 | zoom: '=', | 87 | zoom: '=', |
86 | marcadores: '=', | 88 | marcadores: '=', |
87 | parametros: '=' | 89 | parametros: '=' |
88 | } | 90 | } |
89 | }; | 91 | }; |
90 | }); | 92 | }); |
91 | 93 |
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('idUsuario'), | 11 | idUsuario: $cookies.get('idUsuario'), |
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 | obtenerVehiculoById: function(idVehiculo) { | 15 | obtenerVehiculoById: function(idVehiculo) { |
16 | return $http.get(url + '/vehiculo/' + idVehiculo); | 16 | return $http.get(url + '/vehiculo/' + idVehiculo); |
17 | }, | 17 | }, |
18 | obtenerRemitoById: function(idRemito) { | 18 | obtenerRemitoById: function(idRemito) { |
19 | return $http.get(url + '/remito/obtener/' + idRemito); | 19 | return $http.get(url + '/remito/obtener/' + idRemito); |
20 | }, | 20 | }, |
21 | guardarCisternas: function(cisterna, idRemito) { | 21 | guardarCisternas: function(cisterna, idRemito) { |
22 | return $http.post(url + '/cisterna/guardar/cargar/' + | 22 | return $http.post(url + '/cisterna/guardar/cargar/' + |
23 | this.idUsuario + '/' + idRemito,cisterna); | 23 | this.idUsuario + '/' + idRemito,cisterna); |
24 | }, | 24 | }, |
25 | numeroHojaRuta: function() { | 25 | numeroHojaRuta: function() { |
26 | return $http.get(url + '/hoja-ruta/numero-siguiente'); | 26 | return $http.get(url + '/hoja-ruta/numero-siguiente'); |
27 | }, | 27 | }, |
28 | getRemitos: function(idVehiculo) { | 28 | getRemitos: function(idVehiculo) { |
29 | return $http.get(url + '/remito/sin-hoja-ruta/' +idVehiculo); | 29 | return $http.get(url + '/remito/sin-hoja-ruta/' +idVehiculo); |
30 | }, | 30 | }, |
31 | cerrarDistribuicion: function(remitos) { | 31 | cerrarDistribuicion: function(remitos) { |
32 | return $http.post(url + '/vehiculo/cierre-distribuicion', remitos); | 32 | return $http.post(url + '/vehiculo/cierre-distribuicion', remitos); |
33 | }, | 33 | }, |
34 | desasociarRemitos: function(remitos, idVehiculo, sinRemitos) { | 34 | desasociarRemitos: function(remitos, idVehiculo, sinRemitos) { |
35 | var idsRemitos = []; | 35 | var idsRemitos = []; |
36 | for (var i = 0; i < remitos.length; i++) { | 36 | for (var i = 0; i < remitos.length; i++) { |
37 | idsRemitos.push(remitos[i].id); | 37 | idsRemitos.push(remitos[i].id); |
38 | } | 38 | } |
39 | return $http.post(url + '/vehiculo/desasociar-remitos', | 39 | return $http.post(url + '/vehiculo/desasociar-remitos', |
40 | { | 40 | { |
41 | idsRemitos: idsRemitos, | 41 | idsRemitos: idsRemitos, |
42 | idVehiculo: idVehiculo, | 42 | idVehiculo: idVehiculo, |
43 | vehiculoSinRemitos: sinRemitos | 43 | vehiculoSinRemitos: sinRemitos |
44 | }); | 44 | }); |
45 | }, | 45 | }, |
46 | obtenerRemitosDeCarga: function(remitos) { | 46 | obtenerRemitosDeCarga: function(remitos) { |
47 | var remitosRes = []; | 47 | var remitosRes = []; |
48 | for(var i = 0; i < remitos.cisternas.length; i++) { | 48 | for(var i = 0; i < remitos.cisternas.length; i++) { |
49 | procesoCistena(remitos.cisternas[i], this.fecha.toISOString()); | 49 | procesoCistena(remitos.cisternas[i], this.fecha.toISOString()); |
50 | } | 50 | } |
51 | function procesoCistena(cisterna, fecha) { | 51 | function procesoCistena(cisterna, fecha) { |
52 | for(var j = 0; j < cisterna.cisternasCarga.length; j++) { | 52 | for(var j = 0; j < cisterna.cisternasCarga.length; j++) { |
53 | for(var k = 0; k < cisterna.cisternasCarga[j].cisternaMovimientos | 53 | for(var k = 0; k < cisterna.cisternasCarga[j].cisternaMovimientos |
54 | .length; k++) | 54 | .length; k++) |
55 | { | 55 | { |
56 | if(cisterna.cisternasCarga[j].fechaReparto.substring(0, 10) === | 56 | if(cisterna.cisternasCarga[j].fechaReparto.substring(0, 10) === |
57 | fecha.substring(0, 10) && !cisterna.cisternasCarga[j] | 57 | fecha.substring(0, 10)) |
58 | .confirmado) | ||
59 | { | 58 | { |
60 | procesoMovimiento(cisterna.cisternasCarga[j] | 59 | procesoMovimiento(cisterna.cisternasCarga[j] |
61 | .cisternaMovimientos[k]); | 60 | .cisternaMovimientos[k]); |
62 | } | 61 | } |
63 | } | 62 | } |
64 | } | 63 | } |
65 | } | 64 | } |
66 | function procesoMovimiento(movimiento) { | 65 | function procesoMovimiento(movimiento) { |
67 | if(!movimiento.anulado && movimiento.remito && | 66 | if(!movimiento.anulado && movimiento.remito && |
68 | !movimiento.remito.idHojaRuta) { | 67 | !movimiento.remito.idHojaRuta) { |
69 | var remito = movimiento.remito; | 68 | var remito = movimiento.remito; |
70 | var yaEstaCargado = $filter('filter')(remitosRes, {id: remito.id}); | 69 | var yaEstaCargado = $filter('filter')(remitosRes, {id: remito.id}); |
71 | if(!yaEstaCargado.length && movimiento.metodo === 'carga') { | 70 | if(!yaEstaCargado.length && movimiento.metodo === 'carga') { |
72 | remitosRes.push(remito); | 71 | remitosRes.push(remito); |
73 | } | 72 | } |
74 | } | 73 | } |
75 | } | 74 | } |
76 | return remitosRes; | 75 | return remitosRes; |
77 | }, | 76 | }, |
78 | getVehiculosByIdUsuario: function() { | 77 | getVehiculosByIdUsuario: function() { |
79 | return $http.get(url + '/vehiculo/usuario/' + this.idUsuario); | 78 | return $http.get(url + '/vehiculo/usuario/' + this.idUsuario); |
80 | }, | 79 | }, |
81 | obtenerCisternasPorFecha: function(idVehiculo) { | 80 | obtenerCisternasPorFecha: function(idVehiculo) { |
82 | return $http.post(url + '/cisterna/listar/fecha', | 81 | return $http.post(url + '/cisterna/listar/fecha', |
83 | {idVehiculo: idVehiculo, fechaReparto: this.fecha}); | 82 | {idVehiculo: idVehiculo, fechaReparto: this.fecha}); |
84 | }, | 83 | }, |
85 | getUnidadesByFecha: function() { | 84 | getUnidadesByFecha: function() { |
86 | return $http.post(url + '/vehiculo/listar/fecha', | 85 | return $http.post(url + '/vehiculo/listar/fecha', |
87 | {fecha: this.fecha}); | 86 | {fecha: this.fecha}); |
88 | }, | 87 | }, |
89 | setFechaReparto: function(fechaReparto) { | 88 | setFechaReparto: function(fechaReparto) { |
90 | this.fecha = fechaReparto; | 89 | this.fecha = fechaReparto; |
91 | }, | 90 | } |
92 | }; | 91 | }; |
93 | }]); | 92 | }]); |
94 | 93 |