diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bf9275c --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/dist +/tmp +package-lock\.json + +src/etc/develop\.js diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 0000000..d8cbb07 --- /dev/null +++ b/.jshintrc @@ -0,0 +1,64 @@ +{ + /* + * ENVIRONMENTS + * ================= + */ + + // Define globals exposed by modern browsers. + "browser": true, + + // Define globals exposed by jQuery. + "jquery": true, + + // Define globals exposed by Node.js. + "node": true, + + // Allow ES6. + "esversion": 6, + + /* + * ENFORCING OPTIONS + * ================= + */ + + // Force all variable names to use either camelCase style or UPPER_CASE + // with underscores. + "camelcase": true, + + // Prohibit use of == and != in favor of === and !==. + "eqeqeq": true, + + // Enforce tab width of 2 spaces. + "indent": 4, + + // Prohibit use of a variable before it is defined. + "latedef": false, + + // Enforce line length to 100 characters + "maxlen": 100, + + // Require capitalized names for constructor functions. + "newcap": true, + + // Enforce use of single quotation marks for strings. + "quotmark": "single", + + // Enforce placing 'use strict' at the top function scope + "strict": false, + + // Prohibit use of explicitly undeclared variables. + "undef": true, + + // Warn when variables are defined but never used. + "unused": true, + + // Para que funcione en angular + "predef": ["angular", "alert", "spyOn", "expect", "it", "inject", "beforeEach", "describe"], + /* + * RELAXING OPTIONS + * ================= + */ + + // Suppress warnings about == null comparisons. + "eqnull": true +} diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 0000000..61827e3 --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,94 @@ +const templateCache = require('gulp-angular-templatecache'); +const concat = require('gulp-concat'); +const htmlmin = require('gulp-htmlmin'); +const rename = require('gulp-rename'); +const uglify = require('gulp-uglify'); +const gulp = require('gulp'); +const pump = require('pump'); +const jshint = require('gulp-jshint'); +const replace = require('gulp-replace'); +const connect = require('gulp-connect'); +const clean = require('gulp-clean'); + +var paths = { + srcJS: 'src/js/*.js', + srcViews: 'src/views/*.html', + tmp: 'tmp', + dist: 'dist/' +}; + +gulp.task('clean', function() { + return gulp.src(['tmp', 'dist'], {read: false}) + .pipe(clean()); +}); + +gulp.task('templates', ['clean'], function() { + return pump( + [ + gulp.src(paths.srcViews), + htmlmin(), + templateCache('views.js', { + module: 'focaModalInforme', + root: '' + }), + gulp.dest(paths.tmp) + ] + ); +}); + +gulp.task('uglify', ['templates'], function() { + return pump( + [ + gulp.src([ + paths.srcJS, + 'tmp/views.js' + ]), + concat('foca-modal-informe.js'), + replace('src/views/', ''), + gulp.dest(paths.tmp), + rename('foca-modal-informe.min.js'), + uglify(), + gulp.dest(paths.dist) + ] + ); +}); + +gulp.task('pre-commit', function() { + return pump( + [ + gulp.src(paths.srcJS), + jshint('.jshintrc'), + jshint.reporter('default'), + jshint.reporter('fail') + ] + ); + + gulp.start('uglify'); +}); + +gulp.task('webserver', function() { + pump [ + connect.server({port: 3000}) + ] +}); + +gulp.task('clean-post-install', function() { + return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js', + 'index.html'], {read: false}) + .pipe(clean()); +}); + +gulp.task('default', ['webserver']); + +gulp.task('watch', function() { + gulp.watch([paths.srcJS, paths.srcViews], ['uglify']) +}); + +gulp.task('copy', ['uglify'], function() { + gulp.src('dist/*.js') + .pipe(gulp.dest('../wrapper-demo/node_modules/foca-informe-hoja-ruta/dist')); +}); + +gulp.task('watchAndCopy', function() { + return gulp.watch([paths.srcJS, paths.srcViews], ['copy']); +}); diff --git a/package.json b/package.json new file mode 100644 index 0000000..b5513e9 --- /dev/null +++ b/package.json @@ -0,0 +1,62 @@ +{ + "name": "foca-modal-informe", + "version": "0.0.1", + "description": "Modales generadoras de informes", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1", + "gulp-pre-commit": "gulp pre-commit", + "compile": "gulp uglify", + "postinstall": "npm run compile && gulp clean-post-install", + "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" + }, + "pre-commit": [ + "gulp-pre-commit" + ], + "repository": { + "type": "git", + "url": "http://git.focasoftware.com/npm/foca-modal-informe" + }, + "author": "Foca software", + "license": "ISC", + "peerDependencies": { + "angular": "^1.7.4", + "bootstrap": "^4.1.3", + "font-awesome": "^4.7.0", + "ui-bootstrap4": "^3.0.4", + "gulp": "^3.9.1", + "gulp-angular-templatecache": "^2.2.1", + "gulp-concat": "^2.6.1", + "gulp-connect": "^5.6.1", + "gulp-htmlmin": "^5.0.1", + "gulp-rename": "^1.4.0", + "gulp-replace": "^1.0.0", + "gulp-uglify": "^3.0.1", + "jquery": "^3.3.1", + "pump": "^3.0.0", + "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git" + }, + "devDependencies": { + "angular": "^1.7.5", + "angular-ladda": "^0.4.3", + "bootstrap": "^4.1.3", + "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git", + "font-awesome": "^4.7.0", + "gulp": "^3.9.1", + "gulp-angular-templatecache": "^2.2.3", + "gulp-clean": "^0.4.0", + "gulp-concat": "^2.6.1", + "gulp-connect": "^5.6.1", + "gulp-htmlmin": "^5.0.1", + "gulp-jshint": "^2.1.0", + "gulp-rename": "^1.4.0", + "gulp-replace": "^1.0.0", + "gulp-uglify": "^3.0.1", + "jasmine-core": "^3.3.0", + "jquery": "^3.3.1", + "jshint": "^2.9.6", + "ladda": "1.0.6", + "pre-commit": "^1.2.2", + "pump": "^3.0.0", + "ui-bootstrap4": "^3.0.5" + } +} diff --git a/src/etc/develop.js.ejemplo b/src/etc/develop.js.ejemplo new file mode 100644 index 0000000..0cd287f --- /dev/null +++ b/src/etc/develop.js.ejemplo @@ -0,0 +1,4 @@ +angular.module('focaModalInforme') + .constant("API_ENDPOINT", { + 'URL': '//127.0.0.1:9000' + }); diff --git a/src/js/app.js b/src/js/app.js new file mode 100644 index 0000000..94aebad --- /dev/null +++ b/src/js/app.js @@ -0,0 +1 @@ +angular.module('focaModalInforme', []); diff --git a/src/js/controller-chofer.js b/src/js/controller-chofer.js new file mode 100644 index 0000000..84e99ff --- /dev/null +++ b/src/js/controller-chofer.js @@ -0,0 +1,151 @@ +angular.module('focaModalInforme') + .controller('focaModalInformeChoferController', + [ + '$filter', + '$scope', + '$uibModalInstance', + 'focaModalInformeChoferService', + 'i18nService', + function($filter, $scope, $uibModalInstance, + focaModalInformeChoferService, i18nService + ) { + var fecha = new Date(); + $scope.generando = false; + $scope.fechaHasta = new Date(); + $scope.fechaDesde = new Date(fecha.setMonth(fecha.getMonth() - 1)); + $scope.buscar = true; + $scope.informe = {}; + i18nService.setCurrentLang('es'); + $scope.gridOptions = { + enableGridMenu: true, + exporterMenuCsv: false, + exporterPdfPageSize: 'A4', + exporterPdfFooter: function(currentPage, pageCount) { + return { + columns: [ + {text: $filter('date')(new Date(), 'dd/MM/yyyy'), + margin: [40, 0]}, + {text: currentPage + ' de ' + pageCount, + margin: [28, 0], alignment: 'right'} + ] + }; + } + }; + $scope.generarInforme = function() { + $scope.generando = true; + focaModalInformeChoferService + .getDescargas( + $scope.fechaDesde.toISOString().split('.')[0], + $scope.fechaHasta.toISOString().split('.')[0] + ) + .then(function(res) { + var promesas = []; + $scope.gridOptions.data = orderData(res.data); + + res.data.forEach(function(descargas) { + var idsRemito = descargas.map(function(descarga) { + return descarga.remito.id; + }); + idsRemito = eliminarDuplicados(idsRemito); + promesas.push( + focaModalInformeChoferService + .getDistanciaPorIdRemito(idsRemito)); + }); + return Promise.all(promesas); + }) + .then(function(res) { + res.forEach(function(movimiento, idx) { + //Calculo lts/km y los agrego a la grilla + var ltsPorKm = 0; + if (movimiento.data.totalKms) { + ltsPorKm = + $scope.gridOptions.data[idx].litros / + movimiento.data.totalKms; + } else { + ltsPorKm = $scope.gridOptions.data[idx].litros; + } + $scope.gridOptions.data[idx].kmRecorridos = + $filter('number')(movimiento.data.totalKms); + $scope.gridOptions.data[idx].ltsPorKm = + $filter('number')(ltsPorKm, 7); + }); + //TODO: sacar id empresa hardcodeado + return focaModalInformeChoferService.getEmpresa(1); + }) + .then(function(res) { + //Seteo filename para PDF y Excel, y cabecera de PDF + var filenameStamp = 'Informe choferes - ' + + $filter('date')(new Date(), 'dd/MM/yyyy'); + $scope.informe.nombreEmpresa = res.data.NOM.trim(); + $scope.informe.direccionEmpresa = res.data.DIR.trim(); + $scope.gridOptions.exporterPdfFilename = filenameStamp + '.pdf'; + $scope.gridOptions.exporterExcelFilename = filenameStamp + '.xlsx'; + $scope.gridOptions.exporterPdfHeader = { + columns: [ + { + text: $scope.informe.nombreEmpresa, + margin: [40, 0], + fontSize: 9 + }, + { + text: '\nInforme de choferes', + margin: [-170, -4, 0, 0], + fontSize: 12 + }, + { + text: [ + '\n\nFiltros: ', + 'Fecha desde: ', + $filter('date')($scope.fechaDesde, 'dd/MM/yyyy'), + ' Fecha hasta: ', + $filter('date')($scope.fechaHasta, 'dd/MM/yyyy') + ], + margin: [-380, 2, 0, 0], + fontSize: 9 + }, + { + text: $scope.informe.direccionEmpresa, + margin: [28, 0], + alignment: 'right', + fontSize: 9 + } + ] + }; + $scope.buscar = false; + $scope.generando = false; + }); + }; + $scope.volver = function() { + $scope.buscar = true; + }; + $scope.cancel = function() { + $uibModalInstance.dismiss('Cancelar'); + }; + + function orderData(data) { + var result = []; + data.forEach(function(descargas) { + var row = { + chofer: descargas[0].remito.hojaRuta.chofer.nombre, + litros: 0 + }; + descargas.forEach(function(descarga) { + row.litros += descarga.cantidad; + }); + result.push(row); + }); + return result; + } + + function eliminarDuplicados(datos) { + var result = []; + datos.forEach(function(dato) { + if (result.indexOf(dato) === -1) { + result.push(dato); + } + }); + return result; + } + } + ] + ); diff --git a/src/js/controller-general-unidad.js b/src/js/controller-general-unidad.js new file mode 100644 index 0000000..a68bd6f --- /dev/null +++ b/src/js/controller-general-unidad.js @@ -0,0 +1,167 @@ +angular.module('focaModalInforme') + .controller('focaModalInformeGeneralUnidadController', + [ + '$filter', + '$scope', + '$uibModalInstance', + 'focaModalInformeGeneralUnidadService', + 'i18nService', + 'focaModalService', + function($filter, $scope, $uibModalInstance, + focaModalInformeGeneralUnidadService, i18nService, focaModalService + ) { + i18nService.setCurrentLang('es'); + var fecha = new Date(); + $scope.generando = false; + $scope.buscar = true; + $scope.informe = {}; + $scope.params = { + fechaHasta: new Date(), + fechaDesde: new Date(fecha.setMonth(fecha.getMonth() - 1)), + sector: undefined, + diferenciarProductos: false, + detallarPorMes: false + }; + $scope.gridOptions = { + enableGridMenu: true, + exporterMenuCsv: false, + exporterPdfPageSize: 'A4', + exporterPdfFooter: function (currentPage, pageCount) { + return { + columns: [ + {text: $filter('date')(new Date(), 'dd/MM/yyyy'), + margin: [40, 0]}, + {text: currentPage + ' de ' + pageCount, + margin: [28, 0], alignment: 'right'} + ] + }; + }, + columnDefs: [ + { + field: 'vehiculo', + enableSorting: false, + cellClass: function(grid, row, col, rowRenderIndex, colRenderIndex) { + if (grid.getCellValue(row,col).indexOf('Sector:') !== -1) + return 'yellow w-100'; + if (grid.getCellValue(row,col).indexOf('Producto:') !== -1) + return 'red w-100'; + if (grid.getCellValue(row,col).indexOf('Mes:') !== -1) + return 'green w-100'; + } + }, + { + field: 'kmRecorridos', + enableSorting: false, + cellClass: function(grid, row, col, rowRenderIndex, colRenderIndex) { + if (!grid.getCellValue(row,col)) + return 'd-none'; + } + }, + { + field: 'litrosRepartidos', + enableSorting: false, + cellClass: function(grid, row, col, rowRenderIndex, colRenderIndex) { + if (!grid.getCellValue(row,col)) + return 'd-none'; + } + }, + { + field: 'viajes', + enableSorting: false, + cellClass: function(grid, row, col, rowRenderIndex, colRenderIndex) { + if (!grid.getCellValue(row,col)) + return 'd-none'; + } + } + ] + }; + $scope.generarInforme = function() { + $scope.generando = true; + focaModalInformeGeneralUnidadService + .getInformeData($scope.params) + .then(function(res) { + console.log(res); + var result = []; + + res.data.forEach(function(sector) { + if (!$scope.params.sector || + $scope.params.sector.ID === sector.idSector) { + result.push({ + vehiculo: 'Sector: ' + + $filter('rellenarDigitos')(sector.idSector, 2, '0') + + ' - ' + sector.sector.trim() + }); + sector.productos.forEach(function(producto) { + result.push({ + vehiculo: 'Producto: ' + + producto.idProducto + + ' - ' + producto.producto + }); + producto.fechas.forEach(function(fecha) { + result.push({ + vehiculo: 'Mes: ' + fecha.fecha + }); + fecha.vehiculos.forEach(function(vehiculo) { + result.push({ + vehiculo: vehiculo.vehiculo, + kmRecorridos: $filter('number')(vehiculo.data.kms, 2), + litrosRepartidos: $filter('number')(vehiculo.data.lts, 2), + viajes: $filter('number')(vehiculo.data.viajes, 0) + }); + }); + }); + }); + } + }); + + + $scope.gridOptions.data = result; + $scope.generando = false; + $scope.buscar = false; + }); + }; + + $scope.seleccionarSector = function(key) { + if (key === 13) { + var parametrosModal = { + titulo: 'Búsqueda de Sector', + query: '/sector', + columnas: [ + { + nombre: 'Código', + propiedad: 'ID' + }, + { + nombre: 'Nombre', + propiedad: 'NOMBRE' + } + ], + size: 'md' + }; + focaModalService.modal(parametrosModal).then( + function(sector) { + $scope.params.sector = sector; + }, function() {} + ); + } + }; + $scope.volver = function() { + $scope.buscar = true; + }; + $scope.cancel = function() { + $uibModalInstance.dismiss('Cancelar'); + }; + + function agruparProductos(productos) { + console.log('productos', productos); + var result = { + vehiculos: [] + }; + productos.forEach(function(producto) { + result.vehiculos = result.vehiculos.concat(); + }); + return productos; + } + } + ] + ); diff --git a/src/js/controller-hoja-ruta.js b/src/js/controller-hoja-ruta.js new file mode 100644 index 0000000..73fdcec --- /dev/null +++ b/src/js/controller-hoja-ruta.js @@ -0,0 +1,107 @@ +angular.module('focaModalInforme') + .controller('focaModalInformeHojaRutaController', + [ + '$filter', + '$scope', + '$uibModalInstance', + 'focaModalInformeHojaRutaService', + 'i18nService', + 'uiGridConstants', + function($filter, $scope, $uibModalInstance, + focaModalInformeHojaRutaService, i18nService, uiGridConstants + ) { + var fecha = new Date(); + $scope.fechaHasta = new Date(); + $scope.fechaDesde = new Date(fecha.setMonth(fecha.getMonth() - 1)); + $scope.buscar = true; + $scope.informe = {}; + i18nService.setCurrentLang('es'); + $scope.gridOptions = { + enableHorizontalScrollbar: uiGridConstants.scrollbars.ALWAYS, + enableVerticalScrollbar: uiGridConstants.scrollbars.WHEN_NEEDED, + enableGridMenu: true, + exporterMenuCsv: false, + exporterPdfPageSize: 'A4', + exporterPdfFooter: function (currentPage, pageCount) { + return { + columns: [ + {text: $filter('date')(new Date(), 'dd/MM/yyyy'), + margin: [40, 0]}, + {text: currentPage + ' de ' + pageCount, + margin: [28, 0], alignment: 'right'} + ] + }; + }, + + }; + $scope.generarInforme = function() { + focaModalInformeHojaRutaService + .getHojasRuta( + $scope.fechaDesde.toISOString().split('.')[0], + $scope.fechaHasta.toISOString().split('.')[0] + ) + .then(function(res) { + $scope.gridOptions.data = res.data.map(function(hojaRuta) { + return { + sucursal: hojaRuta.sucursal, + numero: hojaRuta.numeroHojaRuta, + transportista: hojaRuta.transportista.NOM, + unidad: hojaRuta.vehiculo.codigo, + chofer: hojaRuta.chofer.nombre, + fechaDeReparto: $filter('date')(hojaRuta.fechaReparto, 'dd/MM/yyyy') + }; + }); + + //TODO: sacar id empresa hardcodeado + return focaModalInformeHojaRutaService.getEmpresa(1); + }) + .then(function(res) { + var filenameStamp = 'Informe de correlatividad de hojas de ruta - ' + + $filter('date')(new Date(), 'dd/MM/yyyy'); + $scope.informe.nombreEmpresa = res.data.NOM.trim(); + $scope.informe.direccionEmpresa = res.data.DIR.trim(); + $scope.gridOptions.exporterPdfFilename = filenameStamp + '.pdf'; + $scope.gridOptions.exporterExcelFilename = filenameStamp + '.xlsx'; + $scope.gridOptions.exporterPdfHeader = { + columns: [ + { + text: $scope.informe.nombreEmpresa, + margin: [40, 0], + fontSize: 9 + }, + { + text: '\nInforme de correlatividad de hojas de ruta', + margin: [-170, -4, 0, 0], + fontSize: 12 + }, + { + text: [ + '\n\nFiltros: ', + 'Fecha desde: ', + $filter('date')($scope.fechaDesde, 'dd/MM/yyyy'), + ' Fecha hasta: ', + $filter('date')($scope.fechaHasta, 'dd/MM/yyyy') + ], + margin: [-380, 2, 0, 0], + fontSize: 9 + }, + { + text: $scope.informe.direccionEmpresa, + margin: [28, 0], + alignment: 'right', + fontSize: 9 + } + ] + }; + $scope.buscar = false; + }); + }; + $scope.volver = function() { + $scope.buscar = true; + }; + $scope.cancel = function() { + $uibModalInstance.dismiss('Cancelar'); + }; + } + ] + ); diff --git a/src/js/controller-litros-km-unidad.js b/src/js/controller-litros-km-unidad.js new file mode 100644 index 0000000..ce6d1b1 --- /dev/null +++ b/src/js/controller-litros-km-unidad.js @@ -0,0 +1,188 @@ +angular.module('focaModalInforme') + .controller('focaModalInformeLitrosKmUnidadController', + [ + '$filter', + '$scope', + '$uibModalInstance', + 'focaModalInformeLitrosKmUnidadService', + 'i18nService', + 'focaModalService', + '$uibModal', + function($filter, $scope, $uibModalInstance, focaModalInformeLitrosKmUnidadService, + i18nService, focaModalService, $uibModal + ) { + var meses = ['ene', 'feb', 'mar', 'abr', 'may', 'jun', + 'jul', 'ago', 'sep', 'oct', 'nov', 'dic']; + var fecha = new Date(); + $scope.generando = false; + $scope.fechaHasta = new Date(); + $scope.fechaDesde = new Date(fecha.setMonth(fecha.getMonth() - 1)); + $scope.buscar = true; + $scope.informe = {}; + i18nService.setCurrentLang('es'); + $scope.gridOptions = { + enableGridMenu: true, + exporterMenuCsv: false, + exporterPdfPageSize: 'A4', + exporterPdfFooter: function (currentPage, pageCount) { + return { + columns: [ + {text: $filter('date')(new Date(), 'dd/MM/yyyy'), + margin: [40, 0]}, + {text: currentPage + ' de ' + pageCount, + margin: [28, 0], alignment: 'right'} + ] + }; + }, + columnDefs: [ + { + field: 'fecha', + enableSorting: false, + cellClass: function(grid, row, col, rowRenderIndex, colRenderIndex) { + if (grid.getCellValue(row,col).indexOf('Sector:') !== -1) + return 'yellow w-100'; + if (grid.getCellValue(row,col).indexOf('Producto:') !== -1) + return 'red w-100'; + } + }, + { + field: 'litrosRepartidos', + enableSorting: false, + cellClass: function(grid, row, col, rowRenderIndex, colRenderIndex) { + if (!grid.getCellValue(row,col)) + return 'd-none'; + } + }, + { + field: 'kmRecorridos', + enableSorting: false, + cellClass: function(grid, row, col, rowRenderIndex, colRenderIndex) { + if (!grid.getCellValue(row,col)) + return 'd-none'; + } + }, + { + field: 'lts/Km', + enableSorting: false, + cellClass: function(grid, row, col, rowRenderIndex, colRenderIndex) { + if (!grid.getCellValue(row,col)) + return 'd-none'; + } + } + ] + + }; + $scope.generarInforme = function() { + if(!$scope.unidad){ + focaModalService.alert('Primero seleccione una unidad'); + return; + } + $scope.generando = true; + focaModalInformeLitrosKmUnidadService + .getDescargas( + $scope.unidad.id, + $scope.fechaDesde.toISOString().split('.')[0], + $scope.fechaHasta.toISOString().split('.')[0] + ) + .then(function(res) { + var result = []; + res.data.forEach(function(sector) { + result.push({ + fecha: 'Sector: ' + + $filter('rellenarDigitos')(sector[0].articulo.CodSec, 2, '0') + + ' - ' + sector[0].articulo.sector.NOMBRE.trim() + }); + sector.forEach(function(cisternaCarga) { + result.push({ + fecha: 'Producto: ' + + cisternaCarga.articulo.CodArt + + ' - ' + cisternaCarga.articulo.DetArt + }); + cisternaCarga.cisternaMovimientos.forEach(function(cisternaMovimiento) { + var lts = cisternaMovimiento.lts; + var kms = cisternaMovimiento.kms; + + result.push({ + fecha: meses[cisternaMovimiento.month] + ' - ' + cisternaMovimiento.year, + litrosRepartidos: $filter('number')(lts, 2), + kmRecorridos: $filter('number')(kms, 2), + 'lts/Km': (kms) ? $filter('number')(lts / kms, 2) : lts + }); + }); + }); + }); + $scope.gridOptions.data = result; + $scope.generando = false; + $scope.buscar = false; + }); + }; + $scope.seleccionarTransportista = function() { + var parametrosModal = { + titulo: 'Búsqueda de Transportista', + query: '/transportista', + columnas: [ + { + propiedad: 'COD', + nombre: 'Código', + filtro: { + nombre: 'rellenarDigitos', + parametro: 5 + } + }, + { + propiedad: 'NOM', + nombre: 'Nombre' + }, + { + propiedad: 'CUIT', + nombre: 'CUIT' + } + ], + size: 'md' + }; + return focaModalService.modal(parametrosModal) + }; + + $scope.seleccionarUnidad = function() { + $scope.seleccionarTransportista().then( + function(transportista) { + var parametrosModal = { + titulo: 'Búsqueda de vehículos', + query: '/vehiculo/transportista/' + transportista.COD, + columnas: [ + { + propiedad: 'codigo', + nombre: 'Código' + }, + { + propiedad: 'tractor', + nombre: 'Tractor' + }, + { + propiedad: 'semi', + nombre: 'Semi' + }, + { + propiedad: 'tractor', + nombre: 'Tractor' + } + ], + size: 'md' + }; + focaModalService.modal(parametrosModal).then( + function(unidad) { + $scope.unidad = unidad; + }, function() { + $scope.seleccionarUnidad(); + }); + }); + }; + $scope.volver = function() { + $scope.buscar = true; + }; + $scope.cancel = function() { + $uibModalInstance.dismiss('Cancelar'); + }; + } + ] + ); diff --git a/src/js/service.js b/src/js/service.js new file mode 100644 index 0000000..09080de --- /dev/null +++ b/src/js/service.js @@ -0,0 +1,66 @@ +angular.module('focaModalInforme') + .factory('focaModalInformeChoferService', [ + '$http', + 'API_ENDPOINT', + function($http, API_ENDPOINT) { + return { + getDescargas: function(fechaDesde, fechaHasta) { + return $http.post(API_ENDPOINT.URL + '/informe/chofer', + {fechaDesde: fechaDesde, fechaHasta: fechaHasta}); + }, + getEmpresa: function(id) { + return $http.get(API_ENDPOINT.URL + '/empresa/' + id); + }, + getDistanciaPorIdRemito: function(ids) { + return $http.post(API_ENDPOINT.URL + '/remito/distancia', {ids: ids}); + } + }; + } + ]) + .factory('focaModalInformeGeneralUnidadService', [ + '$http', + 'API_ENDPOINT', + function($http, API_ENDPOINT) { + return { + getEmpresa: function(id) { + return $http.get(API_ENDPOINT.URL + '/empresa/' + id); + }, + getInformeData: function(params) { + return $http.post(API_ENDPOINT.URL + '/informe/general-unidad-reparto', {params: params}); + } + }; + } + ]) + .factory('focaModalInformeLitrosKmUnidadService', [ + '$http', + 'API_ENDPOINT', + function($http, API_ENDPOINT) { + return { + getDescargas: function(idVehiculo, fechaDesde, fechaHasta) { + return $http.post(API_ENDPOINT.URL + '/informe/litros-por-km', + {idVehiculo: idVehiculo, fechaDesde: fechaDesde, fechaHasta: fechaHasta}); + }, + getEmpresa: function(id) { + return $http.get(API_ENDPOINT.URL + '/empresa/' + id); + }, + getDistanciaPorIdRemito: function(ids) { + return $http.post(API_ENDPOINT.URL + '/remito/distancia', {ids: ids}); + } + }; + } + ]) + .factory('focaModalInformeHojaRutaService', [ + '$http', + 'API_ENDPOINT', + function($http, API_ENDPOINT) { + return { + getHojasRuta: function(fechaDesde, fechaHasta) { + return $http.get(API_ENDPOINT.URL + '/hoja-ruta/listar/' + + fechaDesde + '/' + fechaHasta); + }, + getEmpresa: function(id) { + return $http.get(API_ENDPOINT.URL + '/empresa/' + id); + } + }; + } + ]); \ No newline at end of file diff --git a/src/views/informe-chofer.html b/src/views/informe-chofer.html new file mode 100644 index 0000000..d65abf6 --- /dev/null +++ b/src/views/informe-chofer.html @@ -0,0 +1,84 @@ + + + diff --git a/src/views/informe-general-unidad.html b/src/views/informe-general-unidad.html new file mode 100644 index 0000000..4f0f3f3 --- /dev/null +++ b/src/views/informe-general-unidad.html @@ -0,0 +1,130 @@ + + + diff --git a/src/views/informe-hoja-ruta.html b/src/views/informe-hoja-ruta.html new file mode 100644 index 0000000..d424404 --- /dev/null +++ b/src/views/informe-hoja-ruta.html @@ -0,0 +1,86 @@ + + + diff --git a/src/views/informe-litros-km-unidad.html b/src/views/informe-litros-km-unidad.html new file mode 100644 index 0000000..f539684 --- /dev/null +++ b/src/views/informe-litros-km-unidad.html @@ -0,0 +1,107 @@ + + +