Blame view

html/gestionReservation.php 4.69 KB
5aaa2b1b   lwadbled   feat(gestionReser...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
  <!DOCTYPE html>
  <html>
  	<head>
  		<meta charset="utf-8"/>
  		<title>Gestion des reservations</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>
  		<form method="POST" action="menu.php"> 
  			<button class="btn-lg btn-secondary" type="submit">Retour au menu</button>
  		</form>
  		<?php
  			session_start();
a0f8f60e   lwadbled   fix(): ajustement...
21
  			if(isset($_SESSION['identifiant']) && $_SESSION['identifiant']=="admin"){
5aaa2b1b   lwadbled   feat(gestionReser...
22
23
  				$identifiant = $_SESSION['identifiant'];
  			}else{
a0f8f60e   lwadbled   fix(): ajustement...
24
  				echo "<meta http-equiv=\"refresh\" content=\"0;url=menu.php\">";
5aaa2b1b   lwadbled   feat(gestionReser...
25
26
27
28
29
30
31
32
33
34
35
36
37
38
  			}
  			include("connexion.php");
  			$requete = "SELECT * FROM banc ORDER BY numero";
  			$exec_requete = mysqli_query($db,$requete);
  			$reponse = mysqli_fetch_all($exec_requete);
  			if(isset($_POST['txtDate']) && isset($_POST['banc'])){
  				$txtDate = $_POST['txtDate'];
  				$banc = $_POST['banc'];
  			}else{
  				$txtDate = date("Y-n-j");
  				$banc = $reponse[0][0];
  				/* Verification de la syntaxe de la date */
  				$explosion_date = explode("-",$txtDate);
  				$jour = $explosion_date[2];
cdb865f1   lwadbled   feat(Python): Ajo...
39
40
  				$mois = $explosion_date[1];
  				$annee = $explosion_date[0];
5aaa2b1b   lwadbled   feat(gestionReser...
41
  				if($jour<10){
cdb865f1   lwadbled   feat(Python): Ajo...
42
43
44
45
46
  					$jour = "0$jour";	
  					$txtDate = "$annee-$mois-$jour";
  				}
  				if($mois<10){
  					$mois = "0$mois";
5aaa2b1b   lwadbled   feat(gestionReser...
47
48
49
  					$txtDate = "$annee-$mois-$jour";
  				}
  			}	
5aaa2b1b   lwadbled   feat(gestionReser...
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
  		?>
  		
  		<form method="POST" action="gestionReservation.php"> 
  			<div class="text-center">
  				<input type="date" name="txtDate" id="txtDate" onchange="this.form.submit();" <?php echo "value=\"$txtDate\""; ?> required>
  			</div>
  
  			<div class="text-center" style="padding-left: 40rem!important; padding-right: 40rem!important;">
  				Banc choisi : 
  				<select class="form-select" name="banc" id="banc" onchange="this.form.submit();" required>
  				<?php
  					foreach($reponse as $value){
  						echo '<option value="'.$value[0].'"';
  						if($banc==$value[0]){
  							echo "selected";
  						}
  						echo '>'.$value[0].'</option>';
  					}	
  				?>
  				</select>
  			</div>
  		</form>	
  		<div class="text-center">
  		<?php
  			$requete = "SELECT * FROM reservation";
  			$exec_requete = mysqli_query($db,$requete);
  			$reponse = mysqli_fetch_all($exec_requete);
  			/* Affichage des reservations */
13809968   lwadbled   fix(gestionReserv...
78
  			/* TODO : Si date déjà passée = Seulement consultation */
5aaa2b1b   lwadbled   feat(gestionReser...
79
80
81
82
83
84
85
86
87
  			echo "<table class='table table-striped'>";
  			echo "<thead>";
  			echo "<tr>";
  			echo "<th>Heure de début</th>";
  			echo "<th>Reservé par</th>";
  			echo "<th></th>";
  			echo "</tr>";
  			echo "</thead>";
  			echo "<tbody>";
b12775c2   lwadbled   fix(): resolution...
88
89
90
91
92
93
94
95
96
97
98
  
  			$explosion_date = explode("-",$txtDate);
  			$jour = $explosion_date[2];
  			$mois = $explosion_date[1];
  			$annee = $explosion_date[0];
  			$actualDate = date("Y-m-d");
  			$new = explode("-",$actualDate);
  			$new_jour = $new[2];
  			$new_mois = $new[1];
  			$new_annee = $new[0];
  
5aaa2b1b   lwadbled   feat(gestionReser...
99
100
101
102
103
104
105
106
107
  			for($i=0;$i<24;$i++){
  				if($i<10){
  					$heure = "0".$i.":00";
  				}else{
  					$heure = $i.":00";
  				}
  				echo "<tr>";
  				echo "<td>$heure</td>";
  				/* Requete pour connaitre l'utilisateur reservant le creneau s'il y en a un */
b12775c2   lwadbled   fix(): resolution...
108
  				$requete = "SELECT login FROM reservation WHERE jour='$txtDate' AND numero=$banc AND HEUREDEBUT='$heure'";
5aaa2b1b   lwadbled   feat(gestionReser...
109
110
  				$exec_requete = mysqli_query($db,$requete);
  				$reponse = mysqli_fetch_all($exec_requete);
83dd807a   lwadbled   fix(Reservation):...
111
112
113
114
115
116
  				if($reponse!=null){
  					$personne = $reponse[0][0];
  					echo "<td>$personne</td>";
  				}else{
  					echo "<td></td>";
  				}
b12775c2   lwadbled   fix(): resolution...
117
118
119
120
  				if($new_annee>$annee || ($new_annee>=$annee && $new_mois>=$mois && $new_jour>$jour)){
  					echo "<td><form method='POST' action=''><button disabled class='btn-lg btn-outline-info' type='submit'>Date déjà passée</button></form>";
  				}else if($reponse==null){
  					echo "<td><form method='POST' action='ajoutReservation.php?txtDate=$txtDate&banc=$banc&heure=$heure'><button class='btn-lg btn-danger' type='submit'>Bloquer le créneau</button></form>";
5aaa2b1b   lwadbled   feat(gestionReser...
121
  				}else if($reponse[0][0]=="admin"){
b12775c2   lwadbled   fix(): resolution...
122
  					echo "<td><form method='POST' action='supprReservation.php?banc=$banc&moment=$txtDate&personne=$personne&heuredebut=$heure'><button class='btn-lg btn-success' type='submit'>Débloquer le créneau</button></form>";
5aaa2b1b   lwadbled   feat(gestionReser...
123
  				}else{
b12775c2   lwadbled   fix(): resolution...
124
  					echo "<td><form method='POST' action='supprReservation.php?banc=$banc&moment=$txtDate&personne=$personne&heuredebut=$heure'><button class='btn-lg btn-warning' type='submit'>Supprimer la réservation</button></form>";
5aaa2b1b   lwadbled   feat(gestionReser...
125
126
127
128
129
130
131
132
133
134
135
136
137
  				}
  				echo "</tr>";
  			}
  			echo "</tbody>";
  			echo "</table>";	
  			echo "</form>";
  			mysqli_close($db);
  		?>
  		</div>
  	</body>
  </html>