<?php
	session_start();	
	
	if( $_POST["user"] != "" &&  $_POST["password"] != "" ){

		include("models/connect.php");
		$query = mysqli_query($connect,"SELECT * FROM Usuarios WHERE correo = '".$_POST["user"]."' AND pass = '".$_POST["password"]."' ");
		if($query->num_rows > 0){
			$data = mysqli_fetch_array($query);
			
			$_SESSION['id_user_admin'] = $data["id"];
			$_SESSION['nombre_admin'] = $data["nombre"];
            $_SESSION['role_admin'] = $data["role"];
			header('Location: '.$url.'/admin/' );
		}
		else{
			$respuesta = '
			<div class="alert alert-danger">
			  <strong>Algo va mal!</strong> Credenciales Inválidas .
			</div>
			';
		}
	}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ACROSS T2D Administrador</title>

<link rel="stylesheet" href="css/bootstrap.css" crossorigin="anonymous">
<link rel="stylesheet" href="css/style.css" crossorigin="anonymous">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" crossorigin="anonymous">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="js/bootstrap.bundle.js" crossorigin="anonymous"></script>
<script src="js/bootstrap.js" crossorigin="anonymous"></script>

<style>
body{
	background-color: #efeff5;
	font-size:13px;
	background-image: url(img/bg.jpg);
    background-size: 150%;
}
</style>

</head>

<body style="background-size: cover; background-attachment: fixed; background-position: center">



<!-- CONTENIDO -->
<div class="container rounded-bottom" style="background-color:#f9f9fc; box-shadow: 0px 0px 10px rgba(0,0,0,0.1);">	
	<div class="row" style="margin-top: 30px;">
        <div align="center" style="background: rgb(0,180,138);
    background: linear-gradient(90deg, rgba(0,180,138,1) 0%, rgba(0,121,190,1) 24%, rgba(0,178,139,1) 100%); padding: 15px; width: 100%;">
			<img src="img/logo_our_north_co.png" width="90%" style="margin-top:25px" />
		</div>
		
		<div class="col-md-12" style=" background-color: #ffffff; padding-bottom:15px">	
        
        	
            <h5 style="text-align:center">Iniciar Sesión</h5>
        	<div style="padding-top:20px; padding-bottom:20px; text-align:center"></div>
			<?php echo $respuesta; ?>
            <form action="" method="post">
              <div class="form-group">
                <label for="exampleInputEmail1">Ingrese Usuario</label>
                <input type="email" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" placeholder="Correo" name="user">
                <small id="emailHelp" class="form-text text-muted">Ingrese el correo registrado en la plataforma.</small>
              </div>
              <div class="form-group">
                <label for="exampleInputPassword1">Ingrese contraseña</label>
                <input type="password" class="form-control" id="exampleInputPassword1" placeholder="Password" name="password">
              </div>
              <div align="right">
                <button type="submit" class="btn btn-success">Ingresar</button>
              </div>
            </form>
        	
    	</div>

    </div>
</div>


<style>
.container{
	max-width:500px;
}

.list-group-item.active {
    background-color: #2f2e01;
    border-color: #2f2e01;
}

</style>


</body>
</html>