<?php  session_start(); error_reporting(0); ?>
<?php if(isset($_SESSION['j_admin']) || isset($_SESSION['j_admin'])){ 
    $url = urlencode("http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"); header('location: ../');  
} ?>
<!doctype html>
<html lang="en"> 
<head>
	<?php
    require_once("../j_conn/url.php");
    require_once("../j_conn/dbc.php");
    require_once("../j_incs/functions.php");
    $page_name="Login to your account";
    $page_desc="Enter your credential to get access";
    $page_img="".$dir."j_files/j_img/logo/logo-meta.png";
    $page_author="$company";
    $page_keywords="".$company.", $page_name, $page_desc, ".$company_motto.", $company_desc";
    $page_url="".$dir."login/";
    require_once("../j_incs/metas.php");
    require_once("../j_incs/scripts-top.php");
    ?>
</head>
<body>
    <div class="app">
       
        <div class="container-fluid p-0 h-100">
            <div class="row no-gutters h-100 full-height">
                <?php require_once("../j_incs/slides.php"); //slides ?>
                <div class="col-lg-6 bg-white login_bg">
                    <div class="container h-100">
                        <div class="row no-gutters h-100 align-items-center">
                            <div class="col-md-8 col-lg-8 col-xl-8 mx-auto">
                                <div class="text-center">
                                    <a href="<?php echo $home_dir; ?>">
                                        <img src="<?php echo $dir; ?>j_files/j_img/logo/logo-nav.png" alt="" class="j_logo">
                                    </a>
                                </div>
                                <h2 class="m-b-20"><?php echo $page_name; ?></h2>
                                <?php /*<p class="m-b-30">Enter your credential to get access</p>*/ ?>
                                <form method="POST" action="" id="form">
                                    
                                    <div class="form-group" style="display:none;">
                                         <div class="input-affix">
                                              <input value="<?php echo RMC($_GET['url']); ?>" autocomplete="off" type="text" class="form-control" name="url"/>
                                        </div>
                                    </div>
                                    
                                    <div class="form-group">
                                        <label class="font-weight-semibold" for="username">Username</label>
                                        <div class="input-affix">
                                            <i class="prefix-icon anticon anticon-user"></i>
                                            <!--<input type="text" class="form-control is-valid" id="userName" placeholder="Username">-->
                                            <input value="<?php if(isset($_COOKIE['rememberMe'])){ echo $_COOKIE['rememberMe']; } ?>" autofocus autocomplete="off" type="text" class="form-control rMe" name="username" placeholder="Username">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="font-weight-semibold" for="password">Password</label>
                                        <div class="input-affix m-b-10">
                                            <i class="prefix-icon anticon anticon-lock"></i>
                                            <input type="password" class="form-control passw rMe" name="password" placeholder="Password"/>
                                            <span class="prefix-icon" id="sPass" style="cursor: pointer; margin-left: 87%;">
                                                <i class="anticon anticon-eye"></i>
                                            </span>
                                            <span id="sStatus" style="display:none;">0</span>
                                        </div>
                                        <a class="float-right font-size-13 text-muted" href="<?php echo $dir; ?>forget-password/">Forget Password?</a>
                                    </div>
                                    <div class="form-group">
                                        <div class="form-check">
                                            <input type="checkbox" class="form-check-input" id="rememberMe" name="rememberMe" value="1">
                                            <label class="form-check-label" for="rememberMe">Remember Me</label>
                                        </div>
                                    </div>
                                    <div class="form-group">
										<button id="submit"  name="submit" class="btn btn-lg btn-primary btn-block">
											Login to your account
										</button>
									</div>
                                </form>
                                <div id="formresult"></div>
                            </div>
                        </div>  
                    </div>
                </div>
            </div>
        </div>
    </div>
    <?php
    require_once("../j_incs/scripts-bottom.php");
    ?>
    <script>
        var form = "#form";
        var button = "#submit";
        var button_val = $(button).html();
        var result = "#formresult";
        $(form).on('submit',(function(e) {
        e.preventDefault();
        $(button).attr('disabled', '');
        $(button).html("<i class='anticon anticon-loading'></i> Processing");
        $(result).html("<div class='alert alert-warning'> Taking too long? <a href=''>Reload </a></div>");
         $.ajax({
        url: "save.php",
        type: "POST",
        data: new FormData(this),
        contentType: false,
        cache: false,
        processData:false,
        success: function(data)
        {
        if(data){
         $(button).removeAttr('disabled');
        $(button).html(button_val);
        $(result).html(data);
        }else{
        $(result).html("Error occurred.");
        $(button).removeAttr('disabled');
        $(button).html(button_val);
        }
        }
        });
        }));
        </script>
   
</body>
</html>