Commit 14d588f846905f3b4579c9972174b42b126dc0c7

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

mejora de filtro de fechas para seguimiento

Showing 1 changed file with 6 additions and 7 deletions   Show diff stats
src/js/controller.js
1 angular.module('focaAdminSeguimiento').controller('focaAdminSeguimientoController', [ 1 angular.module('focaAdminSeguimiento').controller('focaAdminSeguimientoController', [
2 '$scope', '$timeout', 'focaAdminSeguimientoService', 2 '$scope', '$timeout', 'focaAdminSeguimientoService',
3 'focaBotoneraLateralService','$location', '$routeParams', 3 'focaBotoneraLateralService','$location', '$routeParams',
4 function($scope, $timeout, focaAdminSeguimientoService, 4 function($scope, $timeout, focaAdminSeguimientoService,
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 function getSeguimiento() { 81 function getSeguimiento() {
82 $scope.$broadcast('cleanCabecera');
83 var now = $scope.now; 82 var now = $scope.now;
84 var desde = new Date(new Date(now.setHours(0)).setMinutes(0)); 83 var hasta = angular.copy(now);
85 desde = desde.setDate(desde.getDate() - 1); 84 hasta.setDate(hasta.getDate() + 1);
86 desde = new Date(desde); 85
87 var datos = { 86 var datos = {
88 actividad: $scope.actividad, 87 actividad: $scope.actividad,
89 idUsuario: $scope.idUsuario, 88 idUsuario: $scope.idUsuario,
90 fechaDesde: desde, 89 fechaDesde: now,
91 fechaHasta: new Date(new Date(now.setHours(23)).setMinutes(59)), 90 fechaHasta: hasta,
92 entregado: $scope.filtroEstado ? true : ($scope.filtroEstado !== undefined ? 91 entregado: $scope.filtroEstado ? true : ($scope.filtroEstado !== undefined ?
93 false : undefined) 92 false : undefined)
94 }; 93 };
95 94
96 $scope.datosBuscados = { 95 $scope.datosBuscados = {
97 actividad: $scope.actividad, 96 actividad: $scope.actividad,
98 individual: $scope.idUsuario !== 0 ? true : false 97 individual: $scope.idUsuario !== 0 ? true : false
99 }; 98 };
100 99
101 focaAdminSeguimientoService.obtenerActividad(datos).then(function(datos) { 100 focaAdminSeguimientoService.obtenerActividad(datos).then(function(datos) {
102 $scope.marcadores = datos.data; 101 $scope.marcadores = datos.data;
102 $scope.$broadcast('cleanCabecera');
103 103
104 if ($scope.idUsuario !== 0) { 104 if ($scope.idUsuario !== 0) {
105 $scope.$broadcast('removeCabecera', 'General -');
106 $scope.$broadcast('addCabecera', { 105 $scope.$broadcast('addCabecera', {
107 label: 'Individual', 106 label: 'Individual',
108 valor: '' 107 valor: ''
109 }); 108 });
110 109
111 var valor = ''; 110 var valor = '';
112 switch ($routeParams.parametro) { 111 switch ($routeParams.parametro) {
113 case 'nota-pedido': 112 case 'nota-pedido':
114 if (datos.data.length) { 113 if (datos.data.length) {
115 valor = datos.data[0].notaPedido.vendedor.NUM + ' - ' + 114 valor = datos.data[0].notaPedido.vendedor.NUM + ' - ' +
116 datos.data[0].notaPedido.vendedor.NOM.trim(); 115 datos.data[0].notaPedido.vendedor.NOM.trim();
117 } else { 116 } else {
118 valor = $scope.idUsuario; 117 valor = $scope.idUsuario;
119 } 118 }
120 break; 119 break;
121 case 'hoja-ruta': 120 case 'hoja-ruta':
122 if (datos.data.length) { 121 if (datos.data.length) {
123 valor = $scope.idUsuario + ' - ' + datos.data[0] 122 valor = $scope.idUsuario + ' - ' + datos.data[0]
124 .hojaRutaMovimiento.remito.hojaRuta.vehiculo.tractor.trim(); 123 .hojaRutaMovimiento.remito.hojaRuta.vehiculo.tractor.trim();
125 } else { 124 } else {
126 valor = $scope.idUsuario; 125 valor = $scope.idUsuario;
127 } 126 }
128 127
129 break; 128 break;
130 case 'cobranza': 129 case 'cobranza':
131 if (datos.data.length) { 130 if (datos.data.length) {
132 valor = datos.data[0].notaPedido.vendedor.NUM + ' - ' + 131 valor = datos.data[0].notaPedido.vendedor.NUM + ' - ' +
133 datos.data[0].notaPedido.vendedor.NOM.trim(); 132 datos.data[0].notaPedido.vendedor.NOM.trim();
134 } else { 133 } else {
135 valor = $scope.idUsuario; 134 valor = $scope.idUsuario;
136 } 135 }
137 break; 136 break;
138 } 137 }
139 138
140 $scope.$broadcast('addCabecera', { 139 $scope.$broadcast('addCabecera', {
141 label: cabecera, 140 label: cabecera,
142 valor: valor 141 valor: valor
143 }); 142 });
144 143
145 } else { 144 } else {
146 $scope.$broadcast('addCabecera',{ 145 $scope.$broadcast('addCabecera',{
147 label: 'General', 146 label: 'General',
148 valor: '' 147 valor: ''
149 }); 148 });
150 } 149 }
151 150
152 $scope.$broadcast('addCabecera', { 151 $scope.$broadcast('addCabecera', {
153 label: 'Cantidad: ', 152 label: 'Cantidad: ',
154 valor: datos.data.length + ' Marcadores' 153 valor: datos.data.length + ' Marcadores'
155 }); 154 });
156 }); 155 });
157 } 156 }
158 } 157 }
159 ]); 158 ]);