<?php
include('./dao/auto_load.php');
if (isset($_SESSION['id_usuario'])) {
    \Dao\Funcoes::redireciona('./');
    return;
}
?>
<!DOCTYPE html>
<html lang="pt-Br">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <title>.:: Painel Visual Prime --</title>
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="robots" content="all,follow">
        <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700">
        <link rel="stylesheet" href="assets/css/bootstrap.css">
        <link rel="stylesheet" href="assets/css/custom.min.css">
        <link rel="stylesheet" href="assets/css/style.default.css">
        <link rel="shortcut icon" href="../img/logo-vp.png" type="image/png">
        <link rel="apple-touch-icon" href="../img/logo-vp.png" type="image/png" sizes="1270x861">
        <!--[if lt IE 9]>
            <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
            <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
        <![endif]-->
    </head>
    <body>
        <div class="page login-page">
            <div class="container">
                <div class="form-outer text-center d-flex align-items-center">
                    <div class="form-inner">
                        <div class="logo text-uppercase"><span>Painel</span> <strong class="text-primary">Visual Prime</strong></div>
                        <p>Informe seus dados abaixo para efetuar o login no painel gerenciador do Sistema da Visual Prime</p>
                        <form id="login-form" method="post" action="php/login.php">
                            <div class="form-group">
                                <label for="login-username" class="label-custom">Usuário</label>
                                <input id="login-username" type="text" name="usuario" required>
                            </div>
                            <div class="form-group">
                                <label for="login-password" class="label-custom">Senha</label>
                                <input id="login-password" type="password" name="senha" required>
                            </div>
                            <button id="login" class="btn btn-sm btn-primary">Login</button>
                        </form>
                    </div>
                </div>
            </div>
        </div>
        <script src="assets/js/jquery-3.2.1.min.js"></script>
        <script src="assets/js/popper.js"></script>
        <script src="assets/js/bootstrap.js"></script>
        <script src="assets/js/confirm.min.js"></script>
        <script src="assets/js/parsley.js"></script>
        <script src="assets/js/parsley_pt-br.js"></script>
        <script src="assets/js/front.js"></script>
    </body>
</html>
<?php
$message = '';
switch (filter_input(INPUT_GET, 'msg')) {
    case 'no-token':
        $message = 'Não foi informado o token de segurança!';
        break;
    case 'invalid-token':
        $message = 'Token de segurança informado é inválido!';
        break;
    case 'invalid-user':
        $message = 'Erro ao efetuar login! Verifique usuário e senha!';
        break;
}
if ($message != '') {
    echo '
        <script type="text/javascript">
            $(function(){
                $.alert({
                    title: "Erro",
                    content: "' . $message . '",
                    type: "red",
                    buttons: {
                        Ok: function () {}
                    }
                });
            });
        </script>
    ';
}