<?php
require_once('../redd/lib/table-traits.php');
require_once('../redd/lib/basic-function.php');
require_once('../' . $basicFunctn->admin_url . '/lib/mailing/emails.php');
require_once('../' . $basicFunctn->admin_url . '/lib/user-functions.php');

if (!isset($_GET['em'])) {
    header("location:../en/");
}
if ($_GET['ip'] !== 'fd62b6b32557a22a8682d674ec478407') {
    header("location:../en/");
}
$user_exist = $basicFunctn->selectWhereDlt($basicFunctn->user_tb,'email',$_GET['em']);
if(count($user_exist) < 1){
    header("location:../en/");
}
$full_name = explode('++', $user_exist[0]['full_name']);
$first_name = $full_name[0];
$last_name = $full_name[1];
// print_r($user);die();
$title = 'Reset Password';
require_once('head-auth.php') ?>

<body>

    <div class="uk-grid-collapse uk-flex" style="height: 100vh;" data-uk-grid>
        <div class="uk-width-1-2@m uk-padding-large uk-flex uk-flex-middle uk-flex-center" data-uk-height-viewport>
            <div class="uk-width-3-4@s">
                <div class="uk-text-center uk-margin-bottom">
                    <a class="uk-logo uk-text-primary uk-text-bold"></a>
                    <!-- <img src="assets/images/New/logo3.png" alt="" href="./"> -->
                </div>
                <div class="uk-text-center text-theme">
                    <h2>Reset Your Password</h2>
                </div>
                <div class="uk-text-center uk-margin">
                    <p class="uk-margin-remove">Enter a new password below</p>
                </div>
                <form class="reset_password_form">
                                    <input type="hidden" name="reset_password_user_id" value="<?php print $user_exist[0]['unique_id'] ?>">
                    <div class="uk-width-1-1 uk-margin">
                        <!-- <label class="uk-form-label" for="email">Email</label> -->
                        <input class="uk-input uk-form-large" disabled type="email" value="<?php print ucwords($first_name . ' ' . $last_name); ?>" placeholder="full name">
                    </div>
                    <div class="uk-width-1-1 uk-margin">
                        <!-- <label class="uk-form-label" for="email">Email</label> -->
                        <input class="uk-input uk-form-large" type="password" name="password" placeholder="Enter password">
                    </div>
                    <div class="uk-width-1-1 uk-margin">
                        <!-- <label class="uk-form-label" for="email">Email</label> -->
                        <input class="uk-input uk-form-large" type="password" name="c_password" placeholder="Confirm password">
                    </div>
                    <div class="uk-width-1-1 uk-margin uk-text-right">
                        <p class="uk-text-small uk-margin-remove"><a class="uk-link-border" href="./">Home</a></p>
                    </div>
                    <div class="uk-width-1-1 uk-text-center">
                        <a class="uk-button uk-button-primary uk-button-large reset_password_btn">
                            Submit
                        </a>
                    </div>

                    <!-- <div class="uk-width-1-1 uk-margin uk-text-center">
                        <h6 class="uk-text-small uk-margin-remove">Don't have an account? <a class="uk-link-border " href="register">Sign Up</a> </h6>
                    </div> -->
                </form>
            </div>
        </div>
        <div class="uk-width-1-2@m right-cover uk-padding-large uk-flex uk-flex-middle uk-flex-center uk-light
    uk-background-cover uk-background-norepeat uk-background-blend-overlay uk-overlay-blend" style="background-image: url(assets/images/New/anonymous.jpg);" data-uk-height-viewport>
            <div>
                <!-- <div class="uk-text-center">
                    <h2 class="uk-h1 uk-letter-spacing-small text-white">Get Started with the best trading platform there is.</h2>
                </div>
                <div class="uk-margin-top uk-margin-medium-bottom uk-text-center">
                    <p>Get started with the best trading platform there is:</p>
                </div> -->
                <!-- <div class="uk-width-1-1 uk-text-center">
        <a href="sign-in.html" class="uk-button uk-button-primary uk-button-large">Sign In</a>
      </div> -->
            </div>
        </div>
    </div>

    <!-- customs scripts starts -->
    <?php require_once('scripts-auth.php') ?>
    <!-- dashboard js ends -->

    <script>
        $(document).ready(function() {

            let referrer = $('.referrer').text();
            if (referrer.length !== 0) {
                $('.registerModal').modal('show');
            }



            $('.reset_password_btn').click(async function(e) {
                e.preventDefault();
                let reset_password_form = $('.reset_password_form').serializeArray();
                let form_data = set_form_data(reset_password_form);
                // console.log(reset_password_form);return;
                let returned = await ajaxRequest('ajax.php', form_data);
                // console.log(returned);return;
                throwSweetalert(returned, './', 1);
            });
            // $('.forgot_pass_btn').click(async function(e) {
            //     e.preventDefault();
            //     let forgot_pass_form = $('.forgot_pass_form').serializeArray();
            //     let form_data = set_form_data(forgot_pass_form);
            //     // console.log(forgot_pass_form);return;
            //     let returned = await ajaxRequest('ajax.php', form_data);
            //     // console.log(returned);return;
            //     if (returned.error == 1) {
            //         Swal.fire("Sorry", returned.msg, "error");
            //     } else if (returned.error == 0) {
            //         Swal.fire("Congratulations!", returned.msg, "success");
            //         // swal('Congratulations', returned.msg + returned.first_name, 'success');
            //         setTimeout(() => {
            //             window.location.href = './account-recovery';
            //         }, 3000);
            //     }
            // });

        });
    </script>

</body>

</html>