<?php
session_start();

require_once("Class/class.pdo.php");

$pdo = new PdoGsb();

/**
 * Direction si non renseigné et non connecté
 */
if (!isset($_REQUEST['direction']) && !isset($_SESSION['uId'])) {
	$_REQUEST['direction'] = 'connexion';
} elseif (!isset($_REQUEST['direction']) && isset($_SESSION['uId'])) {
	$_REQUEST['direction'] = 'home';
}

?>
<!DOCTYPE html>
<html lang="fr">

<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>Page accueil</title>
	<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet"
		integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
	<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"
		integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL"
		crossorigin="anonymous"></script>
	<script src="https://code.jquery.com/jquery-3.7.1.js"
		integrity="sha256-eKhayi8LEQwp4NKxN+CfCh+3qOVUtJn3QNZ0TciWLP4=" crossorigin="anonymous"></script>
</head>

<body>
	<div class="container-fluid">
		<div class="row flex-nowrap">
			<?php
			if (!isset($_SESSION['uId'])) {
				$_REQUEST['direction'] = 'connexion';
			} else {
				include('include/menu.php');
			}
			?>
			<div class="col py-3">
				<?php
				switch ($_REQUEST['direction']) {
					case 'connexion':
						include("controleurs/c_connexion.php");
						break;

					case 'gestionFiche':
						include(__DIR__ . "/controleurs/c_gestionFiche.php");
						break;

					case 'home':
						include("controleurs/c_homePage.php");
						break;

					case 'nouvelleFiche':
						include(__DIR__ . "/controleurs/c_nouvelleFiche.php");
						break;

					case 'ficheAvalider':
						include(__DIR__ . "/controleurs/c_ficheAvalider.php");
						break;

					default:
						include("controleurs/c_homePage.php");
						break;
				}
				?>
			</div>
		</div>
	</div>
</body>

</html>