Commit 36d15cd545790cd129bf346f30e65648d6110d54

Authored by Marcelo Puebla
1 parent 37887c105f
Exists in master and in 2 other branches develop, lab

Cambiada variable let a var.

Showing 1 changed file with 1 additions and 1 deletions   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', 'focaModalService', 3 'focaBotoneraLateralService', '$location', '$routeParams', 'focaModalService',
4 function ($scope, $timeout, focaAdminSeguimientoService, $uibModal, 4 function ($scope, $timeout, focaAdminSeguimientoService, $uibModal,
5 focaBotoneraLateralService, $location, $routeParams, focaModalService) { 5 focaBotoneraLateralService, $location, $routeParams, focaModalService) {
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 148 focaAdminSeguimientoService
149 .obtenerActividad(datos) 149 .obtenerActividad(datos)
150 .then(function (datos) { 150 .then(function (datos) {
151 $scope.marcadores = datos.data; 151 $scope.marcadores = datos.data;
152 $scope.$broadcast('cleanCabecera'); 152 $scope.$broadcast('cleanCabecera');
153 153
154 if ($scope.idUsuario !== 0) { 154 if ($scope.idUsuario !== 0) {
155 $scope.$broadcast('addCabecera', { 155 $scope.$broadcast('addCabecera', {
156 label: 'Individual', 156 label: 'Individual',
157 valor: '' 157 valor: ''
158 }); 158 });
159 159
160 var valor = ''; 160 var valor = '';
161 switch ($routeParams.parametro) { 161 switch ($routeParams.parametro) {
162 case 'nota-pedido': 162 case 'nota-pedido':
163 if (datos.data.length) { 163 if (datos.data.length) {
164 valor = datos.data[0].notaPedido.vendedor.NUM + ' - ' + 164 valor = datos.data[0].notaPedido.vendedor.NUM + ' - ' +
165 datos.data[0].notaPedido.vendedor.NOM.trim(); 165 datos.data[0].notaPedido.vendedor.NOM.trim();
166 } else { 166 } else {
167 valor = $scope.idUsuario; 167 valor = $scope.idUsuario;
168 } 168 }
169 break; 169 break;
170 case 'hoja-ruta': 170 case 'hoja-ruta':
171 if (datos.data.length) { 171 if (datos.data.length) {
172 valor = datos.data[0].hojaRutaMovimiento.remito.hojaRuta 172 valor = datos.data[0].hojaRutaMovimiento.remito.hojaRuta
173 .vehiculo.codigo + ' - ' + datos.data[0] 173 .vehiculo.codigo + ' - ' + datos.data[0]
174 .hojaRutaMovimiento.remito.hojaRuta.vehiculo.tractor.trim(); 174 .hojaRutaMovimiento.remito.hojaRuta.vehiculo.tractor.trim();
175 } else { 175 } else {
176 valor = $scope.idUsuario; 176 valor = $scope.idUsuario;
177 } 177 }
178 178
179 break; 179 break;
180 case 'cobranza': 180 case 'cobranza':
181 if (datos.data.length) { 181 if (datos.data.length) {
182 valor = datos.data[0].recibo.cobrador.NUM + ' - ' + 182 valor = datos.data[0].recibo.cobrador.NUM + ' - ' +
183 datos.data[0].recibo.cobrador.NOM.trim(); 183 datos.data[0].recibo.cobrador.NOM.trim();
184 } else { 184 } else {
185 valor = $scope.idUsuario; 185 valor = $scope.idUsuario;
186 } 186 }
187 break; 187 break;
188 } 188 }
189 189
190 $scope.$broadcast('addCabecera', { 190 $scope.$broadcast('addCabecera', {
191 label: cabecera, 191 label: cabecera,
192 valor: valor 192 valor: valor
193 }); 193 });
194 194
195 } else { 195 } else {
196 $scope.$broadcast('addCabecera', { 196 $scope.$broadcast('addCabecera', {
197 label: 'General', 197 label: 'General',
198 valor: '' 198 valor: ''
199 }); 199 });
200 } 200 }
201 201
202 $scope.$broadcast('addCabecera', { 202 $scope.$broadcast('addCabecera', {
203 label: 'Cantidad: ', 203 label: 'Cantidad: ',
204 valor: datos.data.length + ' Marcadores' 204 valor: datos.data.length + ' Marcadores'
205 }); 205 });
206 }); 206 });
207 } 207 }
208 $scope.openModal = function () { 208 $scope.openModal = function () {
209 let parametrosModal = {}; 209 var parametrosModal = {};
210 switch ($routeParams.parametro) { 210 switch ($routeParams.parametro) {
211 case 'nota-pedido': 211 case 'nota-pedido':
212 parametrosModal = { 212 parametrosModal = {
213 titulo: 'Búsqueda vendedores', 213 titulo: 'Búsqueda vendedores',
214 query: '/vendedor', 214 query: '/vendedor',
215 columnas: [ 215 columnas: [
216 { 216 {
217 propiedad: 'NUM', 217 propiedad: 'NUM',
218 nombre: 'Código', 218 nombre: 'Código',
219 filtro: { 219 filtro: {
220 nombre: 'rellenarDigitos', 220 nombre: 'rellenarDigitos',
221 parametro: 3 221 parametro: 3
222 } 222 }
223 }, 223 },
224 { 224 {
225 propiedad: 'NOM', 225 propiedad: 'NOM',
226 nombre: 'Nombre' 226 nombre: 'Nombre'
227 } 227 }
228 ], 228 ],
229 size: 'md' 229 size: 'md'
230 }; 230 };
231 break; 231 break;
232 case 'hoja-ruta': 232 case 'hoja-ruta':
233 parametrosModal = { 233 parametrosModal = {
234 titulo: 'Búsqueda de Transportista', 234 titulo: 'Búsqueda de Transportista',
235 query: '/transportista', 235 query: '/transportista',
236 columnas: [ 236 columnas: [
237 { 237 {
238 nombre: 'Código', 238 nombre: 'Código',
239 propiedad: 'COD' 239 propiedad: 'COD'
240 }, 240 },
241 { 241 {
242 nombre: 'Nombre', 242 nombre: 'Nombre',
243 propiedad: 'NOM' 243 propiedad: 'NOM'
244 }, 244 },
245 { 245 {
246 nombre: 'CUIT', 246 nombre: 'CUIT',
247 propiedad: 'CUIT' 247 propiedad: 'CUIT'
248 } 248 }
249 ], 249 ],
250 size: 'md' 250 size: 'md'
251 }; 251 };
252 break; 252 break;
253 case 'cobranza': 253 case 'cobranza':
254 parametrosModal = { 254 parametrosModal = {
255 titulo: 'Búsqueda de cobradores', 255 titulo: 'Búsqueda de cobradores',
256 query: '/cobrador', 256 query: '/cobrador',
257 columnas: [ 257 columnas: [
258 { 258 {
259 propiedad: 'NUM', 259 propiedad: 'NUM',
260 nombre: 'Codigo', 260 nombre: 'Codigo',
261 filtro: { 261 filtro: {
262 nombre: 'rellenarDigitos', 262 nombre: 'rellenarDigitos',
263 parametro: 3 263 parametro: 3
264 } 264 }
265 }, 265 },
266 { 266 {
267 propiedad: 'NOM', 267 propiedad: 'NOM',
268 nombre: 'Nombre' 268 nombre: 'Nombre'
269 } 269 }
270 ], 270 ],
271 size: 'md' 271 size: 'md'
272 }; 272 };
273 break; 273 break;
274 default: 274 default:
275 break; 275 break;
276 } 276 }
277 focaModalService.modal(parametrosModal) 277 focaModalService.modal(parametrosModal)
278 .then( 278 .then(
279 function (data) { 279 function (data) {
280 $scope.idUsuario = $scope.idUsuarioInput = data.NUM; 280 $scope.idUsuario = $scope.idUsuarioInput = data.NUM;
281 getSeguimiento(); 281 getSeguimiento();
282 if ($scope.actividad === 'Entrega de producto' && $scope.idUsuario !== 0) { 282 if ($scope.actividad === 'Entrega de producto' && $scope.idUsuario !== 0) {
283 focaAdminSeguimientoService.obtenerRemitosVehiculo($scope.idUsuario) 283 focaAdminSeguimientoService.obtenerRemitosVehiculo($scope.idUsuario)
284 .then(function (res) { 284 .then(function (res) {
285 var remitos = []; 285 var remitos = [];
286 for (var i = 0; i < res.data.length; i++) { 286 for (var i = 0; i < res.data.length; i++) {
287 remitos = remitos.concat(res.data[i].remitos); 287 remitos = remitos.concat(res.data[i].remitos);
288 } 288 }
289 $scope.remitosVehiculo = remitos; 289 $scope.remitosVehiculo = remitos;
290 }); 290 });
291 } 291 }
292 } 292 }
293 ) 293 )
294 .catch(function (e) { console.log(e) }); 294 .catch(function (e) { console.log(e) });
295 } 295 }
296 } 296 }
297 ]); 297 ]);
298 298