Commit 5df5c2a273eae8937686828c9e40fc3b98ba7aab

Authored by Marcelo Puebla
1 parent 61f6d52a80
Exists in master and in 1 other branch develop

Arreglo en buscador en informe productividad.

src/js/controller-productividad.js
1 angular.module('focaModalInforme') 1 angular.module('focaModalInforme')
2 .controller('focaModalInformeProductividadController', 2 .controller('focaModalInformeProductividadController',
3 [ 3 [
4 '$filter', 4 '$filter',
5 '$scope', 5 '$scope',
6 '$uibModalInstance', 6 '$uibModalInstance',
7 'focaModalInformeProductividadService', 7 'focaModalInformeProductividadService',
8 'i18nService', 8 'i18nService',
9 'focaModalService', 9 'focaModalService',
10 function($filter, $scope, $uibModalInstance, 10 function($filter, $scope, $uibModalInstance,
11 focaModalInformeProductividadService, i18nService, focaModalService 11 focaModalInformeProductividadService, i18nService, focaModalService
12 ) { 12 ) {
13 i18nService.setCurrentLang('es'); 13 i18nService.setCurrentLang('es');
14 var fecha = new Date(); 14 var fecha = new Date();
15 $scope.generando = false; 15 $scope.generando = false;
16 $scope.buscar = true; 16 $scope.buscar = true;
17 $scope.informe = {}; 17 $scope.informe = {};
18 $scope.params = { 18 $scope.params = {
19 fechaHasta: new Date(), 19 fechaHasta: new Date(),
20 fechaDesde: new Date(fecha.setMonth(fecha.getMonth() - 1)), 20 fechaDesde: new Date(fecha.setMonth(fecha.getMonth() - 1)),
21 sector: undefined, 21 sector: undefined,
22 diferenciarProductos: false, 22 diferenciarProductos: false,
23 diferenciarMeses: false 23 diferenciarMeses: false,
24 entidad:{
25 label: ''
26 }
24 }; 27 };
25 $scope.gridOptions = { 28 $scope.gridOptions = {
26 enableGridMenu: true, 29 enableGridMenu: true,
27 exporterMenuCsv: false, 30 exporterMenuCsv: false,
28 exporterPdfPageSize: 'A4', 31 exporterPdfPageSize: 'A4',
29 exporterPdfFooter: function (currentPage, pageCount) { 32 exporterPdfFooter: function (currentPage, pageCount) {
30 return { 33 return {
31 columns: [ 34 columns: [
32 {text: $filter('date')(new Date(), 'dd/MM/yyyy'), 35 {text: $filter('date')(new Date(), 'dd/MM/yyyy'),
33 margin: [40, 0]}, 36 margin: [40, 0]},
34 {text: currentPage + ' de ' + pageCount, 37 {text: currentPage + ' de ' + pageCount,
35 margin: [28, 0], alignment: 'right'} 38 margin: [28, 0], alignment: 'right'}
36 ] 39 ]
37 }; 40 };
38 }, 41 },
39 columnDefs: [ 42 columnDefs: [
40 { 43 {
41 field: 'cliente', 44 field: 'cliente',
42 enableSorting: false, 45 enableSorting: false,
43 cellClass: function(grid, row, col) { 46 cellClass: function(grid, row, col) {
44 var value = grid.getCellValue(row,col); 47 var value = grid.getCellValue(row,col);
45 48
46 if (value.indexOf('Vendedores') !== -1 || 49 if (value.indexOf('Vendedores') !== -1 ||
47 value.indexOf('Cobradores') !== -1 || 50 value.indexOf('Cobradores') !== -1 ||
48 value.indexOf('Transportistas') !== -1) 51 value.indexOf('Transportistas') !== -1)
49 return 'yellow w-100'; 52 return 'yellow w-100';
50 if (value.indexOf('Vendedor:') !== -1 || 53 if (value.indexOf('Vendedor:') !== -1 ||
51 value.indexOf('Cobrador:') !== -1 || 54 value.indexOf('Cobrador:') !== -1 ||
52 value.indexOf('Transportista:') !== -1) 55 value.indexOf('Transportista:') !== -1)
53 return 'red w-100'; 56 return 'red w-100';
54 if (value.indexOf('Fecha:') !== -1) 57 if (value.indexOf('Fecha:') !== -1)
55 return 'green w-100'; 58 return 'green w-100';
56 } 59 }
57 }, 60 },
58 { 61 {
59 field: 'fecha', 62 field: 'fecha',
60 enableSorting: false, 63 enableSorting: false,
61 cellClass: function(grid, row, col) { 64 cellClass: function(grid, row, col) {
62 if (!grid.getCellValue(row,col)) 65 if (!grid.getCellValue(row,col))
63 return 'd-none'; 66 return 'd-none';
64 } 67 }
65 }, 68 },
66 { 69 {
67 field: 'kmRecorridos', 70 field: 'kmRecorridos',
68 enableSorting: false, 71 enableSorting: false,
69 cellClass: function(grid, row, col) { 72 cellClass: function(grid, row, col) {
70 if (!grid.getCellValue(row,col)) 73 if (!grid.getCellValue(row,col))
71 return 'd-none'; 74 return 'd-none';
72 } 75 }
73 }, 76 },
74 { 77 {
75 field: 'geolocalizacion', 78 field: 'geolocalizacion',
76 enableSorting: false, 79 enableSorting: false,
77 cellClass: function(grid, row, col) { 80 cellClass: function(grid, row, col) {
78 if (!grid.getCellValue(row,col)) 81 if (!grid.getCellValue(row,col))
79 return 'd-none'; 82 return 'd-none';
80 } 83 }
81 } 84 }
82 ] 85 ]
83 }; 86 };
84 $scope.seleccionarTipo = function() { 87 $scope.seleccionarTipo = function() {
85 var data = [ 88 var parametrosModal = {
86 { 89 searchText: $scope.params.entidad.label,
87 id: 0,
88 label: 'Todos'
89 },
90 {
91 id: 1,
92 label: 'Vendedores'
93 },
94 {
95 id: 2,
96 label: 'Cobradores'
97 },
98 {
99 id: 3,
100 label: 'Transportistas'
101 }
102 ];
103 focaModalService.modal({
104 titulo: 'Seleccionar entidad',
105 data: data,
106 columnas: [ 90 columnas: [
107 { 91 {
108 propiedad: 'label', 92 propiedad: 'label',
109 nombre: 'Entidad' 93 nombre: 'Entidad'
110 } 94 }
111 ], 95 ],
112 }).then(function(res) { 96 titulo: 'Seleccionar entidad',
97 size: 'md',
98 data: [
99 {
100 id: 0,
101 label: 'Todos'
102 },
103 {
104 id: 1,
105 label: 'Vendedores'
106 },
107 {
108 id: 2,
109 label: 'Cobradores'
110 },
111 {
112 id: 3,
113 label: 'Transportistas'
114 }
115 ]
116 };
117
118 focaModalService.modal(parametrosModal).then(function(res) {
113 $scope.params.entidad = res; 119 $scope.params.entidad = res;
114 }); 120 });
115 }; 121 };
116 $scope.generarInforme = function() { 122 $scope.generarInforme = function() {
117 if (!$scope.params.entidad) { 123 if ($scope.params.entidad.id === undefined) {
118 focaModalService.alert('Seleccione una entidad'); 124 focaModalService.alert('Seleccione una entidad');
119 return; 125 return;
120 } 126 }
121 $scope.generando = true; 127 $scope.generando = true;
122 focaModalInformeProductividadService 128 focaModalInformeProductividadService
123 .getInformeData($scope.params) 129 .getInformeData($scope.params)
124 .then(function(res) { 130 .then(function(res) {
125 var result = []; 131 var result = [];
126 132
127 if ($scope.params.entidad.id === 1 || !$scope.params.entidad.id) { 133 if ($scope.params.entidad.id === 1 || !$scope.params.entidad.id) {
128 result.push({ 134 result.push({
129 cliente: 'Vendedores' 135 cliente: 'Vendedores'
130 }); 136 });
131 res.data.vendedores.forEach(function(vendedor) { 137 res.data.vendedores.forEach(function(vendedor) {
132 result.push({ 138 result.push({
133 cliente: 'Vendedor: ' + vendedor.NOM 139 cliente: 'Vendedor: ' + vendedor.NOM
134 }); 140 });
135 vendedor.notasPedido.forEach(function(notaPedido) { 141 vendedor.notasPedido.forEach(function(notaPedido) {
136 var seguimiento = notaPedido.seguimiento; 142 var seguimiento = notaPedido.seguimiento;
137 result.push({ 143 result.push({
138 cliente: notaPedido.cliente.NOM, 144 cliente: notaPedido.cliente.NOM,
139 fecha: seguimiento ? $filter('date')(seguimiento.fecha) : $filter('date')(notaPedido.fechaCarga), 145 fecha: seguimiento ? $filter('date')(seguimiento.fecha) : $filter('date')(notaPedido.fechaCarga),
140 kmRecorridos: seguimiento ? $filter('number')(seguimiento.kmRecorridos || 0, 2) : $filter('number')(0, 2), 146 kmRecorridos: seguimiento ? $filter('number')(seguimiento.kmRecorridos || 0, 2) : $filter('number')(0, 2),
141 geolocalizacion: seguimiento ? seguimiento.latitud + ', ' + seguimiento.longitud : '' 147 geolocalizacion: seguimiento ? seguimiento.latitud + ', ' + seguimiento.longitud : ''
142 }); 148 });
143 }); 149 });
144 }); 150 });
145 } 151 }
146 if ($scope.params.entidad.id === 2 || !$scope.params.entidad.id) { 152 if ($scope.params.entidad.id === 2 || !$scope.params.entidad.id) {
147 result.push({ 153 result.push({
148 cliente: 'Cobradores' 154 cliente: 'Cobradores'
149 }); 155 });
150 res.data.cobradores.forEach(function(cobrador) { 156 res.data.cobradores.forEach(function(cobrador) {
151 result.push({ 157 result.push({
152 cliente: 'Cobrador: ' + cobrador.NOM 158 cliente: 'Cobrador: ' + cobrador.NOM
153 }); 159 });
154 cobrador.cobranzas.forEach(function(cobranza) { 160 cobrador.cobranzas.forEach(function(cobranza) {
155 var seguimiento = cobranza.seguimiento; 161 var seguimiento = cobranza.seguimiento;
156 result.push({ 162 result.push({
157 cliente: cobranza.cliente.NOM, 163 cliente: cobranza.cliente.NOM,
158 fecha: seguimiento ? $filter('date')(seguimiento.fecha, 'dd/MM/yyyy') : $filter('date')(cobranza.FEC), 164 fecha: seguimiento ? $filter('date')(seguimiento.fecha, 'dd/MM/yyyy') : $filter('date')(cobranza.FEC),
159 kmRecorridos: seguimiento ? $filter('number')(seguimiento.kmRecorridos || 0, 2) : $filter('number')(0, 2), 165 kmRecorridos: seguimiento ? $filter('number')(seguimiento.kmRecorridos || 0, 2) : $filter('number')(0, 2),
160 geolocalizacion: seguimiento ? seguimiento.latitud + ', ' + seguimiento.longitud : '' 166 geolocalizacion: seguimiento ? seguimiento.latitud + ', ' + seguimiento.longitud : ''
161 }); 167 });
162 }); 168 });
163 }); 169 });
164 } 170 }
165 if ($scope.params.entidad.id === 3 || !$scope.params.entidad.id) { 171 if ($scope.params.entidad.id === 3 || !$scope.params.entidad.id) {
166 result.push({ 172 result.push({
167 cliente: 'Transportistas' 173 cliente: 'Transportistas'
168 }); 174 });
169 res.data.transportistas.forEach(function(transportista) { 175 res.data.transportistas.forEach(function(transportista) {
170 result.push({ 176 result.push({
171 cliente: 'Transportista: ' + transportista.NOM 177 cliente: 'Transportista: ' + transportista.NOM
172 }); 178 });
173 transportista.remitos.forEach(function(remito) { 179 transportista.remitos.forEach(function(remito) {
174 var kms = 0, 180 var kms = 0,
175 geolocalizacion; 181 geolocalizacion;
176 remito.hojaRutaMovimiento.forEach(function(movimiento) { 182 remito.hojaRutaMovimiento.forEach(function(movimiento) {
177 kms += movimiento.seguimiento.kmRecorridos || 0; 183 kms += movimiento.seguimiento.kmRecorridos || 0;
178 geolocalizacion = geolocalizacion || 184 geolocalizacion = geolocalizacion ||
179 movimiento.seguimiento.latitud + ', ' + 185 movimiento.seguimiento.latitud + ', ' +
180 movimiento.seguimiento.longitud; 186 movimiento.seguimiento.longitud;
181 }); 187 });
182 result.push({ 188 result.push({
183 cliente: remito.cliente.NOM, 189 cliente: remito.cliente.NOM,
184 fecha: $filter('date')(remito.fechaRemito, 'dd/MM/yyyy'), 190 fecha: $filter('date')(remito.fechaRemito, 'dd/MM/yyyy'),
185 kmRecorridos: $filter('number')(kms, 2), 191 kmRecorridos: $filter('number')(kms, 2),
186 geolocalizacion: geolocalizacion 192 geolocalizacion: geolocalizacion
187 }); 193 });
188 }); 194 });
189 }); 195 });
190 } 196 }
191 $scope.gridOptions.data = result; 197 $scope.gridOptions.data = result;
src/views/informe-productividad.html
1 <div class="modal-header py-1"> 1 <div class="modal-header py-1">
2 <div class="row w-100"> 2 <div class="row w-100">
3 <div class="col-12"><h5 class="modal-title">Informe de productividad</h5></div> 3 <div class="col-12"><h5 class="modal-title">Informe de productividad</h5></div>
4 <div class="col-12" ng-hide="buscar"> 4 <div class="col-12" ng-hide="buscar">
5 Filtros: Fecha desde: {{params.fechaDesde | date: 'dd/MM/yyyy'}}, 5 Filtros: Fecha desde: {{params.fechaDesde | date: 'dd/MM/yyyy'}},
6 Fecha hasta: {{params.fechaHasta | date: 'dd/MM/yyyy'}} 6 Fecha hasta: {{params.fechaHasta | date: 'dd/MM/yyyy'}}
7 <span ng-if="params.sector">, Sector: {{params.sector.NOMBRE}}</span> 7 <span ng-if="params.sector">, Sector: {{params.sector.NOMBRE}}</span>
8 <span ng-if="params.diferenciarProductos">, Productos diferenciados</span> 8 <span ng-if="params.diferenciarProductos">, Productos diferenciados</span>
9 <span ng-if="params.diferenciarMeses">, Meses diferenciados</span> 9 <span ng-if="params.diferenciarMeses">, Meses diferenciados</span>
10 </div> 10 </div>
11 </div> 11 </div>
12 </div> 12 </div>
13 <div class="modal-body" id="modal-body"> 13 <div class="modal-body" id="modal-body">
14 14
15 <div class="input-group row" 15 <div class="input-group row"
16 ng-show="buscar"> 16 ng-show="buscar">
17 <small class="col-md-2 col-4 text-left my-1">Fecha Desde</small> 17 <small class="col-md-2 col-4 text-left my-1">Fecha Desde</small>
18 <div class="col-md-4 col-8 input-group mb-3"> 18 <div class="col-md-4 col-8 input-group mb-3">
19 <div class="input-group-prepend"> 19 <div class="input-group-prepend">
20 <div class="input-group-text"> 20 <div class="input-group-text">
21 <i class="fa fa-calendar"></i> 21 <i class="fa fa-calendar"></i>
22 </div> 22 </div>
23 </div> 23 </div>
24 <input 24 <input
25 class="form-control form-control-sm" 25 class="form-control form-control-sm"
26 id="inlineFormInputGroup" 26 id="inlineFormInputGroup"
27 type="text" 27 type="text"
28 ng-model="params.fechaDesde" 28 ng-model="params.fechaDesde"
29 ng-required="true" 29 ng-required="true"
30 uib-datepicker-popup="dd/MM/yyyy" 30 uib-datepicker-popup="dd/MM/yyyy"
31 show-button-bar="false" 31 show-button-bar="false"
32 is-open="datepickerOpen" 32 is-open="datepickerOpen"
33 on-open-focus="false" 33 on-open-focus="false"
34 ng-focus="datepickerOpen = true" 34 ng-focus="datepickerOpen = true"
35 datepicker-options="dateOptions" 35 datepicker-options="dateOptions"
36 /> 36 />
37 </div> 37 </div>
38 <small class="col-md-2 col-4 text-left my-1">Fecha Hasta</small> 38 <small class="col-md-2 col-4 text-left my-1">Fecha Hasta</small>
39 <div class="col-md-4 col-8 input-group mb-3"> 39 <div class="col-md-4 col-8 input-group mb-3">
40 <div class="input-group-prepend"> 40 <div class="input-group-prepend">
41 <div class="input-group-text"> 41 <div class="input-group-text">
42 <i class="fa fa-calendar"></i> 42 <i class="fa fa-calendar"></i>
43 </div> 43 </div>
44 </div> 44 </div>
45 <input 45 <input
46 class="form-control form-control-sm" 46 class="form-control form-control-sm"
47 id="inlineFormInputGroup" 47 id="inlineFormInputGroup"
48 type="text" 48 type="text"
49 ng-model="params.fechaHasta" 49 ng-model="params.fechaHasta"
50 ng-required="true" 50 ng-required="true"
51 uib-datepicker-popup="dd/MM/yyyy" 51 uib-datepicker-popup="dd/MM/yyyy"
52 show-button-bar="false" 52 show-button-bar="false"
53 is-open="datepicker2Open" 53 is-open="datepicker2Open"
54 on-open-focus="false" 54 on-open-focus="false"
55 ng-focus="datepicker2Open = true" 55 ng-focus="datepicker2Open = true"
56 /> 56 />
57 </div> 57 </div>
58 <small class="col-md-2 col-4 text-left my-1">Entidad</small> 58 <small class="col-md-2 col-4 text-left my-1">Entidad</small>
59 <div class="col-md-4 col-8 input-group mb-2"> 59 <div class="col-md-4 col-8 input-group mb-3">
60 <input type="text" class="form-control" ng-model="params.entidad.label" readonly> 60 <input type="text" class="form-control form-control-sm" ng-model="params.entidad.label">
61 <button 61 <button
62 ng-show="params.entidad.label.length >= 1" 62 ng-show="params.entidad.label.length >= 1"
63 type="button" 63 type="button"
64 class="clear-input" 64 class="clear-input"
65 ng-click="clearEntidad()" 65 ng-click="clearEntidad()"
66 > 66 >
67 <i class="fa fa-times"></i> 67 <i class="fa fa-times"></i>
68 </button> 68 </button>
69 <div class="input-group-append"> 69 <div class="input-group-append">
70 <div class="input-group-append" ng-hide="ingreso"> 70 <div class="input-group-append" ng-hide="ingreso">
71 <button 71 <button
72 ladda="searchLoading" 72 ladda="searchLoading"
73 data-spinner-color="#FF0000" 73 data-spinner-color="#FF0000"
74 class="btn btn-outline-secondary" 74 class="btn btn-outline-secondary"
75 type="button" 75 type="button"
76 ng-click="seleccionarTipo()"> 76 ng-click="seleccionarTipo()">
77 <i class="fa fa-search" aria-hidden="true"></i> 77 <i class="fa fa-search" aria-hidden="true"></i>
78 </button> 78 </button>
79 </div> 79 </div>
80 </div> 80 </div>
81 </div> 81 </div>
82 </div> 82 </div>
83 <div 83 <div
84 ng-if="!buscar" 84 ng-if="!buscar"
85 class="row"> 85 class="row">
86 <div class="col-12"> 86 <div class="col-12">
87 <div 87 <div
88 class="gridInforme" 88 class="gridInforme"
89 ui-grid="gridOptions" 89 ui-grid="gridOptions"
90 ui-grid-exporter 90 ui-grid-exporter
91 ui-grid-resize-columns 91 ui-grid-resize-columns
92 ></div> 92 ></div>
93 </div> 93 </div>
94 </div> 94 </div>
95 </div> 95 </div>
96 <div class="modal-footer py-1"> 96 <div class="modal-footer py-1">
97 <button 97 <button
98 ladda="generando" 98 ladda="generando"
99 class="btn btn-sm btn-secondary" 99 class="btn btn-sm btn-secondary"
100 type="button" 100 type="button"
101 ng-click="generarInforme()" 101 ng-click="generarInforme()"
102 ng-show="buscar">Generar</button> 102 ng-show="buscar">Generar</button>
103 <button 103 <button
104 class="btn btn-sm btn-secondary" 104 class="btn btn-sm btn-secondary"
105 type="button" 105 type="button"
106 ng-click="cancel()" 106 ng-click="cancel()"
107 ng-show="buscar">Salir</button> 107 ng-show="buscar">Salir</button>
108 <button 108 <button
109 class="btn btn-sm btn-secondary" 109 class="btn btn-sm btn-secondary"
110 type="button" 110 type="button"
111 ng-click="volver()" 111 ng-click="volver()"
112 ng-hide="buscar">Volver</button> 112 ng-hide="buscar">Volver</button>
113 </div> 113 </div>
114 114