function enviarFormulario( formulario ) { var elFormulario = document.getElementById( formulario ); elFormulario.submit(); } $(document).ready(function(){ $("#servicio-campo-referencia").change(function () { $("#servicio-campo-referencia option:selected").each(function () { id_municipio = $(this).val(); $.post("includes/getLocalidad.php", { id_municipio: id_municipio }, function(data){ $("#cbx_localidad").html(data); }); }); }) }); function mostrarTab( evento, nombreTab ) { var i=0; var tabcontent; var tablinks; // Ocultar todos los contenidos existentes tabcontent = document.getElementsByClassName("tabcontent"); for (i = 0; i < tabcontent.length; i++) { tabcontent[i].style.display = "none"; } // Tomamos todos los elementos y y desactivamos el parámetro active tablinks = document.getElementsByClassName("tablinks"); for (i = 0; i < tablinks.length; i++) { tablinks[i].className = tablinks[i].className.replace(" active", ""); } // Mostrar el tabname seleccionado y marcarlo como activo para el css tabcontent = document.getElementById(nombreTab); if( tabcontent != null ) { tabcontent.style.display = "block"; if( evento != null ) { evento.currentTarget.className += " active"; } else { /* No hay evento definido, buscar el button con el identificador y activar */ tabcontent = document.getElementsByClassName("menu-2"); if( tabcontent != null ) { tablinks = document.getElementById(nombreTab+"_links"); if( tablinks != null ) { tablinks.className += " active"; } } } } } function solo_numero( e ){ tecla = (document.all) ? e.keyCode : e.which; //Tecla de retroceso para borrar, siempre la permite if ( tecla == 8 ) { return true; } // Patron de entrada, en este caso solo acepta numeros patron =/[0-9]/; tecla_final = String.fromCharCode(tecla); return patron.test(tecla_final); } function evitar_tecla_enter( e ) { tecla = (document.all) ? e.keyCode : e.which; return ( tecla != 13 ); } function pregutar_eliminar() { return confirm( 'Se va a proceder con la eliminación del resgistro seleccionado. ¿Desea continuar?'); } function preguntar_confirmacion_reconstruir_carpetaBasica() { return confirm( 'Se va a proceder con la reconstrucción de la esctructura básica en todos los cliente. Este proceso es irreversible. ¿Desea continuar?' ); } function ventana_emergente( fichero_php ) { // Capturamos las dimensiones de la pantalla para centrar la pagina var altoPantalla = parseInt(screen.availHeight); var anchoPantalla = parseInt(screen.availWidth); // Calculamos el centro de la pantalla var centroAncho = parseInt((anchoPantalla/2)); var centroAlto = parseInt((altoPantalla/2)); // dimensiones del popup var anchoPagina = 800; var altoPagina = 600; // Calculamos las coordenadas de colocación var laXPopup = centroAncho - parseInt((anchoPagina/2)); var laYPopup = centroAlto - parseInt((altoPagina/2)); // Definimos que página vamos a ver sel = window.open(fichero_php,"","scrollbars=yes,status=no,width=" + anchoPagina + ", height=" + altoPagina + ",left = " + laXPopup + ",top = " + laYPopup); } function volver() { window.history.back(); } function mostrarFormularioModal( nombreFormulario, mostrar = true ) { // Ocultar todos los contenidos existentes formulario = document.getElementById(nombreFormulario); if ( formulario != null ) { // Mostrar el formulario if ( mostrar == true ) formulario.className = "subir-fichero"; else formulario.className = "subir-fichero" + " ocultar"; } else { console.log( "Error buscando el elemento formulario" ); } } /** * \fn mostrarFormularioModalRenombrar( nombreFormulario, mostrar = true, parametros = new Array() ) * \param STRING nombreFormulario Identificador del formulario destinado al cambio de nombre del item * \param BOOL mostrar Indica la visibilidad del formulario * \param ARRAY parametros Los parámetros a tener en cuenta * \arg STRING id Identificador del item * \arg STRING nombre Nombre del item a renombrar */ function mostrarFormularioModalRenombrar( nombreFormulario, mostrar = true, parametros = new Array() ) { var item; var itemId; var nombre; // Hay parámetros if ( parametros.length == 0 ) console.log("NO HAY PARÁMETROS" ); else console.log("TENEMOS PARÁMETROS " + parametros['nombre'] ); // Ocultar todos los contenidos existentes formulario = document.getElementById(nombreFormulario); item = formulario.getElementsByTagName('span')[0]; itemId = document.getElementById('taxonomia-id'); nombre = document.getElementById('nombre-nuevo'); if ( formulario != null ) { // Mostrar el formulario if ( mostrar == true ) { // Tomar el elemento titulo para cambiarlo if ( item != null ) { item.innerText = 'Renombrar ' + parametros['nombre']; } if ( itemId != null ) { console.log("MODIFICAR ID DE LA TAXONOMIA A " + parametros['id']); itemId.value = parametros['id']; } if ( nombre != null ) { nombre.value = parametros['nombre']; } formulario.className = "subir-fichero"; } else { formulario.className = "subir-fichero" + " ocultar"; } } else { console.log( "Error buscando el elemento formulario" ); } } /** * \fn descargarDocumento( documentoUuid ) * \param UUID documentoUuid Identificador del item */ function descargarDocumento( documentoUuid ) { // Abrir una nueva ventana con la uri para la descarga del documento window.open( "http://" + location.hostname + "/doc/" + documentoUuid, "Descargar documento", "width=200, height=100" ); } function generarNuevaClave( destino ) { var dest = document.getElementById( destino ); var caracteres = "abcdefghijkmnpqrtuvwxyzABCDEFGHIJKLMNPQRTUVWXYZ2346789!·$%&/()=?¿+*[]{}-_.:,;"; var clave = ""; var longitudClave = 10; if ( dest != null ) { // Generar la clave for ( contador=0;contador= tamanyo ) { return true; } var alerta = document.getElementById('alerta'); if ( alerta != null ) { alerta.innerHTML="La longitud mínima para la clave es de " + longitud; } return false; } else { return false; } } function marcarTodosLosCheckbox() { var boton = document.getElementById('botonMarcarDesmarcar'); var elementos = document.getElementsByClassName('checkbox'); var hijos = null; var activar = false; if ( boton.getAttribute( "valor") == "activar" ) activar = true; if ( elementos != null ) { for ( contador = 0; contador < elementos.length; contador++ ) { hijos = elementos[ contador ].getElementsByTagName('input'); for ( contadorB = 0; contadorB < hijos.length; contadorB++ ) hijos[ contadorB ].checked = activar; } if ( activar ) { boton.innerHTML="DESELECCIONAR TODO"; boton.setAttribute( "valor", "desactivar" ); } else { boton.innerHTML="SELECCIONAR TODO"; boton.setAttribute( "valor", "activar" ); } } else { console.log("No se ha localizado el formulario para enviar la notificacion"); } } function cambiarCampoDefault() { var tipo = document.getElementById("campo-tipo").value; var etiqueta = document.getElementById("label-default"); var campo = document.getElementById("campo-default"); console.log( tipo ) if( tipo == 'checkbox' || tipo == 'radio' || tipo == 'select' ) { etiqueta.innerHTML = "Valores"; campo.placeholder = "Indique los valores separados por ';'"; } else { etiqueta.innerHTML = "Default"; campo.placeholder = "Valor a mostrar por defecto"; } } function mostrarOcultarClaveLogin() { var objeto = document.getElementById("password"); var span = document.getElementById("ver-clave-login"); if( objeto != null ) { if( span.classList.contains( "icon-eye") ) { span.classList.replace("icon-eye", "icon-eye-slash"); objeto.type="text"; } else if( span.classList.contains( "icon-eye-slash") ) { span.classList.replace("icon-eye-slash", "icon-eye"); objeto.type="password"; } else { console.log("Vacío"); } } else { console.log("No hay objeto"); } } /* 'nombre' => 'Nombre', 'apellidos' => 'Apellidos', 'cargo' => 'Cargo', 'participacion' => 'Participación' */ function formulario_socios_editar( idSocio, idModulo ) { let fila = document.getElementById(idSocio); if( fila != null ) { let columnas = fila.cells; if( columnas.length > 3 ) { let obj; // Cambiar los valores de los campos de texto para poder actualizar document.getElementById(idModulo + "-nombre").value = columnas[0].innerHTML; document.getElementById(idModulo + "-apellidos").value = columnas[1].innerHTML; document.getElementById(idModulo + "-cargo").value = columnas[2].innerHTML; document.getElementById(idModulo + "-participacion").value = columnas[3].innerHTML; // Cambiar el value del boton obj = document.getElementById('botonAccionSocio'); if( obj != undefined ){ obj.value="Actualizar"; } // Indicar el valor del identificador del socio obj = document.getElementById('uuid_empresa_socio'); if( obj != undefined ) { obj.value=idSocio; } } /* for( contador = 0; contador < columnas.length - 1 ; contador++ ) { console.log( "Col: " + contador + ": " + columnas[ contador ].innerHTML ); } */ } console.log( idSocio ); } function esDigito( letra ) { let ascii = letra.charCodeAt(0); return ( ascii > 47 && ascii < 58 ); } function esSimbolo( letra ) { let ascii = letra.charCodeAt(0); return ( ( ascii > 32 && ascii < 48 ) || ( ascii > 57 && ascii < 65 ) || ( ascii > 90 && ascii < 97) || ( ascii > 122 && ascii < 127) ); } function esMayuscula( letra ) { return letra === letra.toUpperCase(); } function esMinuscula( letra ) { return letra === letra.toLowerCase(); } function comprobarIntegridadPassword( clave ) { let tamanyo_minimo = 8; var digito = 0; var simbolo = 0; var mayuscula = 0; var minuscula = 0; for( var indice = 0; indice < clave.length; indice++ ) { if( esDigito( clave.charAt(indice) ) ) { digito += 1; } else if( esSimbolo( clave.charAt(indice) ) ) { simbolo += 1; }else if( esMayuscula( clave.charAt(indice) ) ) { mayuscula += 1; } else if( esMinuscula( clave.charAt(indice) ) ) { minuscula += 1; } } console.log( "May: " + mayuscula ); console.log( "Min: " + minuscula ); console.log( "Dig: " + digito ); console.log( "Sim: " + simbolo ); return ( mayuscula > 0 && minuscula > 0 && digito > 0 && clave.length >= tamanyo_minimo ); } function comprobarPassword( formulario ) { // Tomar los valores del formulario var pass_1 = document.getElementById('clave'); var pass_2 = document.getElementById('clave_repetido'); var error = document.getElementById('informacion-error'); // Comprobar los valores if( pass_1.value == pass_2.value ) { if( comprobarIntegridadPassword( pass_1.value ) ) { return true; } else { error.innerHTML = "Error - Compruebe las claves"; return false; } } else { error.innerHTML = "Error - Compruebe las claves"; return false; } } class DatosEmpresa { constructor() { // Buscar la página de los datos de la empresa this.nombre=document.getElementById("empresa-nombre").value; // this.actividad=document.getElementById("empresa-actividad").value; this.epigrafe=document.getElementById("empresa-epigrafe").value; this.cnae=document.getElementById("empresa-cnae").value; this.contacto=document.getElementById("empresa-contacto").value; this.email=document.getElementById("empresa-email").value; this.telefono=document.getElementById("empresa-telefono").value; this.movil=document.getElementById("empresa-movil").value; this.seguridad_social_autonomo=document.getElementById("empresa-seguridad_social_autonomo").value; this.coberturas_it=document.getElementById("empresa-coberturas_it").value; this.seguridad_social_patronal=document.getElementById("empresa-seguridad_social_patronal").value; this.mutua_accidente_trabajo=document.getElementById("empresa-mutua_accidente_trabajo").value; this.contingencia_enfermedad=document.getElementById("empresa-contingencia_enfermedad").value; this.obligaciones_empresa=document.getElementById("obligaciones-empresa").innerHTML; } } datosEmpresa = null; function almacenarDatosEmpresa() { datosEmpresa = new DatosEmpresa(); console.log( datosEmpresa ); } function analizarCambiosDatosEmpresa() { let datosEmpresaTmp = new DatosEmpresa(); var cambios = false; if( datosEmpresaTmp.nombre != datosEmpresa.nombre ) { cambios = true; }else if( datosEmpresaTmp.epigrafe != datosEmpresa.epigrafe ) { cambios = true; }else if( datosEmpresaTmp.cnae != datosEmpresa.cnae ) { cambios = true; }else if( datosEmpresaTmp.contacto != datosEmpresa.contacto ) { cambios = true; }else if( datosEmpresaTmp.email != datosEmpresa.email ) { cambios = true; }else if( datosEmpresaTmp.telefono != datosEmpresa.telefono ) { cambios = true; }else if( datosEmpresaTmp.movil != datosEmpresa.movil ) { cambios = true; }else if( datosEmpresaTmp.seguridad_social_autonomo != datosEmpresa.seguridad_social_autonomo ) { cambios = true; }else if( datosEmpresaTmp.coberturas_it != datosEmpresa.coberturas_it ) { cambios = true; }else if( datosEmpresaTmp.seguridad_social_patronal != datosEmpresa.seguridad_social_patronal ) { cambios = true; }else if( datosEmpresaTmp.mutua_accidente_trabajo != datosEmpresa.mutua_accidente_trabajo ) { cambios = true; }else if( datosEmpresaTmp.contingencia_enfermedad != datosEmpresa.contingencia_enfermedad ) { cambios = true; }else if( datosEmpresaTmp.obligaciones_empresa != datosEmpresa.obligaciones_empresa ) { cambios = true; }else { cambios = false; } if( cambios == true ) { if( confirm( 'Hay cambios en la ficha. ¿Desea continuar sin guardar?' ) ) { return true; } else { return false; } } return true; }