Commit 0e7aaffba9aade17c616544d6bd650c98abb14ba

Authored by Nicolás Guarnieri
Exists in master

Merge branch 'master' into 'master'

arreglos parametros

See merge request modulos-npm/foca-admin-seguimiento!10
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 observacion += 'Actividad: ' + marcador.actividad + '<br/>'; 20 observacion += 'Actividad: ' + marcador.actividad + '<br/>';
21 21
22 observacion += 'Fecha: ' + 22 observacion += 'Fecha: ' +
23 $filter('date')(marcador.fecha.slice(0,10), 'dd/MM/yyyy') + ' ' + 23 $filter('date')(marcador.fecha.slice(0,10), 'dd/MM/yyyy') + ' ' +
24 marcador.fecha.slice(11,19) + '<br/>'; 24 marcador.fecha.slice(11,19) + '<br/>';
25 25
26 if ($scope.parametros.actividad === 'Nota de pedido') { 26 if ($scope.parametros.actividad === 'Nota de pedido') {
27 observacion += 27 observacion +=
28 'Vendedor: ' + marcador.idUsuario + ' - ' + 28 'Vendedor: ' + marcador.notaPedido[0].idVendedor + ' - ' +
29 ( 29 (
30 marcador.notaPedido.vendedor ? 30 marcador.notaPedido[0].vendedor ?
31 marcador.notaPedido.vendedor.nombre : 31 marcador.notaPedido[0].vendedor.NomVen :
32 '' 32 ''
33 ) + '<br/>'; 33 ) + '<br/>';
34 34
35 if ($scope.parametros.individual) { 35 if ($scope.parametros.individual) {
36 observacion += 'Nº: ' + $filter('comprobante')([ 36 observacion += 'Nº: ' + $filter('comprobante')([
37 marcador.notaPedido.sucursal, 37 marcador.notaPedido[0].sucursal,
38 marcador.notaPedido.numeroNotaPedido 38 marcador.notaPedido[0].numeroNotaPedido
39 ]) + '<br/>'; 39 ]) + '<br/>';
40 observacion += 40 observacion +=
41 'Total: ' + $filter('currency')(marcador.notaPedido.total, '$'); 41 'Total: ' + $filter('currency')(marcador.notaPedido.total, '$');
42 } else { 42 } else {
43 observacion += 'Cantidad de nota de pedido: ' + marcador.cantidad; 43 observacion += 'Cantidad de nota de pedido: ' +
44 marcador.cantidad + '<br/>';
44 observacion += 'Total Vendido: ' + 45 observacion += 'Total Vendido: ' +
45 $filter('currency')(marcador.total, '$'); 46 $filter('currency')(marcador.total, '$');
46 } 47 }
47 } else { 48 } else {
48 observacion += 'Vehiculo: ' + marcador.idUsuario + '<br/>'; 49 observacion += 'Vehiculo: ' + marcador.idUsuario + '<br/>';
49 if ($scope.parametros.individual) { 50 if ($scope.parametros.individual) {
50 observacion += 'Hoja de ruta: ' + $filter('comprobante')([ 51 observacion += 'Hoja de ruta: ' + $filter('comprobante')([
51 marcador.remito[0].hojaRuta[0].sucursal, 52 marcador.remito[0].hojaRuta[0].sucursal,
52 marcador.remito[0].hojaRuta[0].numeroHojaRuta 53 marcador.remito[0].hojaRuta[0].numeroHojaRuta
53 ]) + '<br/>'; 54 ]) + '<br/>';
54 observacion += 'Remito: ' + $filter('comprobante')([ 55 observacion += 'Remito: ' + $filter('comprobante')([
55 marcador.remito[0].sucursal, 56 marcador.remito[0].sucursal,
56 marcador.remito[0].numeroRemito 57 marcador.remito[0].numeroRemito
57 ]) + '<br/>'; 58 ]) + '<br/>';
58 observacion += 'Producto: ' + 59 observacion += 'Producto: ' +
59 marcador.remito[0].articuloRemito[0].descripcion + '<br/>'; 60 marcador.remito[0].articuloRemito[0].descripcion + '<br/>';
60 observacion += 'Cantidad entregada: ' + 61 observacion += 'Cantidad entregada: ' +
61 marcador.remito[0].carga + '<br/>'; 62 marcador.remito[0].carga + '<br/>';
62 } 63 }
63 } 64 }
64 65
65 $scope.markers.push( 66 $scope.markers.push(
66 L.marker([marcador.latitud, marcador.longitud]).addTo($scope.map) 67 L.marker([marcador.latitud, marcador.longitud]).addTo($scope.map)
67 .bindPopup(observacion) 68 .bindPopup(observacion)
68 ); 69 );
69 70
70 $scope.markers[0].openPopup(); 71 $scope.markers[0].openPopup();
71 }); 72 });
72 }); 73 });
73 }], 74 }],
74 scope: { 75 scope: {
75 latitud: '=', 76 latitud: '=',
76 longitud: '=', 77 longitud: '=',
77 zoom: '=', 78 zoom: '=',
78 marcadores: '=', 79 marcadores: '=',
79 parametros: '=' 80 parametros: '='
80 } 81 }
81 }; 82 };
82 }); 83 });
83 84