<?php
include '../root/config.php';
if ($_SESSION['aid'] != "") {
    ?>
    <script type="text/javascript">
        document.location.href = 'dashboard.php';
    </script>
    <?php
}
?>
<!DOCTYPE html>
<html lang="en" class="loading">

    <!-- Mirrored from pixinvent.com/apex-angular-4-bootstrap-admin-template/html-demo-1/login-page.html by HTTrack Website Copier/3.x [XR&CO'2014], Mon, 18 Jun 2018 15:40:33 GMT -->
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">    
        <meta name="author" content="Accurate Infoway">
        <title>Login Page - <?= SITE_TITLE; ?></title>
        <link href="https://fonts.googleapis.com/css?family=Rubik:300,400,500,700,900|Montserrat:300,400,500,600,700,800,900" rel="stylesheet">        
        <link rel="stylesheet" type="text/css" href="<?= ADMIN_URL; ?>assets/fonts/feather/style.min.css">
        <link rel="stylesheet" type="text/css" href="<?= ADMIN_URL; ?>assets/fonts/simple-line-icons/style.css">
        <link rel="stylesheet" type="text/css" href="<?= ADMIN_URL; ?>assets/fonts/font-awesome/css/font-awesome.min.css">
        <link rel="stylesheet" type="text/css" href="<?= ADMIN_URL; ?>assets/vendors/css/perfect-scrollbar.min.css">
        <link rel="stylesheet" type="text/css" href="<?= ADMIN_URL; ?>assets/vendors/css/prism.min.css">       
        <link rel="stylesheet" type="text/css" href="<?= ADMIN_URL; ?>assets/css/app.css">       
    </head>
    <body data-col="1-column" class=" 1-column  blank-page blank-page">

        <div class="wrapper">
            <div class="main-panel">
                <div class="main-content">
                    <div class="content-wrapper"><!--Login Page Starts-->
                        <section id="login">
                            <div class="container-fluid">
                                <div class="row full-height-vh">
                                    <div class="col-12 d-flex align-items-center justify-content-center">
                                        <div class="card gradient-indigo-purple text-center width-400">
                                            <div class="card-img overlap">
                                                <img alt="element 06" class="mb-1" src="<?= ADMIN_URL; ?>assets/img/portrait/avatars/avatar-08.png" width="190">
                                            </div>
                                            <div class="card-body">
                                                <div class="card-block">
                                                    <h2 class="white">Administrator Login</h2>
                                                    <form>
                                                        <div class="form-group">
                                                            <div class="col-md-12">
                                                                <input type="text" class="form-control" name="inputUsername" id="inputUsername" placeholder="Username" required >
                                                            </div>
                                                        </div>

                                                        <div class="form-group">
                                                            <div class="col-md-12">
                                                                <input type="password" class="form-control" name="inputPass" id="inputPass" placeholder="Password" required>
                                                            </div>
                                                        </div>

                                                        <div class="form-group">
                                                            <div class="row">
                                                                <div class="col-md-12">
                                                                    <div class="custom-control custom-checkbox mb-2 mr-sm-2 mb-sm-0 ml-3">
                                                                        <input type="checkbox" class="custom-control-input" checked id="rememberme">
                                                                        <label class="custom-control-label float-left white" for="rememberme">Remember Me</label>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>

                                                        <div class="form-group">
                                                            <div class="col-md-12">
                                                                <button type="button" class="btn btn-pink btn-block btn-raised" id="login-btn">Submit</button>
                                                                <!--                                                                <button type="button" class="btn btn-secondary btn-block btn-raised">Cancel</button>-->
                                                            </div>
                                                        </div>
                                                    </form>
                                                </div>
                                            </div>
                                            <!--                                            <div class="card-footer">
                                                                                            <div class="float-left"><a (click)="onForgotPassword()" class="white">Recover Password</a></div>
                                                                                            <div class="float-right"><a (click)="onRegister()" class="white">New User?</a></div>
                                                                                        </div>-->
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </section>
                        <!--Login Page Ends-->
                    </div>
                </div>
            </div>
        </div>

        <script src="<?= ADMIN_URL; ?>assets/vendors/js/core/jquery-3.2.1.min.js" type="text/javascript"></script>
        <script src="<?= ADMIN_URL; ?>assets/vendors/js/core/popper.min.js" type="text/javascript"></script>
        <script src="<?= ADMIN_URL; ?>assets/vendors/js/core/bootstrap.min.js" type="text/javascript"></script>
        <script src="<?= ADMIN_URL; ?>assets/vendors/js/perfect-scrollbar.jquery.min.js" type="text/javascript"></script>
        <script src="<?= ADMIN_URL; ?>assets/vendors/js/prism.min.js" type="text/javascript"></script>
        <script src="<?= ADMIN_URL; ?>assets/vendors/js/jquery.matchHeight-min.js" type="text/javascript"></script>
        <script src="<?= ADMIN_URL; ?>assets/vendors/js/screenfull.min.js" type="text/javascript"></script>
        <script src="<?= ADMIN_URL; ?>assets/vendors/js/pace/pace.min.js" type="text/javascript"></script>
        <script src="<?= ADMIN_URL; ?>assets/js/app-sidebar.js" type="text/javascript"></script>
        <script src="<?= ADMIN_URL; ?>assets/js/notification-sidebar.js" type="text/javascript"></script>
        <script src="<?= ADMIN_URL; ?>assets/js/customizer.js" type="text/javascript"></script>
        <script>
        $(document).ready(function () {
            $("#login-btn").click(function () {
                var loginUname = $("#inputUsername").val();
                var loginPassword = $("#inputPass").val();
                if (loginUname == '')
                {
                    alert("Please Enter Username!");
                    $("#inputUsername").focus();
                    return false;
                }
                if (loginPassword == '')
                {
                    alert("Please Enter Password!");
                    $("#inputPass").focus();
                    return false;
                }
                $.ajax({
                    type: "POST",
                    url: "ajax.php",
                    data: {
                        action: "login",
                        loginUname: loginUname,
                        loginPassword: loginPassword
                    },
                    success: function (data)
                    {
                        if (data == "success")
                        {
                            document.location.href = 'dashboard.php';
                        }
                        else if (data == "not active")
                        {
                            alert('Your account is not active. Please contact administrator for that.');
                        }
                        else
                        {
                            alert('Wrong Username OR Password!');
                        }
                    },
                    error: function ()
                    {
                        alert('Error while contacting server, please try again');
                    }
                });
            });
        });
        </script>
    </body>
</html>
