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

<head>
    <link rel="stylesheet" href="https://partners.archlinexp.com/public/css/bootstrap/bootstrap.min.css">
    <link rel="stylesheet" href="https://partners.archlinexp.com/public/css/site.css">

    <meta charset="utf-8" name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Resource Manager - Login</title>
</head>

<body>
    <br />

    <?php if (isset($error) != '') : ?>
        <div class="alert alert-warning" role="alert">
            <?= $error ?>
        </div>
    <?php endif; ?>

    <div class="container center login-container">
        <br />

        <form action="" method="post" onsubmit="checkCookie()">
            <div class="row">
                <div class="col-md-3">

                </div>
                <div class="col-md-6 bordered-div">
                    <div class="div-header" style="text-align: center;">
                        Login to your account
                    </div>

                    <div class="row">
                        <div class="col-md-3">
                            Username:
                        </div>

                        <div class="col-md-8">
                            <input type="text" autocomplete="username" class="form-control" id="username" name="username" value="<?= $username ?>" required>
                        </div>
                    </div>
                    <br>
                    <br>

                    <div class="row">
                        <div class="col-md-3">
                            Password:
                        </div>

                        <div class="col-md-8">
                            <input type="password" autocomplete="current-password" class="form-control" name="password" required>
                        </div>
                    </div>
                    <br>
                    <br>

                    <div class="row">
                        <div class="col-md-3">

                        </div>

                        <div class="col-md-1" style="margin-top: -13px;">
                            <input type="checkbox" class="form-control" id="remember" name="remember" <?= isset($_COOKIE["remember_me"]) ? 'checked' : '' ?>>
                        </div>

                        <div class="col-md-3">
                            <label for="remember">Remember me</label>
                        </div>
                    </div>
                    <br>
                    <br>

                    <div class="row">
                        <div class="col-md-5">

                        </div>
                        <div class="col-md-4">
                            <input type="submit" id="login-btn" name="login-btn" value="Login" class="btn btn-primary btn-lg">
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>

    <script type="text/javascript">
        document.getElementById("username").focus();

        function checkCookie() {
            var checkBox = document.getElementById("remember");
            var username = document.getElementById("username").value;

            if (checkBox.checked == true)
                document.cookie = "access_id=" + username + "; expires=Thu, 18 Dec 9999 12:00:00 UTC; path=/";
        }
    </script>
</body>

</html>