<?php
session_start();
require_once("accesBase.php");
$membres = members();
?>

<!DOCTYPE html>

<html>
	<head>
		<?php include("head.php"); ?>
	</head>

	<!-- Contenu du site -->
	<body>
		<?php 
		include("header.php");
		if(getGroupe($_SESSION['Login'])==1)
		{
			?>
			<div class="row">
				<div class="col-6 col-md-6 offset-md-3 offset-3">
					<br/>
					<h1 style="margin-bottom:20px; margin-top:60px; border-bottom:1px solid #CCC; padding-bottom:20px;"><i class="fas fa-database"></i> Membres</h1>
					<table class="table table-striped table-bordered">
						<tbody>
							<tr>
								<td>Nom</td>
								<td>Prénom</td>
								<td>Identifiant</td>
								<td>Groupe</td>
								<td>Action</td>
							</tr>
							
							<?php 
							foreach($membres as $membre){
								?>
								<tr>
									<td><?php echo $membre['nom'];?></td>
									<td><?php echo $membre['prenom'];?></td>
									<td><?php echo $membre['identifiant'];?></td>
									<td><?php echo groupeId($membre['groupe']);?></td>
									<td>
										<form action="suppression.php" method="POST">
											<input type="hidden" name="id" value="<?php echo $membre['identifiant'];?>">
											<input type="submit" name="supprimer" value="Supprimer">
										</form>
									</td>
								</tr>
								<?php
							}
							?>
						</tbody>
					</table>
				</div>
			</div>
			<?php
			include("formSuppression.php");
			include("formInscription.php");
		}
		else
		{ header("Location: accueil.php"); }
		?>
	</body>
</html>
