diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..76a3502 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/dist +package-lock\.json +/src/etc/develop.js + +tmp/ 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..b118c1f --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,86 @@ +const templateCache = require('gulp-angular-templatecache'); +const clean = require('gulp-clean'); +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'); + +var paths = { + srcJS: 'src/js/*.js', + srcViews: 'src/views/*.html', + tmp: 'tmp', + dist: 'dist/' +}; + +gulp.task('templates', ['clean'], function() { + return pump( + [ + gulp.src(paths.srcViews), + htmlmin(), + templateCache('views.js', { + module: 'focaParametros', + root: '' + }), + gulp.dest(paths.tmp) + ] + ); +}); + +gulp.task('uglify', ['templates'], function() { + return pump( + [ + gulp.src([ + paths.srcJS, + 'tmp/views.js' + ]), + concat('foca-parametros.js'), + replace('src/views/', ''), + replace("'ngRoute'", ''), + gulp.dest(paths.tmp), + rename('foca-parametros.min.js'), + uglify(), + gulp.dest(paths.dist) + ] + ); +}); + +gulp.task('clean', function() { + return gulp.src(['tmp', 'dist'], {read: false}) + .pipe(clean()); +}); + +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: 3300, host: '0.0.0.0'}) + ] +}); + +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']); +}); diff --git a/package.json b/package.json new file mode 100644 index 0000000..bcecf3b --- /dev/null +++ b/package.json @@ -0,0 +1,50 @@ +{ + "name": "foca-autorizar-nota-pedido", + "version": "0.0.1", + "description": "foca-autorizar-nota-pedido", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1", + "compile": "gulp uglify", + "gulp-pre-commit": "gulp pre-commit", + "postinstall": "npm run compile && gulp clean-post-install", + "install-dev": "npm install -D jasmine-core pre-commit angular angular-ladda ladda@1.0.6 angular-route bootstrap ui-bootstrap4 font-awesome gulp gulp-angular-templatecache gulp-connect gulp-clean gulp-htmlmin gulp-jshint gulp-rename gulp-replace gulp-sequence gulp-uglify-es gulp-uglify jquery jshint pump git+http://git.focasoftware.com/npm/foca-directivas.git git+http://git.focasoftware.com/npm/foca-modal-remito.git" + }, + "pre-commit": [ + "gulp-pre-commit" + ], + "repository": { + "type": "git", + "url": "git+http://git.focasoftware.com/npm/foca-autorizar-nota-pedido.git" + }, + "author": "Foca Software", + "license": "ISC", + "devDependencies": { + "angular": "^1.7.8", + "angular-ladda": "^0.4.3", + "angular-route": "^1.7.8", + "bootstrap": "^4.3.1", + "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git", + "foca-modal-remito": "git+http://git.focasoftware.com/npm/foca-modal-remito.git", + "font-awesome": "^4.7.0", + "gulp": "^3.9.1", + "gulp-angular-templatecache": "^2.2.6", + "gulp-clean": "^0.4.0", + "gulp-concat": "^2.6.1", + "gulp-connect": "^5.7.0", + "gulp-htmlmin": "^5.0.1", + "gulp-jshint": "^2.1.0", + "gulp-rename": "^1.4.0", + "gulp-replace": "^1.0.0", + "gulp-sequence": "^1.0.0", + "gulp-uglify": "^3.0.2", + "gulp-uglify-es": "^1.0.4", + "jasmine-core": "^3.4.0", + "jquery": "^3.4.0", + "jshint": "^2.10.2", + "ladda": "^1.0.6", + "pre-commit": "^1.2.2", + "pump": "^3.0.0", + "ui-bootstrap4": "^3.0.6" + } +} diff --git a/src/etc/develop.js.ejemplo b/src/etc/develop.js.ejemplo new file mode 100644 index 0000000..25cd0cd --- /dev/null +++ b/src/etc/develop.js.ejemplo @@ -0,0 +1,4 @@ +angular.module('focaCrearHojaRuta') + .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..b7f548c --- /dev/null +++ b/src/js/app.js @@ -0,0 +1 @@ +angular.module('focaParametros', []); diff --git a/src/js/controller.js b/src/js/controller.js new file mode 100644 index 0000000..f34c51e --- /dev/null +++ b/src/js/controller.js @@ -0,0 +1,642 @@ +angular.module('focaParametros') + .controller('focaParametrosCtrl', [ + '$scope', + 'focaParametrosService', + 'focaBotoneraLateralService', + '$filter', + 'focaModalService', + '$timeout', + '$uibModal', + function($scope, focaParametrosService, focaBotoneraLateralService, $filter, + focaModalService, $timeout, $uibModal) + { + + $scope.botonera = []; + $scope.now = new Date(); + + $scope.botoneraPrincipal = focaParametrosService.getBotonesPrincipal; + + $timeout(function() { + focaBotoneraLateralService.showSalir(true); + focaBotoneraLateralService.showGuardar(true, $scope.guardar); + }); + + focaParametrosService.getParametros().then(function(res) { + + $scope.$broadcast('cleanCabecera'); + res.data.forEach(function(entidad) { + + setearEntidad(entidad); + }); + }); + + $scope.guardar = function() { + + focaParametrosService.saveParametros(getObjGuardar()).then(function() { + focaModalService.alert('Parámetros guardados con éxito'); + }); + }; + + $scope.seleccionarPuntosDeDescarga = function() { + if (!$scope[getModulo()].cliente.COD || !$scope[getModulo()].domicilio.id) { + focaModalService.alert('Primero seleccione un cliente y un domicilio'); + return; + } else { + var modalInstance = $uibModal.open( + { + ariaLabelledBy: 'Búsqueda de Puntos de descarga', + templateUrl: 'modal-punto-descarga.html', + controller: 'focaModalPuntoDescargaController', + size: 'lg', + resolve: { + filters: { + idDomicilio: $scope[getModulo()].domicilio.id, + idCliente: $scope[getModulo()].cliente.COD, + articulos: $scope[getModulo()].articulosNotaPedido || [], + puntoDescarga: $scope[getModulo()].notaPedidoPuntoDescarga, + domicilio: $scope[getModulo()].domicilio + } + } + } + ); + modalInstance.result.then( + function(puntoDescarga) { + $scope[getModulo()].notaPedidoPuntoDescarga = puntoDescarga; + + $scope.$broadcast('addCabecera', { + label: 'Puntos de descarga:', + seccion: getModulo('label'), + valor: getCabeceraPuntoDescarga(puntoDescarga) + }); + }, function() { + $scope.abrirModalDomicilios($scope.cliente); + } + ); + } + }; + + $scope.seleccionarFlete = function() { + + if ($scope[getModulo()].flete === undefined) { + $scope[getModulo()].fob = undefined; + $scope[getModulo()].bomba = undefined; + $scope[getModulo()].kilometros = undefined; + + } + + var modalInstance = $uibModal.open( + { + ariaLabelledBy: 'Busqueda de Flete', + templateUrl: 'modal-flete.html', + controller: 'focaModalFleteController', + size: 'lg', + resolve: { + parametrosFlete: + function() { + return { + flete: $scope[getModulo()].fob ? 'FOB' : + ( $scope[getModulo()].flete ? '1' : + ($scope[getModulo()].flete === undefined ? + null : '0')), + bomba: $scope[getModulo()].bomba ? '1' : + ($scope[getModulo()].bomba === undefined ? + null : '0'), + kilometros: $scope[getModulo()].kilometros + }; + } + } + } + ); + modalInstance.result.then( + function(datos) { + $scope[getModulo()].flete = datos.flete; + $scope[getModulo()].fob = datos.FOB; + $scope[getModulo()].bomba = datos.bomba; + $scope[getModulo()].kilometros = datos.kilometros; + $scope.$broadcast('addCabecera', { + label: 'Flete:', + seccion: getModulo('label'), + valor: datos.FOB ? 'FOB' : (datos.flete ? 'Si' : 'No') + }); + if (datos.flete) { + $scope.$broadcast('addCabecera', { + label: 'Bomba:', + seccion: getModulo('label'), + valor: datos.bomba ? 'Si' : 'No' + }); + $scope.$broadcast('addCabecera', { + label: 'Kilometros:', + seccion: getModulo('label'), + valor: datos.kilometros + }); + } else { + $scope.$broadcast('removeCabecera', 'Bomba:'); + $scope.$broadcast('removeCabecera', 'Kilometros:'); + $scope[getModulo()].bomba = false; + $scope[getModulo()].kilometros = null; + } + }, function() { + } + ); + }; + + $scope.seleccionarVendedor = function() { + + var parametrosModal = { + titulo: 'Búsqueda vendedores', + query: '/vendedor', + columnas: [ + { + propiedad: 'NUM', + nombre: 'Código', + filtro: { + nombre: 'rellenarDigitos', + parametro: 3 + } + }, + { + propiedad: 'NOM', + nombre: 'Nombre' + } + ], + size: 'md' + }; + focaModalService.modal(parametrosModal).then( + function(vendedor) { + $scope.$broadcast('addCabecera', { + label: 'Vendedor:', + seccion: getModulo('label'), + valor: $filter('rellenarDigitos')(vendedor.NUM, 3) + ' - ' + + vendedor.NOM + }); + $scope[getModulo()].vendedor = vendedor; + }, function() {} + ); + }; + + $scope.seleccionarCliente = function() { + + if (!$scope[getModulo()].vendedor) { + focaModalService.alert('Seleccione Vendedor'); + return; + } + + var modalInstance = $uibModal.open( + { + ariaLabelledBy: 'Busqueda de Cliente', + templateUrl: 'foca-busqueda-cliente-modal.html', + controller: 'focaBusquedaClienteModalController', + resolve: { + vendedor: function() { return $scope.notaPedido.vendedor; }, + cobrador: function() { return null; } + }, + size: 'lg' + } + ); + modalInstance.result.then( + function(cliente) { + $scope.abrirModalDomicilios(cliente); + }, function() { } + ); + }; + + $scope.seleccionarProveedor = function() { + + var parametrosModal = { + titulo: 'Búsqueda de Proveedor', + query: '/proveedor', + columnas: [ + { + nombre: 'Código', + propiedad: 'COD', + filtro: { + nombre: 'rellenarDigitos', + parametro: 5 + } + }, + { + nombre: 'Nombre', + propiedad: 'NOM' + }, + { + nombre: 'CUIT', + propiedad: 'CUIT' + } + ], + tipo: 'POST', + json: {razonCuitCod: ''} + }; + focaModalService.modal(parametrosModal).then( + function(proveedor) { + $scope[getModulo()].proveedor = proveedor; + $scope.$broadcast('addCabecera', { + label: 'Proveedor:', + seccion: getModulo('label'), + valor: $filter('rellenarDigitos')(proveedor.COD, 5) + ' - ' + + proveedor.NOM + }); + }, function() { + } + ); + + }; + + $scope.abrirModalDomicilios = function(cliente) { + var modalInstanceDomicilio = $uibModal.open( + { + ariaLabelledBy: 'Busqueda de Domicilios', + templateUrl: 'modal-domicilio.html', + controller: 'focaModalDomicilioController', + resolve: { + idCliente: function() { return cliente.cod; }, + esNuevo: function() { return cliente.esNuevo; } + }, + size: 'lg', + } + ); + modalInstanceDomicilio.result.then( + function(domicilio) { + + $scope[getModulo()].domicilio = domicilio; + + $scope[getModulo()].cliente = { + COD: cliente.cod, + CUIT: cliente.cuit, + NOM: cliente.nom, + MOD: cliente.mod + }; + + var domicilioStamp = + domicilio.Calle + ' ' + domicilio.Numero + ', ' + + domicilio.Localidad + ', ' + domicilio.Provincia; + $scope[getModulo()].domicilioStamp = domicilioStamp; + + $scope[getModulo()].notaPedidoPuntoDescarga = domicilio.puntoDescarga; + + $scope.$broadcast('addCabecera', { + label: 'Cliente:', + seccion: getModulo('label'), + valor: $filter('rellenarDigitos')(cliente.cod, 5) + ' - ' + cliente.nom + }); + $scope.$broadcast('addCabecera', { + label: 'Domicilio:', + seccion: getModulo('label'), + valor: domicilioStamp + }); + if (domicilio.verPuntos) { + delete $scope[getModulo()].domicilio.verPuntos; + $scope.seleccionarPuntosDeDescarga(); + } else { + focaParametrosService + .getPuntosDescargaByClienDom(domicilio.id, cliente.cod) + .then(function(res) { + if (res.data.length) $scope.seleccionarPuntosDeDescarga(); + }); + } + }, function() { + $scope.seleccionarCliente(true); + return; + } + ); + }; + + $scope.seleccionarMoneda = function() { + + var parametrosModal = { + titulo: 'Búsqueda de monedas', + query: '/moneda', + columnas: [ + { + propiedad: 'DETALLE', + nombre: 'Nombre' + }, + { + propiedad: 'SIMBOLO', + nombre: 'Símbolo' + } + ], + size: 'md' + }; + focaModalService.modal(parametrosModal).then( + function(moneda) { + $scope.abrirModalCotizacion(moneda); + }, function() { + } + ); + + }; + + $scope.abrirModalCotizacion = function(moneda) { + var modalInstance = $uibModal.open( + { + ariaLabelledBy: 'Busqueda de Cotización', + templateUrl: 'modal-cotizacion.html', + controller: 'focaModalCotizacionController', + size: 'lg', + resolve: { + idMoneda: function() { + return moneda.ID; + } + } + } + ); + modalInstance.result.then( + function(cotizacion) { + // var articulosTablaTemp = $scope.notaPedido.articulosNotaPedido || []; + // for (var i = 0; i < articulosTablaTemp.length; i++) { + // articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * + // $scope.notaPedido.cotizacion.VENDEDOR; + // articulosTablaTemp[i].precio = (articulosTablaTemp[i].precio / + // cotizacion.VENDEDOR).toFixed(4); + // } + // $scope[getModulo()].articulosNotaPedido = articulosTablaTemp; + $scope[getModulo()].cotizacion = cotizacion; + $scope[getModulo()].cotizacion.moneda = moneda; + + $scope.$broadcast('addCabecera', { + label: 'Moneda:', + seccion: getModulo('label'), + valor: moneda.DETALLE + }); + $scope.$broadcast('addCabecera', { + label: 'Fecha cotizacion:', + seccion: getModulo('label'), + valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') + }); + $scope.$broadcast('addCabecera', { + label: 'Cotizacion:', + seccion: getModulo('label'), + valor: $filter('number')(cotizacion.VENDEDOR, '2') + }); + + }, function() { + + } + ); + }; + + $scope.seleccionarObservaciones = function() { + var observacion = { + titulo: 'Ingrese Observaciones', + value: $scope[getModulo()].observaciones, + maxlength: 155, + textarea: true + }; + + focaModalService + .prompt(observacion) + .then(function(observaciones) { + $scope[getModulo()].observaciones = observaciones; + $scope.$broadcast('addCabecera', { + label: 'Observaciones:', + valor: observaciones + }); + }); + }; + + $scope.$watch('botonera', function() { + + // Creo el string en donde guardo el objeto parseado + $scope[getModulo()] = $scope[getModulo()] || {}; + + getCheckeds(); + }, true); + + $scope.botoneraPrincipal.forEach(function(botonPincipal) { + + // watch en objetos principales para ir guardando los valores + $scope.$watch(botonPincipal.variable, function() { + + $scope[botonPincipal.variable + 'String'] = { + jsonText: JSON.stringify($scope[botonPincipal.variable]), + modulo: botonPincipal.variable, + id: $scope[botonPincipal.variable] ? + $scope[botonPincipal.variable].id : null + }; + + getCheckeds(); + }, true); + + // creo las funciones para seleccionar boton principal + $scope[nombreFuncion(botonPincipal.label)] = function() { + + $scope.botoneraPrincipal.filter(function(boton) { + boton.checked = false; + }); + + botonPincipal.checked = true; + $scope.botonera = focaParametrosService.getBotones(botonPincipal.modulo); + }; + + }); + + function nombreFuncion(string) { + var texto = 'seleccionar'; + var arr = string.split(' '); + arr.forEach(function(palabra) { + palabra = palabra.charAt(0).toUpperCase() + palabra.slice(1); + texto += palabra; + }); + return texto; + } + + function getModulo(propiedad) { + var nombre = ''; + + $scope.botoneraPrincipal.filter(function(boton) { + if (boton.checked) { + if(!propiedad) { + nombre = boton.variable; + } else { + nombre = boton[propiedad]; + } + } + }); + return nombre; + } + + function getCheckeds() { + + $scope.botonera.forEach(function(boton) { + + if ($scope[getModulo()][boton.variable] !== undefined) { + + boton.checked = true; + + //Creo la función para limpiar obj + $scope['clean' + boton.variable] = function() { + + focaModalService.alert('Esta seguro que desea eliminar el parámetro?') + .then(function() { + delete $scope[getModulo()][boton.variable]; + $scope.$broadcast('cleanCabecera', { + seccion: getModulo('label') + }); + setearEntidad({ + jsonText: JSON.stringify($scope[getModulo()]), + modulo: getModulo(), + id: $scope[getModulo()].id + }); + }); + }; + + } else { + boton.checked = false; + } + }); + } + + function getCabeceraPuntoDescarga(puntoDescarga) { + var puntosStamp = ''; + puntoDescarga.forEach(function(punto, idx, arr) { + puntosStamp += punto.descripcion; + if ((idx + 1) !== arr.length) puntosStamp += ', '; + }); + return puntosStamp; + } + + function setearEntidad(entidad) { + + $scope[entidad.modulo] = JSON.parse(entidad.jsonText) || {}; + $scope[entidad.modulo].id = entidad.id; + + if (!$scope[entidad.modulo].domicilio) { + $scope[entidad.modulo].domicilio = { + id: $scope[entidad.modulo].idDomicilio + }; + } + + var cabeceras = []; + + if ($scope[entidad.modulo].cotizacion && + $scope[entidad.modulo].cotizacion.moneda.CODIGO_AFIP !== 'PES') + { + cabeceras.push({ + label: 'Moneda:', + valor: $scope[entidad.modulo].cotizacion.moneda.DETALLE + }); + cabeceras.push({ + label: 'Fecha cotizacion:', + valor: $filter('date')($scope[entidad.modulo].cotizacion.FECHA, + 'dd/MM/yyyy') + }); + cabeceras.push({ + label: 'Cotizacion:', + valor: $filter('number')($scope[entidad.modulo].cotizacion.VENDEDOR, + '2') + }); + } + + if ($scope[entidad.modulo].vendedor && $scope[entidad.modulo].vendedor.NUM) { + cabeceras.push({ + label: 'Vendedor:', + valor: $filter('rellenarDigitos')($scope[entidad.modulo].vendedor.NUM, 3) + + ' - ' + $scope[entidad.modulo].vendedor.NOM + }); + } + + if ($scope[entidad.modulo].cliente && $scope[entidad.modulo].cliente.COD) { + cabeceras.push({ + label: 'Cliente:', + valor: $scope[entidad.modulo].cliente.NOM + }); + cabeceras.push({ + label: 'Domicilio:', + valor: $scope[entidad.modulo].domicilioStamp + }); + } + + if ($scope[entidad.modulo].proveedor && $scope[entidad.modulo].proveedor.COD) { + cabeceras.push({ + label: 'Proveedor:', + valor: $filter('rellenarDigitos')($scope[entidad.modulo].proveedor.COD, 5) + + ' - ' + $scope[entidad.modulo].proveedor.NOM + }); + } + + if ($scope[entidad.modulo][entidad + 'Plazo'] && + $scope[entidad.modulo][entidad + 'Plazo'].length) + { + cabeceras.push({ + label: 'Precios y condiciones:', + valor: valorPrecioCondicion() + ' ' + + focaParametrosService.plazoToString( + $scope[entidad.modulo][entidad.modulo + 'Plazo']) + }); + } + + if ($scope[entidad.modulo].flete !== undefined) { + cabeceras.push({ + label: 'Flete:', + valor: $scope[entidad.modulo].fob === 1 ? 'FOB' : ( + $scope[entidad.modulo].flete === 1 ? 'Si' : 'No') + }); + } + + function valorPrecioCondicion() { + if ($scope[entidad.modulo].idPrecioCondicion > 0) { + return $scope[entidad.modulo].precioCondicion.nombre; + } else { + return 'Ingreso Manual'; + } + } + + if ($scope[entidad.modulo].flete === 1) { + var cabeceraBomba = { + label: 'Bomba:', + valor: $scope[entidad.modulo].bomba === 1 ? 'Si' : 'No' + }; + if ($scope[entidad.modulo].kilometros) { + var cabeceraKilometros = { + label: 'Kilometros:', + valor: $scope[entidad.modulo].kilometros + }; + cabeceras.push(cabeceraKilometros); + } + cabeceras.push(cabeceraBomba); + } + + if ($scope[entidad.modulo].idPrecioCondicion > 0) { + $scope.idLista = $scope[entidad.modulo].precioCondicion.idListaPrecio; + } else { + $scope.idLista = -1; + } + + if ($scope[entidad.modulo][entidad.modulo + 'PuntoDescarga']) { + var puntos = []; + $scope[entidad.modulo][entidad + 'PuntoDescarga'] + .forEach(function(entidadPuntoDescarga) { + puntos.push(entidadPuntoDescarga); + }); + cabeceras.push({ + label: 'Puntos de descarga: ', + valor: $filter('rellenarDigitos')(getCabeceraPuntoDescarga(puntos)) + }); + } + + addArrayCabecera(cabeceras, entidad.modulo); + + } + + function addArrayCabecera(array, entidad) { + for (var i = 0; i < array.length; i++) { + $scope.$broadcast('addCabecera', { + label: array[i].label, + valor: array[i].valor, + seccion: $filter('filter') + ($scope.botoneraPrincipal, {variable: entidad}, true)[0].label + }); + } + } + + function getObjGuardar() { + var guardar = []; + $scope.botoneraPrincipal.forEach(function(botonPincipal) { + if (!botonPincipal || !$scope[botonPincipal.variable + 'String']) return; + guardar.push($scope[botonPincipal.variable + 'String']); + }); + + return guardar; + } + + }]); diff --git a/src/js/route.js b/src/js/route.js new file mode 100644 index 0000000..fa2e7fe --- /dev/null +++ b/src/js/route.js @@ -0,0 +1,7 @@ +angular.module('focaParametros') + .config(['$routeProvider', function($routeProvider) { + $routeProvider.when('/parametros', { + controller: 'focaParametrosCtrl', + templateUrl: 'src/views/foca-parametros.html' + }); + }]); diff --git a/src/js/service.js b/src/js/service.js new file mode 100644 index 0000000..e84aeca --- /dev/null +++ b/src/js/service.js @@ -0,0 +1,94 @@ +angular.module('focaParametros') + .factory('focaParametrosService', ['$http', 'API_ENDPOINT', function ($http, API_ENDPOINT) { + return { + getNotasPedido: function (fechaDesde, fechaHasta) { + return $http.get(API_ENDPOINT.URL + '/nota-pedido/listar/' + fechaDesde + '/' + + fechaHasta + '/sin-remito'); + }, + getPuntosDescargaByClienDom: function(idDomicilio, idCliente) { + return $http.get(API_ENDPOINT.URL + '/punto-descarga/' + + idDomicilio + '/' + idCliente); + }, + saveParametros: function(parametros) { + return $http.post(API_ENDPOINT.URL + '/parametros', parametros); + }, + getParametros: function() { + return $http.get(API_ENDPOINT.URL + '/parametros'); + }, + plazoToString: function(plazos) { + + var result = ''; + + for(var i = 0; i < plazos.length; i++) { + result += plazos[i].dias + ' '; + } + + return result.trim(); + }, + getBotones: function (modulo) { + var botones = [ + { + label: 'Vendedor', + variable: 'vendedor', + image: 'vendedor.png', + modulo: [1, 2] + }, + { + label: 'Cliente', + image: 'cliente.png', + variable: 'cliente', + modulo: [1, 2] + }, + { + label: 'Proveedor', + image: 'proveedor.png', + variable: 'proveedor', + modulo: [1, 2] + }, + { + label: 'Flete', + image: 'flete.png', + variable: 'flete', + modulo: [1, 2] + }, + { + label: 'Moneda', + image: 'moneda.png', + variable: 'cotizacion', + modulo: [1, 2] + }, + { + label: 'Precios y condiciones', + image: 'precios-condiciones.png', + modulo: [1, 2] + }, + { + label: 'Observaciones', + image: 'botonObservaciones.png', + variable: 'observaciones', + modulo: [1] + } + ]; + + // Devuelvo solo los botones correspondietes + // Modulo 1 = nota de pedido, 2 remito, 3 ambos + return botones.filter(function (p) { + return p.modulo.includes(modulo); + }); + }, + getBotonesPrincipal: [ + { + label: 'Nota de Pedido', + image: 'notaPedido.png', + modulo: 1, + variable: 'notaPedido' + }, + { + label: 'Remito', + image: 'remito.png', + modulo: 2, + variable: 'remito' + } + ] + }; + }]); diff --git a/src/views/foca-parametros.html b/src/views/foca-parametros.html new file mode 100644 index 0000000..ef6fb7c --- /dev/null +++ b/src/views/foca-parametros.html @@ -0,0 +1,21 @@ +
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+