Commit 5df4f2de3b1100ddc01b74a51903c6aecdab2e20

Authored by Nicolás Guarnieri
Exists in master and in 1 other branch develop

Merge branch 'master' into 'master'

cartel nota pedido como quiere jorge

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