Commit d7942996a186224861c82ac7631593fdcf148ed0
1 parent
6d606aaa56
Exists in
master
url correcta package.json
Showing
2 changed files
with
4 additions
and
5 deletions
Show diff stats
package.json
1 | { | 1 | { |
2 | "name": "foca-modal-informe-hoja-ruta", | 2 | "name": "foca-modal-informe-chofer", |
3 | "version": "0.0.1", | 3 | "version": "0.0.1", |
4 | "description": "Modal para generar informes de correlatividad de hojas de ruta", | 4 | "description": "Modal para generar informes de correlatividad de hojas de ruta", |
5 | "scripts": { | 5 | "scripts": { |
6 | "test": "echo \"Error: no test specified\" && exit 1", | 6 | "test": "echo \"Error: no test specified\" && exit 1", |
7 | "gulp-pre-commit": "gulp pre-commit", | 7 | "gulp-pre-commit": "gulp pre-commit", |
8 | "compile": "gulp uglify", | 8 | "compile": "gulp uglify", |
9 | "postinstall": "npm run compile && gulp clean-post-install", | 9 | "postinstall": "npm run compile && gulp clean-post-install", |
10 | "install-dev": "npm install -D angular angular-ladda ladda@1.0.6 bootstrap font-awesome gulp gulp-angular-templatecache gulp-concat gulp-connect gulp-htmlmin gulp-jshint gulp-rename gulp-replace gulp-uglify gulp-clean jasmine-core jquery jshint pre-commit pump ui-bootstrap4 && npm i -D git+http://git.focasoftware.com/npm/foca-directivas.git" | 10 | "install-dev": "npm install -D angular angular-ladda ladda@1.0.6 bootstrap font-awesome gulp gulp-angular-templatecache gulp-concat gulp-connect gulp-htmlmin gulp-jshint gulp-rename gulp-replace gulp-uglify gulp-clean jasmine-core jquery jshint pre-commit pump ui-bootstrap4 && npm i -D git+http://git.focasoftware.com/npm/foca-directivas.git" |
11 | }, | 11 | }, |
12 | "pre-commit": [ | 12 | "pre-commit": [ |
13 | "gulp-pre-commit" | 13 | "gulp-pre-commit" |
14 | ], | 14 | ], |
15 | "repository": { | 15 | "repository": { |
16 | "type": "git", | 16 | "type": "git", |
17 | "url": "http://git.focasoftware.com/npm/foca-modal-informe-hoja-ruta" | 17 | "url": "http://git.focasoftware.com/npm/foca-modal-informe-chofer.git" |
18 | }, | 18 | }, |
19 | "author": "Nicolás Guarnieri", | 19 | "author": "Nicolás Guarnieri", |
20 | "license": "ISC", | 20 | "license": "ISC", |
21 | "peerDependencies": { | 21 | "peerDependencies": { |
22 | "angular": "^1.7.4", | 22 | "angular": "^1.7.4", |
23 | "bootstrap": "^4.1.3", | 23 | "bootstrap": "^4.1.3", |
24 | "font-awesome": "^4.7.0", | 24 | "font-awesome": "^4.7.0", |
25 | "ui-bootstrap4": "^3.0.4", | 25 | "ui-bootstrap4": "^3.0.4", |
26 | "gulp": "^3.9.1", | 26 | "gulp": "^3.9.1", |
27 | "gulp-angular-templatecache": "^2.2.1", | 27 | "gulp-angular-templatecache": "^2.2.1", |
28 | "gulp-concat": "^2.6.1", | 28 | "gulp-concat": "^2.6.1", |
29 | "gulp-connect": "^5.6.1", | 29 | "gulp-connect": "^5.6.1", |
30 | "gulp-htmlmin": "^5.0.1", | 30 | "gulp-htmlmin": "^5.0.1", |
31 | "gulp-rename": "^1.4.0", | 31 | "gulp-rename": "^1.4.0", |
32 | "gulp-replace": "^1.0.0", | 32 | "gulp-replace": "^1.0.0", |
33 | "gulp-uglify": "^3.0.1", | 33 | "gulp-uglify": "^3.0.1", |
34 | "jquery": "^3.3.1", | 34 | "jquery": "^3.3.1", |
35 | "pump": "^3.0.0", | 35 | "pump": "^3.0.0", |
36 | "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git" | 36 | "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git" |
37 | }, | 37 | }, |
38 | "devDependencies": { | 38 | "devDependencies": { |
39 | "angular": "^1.7.5", | 39 | "angular": "^1.7.5", |
40 | "angular-ladda": "^0.4.3", | 40 | "angular-ladda": "^0.4.3", |
41 | "bootstrap": "^4.1.3", | 41 | "bootstrap": "^4.1.3", |
42 | "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git", | 42 | "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git", |
43 | "font-awesome": "^4.7.0", | 43 | "font-awesome": "^4.7.0", |
44 | "gulp": "^3.9.1", | 44 | "gulp": "^3.9.1", |
45 | "gulp-angular-templatecache": "^2.2.3", | 45 | "gulp-angular-templatecache": "^2.2.3", |
46 | "gulp-clean": "^0.4.0", | 46 | "gulp-clean": "^0.4.0", |
47 | "gulp-concat": "^2.6.1", | 47 | "gulp-concat": "^2.6.1", |
48 | "gulp-connect": "^5.6.1", | 48 | "gulp-connect": "^5.6.1", |
49 | "gulp-htmlmin": "^5.0.1", | 49 | "gulp-htmlmin": "^5.0.1", |
50 | "gulp-jshint": "^2.1.0", | 50 | "gulp-jshint": "^2.1.0", |
51 | "gulp-rename": "^1.4.0", | 51 | "gulp-rename": "^1.4.0", |
52 | "gulp-replace": "^1.0.0", | 52 | "gulp-replace": "^1.0.0", |
53 | "gulp-uglify": "^3.0.1", | 53 | "gulp-uglify": "^3.0.1", |
54 | "jasmine-core": "^3.3.0", | 54 | "jasmine-core": "^3.3.0", |
55 | "jquery": "^3.3.1", | 55 | "jquery": "^3.3.1", |
56 | "jshint": "^2.9.6", | 56 | "jshint": "^2.9.6", |
57 | "ladda": "1.0.6", | 57 | "ladda": "1.0.6", |
58 | "pre-commit": "^1.2.2", | 58 | "pre-commit": "^1.2.2", |
59 | "pump": "^3.0.0", | 59 | "pump": "^3.0.0", |
60 | "ui-bootstrap4": "^3.0.5" | 60 | "ui-bootstrap4": "^3.0.5" |
61 | } | 61 | } |
62 | } | 62 | } |
63 | 63 |
src/js/controller.js
1 | angular.module('focaModalInformeChofer') | 1 | angular.module('focaModalInformeChofer') |
2 | .controller('focaModalInformeChoferController', | 2 | .controller('focaModalInformeChoferController', |
3 | [ | 3 | [ |
4 | '$filter', | 4 | '$filter', |
5 | '$scope', | 5 | '$scope', |
6 | '$uibModalInstance', | 6 | '$uibModalInstance', |
7 | 'focaModalInformeChoferService', | 7 | 'focaModalInformeChoferService', |
8 | 'i18nService', | 8 | 'i18nService', |
9 | function($filter, $scope, $uibModalInstance, | 9 | function($filter, $scope, $uibModalInstance, |
10 | focaModalInformeChoferService, i18nService | 10 | focaModalInformeChoferService, i18nService |
11 | ) { | 11 | ) { |
12 | var fecha = new Date(); | 12 | var fecha = new Date(); |
13 | $scope.generando = false; | 13 | $scope.generando = false; |
14 | $scope.fechaHasta = new Date(); | 14 | $scope.fechaHasta = new Date(); |
15 | $scope.fechaDesde = new Date(fecha.setMonth(fecha.getMonth() - 1)); | 15 | $scope.fechaDesde = new Date(fecha.setMonth(fecha.getMonth() - 1)); |
16 | $scope.buscar = true; | 16 | $scope.buscar = true; |
17 | $scope.informe = {}; | 17 | $scope.informe = {}; |
18 | i18nService.setCurrentLang('es'); | 18 | i18nService.setCurrentLang('es'); |
19 | $scope.gridOptions = { | 19 | $scope.gridOptions = { |
20 | enableGridMenu: true, | 20 | enableGridMenu: true, |
21 | exporterMenuCsv: false, | 21 | exporterMenuCsv: false, |
22 | exporterPdfPageSize: 'A4', | 22 | exporterPdfPageSize: 'A4', |
23 | exporterPdfFooter: function (currentPage, pageCount) { | 23 | exporterPdfFooter: function(currentPage, pageCount) { |
24 | return { | 24 | return { |
25 | columns: [ | 25 | columns: [ |
26 | {text: $filter('date')(new Date(), 'dd/MM/yyyy'), | 26 | {text: $filter('date')(new Date(), 'dd/MM/yyyy'), |
27 | margin: [40, 0]}, | 27 | margin: [40, 0]}, |
28 | {text: currentPage + ' de ' + pageCount, | 28 | {text: currentPage + ' de ' + pageCount, |
29 | margin: [28, 0], alignment: 'right'} | 29 | margin: [28, 0], alignment: 'right'} |
30 | ] | 30 | ] |
31 | }; | 31 | }; |
32 | }, | 32 | } |
33 | |||
34 | }; | 33 | }; |
35 | $scope.generarInforme = function() { | 34 | $scope.generarInforme = function() { |
36 | $scope.generando = true; | 35 | $scope.generando = true; |
37 | focaModalInformeChoferService | 36 | focaModalInformeChoferService |
38 | .getDescargas( | 37 | .getDescargas( |
39 | $scope.fechaDesde.toISOString().split('.')[0], | 38 | $scope.fechaDesde.toISOString().split('.')[0], |
40 | $scope.fechaHasta.toISOString().split('.')[0] | 39 | $scope.fechaHasta.toISOString().split('.')[0] |
41 | ) | 40 | ) |
42 | .then(function(res) { | 41 | .then(function(res) { |
43 | var promesas = []; | 42 | var promesas = []; |
44 | $scope.gridOptions.data = orderData(res.data); | 43 | $scope.gridOptions.data = orderData(res.data); |
45 | 44 | ||
46 | res.data.forEach(function(descargas) { | 45 | res.data.forEach(function(descargas) { |
47 | var idsRemito = descargas.map(function(descarga) { | 46 | var idsRemito = descargas.map(function(descarga) { |
48 | return descarga.remito.id; | 47 | return descarga.remito.id; |
49 | }); | 48 | }); |
50 | idsRemito = eliminarDuplicados(idsRemito); | 49 | idsRemito = eliminarDuplicados(idsRemito); |
51 | promesas.push( | 50 | promesas.push( |
52 | focaModalInformeChoferService.getDistanciaPorIdRemito(idsRemito)); | 51 | focaModalInformeChoferService.getDistanciaPorIdRemito(idsRemito)); |
53 | }); | 52 | }); |
54 | return Promise.all(promesas); | 53 | return Promise.all(promesas); |
55 | }) | 54 | }) |
56 | .then(function(res) { | 55 | .then(function(res) { |
57 | res.forEach(function(movimiento, idx) { | 56 | res.forEach(function(movimiento, idx) { |
58 | //Calculo lts/km y los agrego a la grilla | 57 | //Calculo lts/km y los agrego a la grilla |
59 | var ltsPorKm = | 58 | var ltsPorKm = |
60 | $scope.gridOptions.data[idx].litros / movimiento.data.totalKms; | 59 | $scope.gridOptions.data[idx].litros / movimiento.data.totalKms; |
61 | $scope.gridOptions.data[idx].kmRecorridos = | 60 | $scope.gridOptions.data[idx].kmRecorridos = |
62 | $filter('number')(movimiento.data.totalKms); | 61 | $filter('number')(movimiento.data.totalKms); |
63 | $scope.gridOptions.data[idx].ltsPorKm = | 62 | $scope.gridOptions.data[idx].ltsPorKm = |
64 | $filter('number')(ltsPorKm, 7); | 63 | $filter('number')(ltsPorKm, 7); |
65 | }); | 64 | }); |
66 | //TODO: sacar id empresa hardcodeado | 65 | //TODO: sacar id empresa hardcodeado |
67 | return focaModalInformeChoferService.getEmpresa(1); | 66 | return focaModalInformeChoferService.getEmpresa(1); |
68 | }) | 67 | }) |
69 | .then(function(res) { | 68 | .then(function(res) { |
70 | //Seteo filename para PDF y Excel, y cabecera de PDF | 69 | //Seteo filename para PDF y Excel, y cabecera de PDF |
71 | var filenameStamp = 'Informe choferes - ' + | 70 | var filenameStamp = 'Informe choferes - ' + |
72 | $filter('date')(new Date(), 'dd/MM/yyyy'); | 71 | $filter('date')(new Date(), 'dd/MM/yyyy'); |
73 | $scope.informe.nombreEmpresa = res.data.NOM.trim(); | 72 | $scope.informe.nombreEmpresa = res.data.NOM.trim(); |
74 | $scope.informe.direccionEmpresa = res.data.DIR.trim(); | 73 | $scope.informe.direccionEmpresa = res.data.DIR.trim(); |
75 | $scope.gridOptions.exporterPdfFilename = filenameStamp + '.pdf'; | 74 | $scope.gridOptions.exporterPdfFilename = filenameStamp + '.pdf'; |
76 | $scope.gridOptions.exporterExcelFilename = filenameStamp + '.xlsx'; | 75 | $scope.gridOptions.exporterExcelFilename = filenameStamp + '.xlsx'; |
77 | $scope.gridOptions.exporterPdfHeader = { | 76 | $scope.gridOptions.exporterPdfHeader = { |
78 | columns: [ | 77 | columns: [ |
79 | { | 78 | { |
80 | text: $scope.informe.nombreEmpresa, | 79 | text: $scope.informe.nombreEmpresa, |
81 | margin: [40, 0], | 80 | margin: [40, 0], |
82 | fontSize: 9 | 81 | fontSize: 9 |
83 | }, | 82 | }, |
84 | { | 83 | { |
85 | text: '\nInforme de choferes', | 84 | text: '\nInforme de choferes', |
86 | margin: [-170, -4, 0, 0], | 85 | margin: [-170, -4, 0, 0], |
87 | fontSize: 12 | 86 | fontSize: 12 |
88 | }, | 87 | }, |
89 | { | 88 | { |
90 | text: [ | 89 | text: [ |
91 | '\n\nFiltros: ', | 90 | '\n\nFiltros: ', |
92 | 'Fecha desde: ', | 91 | 'Fecha desde: ', |
93 | $filter('date')($scope.fechaDesde, 'dd/MM/yyyy'), | 92 | $filter('date')($scope.fechaDesde, 'dd/MM/yyyy'), |
94 | ' Fecha hasta: ', | 93 | ' Fecha hasta: ', |
95 | $filter('date')($scope.fechaHasta, 'dd/MM/yyyy') | 94 | $filter('date')($scope.fechaHasta, 'dd/MM/yyyy') |
96 | ], | 95 | ], |
97 | margin: [-380, 2, 0, 0], | 96 | margin: [-380, 2, 0, 0], |
98 | fontSize: 9 | 97 | fontSize: 9 |
99 | }, | 98 | }, |
100 | { | 99 | { |
101 | text: $scope.informe.direccionEmpresa, | 100 | text: $scope.informe.direccionEmpresa, |
102 | margin: [28, 0], | 101 | margin: [28, 0], |
103 | alignment: 'right', | 102 | alignment: 'right', |
104 | fontSize: 9 | 103 | fontSize: 9 |
105 | } | 104 | } |
106 | ] | 105 | ] |
107 | }; | 106 | }; |
108 | $scope.buscar = false; | 107 | $scope.buscar = false; |
109 | $scope.generando = false; | 108 | $scope.generando = false; |
110 | }); | 109 | }); |
111 | }; | 110 | }; |
112 | $scope.volver = function() { | 111 | $scope.volver = function() { |
113 | $scope.buscar = true; | 112 | $scope.buscar = true; |
114 | }; | 113 | }; |
115 | $scope.cancel = function() { | 114 | $scope.cancel = function() { |
116 | $uibModalInstance.dismiss('Cancelar'); | 115 | $uibModalInstance.dismiss('Cancelar'); |
117 | }; | 116 | }; |
118 | 117 | ||
119 | function orderData(data) { | 118 | function orderData(data) { |
120 | var result = []; | 119 | var result = []; |
121 | data.forEach(function(descargas) { | 120 | data.forEach(function(descargas) { |
122 | var row = { | 121 | var row = { |
123 | chofer: descargas[0].remito.hojaRuta.chofer.nombre, | 122 | chofer: descargas[0].remito.hojaRuta.chofer.nombre, |
124 | litros: 0 | 123 | litros: 0 |
125 | }; | 124 | }; |
126 | descargas.forEach(function(descarga) { | 125 | descargas.forEach(function(descarga) { |
127 | row.litros += descarga.cantidad; | 126 | row.litros += descarga.cantidad; |
128 | }); | 127 | }); |
129 | result.push(row); | 128 | result.push(row); |
130 | }); | 129 | }); |
131 | return result; | 130 | return result; |
132 | } | 131 | } |
133 | 132 | ||
134 | function eliminarDuplicados(datos) { | 133 | function eliminarDuplicados(datos) { |
135 | var result = []; | 134 | var result = []; |
136 | datos.forEach(function(dato) { | 135 | datos.forEach(function(dato) { |
137 | if (result.indexOf(dato) === -1) { | 136 | if (result.indexOf(dato) === -1) { |
138 | result.push(dato); | 137 | result.push(dato); |
139 | } | 138 | } |
140 | }); | 139 | }); |
141 | return result; | 140 | return result; |
142 | } | 141 | } |
143 | } | 142 | } |
144 | ] | 143 | ] |
145 | ); | 144 | ); |
146 | 145 |