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

<?php
require_once "config.php";

if (isset($_SESSION['user_id'])) {
    echo "<script>location.href='myProfile';</script>";
}

?>

<head>
    <meta charset="utf8" />
    <title>Employee - Jobaaj </title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta content="A fully featured admin theme which can be used to build CRM, CMS, etc." name="description" />
    <meta content="Coderthemes" name="author" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />

    <!-- Favicon -->
    <link rel="shortcut icon" href="https://cdn.nishtyainfotech.com/content/jobaaj/assets/img/jobaaj-favicon.ico">

    <!-- App css -->
    <link href="assets/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
    <link href="assets/css/icons.min.css" rel="stylesheet" type="text/css" />
    <link href="assets/css/app.min.css" rel="stylesheet" type="text/css" />

</head>

<body class="authentication-bg">

    <div class="account-pages my-5">
        <div class="container">
            <div class="row justify-content-center">
                <div class="col-xl-10">
                    <div class="card">
                        <div class="card-body p-0">
                            <div class="row">
                                <div class="col-6 p-5">
                                    <div class="mx-auto mb-3 text-center">
                                        <a href="javascript:;" class="text-center">
                                            <img src="https://cdn.nishtyainfotech.com/content/jobaaj/assets/svg/logos/jobaaj1.png" alt="" width="100" />
                                            <!-- <h3 class="d-inline align-middle ml-1 text-logo">Jobaaj</h3> -->
                                        </a>
                                    </div>

                                    <h6 class="h5 mb-0 mt-4">Reset Password</h6>
                                    <p class="text-muted mt-1 mb-5">
                                        Enter your email address and we'll send you an email with instructions to reset your password.
                                    </p>

                                    <form action="#" class="authentication-form">
                                        <div class="form-group">
                                            <label class="form-control-label">Email Address</label>
                                            <div class="input-group input-group-merge">
                                                <div class="input-group-prepend">
                                                    <span class="input-group-text">
                                                        <i class="icon-dual" data-feather="mail"></i>
                                                    </span>
                                                </div>
                                                <input type="email" class="form-control" id="email" placeholder="hello@coderthemes.com">
                                            </div>
                                            <p class="mt-1 text-danger" id="fillMail"></p>
                                        </div>

                                        <div class="form-group mb-0 text-center">
                                            <button class="btn btn-primary btn-block" id="forgotMail" type="button">
                                                <div class="spinner-border text-light d-none" style="width:1rem; height:1rem;" id="spinnerHide" role="status"></div>
                                                Send
                                            </button>
                                        </div>
                                        <p class="mt-2 text-center text-success" id="sendMail"></p>
                                    </form>
                                </div>
                                <div class="col-lg-6 d-none d-md-inline-block">
                                    <div class="auth-page-sidebar">
                                        <div class="overlay"></div>
                                        <div class="auth-user-testimonial">
                                            <p class="font-size-24 font-weight-bold text-white mb-1">I simply love it!</p>
                                            <p class="lead">"It's a elegent templete. I love it very much!"
                                            </p>
                                            <p>- Admin User</p>
                                        </div>
                                    </div>
                                </div>
                            </div>

                        </div> <!-- end card-body -->
                    </div>
                    <!-- end card -->

                    <div class="row mt-3">
                        <div class="col-12 text-center">
                            <p class="text-muted">Back to <a href="index" class="text-primary font-weight-bold ml-1">Login</a></p>
                        </div> <!-- end col -->
                    </div>
                    <!-- end row -->

                </div> <!-- end col -->
            </div>
            <!-- end row -->
        </div>
        <!-- end container -->
    </div>
    <!-- end page -->

    <!-- Vendor js -->
    <script src="assets/js/vendor.min.js"></script>

    <!-- App js -->
    <script src="assets/js/app.min.js"></script>

    <script>
        const validateEmail = (email) => {
            return String(email)
                .toLowerCase()
                .match(
                    /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
                );
        };
        $("#forgotMail").click(function() {

            let mail = $("#email").val();

            if (mail != '') {
                if (validateEmail(mail)) {

                    $("#spinnerHide").removeClass("d-none");
                    $.ajax({
                        url: "fun/function",
                        type: "POST",
                        data: {
                            forgotPasswordFunction: mail
                        },
                        success: function(response) {
                            console.log(response);
                            if (response == 1) {
                                $("#fillMail").html('This email is not exist.');
                            } else {

                                $("#spinnerHide").addClass("d-none");
                                $("#fillMail").html('');
                                $("#sendMail").html('Email Send Successfully !');
                            }
                        }
                    });
                } else {
                    $("#fillMail").html('Please, Enter valid email address !');
                }
            } else {
                $("#fillMail").html('Please, Fill the email address !');
            }
        })
    </script>

</body>

</html>