reservation.php 3.34 KB
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8"/>
		<title>Page principale</title>
		<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css"
		      rel="stylesheet"
		      integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x"
		      crossorigin="anonymous">
		<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/js/bootstrap.bundle.min.js"
			integrity="sha384-gtEjrD/SeCtmISkJkNUaaKMoLD0//E1J19smozuHV6z3Iehds+3Ulb9Bn9Plx0x4"
			crossorigin="anonymous">
		</script>
	</head>
	<body>
		<?php
			include("connexion.php");
			$requete = "SELECT * FROM banc ORDER BY numero";
			$exec_requete = mysqli_query($db,$requete);
			$reponse = mysqli_fetch_all($exec_requete);
			mysqli_close($db);
		?>
		<form method="POST" action="menu.php"> 
			<button class="btn-lg btn-success" type="submit">Retour au menu</button>
		</form>
		<form method="POST" action="ajoutReservation.php">
			<div>
				<input type="date" name="txtDate" id="txtDate" onclick="minimum();" required>
			</div>

			<div>
				Banc choisi : 
				<select class="form-select" name="banc" id="banc" required>
				<?php
					foreach($reponse as $value){
						echo '<option value="'.$value[0].'">'.$value[0].'</option>';
					}	
				?>
				</select>
			</div>

			<div>
				Heure de début du créneau :
				<select class="form-select" name="heure" id="heure" onchange='calcul_fin();' required>
					<option value="0" selected> 00h00 </option>
					<option value="1"> 01h00 </option>
					<option value="2"> 02h00 </option>
					<option value="3"> 03h00 </option>
					<option value="4"> 04h00 </option>
					<option value="5"> 05h00 </option>
					<option value="6"> 06h00 </option>
					<option value="7"> 07h00 </option>
					<option value="8"> 08h00 </option>
					<option value="9"> 09h00 </option>
					<option value="10"> 10h00 </option>
					<option value="11"> 11h00 </option>
					<option value="12"> 12h00 </option>
					<option value="13"> 13h00 </option>
					<option value="14"> 14h00 </option>
					<option value="15"> 15h00 </option>
					<option value="16"> 16h00 </option>
					<option value="17"> 17h00 </option>
					<option value="18"> 18h00 </option>
					<option value="19"> 19h00 </option>
					<option value="20"> 20h00 </option>
					<option value="21"> 21h00 </option>
					<option value="22"> 22h00 </option>
					<option value="23"> 23h00 </option>
				</select>
			</div>

			<div>
				Heure de fin du créneau : <div id="fin">01h00</div>
			</div>

			<div>
				<button class="btn-lg btn-primary" type="submit">Reserver</button>
			</div>
		</form>

		<script type="text/javascript">
			function minimum(){
				var dtToday=new Date();
				var month=dtToday.getMonth()+1;
				var day=dtToday.getDate();
				var year=dtToday.getFullYear();
				if(month<10)
					month='0'+month.toString();
				if(day<10)
					day='0'+day.toString();

				var minDate=year.toString()+'-'+month+'-'+day;
				console.log(minDate);
				var txtdate=document.getElementById('txtDate');
				txtdate.min=minDate;	
			}
			function calcul_fin(){
				var test = document.getElementById('heure');
				var lafin = document.getElementById('fin');
				var valeur=parseInt(test.value)+1;
				if(valeur==24)
					valeur=0;
				if(valeur<10)
					var h='0'+valeur.toString();
				else
					var h=valeur.toString();
				lafin.textContent=h+"h00";
			}
		</script>
	</body>	
</html>