$(document).ready(function(){ var ocupado = 0; var timeSlide = 1000; $('#timer').hide(0); //por el momento no mostramos el ajax $('#timer').css('display','none'); $('#loginfrm').submit(function(e){ e.preventDefault(); $(".entrain").prop('disabled', true); //posicionamos el ajax de cero a 300 en fade $('#timer').fadeIn(300); //mostramos las clases creadas dentro del css para mostrar los mensajes $('.box-info, .box-success, .box-alert, .box-error').slideUp(timeSlide); //configuramos y creamos la condicion if ( $('#login_username').val() != "" && $('#login_userpass').val() != "" ){ setTimeout(function(){ $.ajax({ type: 'POST', url: 'sections/signin.php', data: $('#login_username').attr("name")+'=' + $('#login_username').val() + '&'+$('#login_userpass').attr("name")+'=' + $('#login_userpass').val()+'&'+$("#loglevel").attr("name")+"="+$("#loglevel").val(), //si la sesion se inicia correctamente presentamos el mensaje success:function(msj){ if ( msj.status == 1 ){ //console.log(msj); $('#alertBoxes').html('
'); $('.box-success').hide(0).html('Espera un momento…'); $('.box-success').slideDown(timeSlide); setTimeout(function(){ if(msj.changed == 1){ window.location.href = "socios/home"; }else{ window.location.href = "socios/preferencias"; } },(timeSlide + 500)); } else if ( msj.status == 4 ){ $(".entrain").prop('disabled', false); $('#alertBoxes').html(''); $('.box-error').hide(0).html('Lo sentimos, pero no tiene permiso para acceder a la página'); setTimeout(function(){ window.location.href = "home"; },(timeSlide + 1000)); $('.box-error').slideDown(timeSlide); } //caso contrario los datos son incorrectos else{ $(".entrain").prop('disabled', false); $('#alertBoxes').html(''); $('.box-error').hide(0).html('Lo sentimos, pero los datos son incorrectos '); setTimeout(function(){ window.location.href = "home"; },(timeSlide + 1000)); $('.box-error').slideDown(timeSlide); } $('#timer').fadeOut(300); }, //si se pierden los datos presentamos error de ejecucion. error:function(e1,e2,e3){ console.log(e1); console.log(e2); console.log(e3); $(".entrain").prop('disabled', false); $('#timer').fadeOut(300); $('#alertBoxes').html(''); $('.box-error').hide(0).html('Ha ocurrido un error durante la ejecución'); $('.box-error').slideDown(timeSlide); } }); },timeSlide); //caso cantrario si los campos estan vacios debemos llenarlos } else { $(".entrain").prop('disabled', false); $('#alertBoxes').html(''); $('.box-error').hide(0).html('Los campos están vacíos'); $('.box-error').slideDown(timeSlide); $('#timer').fadeOut(300); } return false; }); $("#btnrecuperarp").click(function(event){ event.preventDefault(); dialogo($("#recuperarp").html(),"Recuperación de contraseña"); $(".correoRecuperacion").val( $("#login_username").val() ); $(".f-recuperarp").submit( function( event ) { event.preventDefault(); if(ocupado == 0){ var value1 = $(this).find('.correoRecuperacion').val(); //console.log(email1); $('.recuperarLoading').show('fast'); ocupado = 1; if(value1){ $.ajax({ type: 'POST', url: 'sections/recupera.php', data: {'nsocioRecuperacion': value1}, success:function(msj){ //console.log(msj); alert(msj.msg); if( (msj.status*1) == 1 ){ $('.correoRecuperacion').val(''); $('.bootbox-alert.fade.in .bootbox-close-button').click(); } $('.recuperarLoading').hide('fast'); ocupado = 0; }, error:function(e1,e2,e3){ console.log(e1); console.log(e2); console.log(e3); alert('Hubo un error, inténtelo de nuevo más tarde'); $('.recuperarLoading').hide('fast'); ocupado = 0; } }); }else{ alert('Introduzca su número de socio'); $('.recuperarLoading').hide('fast'); ocupado = 0; } } }); }); $("#btnnumsociohelp").click(function(event){ event.preventDefault(); dialogo($("#numerodesociohelp").html(),"Ayuda: Identifica tu número de socio"); }); });