<?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)
		{
			include("formInscription.php");
			?>
			<div class="row">
				<div class="col-6 col-md-6 offset-md-3 offset-3">
					<br/>
					<h1 style="margin-bottom:20px; border-bottom:1px solid #CCC; padding-bottom:20px;"><i class="fas fa-database"></i> Membres</h1>
					<table class="table table-striped table-bordered">
						<thead class="thead-dark">
							<th>Nom</th>
							<th>Prénom</th>
							<th>Identifiant</th>
							<th>Groupe</th>
							<th>Action</th>
						</thead>
						<tbody>	
							<?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
		}
		else
		{ header("Location: accueil.php"); }
		?>
	</body>
</html>
