Commit 4391e36fcf42cc5792735d1be674c27a84065a72
Exists in
master
and in
2 other branches
Merge branch 'master' into 'master'
Master See merge request !26
Showing
2 changed files
Show diff stats
src/js/controller.js
1 | angular.module('focaAdminSeguimiento').controller('focaAdminSeguimientoController', [ | 1 | angular.module('focaAdminSeguimiento').controller('focaAdminSeguimientoController', [ |
2 | '$scope', '$timeout', 'focaAdminSeguimientoService', '$uibModal', | 2 | '$scope', '$timeout', 'focaAdminSeguimientoService', '$uibModal', |
3 | 'focaBotoneraLateralService','$location', '$routeParams', | 3 | 'focaBotoneraLateralService','$location', '$routeParams', |
4 | function($scope, $timeout, focaAdminSeguimientoService, $uibModal, | 4 | function($scope, $timeout, focaAdminSeguimientoService, $uibModal, |
5 | focaBotoneraLateralService, $location, $routeParams) { | 5 | focaBotoneraLateralService, $location, $routeParams) { |
6 | $scope.actividad = ''; | 6 | $scope.actividad = ''; |
7 | $scope.titulo = ''; | 7 | $scope.titulo = ''; |
8 | var cabecera = ''; | 8 | var cabecera = ''; |
9 | var plural = ''; | 9 | var plural = ''; |
10 | 10 | ||
11 | $scope.now = new Date(); | 11 | $scope.now = new Date(); |
12 | $scope.dateOptions = { | 12 | $scope.dateOptions = { |
13 | maxDate: new Date() | 13 | maxDate: new Date() |
14 | }; | 14 | }; |
15 | 15 | ||
16 | switch ($routeParams.parametro) { | 16 | switch ($routeParams.parametro) { |
17 | case 'nota-pedido': | 17 | case 'nota-pedido': |
18 | $scope.actividad = 'Nota de pedido'; | 18 | $scope.actividad = 'Nota de pedido'; |
19 | $scope.titulo = 'Seguimiento de nota de pedido'; | 19 | $scope.titulo = 'Seguimiento de nota de pedido'; |
20 | cabecera = 'Vendedor:'; | 20 | cabecera = 'Vendedor:'; |
21 | plural = 'Vendedores'; | 21 | plural = 'Vendedores'; |
22 | break; | 22 | break; |
23 | case 'hoja-ruta': | 23 | case 'hoja-ruta': |
24 | $scope.actividad = 'Entrega de producto'; | 24 | $scope.actividad = 'Entrega de producto'; |
25 | $scope.titulo = 'Seguimiento de hoja de ruta'; | 25 | $scope.titulo = 'Seguimiento de hoja de ruta'; |
26 | cabecera = 'Vehiculo:'; | 26 | cabecera = 'Vehiculo:'; |
27 | plural = 'Vehiculos'; | 27 | plural = 'Vehiculos'; |
28 | break; | 28 | break; |
29 | case 'cobranza': | 29 | case 'cobranza': |
30 | $scope.actividad = 'Cobranza'; | 30 | $scope.actividad = 'Cobranza'; |
31 | $scope.titulo = 'Seguimiento de cobranza'; | 31 | $scope.titulo = 'Seguimiento de cobranza'; |
32 | cabecera = 'Cobrador:'; | 32 | cabecera = 'Cobrador:'; |
33 | plural = 'Cobradores'; | 33 | plural = 'Cobradores'; |
34 | break; | 34 | break; |
35 | } | 35 | } |
36 | 36 | ||
37 | $scope.idUsuario = 0; | 37 | $scope.idUsuario = 0; |
38 | $scope.marcadores = []; | 38 | $scope.marcadores = []; |
39 | getSeguimiento(); | 39 | getSeguimiento(); |
40 | 40 | ||
41 | //SETEO BOTONERA LATERAL | 41 | //SETEO BOTONERA LATERAL |
42 | focaBotoneraLateralService.showSalir(true); | 42 | focaBotoneraLateralService.showSalir(true); |
43 | focaBotoneraLateralService.showPausar(false); | 43 | focaBotoneraLateralService.showPausar(false); |
44 | focaBotoneraLateralService.showGuardar(false); | 44 | focaBotoneraLateralService.showGuardar(false); |
45 | 45 | ||
46 | $scope.general = function() { | 46 | $scope.general = function() { |
47 | $scope.idUsuario = 0; | 47 | $scope.idUsuario = 0; |
48 | getSeguimiento(); | 48 | getSeguimiento(); |
49 | }; | 49 | }; |
50 | 50 | ||
51 | $scope.individual = function() { | 51 | $scope.individual = function() { |
52 | $scope.idUsuario = -1; | 52 | $scope.idUsuario = -1; |
53 | }; | 53 | }; |
54 | 54 | ||
55 | $scope.salir = function() { | 55 | $scope.salir = function() { |
56 | $location.path('/'); | 56 | $location.path('/'); |
57 | }; | 57 | }; |
58 | 58 | ||
59 | $scope.search = function(key) { | 59 | $scope.search = function(key) { |
60 | if (key === 13) { | 60 | if (key === 13) { |
61 | $scope.idUsuario = $scope.idUsuarioInput; | 61 | $scope.idUsuario = $scope.idUsuarioInput; |
62 | 62 | ||
63 | getSeguimiento(); | 63 | getSeguimiento(); |
64 | if ($scope.actividad === 'Entrega de producto' && $scope.idUsuario !== 0) { | 64 | if ($scope.actividad === 'Entrega de producto' && $scope.idUsuario !== 0) { |
65 | focaAdminSeguimientoService.obtenerRemitosVehiculo($scope.idUsuario) | 65 | focaAdminSeguimientoService.obtenerRemitosVehiculo($scope.idUsuario) |
66 | .then(function(res) { | 66 | .then(function(res) { |
67 | var remitos = []; | 67 | var remitos = []; |
68 | for (var i = 0; i < res.data.length; i++) { | 68 | for (var i = 0; i < res.data.length; i++) { |
69 | remitos = remitos.concat(res.data[i].remitos); | 69 | remitos = remitos.concat(res.data[i].remitos); |
70 | } | 70 | } |
71 | $scope.remitosVehiculo = remitos; | 71 | $scope.remitosVehiculo = remitos; |
72 | }); | 72 | }); |
73 | } | 73 | } |
74 | } | 74 | } |
75 | }; | 75 | }; |
76 | 76 | ||
77 | $scope.fecha = function() { | 77 | $scope.fecha = function() { |
78 | getSeguimiento(); | 78 | getSeguimiento(); |
79 | }; | 79 | }; |
80 | 80 | ||
81 | $scope.showMarcadores = function() { | 81 | $scope.showMarcadores = function() { |
82 | var texto = ''; | 82 | var texto = ''; |
83 | 83 | ||
84 | if ($scope.actividad === 'Nota de pedido') { | 84 | if ($scope.actividad === 'Nota de pedido') { |
85 | texto = 'Marcadores de notas de pedido'; | 85 | texto = 'Marcadores de notas de pedido'; |
86 | } | 86 | } |
87 | 87 | ||
88 | if ($scope.actividad === 'Entrega de producto') { | 88 | if ($scope.actividad === 'Entrega de producto') { |
89 | texto = 'Marcadores de entregas'; | 89 | texto = 'Marcadores de entregas'; |
90 | } | 90 | } |
91 | 91 | ||
92 | if ($scope.actividad === 'Cobranza') { | 92 | if ($scope.actividad === 'Cobranza') { |
93 | texto = 'Marcadores de cobranzas'; | 93 | texto = 'Marcadores de cobranzas'; |
94 | } | 94 | } |
95 | 95 | ||
96 | 96 | ||
97 | var modalInstance = $uibModal.open( | 97 | var modalInstance = $uibModal.open( |
98 | { | 98 | { |
99 | ariaLabelledBy: texto, | 99 | ariaLabelledBy: texto, |
100 | templateUrl: 'foca-modal-marcadores.html', | 100 | templateUrl: 'foca-modal-marcadores.html', |
101 | controller: 'focaModalMarcadoresController', | 101 | controller: 'focaModalMarcadoresController', |
102 | size: 'lg', | 102 | size: 'lg', |
103 | resolve: { | 103 | resolve: { |
104 | parametros: function() { | 104 | parametros: function() { |
105 | var parametros = { | 105 | var parametros = { |
106 | marcadores: $scope.marcadores, | 106 | marcadores: $scope.marcadores, |
107 | actividad: $scope.actividad | 107 | actividad: $scope.actividad |
108 | }; | 108 | }; |
109 | 109 | ||
110 | return parametros; | 110 | return parametros; |
111 | } | 111 | } |
112 | } | 112 | } |
113 | } | 113 | } |
114 | ); | 114 | ); |
115 | 115 | ||
116 | modalInstance.result.then( | 116 | modalInstance.result.then( |
117 | function(localizacion) { | 117 | function(localizacion) { |
118 | $scope.$broadcast('moveMap', { | 118 | $scope.$broadcast('moveMap', { |
119 | latitud: localizacion.latitud, | 119 | latitud: localizacion.latitud, |
120 | longitud: localizacion.longitud, | 120 | longitud: localizacion.longitud, |
121 | indice: localizacion.indice | 121 | indice: localizacion.indice |
122 | }); | 122 | }); |
123 | }, function() { | 123 | }, function() { |
124 | // funcion ejecutada cuando se cancela el modal | 124 | // funcion ejecutada cuando se cancela el modal |
125 | } | 125 | } |
126 | ); | 126 | ); |
127 | }; | 127 | }; |
128 | 128 | ||
129 | function getSeguimiento() { | 129 | function getSeguimiento() { |
130 | var now = $scope.now; | 130 | var now = $scope.now; |
131 | var hasta = angular.copy(now); | 131 | var hasta = angular.copy(now); |
132 | hasta.setDate(hasta.getDate() + 1); | 132 | hasta.setDate(hasta.getDate() + 1); |
133 | 133 | ||
134 | var datos = { | 134 | var datos = { |
135 | actividad: $scope.actividad, | 135 | actividad: $scope.actividad, |
136 | idUsuario: $scope.idUsuario, | 136 | idUsuario: $scope.idUsuario, |
137 | fechaDesde: now, | 137 | fechaDesde: now, |
138 | fechaHasta: hasta, | 138 | fechaHasta: hasta, |
139 | entregado: $scope.filtroEstado ? true : ($scope.filtroEstado !== undefined ? | 139 | entregado: $scope.filtroEstado ? true : ($scope.filtroEstado !== undefined ? |
140 | false : undefined) | 140 | false : undefined) |
141 | }; | 141 | }; |
142 | 142 | ||
143 | $scope.datosBuscados = { | 143 | $scope.datosBuscados = { |
144 | actividad: $scope.actividad, | 144 | actividad: $scope.actividad, |
145 | individual: $scope.idUsuario !== 0 ? true : false | 145 | individual: $scope.idUsuario !== 0 ? true : false |
146 | }; | 146 | }; |
147 | 147 | ||
148 | focaAdminSeguimientoService.obtenerActividad(datos).then(function(datos) { | 148 | focaAdminSeguimientoService |
149 | $scope.marcadores = datos.data; | 149 | .obtenerActividad(datos) |
150 | $scope.$broadcast('cleanCabecera'); | 150 | .then(function(datos) { |
151 | 151 | $scope.marcadores = datos.data; | |
152 | if ($scope.idUsuario !== 0) { | 152 | $scope.$broadcast('cleanCabecera'); |
153 | $scope.$broadcast('addCabecera', { | 153 | |
154 | label: 'Individual', | 154 | if ($scope.idUsuario !== 0) { |
155 | valor: '' | 155 | $scope.$broadcast('addCabecera', { |
156 | }); | 156 | label: 'Individual', |
157 | valor: '' | ||
158 | }); | ||
157 | 159 | ||
158 | var valor = ''; | 160 | var valor = ''; |
159 | switch ($routeParams.parametro) { | 161 | switch ($routeParams.parametro) { |
160 | case 'nota-pedido': | 162 | case 'nota-pedido': |
161 | if (datos.data.length) { | 163 | if (datos.data.length) { |
162 | valor = datos.data[0].notaPedido.vendedor.NUM + ' - ' + | 164 | valor = datos.data[0].notaPedido.vendedor.NUM + ' - ' + |
163 | datos.data[0].notaPedido.vendedor.NOM.trim(); | 165 | datos.data[0].notaPedido.vendedor.NOM.trim(); |
164 | } else { | 166 | } else { |
165 | valor = $scope.idUsuario; | 167 | valor = $scope.idUsuario; |
166 | } | 168 | } |
167 | break; | 169 | break; |
168 | case 'hoja-ruta': | 170 | case 'hoja-ruta': |
169 | if (datos.data.length) { | 171 | if (datos.data.length) { |
170 | valor = $scope.idUsuario + ' - ' + datos.data[0] | 172 | valor = $scope.idUsuario + ' - ' + datos.data[0] |
171 | .hojaRutaMovimiento.remito.hojaRuta.vehiculo.tractor.trim(); | 173 | .hojaRutaMovimiento.remito.hojaRuta.vehiculo.tractor.trim(); |
172 | } else { | 174 | } else { |
173 | valor = $scope.idUsuario; | 175 | valor = $scope.idUsuario; |
174 | } | 176 | } |
175 | 177 | ||
176 | break; | 178 | break; |
177 | case 'cobranza': | 179 | case 'cobranza': |
178 | if (datos.data.length) { | 180 | if (datos.data.length) { |
179 | valor = datos.data[0].recibo.cobrador.NUM + ' - ' + | 181 | valor = datos.data[0].recibo.cobrador.NUM + ' - ' + |
180 | datos.data[0].recibo.cobrador.NOM.trim(); | 182 | datos.data[0].recibo.cobrador.NOM.trim(); |
181 | } else { | 183 | } else { |
182 | valor = $scope.idUsuario; | 184 | valor = $scope.idUsuario; |
183 | } | 185 | } |
184 | break; | 186 | break; |
187 | } | ||
188 | |||
189 | $scope.$broadcast('addCabecera', { | ||
190 | label: cabecera, | ||
191 | valor: valor | ||
192 | }); | ||
193 | |||
194 | } else { | ||
195 | $scope.$broadcast('addCabecera',{ | ||
196 | label: 'General', | ||
197 | valor: '' | ||
198 | }); | ||
185 | } | 199 | } |
186 | 200 | ||
187 | $scope.$broadcast('addCabecera', { | 201 | $scope.$broadcast('addCabecera', { |
188 | label: cabecera, | 202 | label: 'Cantidad: ', |
189 | valor: valor | 203 | valor: datos.data.length + ' Marcadores' |
190 | }); | 204 | }); |
191 | |||
192 | } else { | ||
193 | $scope.$broadcast('addCabecera',{ | ||
194 | label: 'General', | ||
195 | valor: '' |
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 | var observacion = ''; | 18 | var observacion = ''; |
19 | 19 | ||
20 | angular.forEach($scope.marcadores, function(marcador) { | 20 | angular.forEach($scope.marcadores, function(marcador) { |
21 | var icon = new L.Icon({ | 21 | var icon = new L.Icon({ |
22 | iconUrl: 'img/marker-icon-2x-blue.png', | 22 | iconUrl: 'img/marker-icon-2x-blue.png', |
23 | shadowUrl: 'img/marker-shadow.png', | 23 | shadowUrl: 'img/marker-shadow.png', |
24 | iconSize: [25, 41], | 24 | iconSize: [25, 41], |
25 | iconAnchor: [12, 41], | 25 | iconAnchor: [12, 41], |
26 | popupAnchor: [1, -34], | 26 | popupAnchor: [1, -34], |
27 | shadowSize: [41, 41] | 27 | shadowSize: [41, 41] |
28 | }); | 28 | }); |
29 | if ($scope.parametros.actividad === 'Nota de pedido') { | 29 | if ($scope.parametros.actividad === 'Nota de pedido') { |
30 | observacion = generarObservacion(getNotaPedido(marcador)); | 30 | observacion = generarObservacion(getNotaPedido(marcador)); |
31 | } | 31 | } |
32 | 32 | ||
33 | if ($scope.parametros.actividad === 'Cobranza') { | 33 | if ($scope.parametros.actividad === 'Cobranza') { |
34 | observacion = getCobranza(marcador); | 34 | observacion = getCobranza(marcador); |
35 | } | 35 | } |
36 | 36 | ||
37 | if ($scope.parametros.actividad === 'Entrega de producto') { | 37 | if ($scope.parametros.actividad === 'Entrega de producto') { |
38 | observacion = getEntrega(marcador); | 38 | observacion = getEntrega(marcador); |
39 | if (marcador.hojaRutaMovimiento.remito.rechazado) { | 39 | if (marcador.hojaRutaMovimiento.remito.rechazado) { |
40 | icon = new L.Icon({ | 40 | icon = new L.Icon({ |
41 | iconUrl: 'img/marker-icon-2x-yellow.png', | 41 | iconUrl: 'img/marker-icon-2x-yellow.png', |
42 | shadowUrl: 'img/marker-shadow.png', | 42 | shadowUrl: 'img/marker-shadow.png', |
43 | iconSize: [25, 41], | 43 | iconSize: [25, 41], |
44 | iconAnchor: [12, 41], | 44 | iconAnchor: [12, 41], |
45 | popupAnchor: [1, -34], | 45 | popupAnchor: [1, -34], |
46 | shadowSize: [41, 41] | 46 | shadowSize: [41, 41] |
47 | }); | 47 | }); |
48 | } else { | 48 | } else { |
49 | icon = new L.Icon({ | 49 | icon = new L.Icon({ |
50 | iconUrl: 'img/marker-icon-2x-green.png', | 50 | iconUrl: 'img/marker-icon-2x-green.png', |
51 | shadowUrl: 'img/marker-shadow.png', | 51 | shadowUrl: 'img/marker-shadow.png', |
52 | iconSize: [25, 41], | 52 | iconSize: [25, 41], |
53 | iconAnchor: [12, 41], | 53 | iconAnchor: [12, 41], |
54 | popupAnchor: [1, -34], | 54 | popupAnchor: [1, -34], |
55 | shadowSize: [41, 41] | 55 | shadowSize: [41, 41] |
56 | }); | 56 | }); |
57 | } | 57 | } |
58 | } | 58 | } |
59 | 59 | ||
60 | if (marcador.visita) icon.options.iconUrl = 'img/marker-icon-2x-yellow.png'; | 60 | if (marcador.visita) icon.options.iconUrl = 'img/marker-icon-2x-yellow.png'; |
61 | 61 | ||
62 | if (observacion) { | 62 | if (observacion) { |
63 | $scope.markers.push( | 63 | $scope.markers.push( |
64 | L.marker( | 64 | L.marker( |
65 | [marcador.latitud, marcador.longitud], | 65 | [marcador.latitud, marcador.longitud], |
66 | {icon: icon}).addTo($scope.map) | 66 | {icon: icon}).addTo($scope.map) |
67 | .bindPopup(observacion) | 67 | .bindPopup(observacion) |
68 | ); | 68 | ); |
69 | 69 | ||
70 | $scope.markers[0].openPopup(); | 70 | $scope.markers[0].openPopup(); |
71 | } | 71 | } |
72 | }); | 72 | }); |
73 | 73 | ||
74 | function getNotaPedido(marcador) { | 74 | function getNotaPedido(marcador) { |
75 | var observacion = []; | 75 | var observacion = []; |
76 | 76 | ||
77 | if(marcador.visita) { | 77 | if(marcador.visita) { |
78 | return getVisita(marcador); | 78 | return getVisita(marcador); |
79 | } else if(!marcador.notaPedido.id) { | 79 | } else if(!marcador.notaPedido.id) { |
80 | return false; | 80 | return false; |
81 | } | 81 | } |
82 | 82 | ||
83 | var notaPedido = marcador.notaPedido; | 83 | var notaPedido = marcador.notaPedido; |
84 | 84 | ||
85 | if (notaPedido.vendedor) { | 85 | if (notaPedido.vendedor) { |
86 | observacion.push([ | 86 | observacion.push([ |
87 | 'Vendedor', | 87 | 'Vendedor', |
88 | notaPedido.vendedor.NUM + ' - ' + notaPedido.vendedor.NOM | 88 | notaPedido.vendedor.NUM + ' - ' + notaPedido.vendedor.NOM |
89 | ]); | 89 | ]); |
90 | } | 90 | } |
91 | 91 | ||
92 | 92 | ||
93 | if (!$scope.parametros.individual) { | 93 | if (!$scope.parametros.individual) { |
94 | observacion.push(['Ultima Nota de Pedido', '']); | 94 | observacion.push(['Ultima Nota de Pedido', '']); |
95 | } | 95 | } |
96 | 96 | ||
97 | var textFecha = $filter('date')(marcador.fecha.slice(0,10), 'dd/MM/yyyy') + | 97 | var textFecha = $filter('date')(marcador.fecha.slice(0,10), 'dd/MM/yyyy') + |
98 | ' ' + marcador.fecha.slice(11,19); | 98 | ' ' + marcador.fecha.slice(11,19); |
99 | observacion.push(['Fecha', textFecha]); | 99 | observacion.push(['Fecha', textFecha]); |
100 | 100 | ||
101 | observacion.push(['Nº', | 101 | observacion.push(['Nº', |
102 | $filter('comprobante')([notaPedido.sucursal, notaPedido.numeroNotaPedido ]) | 102 | $filter('comprobante')([notaPedido.sucursal, notaPedido.numeroNotaPedido ]) |
103 | ]); | 103 | ]); |
104 | 104 | ||
105 | if (notaPedido.cliente) { | 105 | if (notaPedido.cliente) { |
106 | observacion.push(['Cliente', notaPedido.cliente.NOM]); | 106 | observacion.push(['Cliente', notaPedido.cliente.NOM]); |
107 | } | 107 | } |
108 | 108 | ||
109 | if ($scope.parametros.individual) { | 109 | if ($scope.parametros.individual) { |
110 | observacion.push(['Total', $filter('currency')(notaPedido.total, '$')]); | 110 | observacion.push(['Total', $filter('currency')(notaPedido.total, '$')]); |
111 | observacion.unshift(['Orden', marcador.orden]); | 111 | observacion.unshift(['Orden', marcador.orden]); |
112 | 112 | ||
113 | if (marcador.distancia) { | 113 | if (marcador.distancia) { |
114 | observacion.push(['Distancia a casa central', | 114 | observacion.push(['Distancia a casa central', |
115 | marcador.distancia + 'km' | 115 | marcador.distancia + 'km' |
116 | ]); | 116 | ]); |
117 | } | 117 | } |
118 | } else { | 118 | } else { |
119 | observacion.push(['Cantidad de nota de pedido', | 119 | observacion.push(['Cantidad de nota de pedido', |
120 | marcador.cantidad | 120 | marcador.cantidad |
121 | ]); | 121 | ]); |
122 | 122 | ||
123 | observacion.push(['Total Vendido', | 123 | observacion.push(['Total Vendido', |
124 | $filter('currency')(marcador.total, '$') | 124 | $filter('currency')(marcador.total, '$') |
125 | ]); | 125 | ]); |
126 | } | 126 | } |
127 | 127 | ||
128 | return observacion; | 128 | return observacion; |
129 | } | 129 | } |
130 | 130 | ||
131 | function getCobranza(marcador) { | 131 | function getCobranza(marcador) { |
132 | if(marcador.visita) { | 132 | if(marcador.visita) { |
133 | return generarObservacion(getVisita(marcador)); | 133 | return generarObservacion(getVisita(marcador)); |
134 | } | 134 | } |
135 | 135 | ||
136 | observacion = ''; | 136 | observacion = ''; |
137 | observacion += 'Cobrador: ' + marcador.recibo.cobrador.NUM + ' - ' + | 137 | observacion += 'Cobrador: ' + marcador.recibo.cobrador.NUM + ' - ' + |
138 | marcador.recibo.CFE + '<br/>'; | 138 | marcador.recibo.CFE + '<br/>'; |
139 | 139 | ||
140 | if (!$scope.parametros.individual) { | 140 | if (!$scope.parametros.individual) { |
141 | observacion += '<b>Ultima Cobranza</b><br/>'; | 141 | observacion += '<b>Ultima Cobranza</b><br/>'; |
142 | } | 142 | } |
143 | 143 | ||
144 | observacion += 'Fecha: ' + | 144 | observacion += 'Fecha: ' + |
145 | $filter('date')(marcador.fecha.slice(0,10), 'dd/MM/yyyy') + ' ' + | 145 | $filter('date')(marcador.fecha.slice(0,10), 'dd/MM/yyyy') + ' ' + |
146 | marcador.fecha.slice(11,19) + '<br/>'; | 146 | marcador.fecha.slice(11,19) + '<br/>'; |
147 | observacion += 'Nº: ' + $filter('comprobante')([ | 147 | observacion += 'Nº: ' + $filter('comprobante')([ |
148 | marcador.recibo.PVE, marcador.recibo.NCO]) + '<br/>'; | 148 | marcador.recibo.PVE, marcador.recibo.NCO]) + '<br/>'; |
149 | observacion += 'Cliente: ' + marcador.recibo.cliente.NOM + '<br/>'; | 149 | observacion += 'Cliente: ' + marcador.recibo.cliente.NOM + '<br/>'; |
150 | var totalCobrado = 0; | 150 | var totalCobrado = 0; |
151 | for (var i = 0; i < marcador.recibo.cuerpos.length; i++) { | 151 | for (var i = 0; i < marcador.recibo.cuerpos.length; i++) { |
152 | if (marcador.recibo.cuerpos[i].LOP === 'P') { | 152 | if (marcador.recibo.cuerpos[i].LOP === 'P') { |
153 | totalCobrado += marcador.recibo.cuerpos[i].IMP; | 153 | totalCobrado += marcador.recibo.cuerpos[i].IMP; |
154 | } | 154 | } |
155 | } | 155 | } |
156 | 156 | ||
157 | if ($scope.parametros.individual) { | 157 | if ($scope.parametros.individual) { |
158 | if (marcador.distancia) { | 158 | if (marcador.distancia) { |
159 | observacion += 'Distancia a casa central: ' + | 159 | observacion += 'Distancia a casa central: ' + |
160 | marcador.distancia + 'km' + '<br/>'; | 160 | marcador.distancia + 'km' + '<br/>'; |
161 | observacion += 'Total Cobrado: ' + | 161 | observacion += 'Total Cobrado: ' + |
162 | $filter('currency')(totalCobrado, '$'); | 162 | $filter('currency')(totalCobrado, '$'); |
163 | } | 163 | } |
164 | } else { | 164 | } else { |
165 | observacion += 'Cantidad de cobranzas: ' + | 165 | observacion += 'Cantidad de cobranzas: ' + |
166 | marcador.cantidad + '<br/>'; | 166 | marcador.cantidad + '<br/>'; |
167 | observacion += 'Total Cobrado: ' + | 167 | observacion += 'Total Cobrado: ' + |
168 | $filter('currency')(totalCobrado, '$'); | 168 | $filter('currency')(totalCobrado, '$'); |
169 | } | 169 | } |
170 | return observacion; | 170 | return observacion; |
171 | } | 171 | } |
172 | 172 | ||
173 | function getEntrega(marcador) { | 173 | function getEntrega(marcador) { |
174 | var observacion = ''; | 174 | var observacion = ''; |
175 | var remito = marcador.hojaRutaMovimiento.remito; | 175 | var remito = marcador.hojaRutaMovimiento.remito; |
176 | observacion += 'Vehiculo: ' + | 176 | observacion += 'Vehiculo: ' + |
177 | remito.hojaRuta.idVehiculo + ' - ' + | 177 | remito.hojaRuta.idVehiculo + ' - ' + |
178 | remito.hojaRuta.vehiculo.tractor + '<br/>'; | 178 | remito.hojaRuta.vehiculo.tractor + '<br/>'; |
179 | observacion += 'Transportista: ' + | 179 | observacion += 'Transportista: ' + |
180 | remito.hojaRuta.transportista.NOM + '<br/>'; | 180 | remito.hojaRuta.transportista.NOM + '<br/>'; |
181 | observacion += 'Chofer: ' + | 181 | observacion += 'Chofer: ' + |
182 | remito.hojaRuta.chofer.nombre + '<br/>'; | 182 | remito.hojaRuta.chofer.nombre + '<br/>'; |
183 | observacion += 'Hoja de ruta: ' + $filter('comprobante')([ | 183 | observacion += 'Hoja de ruta: ' + $filter('comprobante')([ |
184 | remito.hojaRuta.sucursal, | 184 | remito.hojaRuta.sucursal, |
185 | remito.hojaRuta.numeroHojaRuta | 185 | remito.hojaRuta.numeroHojaRuta |
186 | ]) + '<br/>'; | 186 | ]) + '<br/>'; |
187 | 187 | ||
188 | if (!$scope.parametros.individual) { | 188 | if (!$scope.parametros.individual) { |
189 | observacion += '<b>Ultimo Remito</b><br/>'; | 189 | observacion += '<b>Ultimo Remito</b><br/>'; |
190 | } | 190 | } |
191 | 191 | ||
192 | observacion += 'Fecha: ' + | 192 | observacion += 'Fecha: ' + |
193 | $filter('date')(marcador.fecha.slice(0,10), 'dd/MM/yyyy') + ' ' + | 193 | $filter('date')(marcador.fecha.slice(0,10), 'dd/MM/yyyy') + ' ' + |
194 | marcador.fecha.slice(11,19) + '<br/>'; | 194 | marcador.fecha.slice(11,19) + '<br/>'; |
195 | 195 | ||
196 | observacion += 'Nº: ' + $filter('comprobante')([ | 196 | observacion += 'Nº: ' + $filter('comprobante')([ |
197 | remito.sucursal, | 197 | remito.sucursal, |
198 | remito.numeroRemito | 198 | remito.numeroRemito |
199 | ]) + '<br/>'; | 199 | ]) + '<br/>'; |
200 | observacion += 'Cliente: ' + | 200 | observacion += 'Cliente: ' + |
201 | remito.cliente.NOM + '<br/>'; | 201 | remito.cliente.NOM + '<br/>'; |
202 | 202 | ||
203 | if ($scope.parametros.individual) { | 203 | if ($scope.parametros.individual) { |
204 | // observacion += 'Producto: ' + | 204 | // observacion += 'Producto: ' + |
205 | // remito.articulosRemito[0].descripcion + '<br/>'; | 205 | // remito.articulosRemito[0].descripcion + '<br/>'; |
206 | // observacion += 'Cantidad entregada: ' + | 206 | // observacion += 'Cantidad entregada: ' + |
207 | // remito.carga + '<br/>'; | 207 | // remito.carga + '<br/>'; |
208 | 208 | ||
209 | if (marcador.distancia) { | 209 | if (marcador.distancia) { |
210 | observacion += 'Distancia a casa central: ' + marcador.distancia + | 210 | observacion += 'Distancia a casa central: ' + marcador.distancia + |
211 | 'km <br/>'; | 211 | 'km <br/>'; |
212 | } | 212 | } |
213 | 213 | ||
214 | observacion = 'Orden: ' + marcador.orden + '<br/>' + observacion; | 214 | observacion = 'Orden: ' + marcador.orden + '<br/>' + observacion; |
215 | } else { | 215 | } else { |
216 | observacion += 'Cantidad de entregas: ' + marcador.cantidad; | 216 | observacion += 'Cantidad de entregas: ' + marcador.cantidad; |
217 | } | 217 | } |
218 | observacion += '<br/>'; | 218 | observacion += '<br/>'; |
219 | if (remito.rechazado) { | 219 | if (remito.rechazado) { |
220 | observacion += '<strong>Motivo del rechazo: ' + remito.motivoRechazo; | 220 | observacion += '<strong>Motivo del rechazo: ' + remito.motivoRechazo; |
221 | } | 221 | } |
222 | 222 | ||
223 | return observacion; | 223 | return observacion; |
224 | } | 224 | } |
225 | 225 | ||
226 | function getVisita(marcador) { | 226 | function getVisita(marcador) { |
227 | var observacion = []; | 227 | var observacion = []; |
228 | var textFecha = $filter('date')(marcador.fecha.slice(0,10), 'dd/MM/yyyy') + | 228 | var textFecha = $filter('date')(marcador.fecha.slice(0,10), 'dd/MM/yyyy') + |
229 | ' ' + marcador.fecha.slice(11,19); | 229 | ' ' + marcador.fecha.slice(11,19); |
230 | var prospecto = marcador.visitas.cliente.ES_PROS; | 230 | var prospecto = marcador.visita.cliente.ES_PROS; |
231 | var tipoVisitante = | 231 | var tipoVisitante = |
232 | (marcador.visitas.tipoVisitante) === 1 ? 'Vendedor' : 'Cobrador'; | 232 | (marcador.visita.tipoVisitante) === 1 ? 'Vendedor' : 'Cobrador'; |
233 | var visitante = marcador.visitas.visitante.NUM + ' - ' + | 233 | var visitante = marcador.visita.visitante.NUM + ' - ' + |
234 | marcador.visitas.visitante.NOM; | 234 | marcador.visita.visitante.NOM; |
235 | 235 | ||
236 | observacion.push([tipoVisitante, visitante]); | 236 | observacion.push([tipoVisitante, visitante]); |
237 | observacion.push(['Fecha', textFecha]); | 237 | observacion.push(['Fecha', textFecha]); |
238 | observacion.push(['Cliente', marcador.visitas.cliente.NOM]); | 238 | observacion.push(['Cliente', marcador.visita.cliente.NOM]); |
239 | observacion.push(['Es prospecto', (prospecto) ? 'Si' : 'No']); | 239 | observacion.push(['Es prospecto', (prospecto) ? 'Si' : 'No']); |
240 | 240 | ||
241 | return observacion; | 241 | return observacion; |
242 | } | 242 | } |
243 | 243 | ||
244 | function generarObservacion(array) { | 244 | function generarObservacion(array) { |
245 | var resultado = ''; | 245 | var resultado = ''; |
246 | 246 | ||
247 | for (var i = 0; i < array.length; i++) { | 247 | for (var i = 0; i < array.length; i++) { |
248 | resultado += '<b>' + array[i][0] + ': </b>'; | 248 | resultado += '<b>' + array[i][0] + ': </b>'; |
249 | resultado += array[i][1]; | 249 | resultado += array[i][1]; |
250 | 250 | ||
251 | if (i < (array.length - 1)) { | 251 | if (i < (array.length - 1)) { |
252 | resultado += '<br/>'; | 252 | resultado += '<br/>'; |
253 | } | 253 | } |
254 | } | 254 | } |
255 | 255 | ||
256 | return resultado; | 256 | return resultado; |
257 | } | 257 | } |
258 | }); | 258 | }); |
259 | 259 | ||
260 | 260 | ||
261 | $scope.$on('moveMap', function(evt, data) { | 261 | $scope.$on('moveMap', function(evt, data) { |
262 | var center = new L.LatLng(data.latitud, data.longitud); | 262 | var center = new L.LatLng(data.latitud, data.longitud); |
263 | $scope.map.flyTo(center, 11, {duration: 0.5}); | 263 | $scope.map.flyTo(center, 11, {duration: 0.5}); |
264 | $scope.markers[data.indice].openPopup(); | 264 | $scope.markers[data.indice].openPopup(); |
265 | }); | 265 | }); |
266 | }], | 266 | }], |
267 | scope: { | 267 | scope: { |
268 | latitud: '=', | 268 | latitud: '=', |
269 | longitud: '=', | 269 | longitud: '=', |
270 | zoom: '=', | 270 | zoom: '=', |
271 | marcadores: '=', | 271 | marcadores: '=', |
272 | parametros: '=' | 272 | parametros: '=' |
273 | } | 273 | } |
274 | }; | 274 | }; |
275 | }); | 275 | }); |
276 | 276 |