Commit 0d621de670cae3428a10591be3391dee0fdfd0fa

Authored by Nicolás Guarnieri
Exists in master

Merge branch 'master' into 'master'

Master

See merge request modulos-npm/foca-admin-seguimiento!13
src/js/osm-directive.js
1 angular.module('focaAdminSeguimiento').directive('osm', function() { 1 angular.module('focaAdminSeguimiento').directive('osm', 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 el.append(contenedor); 6 el.append(contenedor);
7 scope.map = L.map(contenedor).setView([attrs.latitud, attrs.longitud], attrs.zoom); 7 scope.map = L.map(contenedor).setView([attrs.latitud, attrs.longitud], attrs.zoom);
8 L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(scope.map); 8 L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(scope.map);
9 }, 9 },
10 controller: ['$scope', '$filter', function($scope, $filter) { 10 controller: ['$scope', '$filter', function($scope, $filter) {
11 $scope.markers = []; 11 $scope.markers = [];
12 $scope.$watch('marcadores', function() { 12 $scope.$watch('marcadores', function() {
13 for(var i in $scope.markers) { 13 for(var i in $scope.markers) {
14 $scope.map.removeLayer($scope.markers[i]); 14 $scope.map.removeLayer($scope.markers[i]);
15 } 15 }
16 16
17 $scope.markers = []; 17 $scope.markers = [];
18 angular.forEach($scope.marcadores, function(marcador) { 18 angular.forEach($scope.marcadores, function(marcador) {
19 var observacion = ''; 19 var observacion = '';
20 20
21 if ($scope.parametros.actividad === 'Nota de pedido') { 21 if ($scope.parametros.actividad === 'Nota de pedido') {
22 observacion += 22 observacion +=
23 'Vendedor: ' + marcador.notaPedido[0].idVendedor + ' - ' + 23 'Vendedor: ' + marcador.notaPedido[0].idVendedor + ' - ' +
24 ( 24 (
25 marcador.notaPedido[0].vendedor[0] ? 25 marcador.notaPedido[0].vendedor[0] ?
26 marcador.notaPedido[0].vendedor[0].NomVen : 26 marcador.notaPedido[0].vendedor[0].NomVen :
27 '' 27 ''
28 ) + '<br/>'; 28 ) + '<br/>';
29 observacion += 'Fecha: ' + 29 observacion += 'Fecha: ' +
30 $filter('date')(marcador.fecha.slice(0,10), 'dd/MM/yyyy') + ' ' + 30 $filter('date')(marcador.fecha.slice(0,10), 'dd/MM/yyyy') + ' ' +
31 marcador.fecha.slice(11,19) + '<br/>'; 31 marcador.fecha.slice(11,19) + '<br/>';
32 observacion += 'Nº: ' + $filter('comprobante')([ 32 observacion += 'Nº: ' + $filter('comprobante')([
33 marcador.notaPedido[0].sucursal, 33 marcador.notaPedido[0].sucursal,
34 marcador.notaPedido[0].numeroNotaPedido 34 marcador.notaPedido[0].numeroNotaPedido
35 ]) + '<br/>'; 35 ]) + '<br/>';
36 if ($scope.parametros.individual) { 36 if ($scope.parametros.individual) {
37 observacion += 37 observacion +=
38 'Total: ' + $filter('currency')(marcador.notaPedido[0].total, '$'); 38 'Total: ' + $filter('currency')(marcador.notaPedido[0].total, '$');
39 } else { 39 } else {
40 observacion += 'Cantidad de nota de pedido: ' + 40 observacion += 'Cantidad de nota de pedido: ' +
41 marcador.cantidad + '<br/>'; 41 marcador.cantidad + '<br/>';
42 observacion += 'Total Vendido: ' + 42 observacion += 'Total Vendido: ' +
43 $filter('currency')(marcador.total, '$'); 43 $filter('currency')(marcador.total, '$');
44 } 44 }
45 } else { 45 } else {
46 observacion += 'Vehiculo: ' + marcador.hojaRuta[0].idVehiculo + '<br/>'; 46 observacion += 'Vehiculo: ' +
47 marcador.remito[0].hojaRuta[0].idVehiculo + '<br/>';
48 observacion += 'Hoja de ruta: ' + $filter('comprobante')([
49 marcador.remito[0].hojaRuta[0].sucursal,
50 marcador.remito[0].hojaRuta[0].numeroHojaRuta
51 ]) + '<br/>';
52 observacion += 'Remito: ' + $filter('comprobante')([
53 marcador.remito[0].sucursal,
54 marcador.remito[0].numeroRemito
55 ]) + '<br/>';
56
47 if ($scope.parametros.individual) { 57 if ($scope.parametros.individual) {
48 observacion += 'Hoja de ruta: ' + $filter('comprobante')([
49 marcador.remito[0].hojaRuta[0].sucursal,
50 marcador.remito[0].hojaRuta[0].numeroHojaRuta
51 ]) + '<br/>';
52 observacion += 'Remito: ' + $filter('comprobante')([
53 marcador.remito[0].sucursal,
54 marcador.remito[0].numeroRemito
55 ]) + '<br/>';
56 observacion += 'Producto: ' + 58 observacion += 'Producto: ' +
57 marcador.remito[0].articuloRemito[0].descripcion + '<br/>'; 59 marcador.remito[0].articuloRemito[0].descripcion + '<br/>';
58 observacion += 'Cantidad entregada: ' + 60 observacion += 'Cantidad entregada: ' +
59 marcador.remito[0].carga + '<br/>'; 61 marcador.remito[0].carga + '<br/>';
62 } else {
63 observacion += 'Cantidad de entregas: ' +
64 marcador.cantidad + '<br/>';
60 } 65 }
61 } 66 }
62 67
63 $scope.markers.push( 68 $scope.markers.push(
64 L.marker([marcador.latitud, marcador.longitud]).addTo($scope.map) 69 L.marker([marcador.latitud, marcador.longitud]).addTo($scope.map)
65 .bindPopup(observacion) 70 .bindPopup(observacion)
66 ); 71 );
67 72
68 $scope.markers[0].openPopup(); 73 $scope.markers[0].openPopup();
69 }); 74 });
70 }); 75 });
71 }], 76 }],
72 scope: { 77 scope: {
73 latitud: '=', 78 latitud: '=',