function SendForgetPwdMail()
{
var userPhone = $.trim($('#user_phone').val());
/*var userEmail = $.trim($('#user_email').val());*/
if(userPhone =='')
{
ShowMsg('error', "Please enter your registered phone no.");
$('#user_phone').focus();
return false;
}
/*if(userEmail =='')
{
ShowMsg('error', "Please enter your registered email id.");
$('#user_email').focus();
return false;
}*/
$('#sendmail_submit').text('Please Wait...').attr('disabled', true);
$.ajax({
url:"page_ajax/forgot_password_ajax.php",
type:"POST",
data:{
operation:"SendForgetPwdMail",
userPhone:userPhone
},
success:function(data)
{
data = $.trim(data);
//alert(data);
if(data == 'Success')
{
$('#sendMailPanel').hide();
$('#verifyTempPwdPanel').show();
$('#resetPwdPanel').hide();
$('#divStepsPanel').children('div').find('h4 > i').removeClass("fa-arrow-right");
$('#divStepsPanel').find("div:eq(1)").find('i').addClass("fa-arrow-right");
ShowMsg('success', "An email has been sent to you. Please check your mail box.");
}
else
{
ShowMsg('error', "Something went wrong. Please contact your system Administrator.");
}
$('#sendmail_submit').text('Submit').removeAttr('disabled');
}
})
}
function VerifyTmpPwd()
{
$('#login_verify_submit').text('Please Wait...').attr('disabled', true);
var v_user_phone = $.trim($('#v_user_phone').val());
var v_tmp_pwd = $.trim($('#v_tmp_pwd').val());
$.ajax({
url:"page_ajax/forgot_password_ajax.php",
type:"POST",
data:{
operation: "VerifyTmpPwd",
v_user_phone :v_user_phone,
v_tmp_pwd: v_tmp_pwd
},
success:function(data)
{
data = $.trim(data);
//cwlAlert(data);
if(data)
{
var dataObj = $.parseJSON(data);
var userId = dataObj.user_login_id;
var businessId = dataObj.business_id;
$('#hdnUserId').val(userId);
$('#hdnBusinessId').val(businessId);
$('#sendMailPanel').hide();
$('#verifyTempPwdPanel').hide();
$('#resetPwdPanel').show();
$('#divStepsPanel').children('div').find('h4 > i').removeClass("fa-arrow-right");
$('#divStepsPanel').find("div:eq(2)").find('i').addClass("fa-arrow-right");
ShowMsg('success', "Reset your password now.");
}
else
{
ShowMsg('error', "Something went wrong.");
}
$('#login_verify_submit').text('Submit').removeAttr('disabled');
}
})
}
function ResetPassword()
{
var userId = $('#hdnUserId').val();
var businessId = $('#hdnBusinessId').val();
var r_password = $.trim($('#r_password').val());
var r_conf_password = $.trim($('#r_conf_password').val());
if(r_password != r_conf_password)
{
ShowMsg('error', "Password and confirm password does not match.");
return false;
}
$('#reset_pwd_submit').text('Please Wait...').attr('disabled', true);
$.ajax({
url:"page_ajax/forgot_password_ajax.php",
type:"POST",
data:{
operation: "ResetPassword",
r_password :r_password,
r_conf_password: r_conf_password,
userId: userId,
businessId: businessId
},
success:function(data)
{
data = $.trim(data);
if(data)
{
$('#r_password').val('');
$('#r_conf_password').val('');
ShowMsg('success', "your password has been changed. Click here to login");
setTimeout(function(){ location.href = "lab_login"; }, 4000);
}
else
{
ShowMsg('error', "Something went wrong.");
}
$('#reset_pwd_submit').text('Submit').removeAttr('disabled');
}
})
}
function ShowMsg(type, msg)
{
$('#msgAlert').removeClass('alert-danger');
$('#msgAlert').removeClass('alert-success');
if(type == 'success')
{
$('#msgAlert').addClass('alert-success');
$('#spnMsg').html('Success: '+msg);
}
if(type == 'error')
{
$('#msgAlert').addClass('alert-danger');
$('#spnMsg').html('Oops: '+msg);
}
$('#msgAlert').slideDown();
setTimeout(function(){$('.alert').slideUp();}, 5000);
}