{% extends "base.html.twig" %}

{% block title %}
	{{ parent() }}
	Accueil
{% endblock %}

{% block content %}

	<style>
		.form-container,
		.account-container {
			max-width: 400px;
			margin: auto;
			background-color: #fff;
			padding: 30px;
			border-radius: 10px;
			box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
		}

		form {
			margin-bottom: 20px;
		}

		.form-control {
			width: 100%;
			padding: 8px;
			margin: 5px 0;
			box-sizing: border-box;
		}

		.room-table,
		.account-table {
			max-width: 400px;
			margin: auto;
			background-color: #fff;
			padding: 30px;
			border-radius: 10px;
			box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);

		}

		th,
		td {
			border: 1px solid #ddd;
			padding: 8px;
			text-align: left;
		}

		th {
			background-color: #f2f2f2;
		}

		.add-room-form,
		.search-room-form,
		.add-account-form,
		.search-account-form {
			display: flex;
			flex-direction: column;
			max-width: 400px;
			margin-bottom: 20px;

		}
	</style>

	<ul class="navbar">
		<li>
			<a href="index.php?page=accueil_client">Accueil</a>
		</li>
		<li>
			<a href="index.php?page=connexion">Mon compte</a>
		</li>
		<li>
			<a href="index.php?page=contact">Contact</a>
		</li>
		<li class="nav-item">
			<a class="nav-link" href="index.php?page=logout">Se déconnecter</a>
		</li>
	</ul>
	<div class="cyan">
		<br><br><br><br>
		<img src="images/image_neptune.png" width="100%">
		<br><br><br><br>
		<div class="noir_centre">
			<h2 class="or">Gestion et Administration</h2>
		</div>
	</div>

	<!--Pannel de gestion et d'administration des chambres du site -->
	<div class="noir_centre">
		<h2 class="or">Gestion des chambres</h2>
	</div>


	<!-- formulaire d'ajout de chambres-->
	<div class="form-container">
		<form action="" method="post" class="add-room-form">
			<input type="text" id="nom" name="nom" class="form-control" placeholder="Nom" required>
			<input type="text" id="prix" name="prix" class="form-control" placeholder="Prix" required>
			<input type="text" id="nbr_lit" name="nbr_lit" class="form-control" placeholder="Nombre de lits" required>
			<input type="text" id="num_chambre" name="num_chambre" class="form-control" placeholder="Numéro chambre" required>
			<input type="text" id="description" name="description" class="form-control" placeholder="Description" required>
			<input type="text" id="superficie" name="superficie" class="form-control" placeholder="Superficie" required>
			<input type="text" id="etat" name="etat" class="form-control" placeholder="Disponibilité" required>
			<input type="text" id="lien_image" name="lien_image" class="form-control" placeholder="lien image" required>
			<input type="text" id="id_type_chambre" name="id_type_chambre" class="form-control" placeholder="Type chambre" required>
			<input type="submit" value="Ajouter">
		</form>

		<!-- saisie mot clé pour rechercher un enregistrement de chambre-->
		<form action="index.php" method="get" class="search-room-form">
			<input type="hidden" name="page" value="accueil_admin">
			<input type="text" id="search_chambre" name="search_chambre" class="form-control" placeholder="Rechercher">
		</form>
	</div>

	<!-- liste des chambres -->
	<table class="room-table">
		<tr>
			<th>Id Chambre</th>
			<th>Nom</th>
			<th>Prix</th>
			<th>Nombre de lits</th>
			<th>Numéro chambre</th>
			<th>Description</th>
			<th>Superficie</th>
			<th>Etat</th>
			<th>Type de chambre</th>
			<th>Lien de l'image</th>
			<th></th>
			<th></th>
		</tr>
		{% if image_chambre is not empty %}
			{% for i in range(0, image_chambre|length - 1) %}
				<tr>
					<th>{{chambre[i].id}}</th>
					<th>{{chambre[i].nom}}</th>
					<th>{{chambre[i].prix}}</th>
					<th>{{chambre[i].nbr_lit}}</th>
					<th>{{chambre[i].num_chambre}}</th>
					<th>{{chambre[i].description}}</th>
					<th>{{chambre[i].superficie}}</th>><th>{{chambre[i].etat}}</th>><th>{{chambre[i].id_type_chambre.getId()}}</th>
					<th><img src="{{image_chambre[i].lien_image}}" width="100px" height="50px"></th>
					<th>
						<a href="index.php?page=deleteEnregistrement&Id_image_chambre={{image_chambre[i].id}}">supprimer</a>
					</th>
					<th>
						<a href="index.php?page=update_chambre&Id_image_chambre={{image_chambre[i].id}}">modifier</a>
					</th>
				</tr>
			{% endfor %}
		{% endif %}

	</table>


	<!--Pannel de gestion et d'administration des comptes des utilisateurs du site -->
	<div class="noir_centre">
		<h2 class="or">Gestion des comptes</h2>
	</div>
	<!-- formulaire d'ajout de compte-->
	<div class="account-container">
		<form action="" method="post" class="add-account-form">
			<input type="text" id="nom" name="nom" class="form-control" placeholder="Nom" required>
			<input type="text" id="prenom" name="prenom" class="form-control" placeholder="Prenom" required>
			<input type="text" id="num_telephone" name="num_telephone" class="form-control" placeholder="Téléphone" required>
			<input type="text" id="mail" name="mail" class="form-control" placeholder="Adresse mail" required>
			<input type="text" id="mot_de_passe" name="mot_de_passe" class="form-control" placeholder="Mot de passe" required>
			<input type="text" id="id_role" name="id_role" class="form-control" placeholder="Role" required>
			<input type="submit" value="Ajouter">
		</form>

		<!-- saisie mot clé pour rechercher un enregistrement de compte-->
		<form action="index.php" method="get" ="search-account-form">
			<input type="hidden" name="page" value="accueil_admin">
			<input type="text" id="search_compte" name="search_compte" class="form-control" placeholder="Rechercher">
		</form>
	</div>
	<!-- liste de compte-->
	<table class="account-table">
		<tr>
			<th>Id Compte</th>
			<th>Nom</th>
			<th>Prenom</th>
			<th>Téléphone</th>
			<th>Mail</th>
			<th>Mot de passe</th>
			<th>Role</th>
			<th></th>
			<th></th>
		</tr>
		{% for compte in comptes %}
			<tr>
				<th>{{compte.id}}</th>
				<th>{{compte.nom}}</th>
				<th>{{compte.prenom}}</th>
				<th>{{compte.num_telephone}}</th>
				<th>{{compte.mail}}</th>
				<th>{{compte.mot_de_passe}}</th>
				<th>{{compte.id_role.getId_role()}}</th>
				<th>
					<a href="index.php?page=deleteEnregistrement&Id_compte={{compte.id}}">supprimer</a>
				</th>
				<th>
					<a href="index.php?page=update_compte&Id_compte={{compte.id}}">modifier</a>
				</th>
			</tr>
			{% endfor%}
		</table>


	{% endblock %}
