Commit 0cbd42e70089d5be02b527d372d6e5339d168bd6
1 parent
b4f51106eb
Exists in
master
and in
1 other branch
informe productividad - ok selector entidad
Showing
2 changed files
with
48 additions
and
18 deletions
Show diff stats
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 | }; | 24 | }; |
25 | $scope.gridOptions = { | 25 | $scope.gridOptions = { |
26 | enableGridMenu: true, | 26 | enableGridMenu: true, |
27 | exporterMenuCsv: false, | 27 | exporterMenuCsv: false, |
28 | exporterPdfPageSize: 'A4', | 28 | exporterPdfPageSize: 'A4', |
29 | exporterPdfFooter: function (currentPage, pageCount) { | 29 | exporterPdfFooter: function (currentPage, pageCount) { |
30 | return { | 30 | return { |
31 | columns: [ | 31 | columns: [ |
32 | {text: $filter('date')(new Date(), 'dd/MM/yyyy'), | 32 | {text: $filter('date')(new Date(), 'dd/MM/yyyy'), |
33 | margin: [40, 0]}, | 33 | margin: [40, 0]}, |
34 | {text: currentPage + ' de ' + pageCount, | 34 | {text: currentPage + ' de ' + pageCount, |
35 | margin: [28, 0], alignment: 'right'} | 35 | margin: [28, 0], alignment: 'right'} |
36 | ] | 36 | ] |
37 | }; | 37 | }; |
38 | }, | 38 | }, |
39 | columnDefs: [ | 39 | columnDefs: [ |
40 | { | 40 | { |
41 | field: 'cliente', | 41 | field: 'cliente', |
42 | enableSorting: false, | 42 | enableSorting: false, |
43 | cellClass: function(grid, row, col) { | 43 | cellClass: function(grid, row, col) { |
44 | var value = grid.getCellValue(row,col); | 44 | var value = grid.getCellValue(row,col); |
45 | 45 | ||
46 | if (value.indexOf('Vendedores') !== -1 || | 46 | if (value.indexOf('Vendedores') !== -1 || |
47 | value.indexOf('Cobradores') !== -1 || | 47 | value.indexOf('Cobradores') !== -1 || |
48 | value.indexOf('Transportistas') !== -1) | 48 | value.indexOf('Transportistas') !== -1) |
49 | return 'yellow w-100'; | 49 | return 'yellow w-100'; |
50 | if (value.indexOf('Vendedor:') !== -1 || | 50 | if (value.indexOf('Vendedor:') !== -1 || |
51 | value.indexOf('Cobrador:') !== -1 || | 51 | value.indexOf('Cobrador:') !== -1 || |
52 | value.indexOf('Transportista:') !== -1) | 52 | value.indexOf('Transportista:') !== -1) |
53 | return 'red w-100'; | 53 | return 'red w-100'; |
54 | if (value.indexOf('Fecha:') !== -1) | 54 | if (value.indexOf('Fecha:') !== -1) |
55 | return 'green w-100'; | 55 | return 'green w-100'; |
56 | } | 56 | } |
57 | }, | 57 | }, |
58 | { | 58 | { |
59 | field: 'fecha', | 59 | field: 'fecha', |
60 | enableSorting: false, | 60 | enableSorting: false, |
61 | cellClass: function(grid, row, col) { | 61 | cellClass: function(grid, row, col) { |
62 | if (!grid.getCellValue(row,col)) | 62 | if (!grid.getCellValue(row,col)) |
63 | return 'd-none'; | 63 | return 'd-none'; |
64 | } | 64 | } |
65 | }, | 65 | }, |
66 | { | 66 | { |
67 | field: 'kmRecorridos', | 67 | field: 'kmRecorridos', |
68 | enableSorting: false, | 68 | enableSorting: false, |
69 | cellClass: function(grid, row, col) { | 69 | cellClass: function(grid, row, col) { |
70 | if (!grid.getCellValue(row,col)) | 70 | if (!grid.getCellValue(row,col)) |
71 | return 'd-none'; | 71 | return 'd-none'; |
72 | } | 72 | } |
73 | }, | 73 | }, |
74 | { | 74 | { |
75 | field: 'geolocalizacion', | 75 | field: 'geolocalizacion', |
76 | enableSorting: false, | 76 | enableSorting: false, |
77 | cellClass: function(grid, row, col) { | 77 | cellClass: function(grid, row, col) { |
78 | if (!grid.getCellValue(row,col)) | 78 | if (!grid.getCellValue(row,col)) |
79 | return 'd-none'; | 79 | return 'd-none'; |
80 | } | 80 | } |
81 | } | 81 | } |
82 | ] | 82 | ] |
83 | }; | 83 | }; |
84 | $scope.seleccionarTipo = function() { | ||
85 | var data = [ | ||
86 | { | ||
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: [ | ||
107 | { | ||
108 | propiedad: 'label', | ||
109 | nombre: 'Entidad' | ||
110 | } | ||
111 | ], | ||
112 | }).then(function(res) { | ||
113 | $scope.params.entidad = res; | ||
114 | }); | ||
115 | }; | ||
84 | $scope.generarInforme = function() { | 116 | $scope.generarInforme = function() { |
85 | //$scope.generando = true; | 117 | if (!$scope.params.entidad) { |
118 | focaModalService.alert('Seleccione una entidad'); | ||
119 | return; | ||
120 | } | ||
121 | $scope.generando = true; | ||
86 | focaModalInformeProductividadService | 122 | focaModalInformeProductividadService |
87 | .getInformeData($scope.params) | 123 | .getInformeData($scope.params) |
88 | .then(function(res) { | 124 | .then(function(res) { |
89 | var result = []; | 125 | var result = []; |
90 | console.log(res); | 126 | |
91 | if (true) { | 127 | if ($scope.params.entidad.id === 1 || !$scope.params.entidad.id) { |
92 | result.push({ | 128 | result.push({ |
93 | cliente: 'Vendedores' | 129 | cliente: 'Vendedores' |
94 | }); | 130 | }); |
95 | res.data.vendedores.forEach(function(vendedor) { | 131 | res.data.vendedores.forEach(function(vendedor) { |
96 | result.push({ | 132 | result.push({ |
97 | cliente: 'Vendedor: ' + vendedor.NOM | 133 | cliente: 'Vendedor: ' + vendedor.NOM |
98 | }); | 134 | }); |
99 | vendedor.notasPedido.forEach(function(notaPedido) { | 135 | vendedor.notasPedido.forEach(function(notaPedido) { |
100 | var seguimiento = notaPedido.seguimiento; | 136 | var seguimiento = notaPedido.seguimiento; |
101 | result.push({ | 137 | result.push({ |
102 | cliente: notaPedido.cliente.NOM, | 138 | cliente: notaPedido.cliente.NOM, |
103 | fecha: seguimiento ? $filter('date')(seguimiento.fecha) : $filter('date')(notaPedido.fechaCarga), | 139 | fecha: seguimiento ? $filter('date')(seguimiento.fecha) : $filter('date')(notaPedido.fechaCarga), |
104 | kmRecorridos: seguimiento ? $filter('number')(seguimiento.kmRecorridos || 0, 2) : $filter('number')(0, 2), | 140 | kmRecorridos: seguimiento ? $filter('number')(seguimiento.kmRecorridos || 0, 2) : $filter('number')(0, 2), |
105 | geolocalizacion: seguimiento ? seguimiento.latitud + ', ' + seguimiento.longitud : '' | 141 | geolocalizacion: seguimiento ? seguimiento.latitud + ', ' + seguimiento.longitud : '' |
106 | }); | 142 | }); |
107 | }); | 143 | }); |
108 | }); | 144 | }); |
109 | } | 145 | } |
110 | if (true) { | 146 | if ($scope.params.entidad.id === 2 || !$scope.params.entidad.id) { |
111 | result.push({ | 147 | result.push({ |
112 | cliente: 'Cobradores' | 148 | cliente: 'Cobradores' |
113 | }); | 149 | }); |
114 | res.data.cobradores.forEach(function(cobrador) { | 150 | res.data.cobradores.forEach(function(cobrador) { |
115 | result.push({ | 151 | result.push({ |
116 | cliente: 'Cobrador: ' + cobrador.NOM | 152 | cliente: 'Cobrador: ' + cobrador.NOM |
117 | }); | 153 | }); |
118 | cobrador.cobranzas.forEach(function(cobranza) { | 154 | cobrador.cobranzas.forEach(function(cobranza) { |
119 | var seguimiento = cobranza.seguimiento; | 155 | var seguimiento = cobranza.seguimiento; |
120 | result.push({ | 156 | result.push({ |
121 | cliente: cobranza.cliente.NOM, | 157 | cliente: cobranza.cliente.NOM, |
122 | fecha: seguimiento ? $filter('date')(seguimiento.fecha, 'dd/MM/yyyy') : $filter('date')(cobranza.FEC), | 158 | fecha: seguimiento ? $filter('date')(seguimiento.fecha, 'dd/MM/yyyy') : $filter('date')(cobranza.FEC), |
123 | kmRecorridos: seguimiento ? $filter('number')(seguimiento.kmRecorridos || 0, 2) : $filter('number')(0, 2), | 159 | kmRecorridos: seguimiento ? $filter('number')(seguimiento.kmRecorridos || 0, 2) : $filter('number')(0, 2), |
124 | geolocalizacion: seguimiento ? seguimiento.latitud + ', ' + seguimiento.longitud : '' | 160 | geolocalizacion: seguimiento ? seguimiento.latitud + ', ' + seguimiento.longitud : '' |
125 | }); | 161 | }); |
126 | }); | 162 | }); |
127 | }); | 163 | }); |
128 | } | 164 | } |
129 | if (true) { | 165 | if ($scope.params.entidad.id === 3 || !$scope.params.entidad.id) { |
130 | result.push({ | 166 | result.push({ |
131 | cliente: 'Transportistas' | 167 | cliente: 'Transportistas' |
132 | }); | 168 | }); |
133 | res.data.transportistas.forEach(function(transportista) { | 169 | res.data.transportistas.forEach(function(transportista) { |
134 | result.push({ | 170 | result.push({ |
135 | cliente: 'Transportista: ' + transportista.NOM | 171 | cliente: 'Transportista: ' + transportista.NOM |
136 | }); | 172 | }); |
137 | transportista.remitos.forEach(function(remito) { | 173 | transportista.remitos.forEach(function(remito) { |
138 | var kms = 0, | 174 | var kms = 0, |
139 | geolocalizacion; | 175 | geolocalizacion; |
140 | remito.hojaRutaMovimiento.forEach(function(movimiento) { | 176 | remito.hojaRutaMovimiento.forEach(function(movimiento) { |
141 | kms += movimiento.seguimiento.kmRecorridos || 0; | 177 | kms += movimiento.seguimiento.kmRecorridos || 0; |
142 | geolocalizacion = geolocalizacion || | 178 | geolocalizacion = geolocalizacion || |
143 | movimiento.seguimiento.latitud + ', ' + | 179 | movimiento.seguimiento.latitud + ', ' + |
144 | movimiento.seguimiento.longitud; | 180 | movimiento.seguimiento.longitud; |
145 | }); | 181 | }); |
146 | result.push({ | 182 | result.push({ |
147 | cliente: remito.cliente.NOM, | 183 | cliente: remito.cliente.NOM, |
148 | fecha: $filter('date')(remito.fechaRemito, 'dd/MM/yyyy'), | 184 | fecha: $filter('date')(remito.fechaRemito, 'dd/MM/yyyy'), |
149 | kmRecorridos: $filter('number')(kms, 2), | 185 | kmRecorridos: $filter('number')(kms, 2), |
150 | geolocalizacion: geolocalizacion | 186 | geolocalizacion: geolocalizacion |
151 | }); | 187 | }); |
152 | }); | 188 | }); |
153 | }); | 189 | }); |
154 | } | 190 | } |
155 | $scope.gridOptions.data = result; | 191 | $scope.gridOptions.data = result; |
156 | $scope.generando = false; | 192 | $scope.generando = false; |
157 | $scope.buscar = false; | 193 | $scope.buscar = false; |
158 | }); | 194 | }); |
159 | }; | 195 | }; |
160 | 196 | ||
161 | 197 | ||
162 | $scope.volver = function() { | 198 | $scope.volver = function() { |
163 | $scope.buscar = true; | 199 | $scope.buscar = true; |
164 | }; | 200 | }; |
165 | $scope.cancel = function() { | 201 | $scope.cancel = function() { |
166 | $uibModalInstance.dismiss('Cancelar'); | 202 | $uibModalInstance.dismiss('Cancelar'); |
167 | }; | 203 | }; |
168 | $scope.clearSector = function() { | 204 | $scope.clearEntidad = function() { |
169 | $scope.params.sector = undefined; | 205 | $scope.params.entidad = undefined; |
170 | }; | 206 | }; |
171 | 207 | ||
172 | |||
173 | } | 208 | } |
174 | ] | 209 | ] |
175 | ); | 210 | ); |
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-2"> | 18 | <div class="col-md-4 col-8 input-group mb-2"> |
19 | <div class="input-group-prepend"> | 19 | <div class="input-group-prepend"> |
20 | <div class="input-group-text form-control-sm"> | 20 | <div class="input-group-text form-control-sm"> |
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-2"> | 39 | <div class="col-md-4 col-8 input-group mb-2"> |
40 | <div class="input-group-prepend"> | 40 | <div class="input-group-prepend"> |
41 | <div class="input-group-text form-control-sm"> | 41 | <div class="input-group-text form-control-sm"> |
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-2"> |
60 | <select class="form-control"> | 60 | <input type="text" class="form-control" ng-model="params.entidad.label" readonly> |
61 | <option value="0">Todos</option> | 61 | <button type="button" class="clear-input text-danger" ng-click="clearEntidad()"> |
62 | <option value="1">Vendedores</option> | ||
63 | <option value="2">Cobradores</option> | ||
64 | <option value="3">Transportistas</option> | ||
65 | </select> | ||
66 | <button type="button" class="clear-input text-danger" ng-click="clearSector()"> | ||
67 | <i class="fa fa-times"></i> | 62 | <i class="fa fa-times"></i> |
68 | </button> | 63 | </button> |
69 | <!-- <div class="input-group-append"> | 64 | <div class="input-group-append"> |
70 | <div class="input-group-append" ng-hide="ingreso"> | 65 | <div class="input-group-append" ng-hide="ingreso"> |
71 | <button | 66 | <button |
72 | ladda="searchLoading" | 67 | ladda="searchLoading" |
73 | data-spinner-color="#FF0000" | 68 | data-spinner-color="#FF0000" |
74 | class="btn btn-outline-secondary" | 69 | class="btn btn-outline-secondary" |
75 | type="button" | 70 | type="button" |
76 | ng-click="seleccionarSector(13)"> | 71 | ng-click="seleccionarTipo()"> |
77 | <i class="fa fa-search" aria-hidden="true"></i> | 72 | <i class="fa fa-search" aria-hidden="true"></i> |
78 | </button> | 73 | </button> |
79 | </div> | 74 | </div> |
80 | </div> --> | 75 | </div> |
81 | </div> | 76 | </div> |
82 | </div> | 77 | </div> |
83 | <div | 78 | <div |
84 | ng-if="!buscar" | 79 | ng-if="!buscar" |
85 | class="row"> | 80 | class="row"> |
86 | <div class="col-12"> | 81 | <div class="col-12"> |
87 | <div | 82 | <div |
88 | class="gridInforme" | 83 | class="gridInforme" |
89 | ui-grid="gridOptions" | 84 | ui-grid="gridOptions" |
90 | ui-grid-exporter | 85 | ui-grid-exporter |
91 | ui-grid-resize-columns | 86 | ui-grid-resize-columns |
92 | ></div> | 87 | ></div> |
93 | </div> | 88 | </div> |
94 | </div> | 89 | </div> |
95 | </div> | 90 | </div> |
96 | <div class="modal-footer py-1"> | 91 | <div class="modal-footer py-1"> |
97 | <button | 92 | <button |
98 | ladda="generando" | 93 | ladda="generando" |
99 | class="btn btn-sm btn-secondary" | 94 | class="btn btn-sm btn-secondary" |
100 | type="button" | 95 | type="button" |
101 | ng-click="generarInforme()" | 96 | ng-click="generarInforme()" |
102 | ng-show="buscar">Generar</button> | 97 | ng-show="buscar">Generar</button> |
103 | <button | 98 | <button |
104 | class="btn btn-sm btn-secondary" | 99 | class="btn btn-sm btn-secondary" |
105 | type="button" | 100 | type="button" |
106 | ng-click="cancel()" | 101 | ng-click="cancel()" |
107 | ng-show="buscar">Salir</button> | 102 | ng-show="buscar">Salir</button> |
108 | <button | 103 | <button |
109 | class="btn btn-sm btn-secondary" | 104 | class="btn btn-sm btn-secondary" |
110 | type="button" | 105 | type="button" |
111 | ng-click="volver()" | 106 | ng-click="volver()" |
112 | ng-hide="buscar">Volver</button> | 107 | ng-hide="buscar">Volver</button> |
113 | </div> | 108 | </div> |
114 | 109 |