Commit fe4c1bfd17d4e7b94fa132bd803379f09f2762fe
1 parent
8fd2c4e9bd
Exists in
master
and in
1 other branch
orden no va en logistica
Showing
1 changed file
with
0 additions
and
1 deletions
Show diff stats
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; | ||
41 | 40 | ||
42 | if(marcador.distancia) { | 41 | if(marcador.distancia) { |
43 | observacion += '<br/>Distancia a casa central: ' + | 42 | observacion += '<br/>Distancia a casa central: ' + |
44 | marcador.distancia + 'km'; | 43 | marcador.distancia + 'km'; |
45 | } | 44 | } |
46 | var icon; | 45 | var icon; |
47 | if(marcador.notaPedido.remito.idUsuarioProceso) { | 46 | if(marcador.notaPedido.remito.idUsuarioProceso) { |
48 | observacion += '<br/>'; | 47 | observacion += '<br/>'; |
49 | observacion += '<strong>'; | 48 | observacion += '<strong>'; |
50 | observacion += 'Fecha de entrega: ' + marcador.notaPedido.remito | 49 | observacion += 'Fecha de entrega: ' + marcador.notaPedido.remito |
51 | .cisternaMovimientos[0].cisternaCarga.fechaReparto.substring(0, 10); | 50 | .cisternaMovimientos[0].cisternaCarga.fechaReparto.substring(0, 10); |
52 | observacion += '<br/>'; | 51 | observacion += '<br/>'; |
53 | observacion += 'Vehículo: ' + marcador.notaPedido.remito | 52 | observacion += 'Vehículo: ' + marcador.notaPedido.remito |
54 | .cisternaMovimientos[0].cisternaCarga.cisterna.vehiculo.codigo; | 53 | .cisternaMovimientos[0].cisternaCarga.cisterna.vehiculo.codigo; |
55 | observacion += '<br/>'; | 54 | observacion += '<br/>'; |
56 | observacion += 'Transportista: ' + marcador.notaPedido.remito | 55 | observacion += 'Transportista: ' + marcador.notaPedido.remito |
57 | .cisternaMovimientos[0].cisternaCarga.cisterna.vehiculo.transportista | 56 | .cisternaMovimientos[0].cisternaCarga.cisterna.vehiculo.transportista |
58 | .NOM; | 57 | .NOM; |
59 | observacion += '</strong>'; | 58 | observacion += '</strong>'; |
60 | //Asignado ROJO | 59 | //Asignado ROJO |
61 | icon = new L.Icon({ | 60 | icon = new L.Icon({ |
62 | iconUrl: 'img/marker-icon-2x-red.png', | 61 | iconUrl: 'img/marker-icon-2x-red.png', |
63 | shadowUrl: 'img/marker-shadow.png', | 62 | shadowUrl: 'img/marker-shadow.png', |
64 | iconSize: [25, 41], | 63 | iconSize: [25, 41], |
65 | iconAnchor: [12, 41], | 64 | iconAnchor: [12, 41], |
66 | popupAnchor: [1, -34], | 65 | popupAnchor: [1, -34], |
67 | shadowSize: [41, 41] | 66 | shadowSize: [41, 41] |
68 | }); | 67 | }); |
69 | }else { | 68 | }else { |
70 | observacion += '<br/>'; | 69 | observacion += '<br/>'; |
71 | observacion += '<i class="fa fa-map-marker fa-3x" aria-hidden="true"'+ | 70 | observacion += '<i class="fa fa-map-marker fa-3x" aria-hidden="true"'+ |
72 | 'class="form-control" ondragend="dropEnd()" ondragstart=\'drag(event, '+ | 71 | 'class="form-control" ondragend="dropEnd()" ondragstart=\'drag(event, '+ |
73 | JSON.stringify(marcador)+')\' draggable="true"></i>(Arrastrar icono)'; | 72 | JSON.stringify(marcador)+')\' draggable="true"></i>(Arrastrar icono)'; |
74 | 73 | ||
75 | //Sin asignar VERDE | 74 | //Sin asignar VERDE |
76 | icon = new L.Icon({ | 75 | icon = new L.Icon({ |
77 | iconUrl: 'img/marker-icon-2x-green.png', | 76 | iconUrl: 'img/marker-icon-2x-green.png', |
78 | shadowUrl: 'img/marker-shadow.png', | 77 | shadowUrl: 'img/marker-shadow.png', |
79 | iconSize: [25, 41], | 78 | iconSize: [25, 41], |
80 | iconAnchor: [12, 41], | 79 | iconAnchor: [12, 41], |
81 | popupAnchor: [1, -34], | 80 | popupAnchor: [1, -34], |
82 | shadowSize: [41, 41] | 81 | shadowSize: [41, 41] |
83 | }); | 82 | }); |
84 | } | 83 | } |
85 | $scope.markers.push( | 84 | $scope.markers.push( |
86 | L.marker( | 85 | L.marker( |
87 | [marcador.latitud, marcador.longitud], {icon: icon}) | 86 | [marcador.latitud, marcador.longitud], {icon: icon}) |
88 | .addTo($scope.map) | 87 | .addTo($scope.map) |
89 | .bindPopup(observacion) | 88 | .bindPopup(observacion) |
90 | .bindTooltip('Haga click para seleccionar') | 89 | .bindTooltip('Haga click para seleccionar') |
91 | ); | 90 | ); |
92 | //abre marcador del primer punto | 91 | //abre marcador del primer punto |
93 | //$scope.markers[0].openPopup(); | 92 | //$scope.markers[0].openPopup(); |
94 | }); | 93 | }); |
95 | }); | 94 | }); |
96 | }], | 95 | }], |
97 | scope: { | 96 | scope: { |
98 | latitud: '=', | 97 | latitud: '=', |
99 | longitud: '=', | 98 | longitud: '=', |
100 | zoom: '=', | 99 | zoom: '=', |
101 | marcadores: '=', | 100 | marcadores: '=', |
102 | parametros: '=' | 101 | parametros: '=' |
103 | } | 102 | } |
104 | }; | 103 | }; |
105 | }); | 104 | }); |
106 | 105 |