Commit 901fea4ec24b5a2ef420a67543747f3911ae29e9
1 parent
be4dfba45b
Exists in
master
Filtrar busqueda por codigo - Cruz para eliminar los datos ingresados
Showing
2 changed files
with
12 additions
and
1 deletions
Show diff stats
src/js/controller-litros-km-unidad.js
1 | angular.module('focaModalInforme') | 1 | angular.module('focaModalInforme') |
2 | .controller('focaModalInformeLitrosKmUnidadController', | 2 | .controller('focaModalInformeLitrosKmUnidadController', |
3 | [ | 3 | [ |
4 | '$filter', | 4 | '$filter', |
5 | '$scope', | 5 | '$scope', |
6 | '$uibModalInstance', | 6 | '$uibModalInstance', |
7 | 'focaModalInformeLitrosKmUnidadService', | 7 | 'focaModalInformeLitrosKmUnidadService', |
8 | 'i18nService', | 8 | 'i18nService', |
9 | 'focaModalService', | 9 | 'focaModalService', |
10 | '$uibModal', | 10 | '$uibModal', |
11 | function($filter, $scope, $uibModalInstance, focaModalInformeLitrosKmUnidadService, | 11 | function($filter, $scope, $uibModalInstance, focaModalInformeLitrosKmUnidadService, |
12 | i18nService, focaModalService, $uibModal | 12 | i18nService, focaModalService, $uibModal |
13 | ) { | 13 | ) { |
14 | var meses = ['ene', 'feb', 'mar', 'abr', 'may', 'jun', | 14 | var meses = ['ene', 'feb', 'mar', 'abr', 'may', 'jun', |
15 | 'jul', 'ago', 'sep', 'oct', 'nov', 'dic']; | 15 | 'jul', 'ago', 'sep', 'oct', 'nov', 'dic']; |
16 | var fecha = new Date(); | 16 | var fecha = new Date(); |
17 | $scope.generando = false; | 17 | $scope.generando = false; |
18 | $scope.fechaHasta = new Date(); | 18 | $scope.fechaHasta = new Date(); |
19 | $scope.fechaDesde = new Date(fecha.setMonth(fecha.getMonth() - 1)); | 19 | $scope.fechaDesde = new Date(fecha.setMonth(fecha.getMonth() - 1)); |
20 | $scope.buscar = true; | 20 | $scope.buscar = true; |
21 | $scope.unidad = { | ||
22 | codigo: '' | ||
23 | }; | ||
21 | $scope.informe = {}; | 24 | $scope.informe = {}; |
22 | i18nService.setCurrentLang('es'); | 25 | i18nService.setCurrentLang('es'); |
23 | $scope.gridOptions = { | 26 | $scope.gridOptions = { |
24 | enableGridMenu: true, | 27 | enableGridMenu: true, |
25 | exporterMenuCsv: false, | 28 | exporterMenuCsv: false, |
26 | exporterPdfPageSize: 'A4', | 29 | exporterPdfPageSize: 'A4', |
27 | exporterPdfFooter: function (currentPage, pageCount) { | 30 | exporterPdfFooter: function (currentPage, pageCount) { |
28 | return { | 31 | return { |
29 | columns: [ | 32 | columns: [ |
30 | {text: $filter('date')(new Date(), 'dd/MM/yyyy'), | 33 | {text: $filter('date')(new Date(), 'dd/MM/yyyy'), |
31 | margin: [40, 0]}, | 34 | margin: [40, 0]}, |
32 | {text: currentPage + ' de ' + pageCount, | 35 | {text: currentPage + ' de ' + pageCount, |
33 | margin: [28, 0], alignment: 'right'} | 36 | margin: [28, 0], alignment: 'right'} |
34 | ] | 37 | ] |
35 | }; | 38 | }; |
36 | }, | 39 | }, |
37 | columnDefs: [ | 40 | columnDefs: [ |
38 | { | 41 | { |
39 | field: 'fecha', | 42 | field: 'fecha', |
40 | enableSorting: false, | 43 | enableSorting: false, |
41 | cellClass: function(grid, row, col, rowRenderIndex, colRenderIndex) { | 44 | cellClass: function(grid, row, col, rowRenderIndex, colRenderIndex) { |
42 | if (grid.getCellValue(row,col).indexOf('Sector:') !== -1) | 45 | if (grid.getCellValue(row,col).indexOf('Sector:') !== -1) |
43 | return 'yellow w-100'; | 46 | return 'yellow w-100'; |
44 | if (grid.getCellValue(row,col).indexOf('Producto:') !== -1) | 47 | if (grid.getCellValue(row,col).indexOf('Producto:') !== -1) |
45 | return 'red w-100'; | 48 | return 'red w-100'; |
46 | } | 49 | } |
47 | }, | 50 | }, |
48 | { | 51 | { |
49 | field: 'litrosRepartidos', | 52 | field: 'litrosRepartidos', |
50 | enableSorting: false, | 53 | enableSorting: false, |
51 | cellClass: function(grid, row, col, rowRenderIndex, colRenderIndex) { | 54 | cellClass: function(grid, row, col, rowRenderIndex, colRenderIndex) { |
52 | if (!grid.getCellValue(row,col)) | 55 | if (!grid.getCellValue(row,col)) |
53 | return 'd-none'; | 56 | return 'd-none'; |
54 | } | 57 | } |
55 | }, | 58 | }, |
56 | { | 59 | { |
57 | field: 'kmRecorridos', | 60 | field: 'kmRecorridos', |
58 | enableSorting: false, | 61 | enableSorting: false, |
59 | cellClass: function(grid, row, col, rowRenderIndex, colRenderIndex) { | 62 | cellClass: function(grid, row, col, rowRenderIndex, colRenderIndex) { |
60 | if (!grid.getCellValue(row,col)) | 63 | if (!grid.getCellValue(row,col)) |
61 | return 'd-none'; | 64 | return 'd-none'; |
62 | } | 65 | } |
63 | }, | 66 | }, |
64 | { | 67 | { |
65 | field: 'lts/Km', | 68 | field: 'lts/Km', |
66 | enableSorting: false, | 69 | enableSorting: false, |
67 | cellClass: function(grid, row, col, rowRenderIndex, colRenderIndex) { | 70 | cellClass: function(grid, row, col, rowRenderIndex, colRenderIndex) { |
68 | if (!grid.getCellValue(row,col)) | 71 | if (!grid.getCellValue(row,col)) |
69 | return 'd-none'; | 72 | return 'd-none'; |
70 | } | 73 | } |
71 | } | 74 | } |
72 | ] | 75 | ] |
73 | 76 | ||
74 | }; | 77 | }; |
75 | $scope.generarInforme = function() { | 78 | $scope.generarInforme = function() { |
76 | if(!$scope.unidad){ | 79 | if(!$scope.unidad){ |
77 | focaModalService.alert('Primero seleccione una unidad'); | 80 | focaModalService.alert('Primero seleccione una unidad'); |
78 | return; | 81 | return; |
79 | } | 82 | } |
80 | $scope.generando = true; | 83 | $scope.generando = true; |
81 | focaModalInformeLitrosKmUnidadService | 84 | focaModalInformeLitrosKmUnidadService |
82 | .getDescargas( | 85 | .getDescargas( |
83 | $scope.unidad.id, | 86 | $scope.unidad.id, |
84 | $scope.fechaDesde.toISOString().split('.')[0], | 87 | $scope.fechaDesde.toISOString().split('.')[0], |
85 | $scope.fechaHasta.toISOString().split('.')[0] | 88 | $scope.fechaHasta.toISOString().split('.')[0] |
86 | ) | 89 | ) |
87 | .then(function(res) { | 90 | .then(function(res) { |
88 | var result = []; | 91 | var result = []; |
89 | res.data.forEach(function(sector) { | 92 | res.data.forEach(function(sector) { |
90 | result.push({ | 93 | result.push({ |
91 | fecha: 'Sector: ' + | 94 | fecha: 'Sector: ' + |
92 | $filter('rellenarDigitos')(sector[0].articulo.CodSec, 2, '0') + | 95 | $filter('rellenarDigitos')(sector[0].articulo.CodSec, 2, '0') + |
93 | ' - ' + sector[0].articulo.sector.NOMBRE.trim() | 96 | ' - ' + sector[0].articulo.sector.NOMBRE.trim() |
94 | }); | 97 | }); |
95 | sector.forEach(function(cisternaCarga) { | 98 | sector.forEach(function(cisternaCarga) { |
96 | result.push({ | 99 | result.push({ |
97 | fecha: 'Producto: ' + | 100 | fecha: 'Producto: ' + |
98 | cisternaCarga.articulo.CodArt + | 101 | cisternaCarga.articulo.CodArt + |
99 | ' - ' + cisternaCarga.articulo.DetArt | 102 | ' - ' + cisternaCarga.articulo.DetArt |
100 | }); | 103 | }); |
101 | cisternaCarga.cisternaMovimientos.forEach(function(cisternaMovimiento) { | 104 | cisternaCarga.cisternaMovimientos.forEach(function(cisternaMovimiento) { |
102 | var lts = cisternaMovimiento.lts; | 105 | var lts = cisternaMovimiento.lts; |
103 | var kms = cisternaMovimiento.kms; | 106 | var kms = cisternaMovimiento.kms; |
104 | 107 | ||
105 | result.push({ | 108 | result.push({ |
106 | fecha: meses[cisternaMovimiento.month] + ' - ' + cisternaMovimiento.year, | 109 | fecha: meses[cisternaMovimiento.month] + ' - ' + cisternaMovimiento.year, |
107 | litrosRepartidos: $filter('number')(lts, 2), | 110 | litrosRepartidos: $filter('number')(lts, 2), |
108 | kmRecorridos: $filter('number')(kms, 2), | 111 | kmRecorridos: $filter('number')(kms, 2), |
109 | 'lts/Km': (kms) ? $filter('number')(lts / kms, 2) : lts | 112 | 'lts/Km': (kms) ? $filter('number')(lts / kms, 2) : lts |
110 | }); | 113 | }); |
111 | }); | 114 | }); |
112 | }); | 115 | }); |
113 | }); | 116 | }); |
114 | $scope.gridOptions.data = result; | 117 | $scope.gridOptions.data = result; |
115 | $scope.generando = false; | 118 | $scope.generando = false; |
116 | $scope.buscar = false; | 119 | $scope.buscar = false; |
117 | }); | 120 | }); |
118 | }; | 121 | }; |
119 | $scope.seleccionarTransportista = function() { | 122 | $scope.seleccionarTransportista = function() { |
120 | var parametrosModal = { | 123 | var parametrosModal = { |
121 | titulo: 'Búsqueda de Transportista', | 124 | titulo: 'Búsqueda de Transportista', |
122 | query: '/transportista', | 125 | query: '/transportista', |
123 | columnas: [ | 126 | columnas: [ |
124 | { | 127 | { |
125 | propiedad: 'COD', | 128 | propiedad: 'COD', |
126 | nombre: 'Código', | 129 | nombre: 'Código', |
127 | filtro: { | 130 | filtro: { |
128 | nombre: 'rellenarDigitos', | 131 | nombre: 'rellenarDigitos', |
129 | parametro: 5 | 132 | parametro: 5 |
130 | } | 133 | } |
131 | }, | 134 | }, |
132 | { | 135 | { |
133 | propiedad: 'NOM', | 136 | propiedad: 'NOM', |
134 | nombre: 'Nombre' | 137 | nombre: 'Nombre' |
135 | }, | 138 | }, |
136 | { | 139 | { |
137 | propiedad: 'CUIT', | 140 | propiedad: 'CUIT', |
138 | nombre: 'CUIT' | 141 | nombre: 'CUIT' |
139 | } | 142 | } |
140 | ], | 143 | ], |
141 | size: 'md' | 144 | size: 'md' |
142 | }; | 145 | }; |
143 | return focaModalService.modal(parametrosModal) | 146 | return focaModalService.modal(parametrosModal) |
144 | }; | 147 | }; |
145 | 148 | ||
146 | $scope.seleccionarUnidad = function(key) { | 149 | $scope.seleccionarUnidad = function(key) { |
147 | if (key === 13) { | 150 | if (key === 13) { |
148 | $scope.seleccionarTransportista().then( | 151 | $scope.seleccionarTransportista().then( |
149 | function(transportista) { | 152 | function(transportista) { |
150 | $scope.transportista = transportista; | 153 | $scope.transportista = transportista; |
151 | var parametrosModal = { | 154 | var parametrosModal = { |
152 | titulo: 'Búsqueda de vehículos', | 155 | titulo: 'Búsqueda de vehículos', |
153 | searchText: $scope.unidad.codigo, | 156 | searchText: $scope.unidad.codigo, |
154 | query: '/vehiculo/transportista/' + transportista.COD, | 157 | query: '/vehiculo/transportista/' + transportista.COD, |
155 | columnas: [ | 158 | columnas: [ |
156 | { | 159 | { |
157 | propiedad: 'codigo', | 160 | propiedad: 'codigo', |
158 | nombre: 'Código' | 161 | nombre: 'Código' |
159 | }, | 162 | }, |
160 | { | 163 | { |
161 | propiedad: 'tractor', | 164 | propiedad: 'tractor', |
162 | nombre: 'Tractor' | 165 | nombre: 'Tractor' |
163 | }, | 166 | }, |
164 | { | 167 | { |
165 | propiedad: 'semi', | 168 | propiedad: 'semi', |
166 | nombre: 'Semi' | 169 | nombre: 'Semi' |
167 | }, | 170 | }, |
168 | { | 171 | { |
169 | propiedad: 'tractor', | 172 | propiedad: 'tractor', |
170 | nombre: 'Tractor' | 173 | nombre: 'Tractor' |
171 | } | 174 | } |
172 | ], | 175 | ], |
173 | size: 'md' | 176 | size: 'md' |
174 | }; | 177 | }; |
175 | focaModalService.modal(parametrosModal).then( | 178 | focaModalService.modal(parametrosModal).then( |
176 | function(unidad) { | 179 | function(unidad) { |
177 | $scope.unidad = unidad; | 180 | $scope.unidad = unidad; |
178 | }, function() { | 181 | }, function() { |
179 | $scope.seleccionarUnidad(); | 182 | $scope.seleccionarUnidad(); |
180 | }); | 183 | }); |
181 | }); | 184 | }); |
182 | } | 185 | } |
183 | }; | 186 | }; |
184 | $scope.volver = function() { | 187 | $scope.volver = function() { |
185 | $scope.buscar = true; | 188 | $scope.buscar = true; |
186 | }; | 189 | }; |
187 | $scope.cancel = function() { | 190 | $scope.cancel = function() { |
188 | $uibModalInstance.dismiss('Cancelar'); | 191 | $uibModalInstance.dismiss('Cancelar'); |
189 | }; | 192 | }; |
190 | } | 193 | } |
191 | ] | 194 | ] |
192 | ); | 195 | ); |
193 | 196 |
src/views/informe-litros-km-unidad.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 litros por km recorrido por unidad de reparto</h5></div> | 3 | <div class="col-12"><h5 class="modal-title">Informe de litros por km recorrido por unidad de reparto</h5></div> |
4 | <div class="col-12" ng-hide="buscar"> | 4 | <div class="col-12" ng-hide="buscar"> |
5 | Filtros: Fecha desde: {{fechaDesde | date: 'dd/MM/yyyy'}}, | 5 | Filtros: Fecha desde: {{fechaDesde | date: 'dd/MM/yyyy'}}, |
6 | Fecha hasta: {{fechaHasta | date: 'dd/MM/yyyy'}}, | 6 | Fecha hasta: {{fechaHasta | date: 'dd/MM/yyyy'}}, |
7 | Transportista : {{transportista.NOM}}, | 7 | Transportista : {{transportista.NOM}}, |
8 | Unidad: {{unidad.codigo}} | 8 | Unidad: {{unidad.codigo}} |
9 | </div> | 9 | </div> |
10 | </div> | 10 | </div> |
11 | </div> | 11 | </div> |
12 | <div class="modal-body" id="modal-body"> | 12 | <div class="modal-body" id="modal-body"> |
13 | <div class="input-group row" | 13 | <div class="input-group row" |
14 | ng-show="buscar"> | 14 | ng-show="buscar"> |
15 | <small class="col-md-2 col-4 text-left my-1">Fecha Desde</small> | 15 | <small class="col-md-2 col-4 text-left my-1">Fecha Desde</small> |
16 | <div class="col-md-4 col-8 input-group mb-3"> | 16 | <div class="col-md-4 col-8 input-group mb-3"> |
17 | <div class="input-group-prepend"> | 17 | <div class="input-group-prepend"> |
18 | <button | 18 | <button |
19 | class="input-group-text" | 19 | class="input-group-text" |
20 | type="button" | 20 | type="button" |
21 | ng-click="datepickerOpen = true" | 21 | ng-click="datepickerOpen = true" |
22 | > | 22 | > |
23 | <i class="fa fa-calendar"></i> | 23 | <i class="fa fa-calendar"></i> |
24 | </button> | 24 | </button> |
25 | </div> | 25 | </div> |
26 | <input | 26 | <input |
27 | class="form-control form-control-sm" | 27 | class="form-control form-control-sm" |
28 | id="inlineFormInputGroup" | 28 | id="inlineFormInputGroup" |
29 | type="text" | 29 | type="text" |
30 | ng-model="fechaDesde" | 30 | ng-model="fechaDesde" |
31 | ng-required="true" | 31 | ng-required="true" |
32 | uib-datepicker-popup="dd/MM/yyyy" | 32 | uib-datepicker-popup="dd/MM/yyyy" |
33 | show-button-bar="false" | 33 | show-button-bar="false" |
34 | is-open="datepickerOpen" | 34 | is-open="datepickerOpen" |
35 | on-open-focus="false" | 35 | on-open-focus="false" |
36 | ng-focus="datepickerOpen = true" | 36 | ng-focus="datepickerOpen = true" |
37 | datepicker-options="dateOptions" | 37 | datepicker-options="dateOptions" |
38 | /> | 38 | /> |
39 | </div> | 39 | </div> |
40 | <small class="col-md-2 col-4 text-left my-1">Fecha Hasta</small> | 40 | <small class="col-md-2 col-4 text-left my-1">Fecha Hasta</small> |
41 | <div class="col-md-4 col-8 input-group mb-3"> | 41 | <div class="col-md-4 col-8 input-group mb-3"> |
42 | <div class="input-group-prepend"> | 42 | <div class="input-group-prepend"> |
43 | <button | 43 | <button |
44 | class="input-group-text" | 44 | class="input-group-text" |
45 | type="button" | 45 | type="button" |
46 | ng-click="datepicker2Open = true" | 46 | ng-click="datepicker2Open = true" |
47 | > | 47 | > |
48 | <i class="fa fa-calendar"></i> | 48 | <i class="fa fa-calendar"></i> |
49 | </button> | 49 | </button> |
50 | </div> | 50 | </div> |
51 | <input | 51 | <input |
52 | class="form-control form-control-sm" | 52 | class="form-control form-control-sm" |
53 | id="inlineFormInputGroup" | 53 | id="inlineFormInputGroup" |
54 | type="text" | 54 | type="text" |
55 | ng-model="fechaHasta" | 55 | ng-model="fechaHasta" |
56 | ng-required="true" | 56 | ng-required="true" |
57 | uib-datepicker-popup="dd/MM/yyyy" | 57 | uib-datepicker-popup="dd/MM/yyyy" |
58 | show-button-bar="false" | 58 | show-button-bar="false" |
59 | is-open="datepicker2Open" | 59 | is-open="datepicker2Open" |
60 | on-open-focus="false" | 60 | on-open-focus="false" |
61 | ng-focus="datepicker2Open = true" | 61 | ng-focus="datepicker2Open = true" |
62 | /> | 62 | /> |
63 | </div> | 63 | </div> |
64 | <small class="col-md-2 col-4 text-left my-1">Unidad</small> | 64 | <small class="col-md-2 col-4 text-left my-1">Unidad</small> |
65 | <div class="col-md-4 col-8 input-group mb-2"> | 65 | <div class="col-md-4 col-8 input-group mb-2"> |
66 | <input | 66 | <input |
67 | class="form-control form-control-sm" | 67 | class="form-control form-control-sm" |
68 | id="inlineFormInputGroup" | 68 | id="inlineFormInputGroup" |
69 | type="text" | 69 | type="text" |
70 | ng-model="unidad.codigo" | 70 | ng-model="unidad.codigo" |
71 | ng-required="true" | 71 | ng-required="true" |
72 | ng-keypress="seleccionarUnidad($event.keyCode)" | 72 | ng-keypress="seleccionarUnidad($event.keyCode)" |
73 | /> | 73 | /> |
74 | <button | ||
75 | ng-show="unidad.codigo.length >= 1" | ||
76 | type="button" | ||
77 | class="clear-input" | ||
78 | ng-click="unidad.codigo = ''" | ||
79 | > | ||
80 | <i class="fa fa-times"></i> | ||
81 | </button> | ||
74 | <div class="input-group-append"> | 82 | <div class="input-group-append"> |
75 | <div class="input-group-append" ng-hide="ingreso"> | 83 | <div class="input-group-append" ng-hide="ingreso"> |
76 | <button | 84 | <button |
77 | ladda="searchLoading" | 85 | ladda="searchLoading" |
78 | data-spinner-color="#FF0000" | 86 | data-spinner-color="#FF0000" |
79 | class="btn btn-outline-secondary" | 87 | class="btn btn-outline-secondary" |
80 | type="button" | 88 | type="button" |
81 | ng-click="seleccionarUnidad(13)"> | 89 | ng-click="seleccionarUnidad(13)"> |
82 | <i class="fa fa-search" aria-hidden="true"></i> | 90 | <i class="fa fa-search" aria-hidden="true"></i> |
83 | </button> | 91 | </button> |
84 | </div> | 92 | </div> |
85 | </div> | 93 | </div> |
86 | </div> | 94 | </div> |
87 | </div> | 95 | </div> |
88 | <div | 96 | <div |
89 | ng-if="!buscar" | 97 | ng-if="!buscar" |
90 | class="row"> | 98 | class="row"> |
91 | <div class="col-12"> | 99 | <div class="col-12"> |
92 | <div | 100 | <div |
93 | class="gridInforme" | 101 | class="gridInforme" |
94 | ui-grid="gridOptions" | 102 | ui-grid="gridOptions" |
95 | ui-grid-exporter | 103 | ui-grid-exporter |
96 | ui-grid-resize-columns | 104 | ui-grid-resize-columns |
97 | ></div> | 105 | ></div> |
98 | </div> | 106 | </div> |
99 | </div> | 107 | </div> |
100 | </div> | 108 | </div> |
101 | <div class="modal-footer py-1"> | 109 | <div class="modal-footer py-1"> |
102 | <button | 110 | <button |
103 | ladda="generando" | 111 | ladda="generando" |
104 | class="btn btn-sm btn-secondary" | 112 | class="btn btn-sm btn-secondary" |
105 | type="button" | 113 | type="button" |
106 | ng-click="generarInforme()" | 114 | ng-click="generarInforme()" |
107 | ng-show="buscar">Generar</button> | 115 | ng-show="buscar">Generar</button> |
108 | <button | 116 | <button |
109 | class="btn btn-sm btn-secondary" | 117 | class="btn btn-sm btn-secondary" |
110 | type="button" | 118 | type="button" |
111 | ng-click="cancel()" | 119 | ng-click="cancel()" |
112 | ng-show="buscar">Salir</button> | 120 | ng-show="buscar">Salir</button> |
113 | <button | 121 | <button |
114 | class="btn btn-sm btn-secondary" | 122 | class="btn btn-sm btn-secondary" |
115 | type="button" | 123 | type="button" |
116 | ng-click="volver()" | 124 | ng-click="volver()" |
117 | ng-hide="buscar">Volver</button> | 125 | ng-hide="buscar">Volver</button> |
118 | </div> | 126 | </div> |
119 | 127 |