<?php require_once('./config.php') ?>
<!DOCTYPE html>
<html lang="es">
<?php require_once('inc/header.php') ?>
<body class="hold-transition">

<script>start_loader()</script>

<style>
html, body{height:100%; background:#f2f2f2;}
.btn-primary{
    background:#b71c1c !important;
    border-color:#b71c1c !important;
}
.card-outline.card-primary{
    border-top:3px solid #b71c1c !important;
}
a{color:#b71c1c !important;}
</style>

<div class="min-vh-100 d-flex align-items-center justify-content-center">

    <div class="card col-md-4 card-outline card-primary shadow">
        <div class="card-header text-center">
            <h4><b>Acceso SGPPBN</b></h4>
        </div>

        <div class="card-body">
            <form id="elogin-frm">

                <div class="form-group">
                    <input type="email" name="email" class="form-control"
                           placeholder="Correo institucional" required>
                </div>

                <div class="form-group">
                    <input type="password" name="password" class="form-control"
                           placeholder="Contraseña" required>
                </div>

                <button type="submit" class="btn btn-primary btn-block">
                    Ingresar
                </button>

            </form>
        </div>
    </div>

</div>

<!-- Scripts -->
<script src="plugins/jquery/jquery.min.js"></script>
<script src="plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
<script src="dist/js/adminlte.min.js"></script>

<script>
$(function(){
    end_loader();

    $('#elogin-frm').submit(function(e){
        e.preventDefault();

        $.ajax({
            url: _base_url_ + "classes/Login.php?f=login",
            method: "POST",
            data: {
                email: $('[name="email"]').val(),
                password: $('[name="password"]').val()
            },
            dataType: "json",
            success: function(resp){
                if(resp.status === 'success'){
                    location.href = _base_url_ + (resp.redirect ?? '');
                }else{
                    alert(resp.msg);
                }
            },
            error: function(){
                alert("Error de conexi��n");
            }
        });
    });
});
</script>

</body>
</html>
