Commit 47b0b44a4aafd560084dc0b9c007fa65b123b98e
1 parent
8fd2c4e9bd
Exists in
master
and in
1 other branch
boton ver productos en popup, fuera total
Showing
2 changed files
with
34 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 | |||
9 | //Datos Pantalla | 8 | //Datos Pantalla |
10 | $scope.titulo = 'Logistica de Pedidos'; | 9 | $scope.titulo = 'Logistica de Pedidos'; |
11 | var transportista = { | 10 | var transportista = { |
12 | label: 'Vehículo', | 11 | label: 'Vehículo', |
13 | image: 'abmChofer.png' | 12 | image: 'abmChofer.png' |
14 | }; | 13 | }; |
15 | var fecha = { | 14 | var fecha = { |
16 | label: 'Fecha Reparto', | 15 | label: 'Fecha Reparto', |
17 | image: 'fechaDeReparto.png' | 16 | image: 'fechaDeReparto.png' |
18 | }; | 17 | }; |
19 | $scope.botonera = [fecha, transportista]; | 18 | $scope.botonera = [fecha, transportista]; |
20 | var cabecera = ''; | 19 | var cabecera = ''; |
21 | $scope.now = new Date(); | 20 | $scope.now = new Date(); |
22 | $scope.idVendedor = 0; | 21 | $scope.idVendedor = 0; |
23 | $scope.marcadores = []; | 22 | $scope.marcadores = []; |
24 | $scope.vehiculos = []; | 23 | $scope.vehiculos = []; |
25 | getSeguimiento(); | 24 | getSeguimiento(); |
26 | $scope.arrastrando = false; | 25 | $scope.arrastrando = false; |
27 | $scope.general = function() { | 26 | $scope.general = function() { |
28 | $scope.idVendedor = 0; | 27 | $scope.idVendedor = 0; |
29 | getSeguimiento(); | 28 | getSeguimiento(); |
30 | }; | 29 | }; |
31 | 30 | ||
32 | //SETEO BOTONERA LATERAL | 31 | //SETEO BOTONERA LATERAL |
33 | focaBotoneraLateralService.showSalir(true); | 32 | focaBotoneraLateralService.showSalir(true); |
34 | focaBotoneraLateralService.showPausar(false); | 33 | focaBotoneraLateralService.showPausar(false); |
35 | focaBotoneraLateralService.showGuardar(false); | 34 | focaBotoneraLateralService.showGuardar(false); |
36 | 35 | ||
37 | $scope.general = function() { | 36 | $scope.general = function() { |
38 | $scope.idVendedor = 0; | 37 | $scope.idVendedor = 0; |
39 | getSeguimiento(); | 38 | getSeguimiento(); |
40 | $scope.$broadcast('removeCabecera', cabecera); | 39 | $scope.$broadcast('removeCabecera', cabecera); |
41 | $scope.$broadcast('addCabecera', { | 40 | $scope.$broadcast('addCabecera', { |
42 | label: 'General', | 41 | label: 'General', |
43 | valor: '' | 42 | valor: '' |
44 | }); | 43 | }); |
45 | }; | 44 | }; |
46 | 45 | ||
47 | $scope.cargar = function(idVehiculo, punto) { | 46 | $scope.cargar = function(idVehiculo, punto) { |
48 | if(!eligioFecha()) return; | 47 | if(!eligioFecha()) return; |
49 | var idRemito; | 48 | var idRemito; |
50 | if(punto === -1) { | 49 | if(punto === -1) { |
51 | idRemito = -1; | 50 | idRemito = -1; |
52 | }else { | 51 | }else { |
53 | idRemito = JSON.parse(punto).notaPedido.remito.id; | 52 | idRemito = JSON.parse(punto).notaPedido.remito.id; |
54 | } | 53 | } |
55 | var modalInstance = $uibModal.open( | 54 | $uibModal.open( |
56 | { | 55 | { |
57 | ariaLabelledBy: 'Busqueda de Vehiculo', | 56 | ariaLabelledBy: 'Busqueda de Vehiculo', |
58 | templateUrl: 'foca-detalle-vehiculo.html', | 57 | templateUrl: 'foca-detalle-vehiculo.html', |
59 | controller: 'focaDetalleVehiculo', | 58 | controller: 'focaDetalleVehiculo', |
60 | size: 'lg', | 59 | size: 'lg', |
61 | resolve: { | 60 | resolve: { |
62 | idVehiculo: function() {return idVehiculo;}, | 61 | idVehiculo: function() {return idVehiculo;}, |
63 | idRemito: function() {return idRemito;}, | 62 | idRemito: function() {return idRemito;}, |
64 | fechaReparto: function() {return $scope.fechaReparto;} | 63 | fechaReparto: function() {return $scope.fechaReparto;} |
65 | } | 64 | } |
66 | } | 65 | } |
67 | ); | 66 | ); |
68 | modalInstance.result.then(function() { | ||
69 | }, function() { | ||
70 | }); | ||
71 | }; | 67 | }; |
72 | 68 | ||
73 | $scope.quitarVehiculo = function(vehiculo) { | 69 | $scope.quitarVehiculo = function(vehiculo) { |
74 | if(!eligioFecha() || vehiculoEnUso(vehiculo)) return; | 70 | if(!eligioFecha() || vehiculoEnUso(vehiculo)) return; |
75 | 71 | ||
76 | focaModalService.confirm('Esta seguro que desea eliminar el vehículo ' + | 72 | focaModalService.confirm('Esta seguro que desea eliminar el vehículo ' + |
77 | vehiculo.codigo + ' de ' + vehiculo.transportista.NOM + '?').then(function() { | 73 | vehiculo.codigo + ' de ' + vehiculo.transportista.NOM + '?').then(function() { |
78 | eliminarVehiculo(vehiculo); | 74 | eliminarVehiculo(vehiculo); |
79 | }); | 75 | }); |
80 | }; | 76 | }; |
81 | 77 | ||
82 | $scope.hacerHojaRuta = function(vehiculo, cerrar) { | 78 | $scope.hacerHojaRuta = function(vehiculo, cerrar) { |
83 | if(!eligioFecha() || vehiculoEnUso(vehiculo)) return; | 79 | if(!eligioFecha() || vehiculoEnUso(vehiculo)) return; |
84 | var modalInstance = $uibModal.open( | 80 | var modalInstance = $uibModal.open( |
85 | { | 81 | { |
86 | ariaLabelledBy: 'Creación hoja ruta', | 82 | ariaLabelledBy: 'Creación hoja ruta', |
87 | templateUrl: 'foca-modal-cerrar-vehiculo.html', | 83 | templateUrl: 'foca-modal-cerrar-vehiculo.html', |
88 | controller: 'focaModalCerrarVehiculo', | 84 | controller: 'focaModalCerrarVehiculo', |
89 | size: 'lg', | 85 | size: 'lg', |
90 | resolve: { | 86 | resolve: { |
91 | idVehiculo: function() {return vehiculo.id;}, | 87 | idVehiculo: function() {return vehiculo.id;}, |
92 | fechaReparto: function() {return $scope.fechaReparto;}, | 88 | fechaReparto: function() {return $scope.fechaReparto;}, |
93 | cerrar: function() {return cerrar;} | 89 | cerrar: function() {return cerrar;} |
94 | } | 90 | } |
95 | } | 91 | } |
96 | ); | 92 | ); |
97 | modalInstance.result.then(function() { | 93 | modalInstance.result.then(function() { |
98 | 94 | ||
99 | }, function() { | 95 | }, function() { |
100 | //usar cuando se cancela el modal | 96 | //usar cuando se cancela el modal |
101 | }); | 97 | }); |
102 | }; | 98 | }; |
103 | 99 | ||
104 | $scope.arrastra = function() { | 100 | $scope.arrastra = function() { |
105 | $scope.arrastrando = true; | 101 | $scope.arrastrando = true; |
106 | $scope.$digest(); | 102 | $scope.$digest(); |
107 | }; | 103 | }; |
108 | 104 | ||
109 | $scope.noArrastra = function() { | 105 | $scope.noArrastra = function() { |
110 | $scope.arrastrando = false; | 106 | $scope.arrastrando = false; |
111 | $scope.$digest(); | 107 | $scope.$digest(); |
112 | }; | 108 | }; |
113 | 109 | ||
114 | $scope.individual = function() { | 110 | $scope.individual = function() { |
115 | $scope.idVendedor = -1; | 111 | $scope.idVendedor = -1; |
116 | }; | 112 | }; |
117 | 113 | ||
118 | $scope.mostrarDetalle = function() { | 114 | $scope.mostrarDetalle = function() { |
119 | $scope.detalle = true; | 115 | $scope.detalle = true; |
120 | }; | 116 | }; |
121 | 117 | ||
122 | $scope.salir = function() { | 118 | $scope.salir = function() { |
123 | $location.path('/'); | 119 | $location.path('/'); |
124 | }; | 120 | }; |
125 | 121 | ||
126 | $scope.search = function() { | 122 | $scope.search = function() { |
127 | getSeguimiento(); | 123 | getSeguimiento(); |
128 | }; | 124 | }; |
129 | 125 | ||
130 | $scope.fecha = function() { | 126 | $scope.fecha = function() { |
131 | getSeguimiento(); | 127 | getSeguimiento(); |
132 | }; | 128 | }; |
133 | 129 | ||
134 | $scope.seleccionarVehículo = function() { | 130 | $scope.seleccionarVehículo = function() { |
135 | var parametrosModal = { | 131 | var parametrosModal = { |
136 | titulo: 'Búsqueda de Transportista', | 132 | titulo: 'Búsqueda de Transportista', |
137 | query: '/transportista', | 133 | query: '/transportista', |
138 | columnas: [ | 134 | columnas: [ |
139 | { | 135 | { |
140 | nombre: 'Código', | 136 | nombre: 'Código', |
141 | propiedad: 'COD' | 137 | propiedad: 'COD' |
142 | }, | 138 | }, |
143 | { | 139 | { |
144 | nombre: 'Nombre', | 140 | nombre: 'Nombre', |
145 | propiedad: 'NOM' | 141 | propiedad: 'NOM' |
146 | }, | 142 | }, |
147 | { | 143 | { |
148 | nombre: 'CUIT', | 144 | nombre: 'CUIT', |
149 | propiedad: 'CUIT' | 145 | propiedad: 'CUIT' |
150 | } | 146 | } |
151 | ] | 147 | ] |
152 | }; | 148 | }; |
153 | focaModalService.modal(parametrosModal).then(function(transportista) { | 149 | focaModalService.modal(parametrosModal).then(function(transportista) { |
154 | $scope.selectVehiculo(transportista.COD, transportista.NOM); | 150 | $scope.selectVehiculo(transportista.COD, transportista.NOM); |
155 | }); | 151 | }); |
156 | }; | 152 | }; |
157 | 153 | ||
158 | $scope.selectVehiculo = function(idTransportista, nombreTransportista) { | 154 | $scope.selectVehiculo = function(idTransportista, nombreTransportista) { |
159 | var parametrosModal = { | 155 | var parametrosModal = { |
160 | columnas: [ | 156 | columnas: [ |
161 | { | 157 | { |
162 | propiedad: 'codigo', | 158 | propiedad: 'codigo', |
163 | nombre: 'Código' | 159 | nombre: 'Código' |
164 | }, | 160 | }, |
165 | { | 161 | { |
166 | propiedad: 'tractor', | 162 | propiedad: 'tractor', |
167 | nombre: 'tractor' | 163 | nombre: 'tractor' |
168 | }, | 164 | }, |
169 | { | 165 | { |
170 | propiedad: 'semi', | 166 | propiedad: 'semi', |
171 | nombre: 'Semi' | 167 | nombre: 'Semi' |
172 | }, | 168 | }, |
173 | { | 169 | { |
174 | propiedad: 'capacidadTotalCisternas', | 170 | propiedad: 'capacidadTotalCisternas', |
175 | nombre: 'Capacidad' | 171 | nombre: 'Capacidad' |
176 | } | 172 | } |
177 | ], | 173 | ], |
178 | query: '/vehiculo/transportista/' + idTransportista, | 174 | query: '/vehiculo/transportista/' + idTransportista, |
179 | titulo: 'Búsqueda de vehiculos', | 175 | titulo: 'Búsqueda de vehiculos', |
180 | subTitulo: idTransportista + '-' + nombreTransportista | 176 | subTitulo: idTransportista + '-' + nombreTransportista |
181 | }; | 177 | }; |
182 | focaModalService.modal(parametrosModal).then( | 178 | focaModalService.modal(parametrosModal).then( |
183 | function(vehiculo) { | 179 | function(vehiculo) { |
184 | var existe = $filter('filter')($scope.vehiculos, {id: vehiculo.id}); | 180 | var existe = $filter('filter')($scope.vehiculos, {id: vehiculo.id}); |
185 | if(existe.length) { | 181 | if(existe.length) { |
186 | focaModalService.alert('El vehiculo ya ha sido cargado'); | 182 | focaModalService.alert('El vehiculo ya ha sido cargado'); |
187 | return; | 183 | return; |
188 | } | 184 | } |
189 | if(!vehiculo.cisternas.length) { | 185 | if(!vehiculo.cisternas.length) { |
190 | focaModalService.alert('El vehiculo no tiene cisternas'); | 186 | focaModalService.alert('El vehiculo no tiene cisternas'); |
191 | return; | 187 | return; |
192 | } | 188 | } |
193 | $scope.vehiculos.push(vehiculo); | 189 | $scope.vehiculos.push(vehiculo); |
194 | }, function() { | 190 | }, function() { |
195 | // funcion ejecutada cuando se cancela el modal | 191 | // funcion ejecutada cuando se cancela el modal |
196 | }); | 192 | }); |
197 | }; | 193 | }; |
198 | 194 | ||
199 | $scope.seleccionarFechaReparto = function() { | 195 | $scope.seleccionarFechaReparto = function() { |
200 | focaModalService.modalFecha('Fecha de reparto').then(function(fecha) { | 196 | focaModalService.modalFecha('Fecha de reparto').then(function(fecha) { |
201 | $scope.$broadcast('addCabecera',{ | 197 | $scope.$broadcast('addCabecera',{ |
202 | label: 'Fecha:', | 198 | label: 'Fecha:', |
203 | valor: fecha.toLocaleDateString() | 199 | valor: fecha.toLocaleDateString() |
204 | }); | 200 | }); |
205 | $scope.fechaReparto = fecha; | 201 | $scope.fechaReparto = fecha; |
206 | focaLogisticaPedidoRutaService.setFechaReparto(fecha); | 202 | focaLogisticaPedidoRutaService.setFechaReparto(fecha); |
207 | focaLogisticaPedidoRutaService.getUnidadesByFecha(fecha).then(function(res) { | 203 | focaLogisticaPedidoRutaService.getUnidadesByFecha(fecha).then(function(res) { |
208 | $scope.vehiculos = res.data; | 204 | $scope.vehiculos = res.data; |
209 | }); | 205 | }); |
210 | }); | 206 | }); |
211 | }; | 207 | }; |
212 | 208 | ||
213 | function getSeguimiento() { | 209 | function getSeguimiento() { |
214 | var desde = new Date('1900/01/01'); | 210 | var desde = new Date('1900/01/01'); |
215 | var hasta = new Date('2099/01/01'); | 211 | var hasta = new Date('2099/01/01'); |
216 | if($scope.fechaDesde) { | 212 | if($scope.fechaDesde) { |
217 | var fechaDesde = $scope.fechaDesde; | 213 | var fechaDesde = $scope.fechaDesde; |
218 | desde = new Date(new Date(fechaDesde.setHours(0)).setMinutes(0)); | 214 | desde = new Date(new Date(fechaDesde.setHours(0)).setMinutes(0)); |
219 | desde = new Date(desde); | 215 | desde = new Date(desde); |
220 | } | 216 | } |
221 | if($scope.fechaHasta) { | 217 | if($scope.fechaHasta) { |
222 | var fechaHasta = $scope.fechaHasta; | 218 | var fechaHasta = $scope.fechaHasta; |
223 | hasta = new Date(new Date(fechaHasta.setHours(0)).setMinutes(0)); | 219 | hasta = new Date(new Date(fechaHasta.setHours(0)).setMinutes(0)); |
224 | hasta = hasta.setDate(hasta.getDate() + 1); | 220 | hasta = hasta.setDate(hasta.getDate() + 1); |
225 | hasta = new Date(hasta); | 221 | hasta = new Date(hasta); |
226 | } | 222 | } |
227 | var datos = { | 223 | var datos = { |
228 | actividad: $scope.actividad, | 224 | actividad: $scope.actividad, |
229 | idUsuario: $scope.idVendedor, | 225 | idUsuario: $scope.idVendedor, |
230 | fechaDesde: desde, | 226 | fechaDesde: desde, |
231 | fechaHasta: hasta, | 227 | fechaHasta: hasta, |
232 | asignacion: $scope.filtroEstado ? true : ($scope.filtroEstado !== undefined ? | 228 | asignacion: $scope.filtroEstado ? true : ($scope.filtroEstado !== undefined ? |
233 | false : undefined) | 229 | false : undefined) |
234 | }; | 230 | }; |
235 | 231 | ||
236 | $scope.datosBuscados = { | 232 | $scope.datosBuscados = { |
237 | actividad: $scope.actividad, | 233 | actividad: $scope.actividad, |
238 | individual: $scope.idVendedor ? true : false | 234 | individual: $scope.idVendedor ? true : false |
239 | }; | 235 | }; |
240 | 236 | ||
241 | focaLogisticaPedidoRutaService.obtenerActividad(datos).then(function(datos) { | 237 | focaLogisticaPedidoRutaService.obtenerActividad(datos).then(function(datos) { |
242 | if(JSON.stringify(datos.data) !== JSON.stringify($scope.marcadores)) { | 238 | if(JSON.stringify(datos.data) !== JSON.stringify($scope.marcadores)) { |
243 | $scope.marcadores = datos.data; | 239 | $scope.marcadores = datos.data; |
244 | } | 240 | } |
245 | }); | 241 | }); |
246 | } | 242 | } |
247 | 243 | ||
248 | function eliminarVehiculo(vehiculo) { | 244 | function eliminarVehiculo(vehiculo) { |
249 | focaLogisticaPedidoRutaService.getRemitosByIdVehiculo(vehiculo.id).then(function(res) { | 245 | focaLogisticaPedidoRutaService.getRemitosByIdVehiculo(vehiculo.id).then(function(res) { |
250 | if(!res.data.length) { | 246 | if(!res.data.length) { |
251 | $scope.vehiculos.splice($scope.vehiculos.indexOf(vehiculo), 1); | 247 | $scope.vehiculos.splice($scope.vehiculos.indexOf(vehiculo), 1); |
252 | }else { | 248 | }else { |
253 | focaModalService.alert('No ha sido posible eliminar el vehiculo porque ' + | 249 | focaModalService.alert('No ha sido posible eliminar el vehiculo porque ' + |
254 | 'tiene remitos asociados').then(function() { | 250 | 'tiene remitos asociados').then(function() { |
255 | $scope.hacerHojaRuta(vehiculo, true); | 251 | $scope.hacerHojaRuta(vehiculo, true); |
256 | }); | 252 | }); |
257 | } | 253 | } |
258 | }); | 254 | }); |
259 | } | 255 | } |
260 | 256 | ||
261 | function eligioFecha() { | 257 | function eligioFecha() { |
262 | if(!$scope.fechaReparto) { | 258 | if(!$scope.fechaReparto) { |
263 | focaModalService.alert('Primero seleccione fecha de reparto'); | 259 | focaModalService.alert('Primero seleccione fecha de reparto'); |
264 | return false; | 260 | return false; |
265 | } | 261 | } |
266 | return true; | 262 | return true; |
267 | } | 263 | } |
268 | 264 | ||
269 | function vehiculoEnUso(vehiculo) { | 265 | function vehiculoEnUso(vehiculo) { |
270 | var idUsuario = focaLogisticaPedidoRutaService.idUsuario; | 266 | var idUsuario = focaLogisticaPedidoRutaService.idUsuario; |
271 | for(var i = 0; i < vehiculo.cisternas.length; i++) { | 267 | for(var i = 0; i < vehiculo.cisternas.length; i++) { |
272 | for(var j = 0; j < vehiculo.cisternas[i].cisternasCarga.length; j++) { | 268 | for(var j = 0; j < vehiculo.cisternas[i].cisternasCarga.length; j++) { |
273 | var cisternaCarga = vehiculo.cisternas[i].cisternasCarga[j]; | 269 | var cisternaCarga = vehiculo.cisternas[i].cisternasCarga[j]; |
274 | if(cisternaCarga.fechaReparto.substring(0, 10) === $scope.fechaReparto | 270 | if(cisternaCarga.fechaReparto.substring(0, 10) === $scope.fechaReparto |
275 | .toISOString().substring(0, 10) && cisternaCarga.idUsuarioProceso && | 271 | .toISOString().substring(0, 10) && cisternaCarga.idUsuarioProceso && |
276 | cisternaCarga.idUsuarioProceso !== idUsuario) | 272 | cisternaCarga.idUsuarioProceso !== idUsuario) |
277 | { | 273 | { |
278 | focaModalService.alert('El vehículo está siendo usado por otro usuario'); | 274 | focaModalService.alert('El vehículo está siendo usado por otro usuario'); |
279 | return true; | 275 | return true; |
280 | } | 276 | } |
281 | } | 277 | } |
282 | } | 278 | } |
283 | return false; | 279 | return false; |
284 | } | 280 | } |
285 | $interval(function() { | 281 | $interval(function() { |
286 | getSeguimiento(); | 282 | getSeguimiento(); |
287 | }, 5000); | 283 | }, 5000); |
288 | } | 284 | } |
289 | ]); | 285 | ]); |
290 | 286 |
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', '$compile', 'focaModalService', |
12 | function($scope, $filter, $compile, focaModalService) { | ||
12 | $scope.markers = []; | 13 | $scope.markers = []; |
14 | $scope.verProductos = function(id) { | ||
15 | var parametrosModal = { | ||
16 | titulo: 'Productos', | ||
17 | query: '/articulos/remito/' + id, | ||
18 | soloMostrar: true, | ||
19 | size: 'md', | ||
20 | columnas: [ | ||
21 | { | ||
22 | nombre: 'Producto', | ||
23 | propiedad: 'descripcion' | ||
24 | }, | ||
25 | { | ||
26 | nombre: 'Cantidad', | ||
27 | propiedad: 'cantidad' | ||
28 | } | ||
29 | ] | ||
30 | }; | ||
31 | focaModalService.modal(parametrosModal).then(); | ||
32 | }; | ||
13 | $scope.$watch('marcadores', function() { | 33 | $scope.$watch('marcadores', function() { |
14 | for(var i in $scope.markers) { | 34 | for(var i in $scope.markers) { |
15 | $scope.map.removeLayer($scope.markers[i]); | 35 | $scope.map.removeLayer($scope.markers[i]); |
16 | } | 36 | } |
17 | $scope.markers = []; | 37 | $scope.markers = []; |
18 | 38 | ||
19 | angular.forEach($scope.marcadores, function(marcador) { | 39 | angular.forEach($scope.marcadores, function(marcador) { |
20 | var observacion = | 40 | var observacion = |
21 | 'Vendedor: ' + marcador.notaPedido.idVendedor + ' - ' + | 41 | 'Vendedor: ' + marcador.notaPedido.idVendedor + ' - ' + |
22 | ( | 42 | ( |
23 | marcador.notaPedido.vendedor ? | 43 | marcador.notaPedido.vendedor ? |
24 | marcador.notaPedido.vendedor.NomVen : | 44 | marcador.notaPedido.vendedor.NomVen : |
25 | '' | 45 | '' |
26 | ) + '<br/>'; | 46 | ) + '<br/>'; |
27 | observacion += 'Fecha: ' + | 47 | observacion += 'Fecha: ' + |
28 | $filter('date')(marcador.fecha.slice(0,10), 'dd/MM/yyyy') + ' ' + | 48 | $filter('date')(marcador.fecha.slice(0,10), 'dd/MM/yyyy') + ' ' + |
29 | marcador.fecha.slice(11,19) + '<br/>'; | 49 | marcador.fecha.slice(11,19) + '<br/>'; |
30 | observacion += 'Remito Nº: ' + $filter('comprobante')([ | 50 | observacion += 'Remito Nº: ' + $filter('comprobante')([ |
31 | marcador.notaPedido.remito.sucursal, | 51 | marcador.notaPedido.remito.sucursal, |
32 | marcador.notaPedido.remito.numeroRemito | 52 | marcador.notaPedido.remito.numeroRemito |
33 | ]) + '<br/>'; | 53 | ]) + '<br/>'; |
34 | observacion += 'Cliente: ' + | 54 | observacion += 'Cliente: ' + |
35 | marcador.notaPedido.cliente.NOM + '<br/>'; | 55 | marcador.notaPedido.cliente.NOM; |
36 | 56 | ||
37 | // if($scope.parametros.individual) { | 57 | // if($scope.parametros.individual) { |
38 | observacion += | ||
39 | 'Total: ' + $filter('currency')(marcador.notaPedido.remito.total, '$'); | ||
40 | observacion = 'Orden: ' + marcador.orden + '<br/>' + observacion; | 58 | observacion = 'Orden: ' + marcador.orden + '<br/>' + observacion; |
41 | 59 | ||
42 | if(marcador.distancia) { | 60 | if(marcador.distancia) { |
43 | observacion += '<br/>Distancia a casa central: ' + | 61 | observacion += '<br/>Distancia a casa central: ' + |
44 | marcador.distancia + 'km'; | 62 | marcador.distancia + 'km'; |
45 | } | 63 | } |
46 | var icon; | 64 | var icon; |
47 | if(marcador.notaPedido.remito.idUsuarioProceso) { | 65 | if(marcador.notaPedido.remito.idUsuarioProceso) { |
48 | observacion += '<br/>'; | 66 | observacion += '<br/>'; |
49 | observacion += '<strong>'; | 67 | observacion += '<strong>'; |
50 | observacion += 'Fecha de entrega: ' + marcador.notaPedido.remito | 68 | observacion += 'Fecha de entrega: ' + marcador.notaPedido.remito |
51 | .cisternaMovimientos[0].cisternaCarga.fechaReparto.substring(0, 10); | 69 | .cisternaMovimientos[0].cisternaCarga.fechaReparto.substring(0, 10); |
52 | observacion += '<br/>'; | 70 | observacion += '<br/>'; |
53 | observacion += 'Vehículo: ' + marcador.notaPedido.remito | 71 | observacion += 'Vehículo: ' + marcador.notaPedido.remito |
54 | .cisternaMovimientos[0].cisternaCarga.cisterna.vehiculo.codigo; | 72 | .cisternaMovimientos[0].cisternaCarga.cisterna.vehiculo.codigo; |
55 | observacion += '<br/>'; | 73 | observacion += '<br/>'; |
56 | observacion += 'Transportista: ' + marcador.notaPedido.remito | 74 | observacion += 'Transportista: ' + marcador.notaPedido.remito |
57 | .cisternaMovimientos[0].cisternaCarga.cisterna.vehiculo.transportista | 75 | .cisternaMovimientos[0].cisternaCarga.cisterna.vehiculo.transportista |
58 | .NOM; | 76 | .NOM; |
59 | observacion += '</strong>'; | 77 | observacion += '</strong>'; |
60 | //Asignado ROJO | 78 | //Asignado ROJO |
61 | icon = new L.Icon({ | 79 | icon = new L.Icon({ |
62 | iconUrl: 'img/marker-icon-2x-red.png', | 80 | iconUrl: 'img/marker-icon-2x-red.png', |
63 | shadowUrl: 'img/marker-shadow.png', | 81 | shadowUrl: 'img/marker-shadow.png', |
64 | iconSize: [25, 41], | 82 | iconSize: [25, 41], |
65 | iconAnchor: [12, 41], | 83 | iconAnchor: [12, 41], |
66 | popupAnchor: [1, -34], | 84 | popupAnchor: [1, -34], |
67 | shadowSize: [41, 41] | 85 | shadowSize: [41, 41] |
68 | }); | 86 | }); |
69 | }else { | 87 | }else { |
70 | observacion += '<br/>'; | 88 | observacion += '<br/>'; |
71 | observacion += '<i class="fa fa-map-marker fa-3x" aria-hidden="true"'+ | 89 | observacion += '<i class="fa fa-map-marker fa-3x" aria-hidden="true"'+ |
72 | 'class="form-control" ondragend="dropEnd()" ondragstart=\'drag(event, '+ | 90 | 'class="form-control" ondragend="dropEnd()" ondragstart=\'drag(event, '+ |
73 | JSON.stringify(marcador)+')\' draggable="true"></i>(Arrastrar icono)'; | 91 | JSON.stringify(marcador)+')\' draggable="true"></i>(Arrastrar icono)'; |
92 | observacion += '<button title="Ver productos" class="btn btn-secondary' + | ||
93 | 'float-right mt-2"'+ | ||
94 | 'ng-click="verProductos('+marcador.notaPedido.remito.id+')">' + | ||
95 | '<i class="fa fa-info" aria-hidden="true"></i>' + | ||
96 | '</button>'; | ||
74 | 97 | ||
75 | //Sin asignar VERDE | 98 | //Sin asignar VERDE |
76 | icon = new L.Icon({ | 99 | icon = new L.Icon({ |
77 | iconUrl: 'img/marker-icon-2x-green.png', | 100 | iconUrl: 'img/marker-icon-2x-green.png', |
78 | shadowUrl: 'img/marker-shadow.png', | 101 | shadowUrl: 'img/marker-shadow.png', |
79 | iconSize: [25, 41], | 102 | iconSize: [25, 41], |
80 | iconAnchor: [12, 41], | 103 | iconAnchor: [12, 41], |
81 | popupAnchor: [1, -34], | 104 | popupAnchor: [1, -34], |
82 | shadowSize: [41, 41] | 105 | shadowSize: [41, 41] |
83 | }); | 106 | }); |
84 | } | 107 | } |
108 | |||
109 | //COMPILO HTML PARA QUE FUNCIONE BOTON EN POPUP | ||
110 | observacion = '<div>' + observacion + '</div>'; | ||
111 | var compiledHtml = $compile(angular.element(observacion))($scope); | ||
112 | |||
85 | $scope.markers.push( | 113 | $scope.markers.push( |
86 | L.marker( | 114 | L.marker( |
87 | [marcador.latitud, marcador.longitud], {icon: icon}) | 115 | [marcador.latitud, marcador.longitud], {icon: icon}) |
88 | .addTo($scope.map) | 116 | .addTo($scope.map) |
89 | .bindPopup(observacion) | 117 | .bindPopup(compiledHtml[0]) |
90 | .bindTooltip('Haga click para seleccionar') | 118 | .bindTooltip('Haga click para seleccionar') |
91 | ); | 119 | ); |
92 | //abre marcador del primer punto | 120 | //abre marcador del primer punto |
93 | //$scope.markers[0].openPopup(); | 121 | //$scope.markers[0].openPopup(); |
94 | }); | 122 | }); |
95 | }); | 123 | }); |
96 | }], | 124 | }], |
97 | scope: { | 125 | scope: { |
98 | latitud: '=', | 126 | latitud: '=', |
99 | longitud: '=', | 127 | longitud: '=', |
100 | zoom: '=', | 128 | zoom: '=', |
101 | marcadores: '=', | 129 | marcadores: '=', |
102 | parametros: '=' | 130 | parametros: '=' |
103 | } | 131 | } |
104 | }; | 132 | }; |