<!DOCTYPE html>
<html lang="en">

<head>
<title>Login</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">

<link rel="icon" type="image/png" href="images/icons/favicon.ico" />

<link rel="stylesheet" type="text/css" href="vendor/bootstrap/css/bootstrap.min.css">

<link rel="stylesheet" type="text/css" href="fonts/font-awesome-4.7.0/css/font-awesome.min.css">

<link rel="stylesheet" type="text/css" href="fonts/iconic/css/material-design-iconic-font.min.css">

<link rel="stylesheet" type="text/css" href="vendor/animate/animate.css">

<link rel="stylesheet" type="text/css" href="vendor/css-hamburgers/hamburgers.min.css">

<link rel="stylesheet" type="text/css" href="vendor/animsition/css/animsition.min.css">

<link rel="stylesheet" type="text/css" href="vendor/select2/select2.min.css">

<link rel="stylesheet" type="text/css" href="vendor/daterangepicker/daterangepicker.css">

<link rel="stylesheet" href="css/sweetalert2.bundle.css">

<link rel="stylesheet" type="text/css" href="css/util.css">
<link rel="stylesheet" type="text/css" href="css/main.css">

</head>
<body>
	<div class="container-login100" style="background-image: url('images/b3.jpg');">
		<div class="wrap-login100 p-l-55 p-r-55 p-t-80 p-b-30" style="background-color:rgba(255,255,255,0.9);">
		<form class="login100-form validate-form">
		<span class="login100-form-title p-b-37">
		    Password Recovery
		</span>
		<div class="wrap-input100 validate-input m-b-20" data-validate="Enter username or email">
			<input class="input100" type="text" name="username" id="username" placeholder="phone or email">
			<span class="focus-input100"></span>
		</div>
		<div class="container-login100-form-btn">
			<button class="login100-form-btn" id="btn_login">
				<span class="btn_display">Send Password </span>
				<div class="process d-none">
					<div class="spinner-grow spinner-grow-sm text-light">
						<span class="sr-only"> ...</span>
					</div>
				</div>
			</button>
			
		</div>
		<div class="text-center p-t-57 p-b-20">
			<span class="txt1">
			<a href="index.php">Back to Login?</a>
			</span>
	</div>


<script src="vendor/jquery/jquery-3.2.1.min.js"></script>

<script src="vendor/animsition/js/animsition.min.js"></script>

<script src="vendor/bootstrap/js/popper.js"></script>
<script src="vendor/bootstrap/js/bootstrap.min.js"></script>

<script src="vendor/select2/select2.min.js"></script>

<script src="vendor/daterangepicker/moment.min.js"></script>
<script src="vendor/daterangepicker/daterangepicker.js"></script>

<script src="vendor/countdowntime/countdowntime.js"></script>
<script src="js/sweetalert2.bundle.js"></script>
<script src="js/main.js"></script>

<script>
$(document).ready(function(){
	$('#btn_login').click(function(e){
		$('.btn_display').text('Please Wait ');
		$('.process').removeClass('d-none');
		e.preventDefault();
		let username = $('#username').val();
		let serverData = {
			username:username,
			recovery:''
		}
		$.post('../controller/loginCode.php',serverData,function(serverResponse){
            console.log(serverResponse)
            if(serverResponse){
                let response = JSON.parse(serverResponse);
                if(response.data=="success"){
                    Swal.fire(
                    {
                        type: "success",
                        title: "New Password has been sent to your Email and Phone",
                        showConfirmButton: false,
                        timer: 2500
                    });
                    $('.btn_display').text('Resend Password ');
                    $('.process').addClass('d-none');
                }else if(response.data=="fail"){
                    $('.btn_display').text('Send Password ');
                    $('.process').addClass('d-none');
                    Swal.fire(
                    {
                        type: "error",
                        title: "Could not find Account ! Please try again",
                        showConfirmButton: false,
                        timer: 2500
                    });
                }else{
                    $('.btn_display').text('Send Password ');
                    $('.process').addClass('d-none');
                    Swal.fire(
                    {
                        type: "error",
                        title: "Internal Error!",
                        showConfirmButton: false,
                        timer: 2500
                    });
                }
            }else{
                $('.btn_display').text('Send Password ');
                $('.process').addClass('d-none');
                Swal.fire(
                {
                    type: "error",
                    title: "Internal Error!",
                    showConfirmButton: false,
                    timer: 2500
                });
            }
		});
	});
});
</script>

</body>

</html>
