Commit 46de4374b4622263b7b160dab9d4a50935e6f6a7
1 parent
add276fa
feat(gestionAppareil.php): Ajout de la gestion des appareils pour un administrateur
Showing
5 changed files
with
136 additions
and
0 deletions
Show diff stats
bdd.sql
@@ -40,6 +40,7 @@ create table reservation | @@ -40,6 +40,7 @@ create table reservation | ||
40 | /* Insertions des donnees dans la BDD */ | 40 | /* Insertions des donnees dans la BDD */ |
41 | 41 | ||
42 | insert into utilisateur values ('lwadbled','Louis'); | 42 | insert into utilisateur values ('lwadbled','Louis'); |
43 | +insert into utilisateur values ('admin','glopglop'); | ||
43 | 44 | ||
44 | /* insert into creneau values ('01/12/2021'); */ | 45 | /* insert into creneau values ('01/12/2021'); */ |
45 | 46 |
@@ -0,0 +1,39 @@ | @@ -0,0 +1,39 @@ | ||
1 | +<!DOCTYPE html> | ||
2 | +<html> | ||
3 | + <head> | ||
4 | + <meta charset="utf-8"/> | ||
5 | + <title>Page principale</title> | ||
6 | + <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css" | ||
7 | + rel="stylesheet" | ||
8 | + integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" | ||
9 | + crossorigin="anonymous"> | ||
10 | + <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/js/bootstrap.bundle.min.js" | ||
11 | + integrity="sha384-gtEjrD/SeCtmISkJkNUaaKMoLD0//E1J19smozuHV6z3Iehds+3Ulb9Bn9Plx0x4" | ||
12 | + crossorigin="anonymous"> | ||
13 | + </script> | ||
14 | + </head> | ||
15 | + <body> | ||
16 | + <?php | ||
17 | + session_start(); | ||
18 | + if(isset($_SESSION['identifiant'])){ | ||
19 | + $login = $_SESSION['identifiant']; | ||
20 | + echo "Vous etes : $login <br>"; | ||
21 | + } | ||
22 | + include("connexion.php"); | ||
23 | + if(isset($_POST['banc']) && isset($_POST['ip']) && isset($_POST['name']) && isset($_POST['type'])){ | ||
24 | + $banc = $_POST['banc']; | ||
25 | + $ip = $_POST['ip']; | ||
26 | + $name = $_POST['name']; | ||
27 | + $type = $_POST['type']; | ||
28 | + echo "banc = ".$banc." // ip = ".$ip." // name = ".$name."// type = ".$type."<br>"; | ||
29 | + $requete = "INSERT INTO equipement VALUES($banc,'$ip','$name','$type')"; | ||
30 | + $exec_requete = mysqli_query($db,$requete); | ||
31 | + echo "<meta http-equiv=\"refresh\" content=\"0;url=gestionAppareil.php\">"; | ||
32 | + }else{ | ||
33 | + //echo "L'ajout n'a pas fonctionné"; | ||
34 | + echo "<meta http-equiv=\"refresh\" content=\"0;url=gestionAppareil.php?erreur=1\">"; | ||
35 | + } | ||
36 | + mysqli_close($db); | ||
37 | + ?> | ||
38 | + </body> | ||
39 | +</html> |
@@ -0,0 +1,75 @@ | @@ -0,0 +1,75 @@ | ||
1 | +<!DOCTYPE html> | ||
2 | +<html> | ||
3 | + <head> | ||
4 | + <meta charset="utf-8"/> | ||
5 | + <title>Mes réservations</title> | ||
6 | + <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css" | ||
7 | + rel="stylesheet" | ||
8 | + integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" | ||
9 | + crossorigin="anonymous"> | ||
10 | + <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/js/bootstrap.bundle.min.js" | ||
11 | + integrity="sha384-gtEjrD/SeCtmISkJkNUaaKMoLD0//E1J19smozuHV6z3Iehds+3Ulb9Bn9Plx0x4" | ||
12 | + crossorigin="anonymous"> | ||
13 | + </script> | ||
14 | + </head> | ||
15 | + <body> | ||
16 | + <form method="POST" action="menu.php"> | ||
17 | + <button class="btn-lg btn-secondary" type="submit">Retour au menu</button> | ||
18 | + </form> | ||
19 | + <?php | ||
20 | + session_start(); | ||
21 | + if(isset($_SESSION['identifiant'])=="admin"){ | ||
22 | + $identifiant = $_SESSION['identifiant']; | ||
23 | + }else{ | ||
24 | + echo "<meta http-equiv=\"refresh\" content=\"0;url=index.html\">"; | ||
25 | + } | ||
26 | + include("connexion.php"); | ||
27 | + $requete = "SELECT * FROM equipement"; | ||
28 | + $exec_requete = mysqli_query($db,$requete); | ||
29 | + $reponse = mysqli_fetch_all($exec_requete); | ||
30 | + $requete = "SELECT * FROM banc"; | ||
31 | + $exec_requete = mysqli_query($db,$requete); | ||
32 | + $banc = mysqli_fetch_all($exec_requete); | ||
33 | + mysqli_close($db); | ||
34 | + /* Affichage des appareils */ | ||
35 | + echo "<table class='table table-striped'>"; | ||
36 | + echo "<thead>"; | ||
37 | + echo "<tr>"; | ||
38 | + echo "<th>Banc</th>"; | ||
39 | + echo "<th>IP</th>"; | ||
40 | + echo "<th>Nom de l'appareil</th>"; | ||
41 | + echo "<th>Type d'appareil</th>"; | ||
42 | + echo "<th></th>"; | ||
43 | + echo "</tr>"; | ||
44 | + echo "</thead>"; | ||
45 | + echo "<tbody>"; | ||
46 | + for($i=0;$i<count($reponse);$i++){ | ||
47 | + echo "<tr>"; | ||
48 | + echo "<td>".$reponse[$i][0]."</td>"; | ||
49 | + echo "<td>".$reponse[$i][1]."</td>"; | ||
50 | + echo "<td>".$reponse[$i][2]."</td>"; | ||
51 | + echo "<td>".$reponse[$i][3]."</td>"; | ||
52 | + echo "<td><form method='POST' action='supprAppareil.php?ip=".$reponse[$i][1]."'><button class='btn-lg btn-danger' type='submit'>Supprimer l'appareil</button></form>"; | ||
53 | + echo "</tr>"; | ||
54 | + } | ||
55 | + /* Ajout appareil */ | ||
56 | + echo "<form method='POST' action='ajoutAppareil.php'>"; | ||
57 | + echo "<tr>"; | ||
58 | + echo "<td><select class='select' name='banc' id='banc' required>"; | ||
59 | + foreach($banc as $value){ | ||
60 | + echo '<option value="'.$value[0].'">'.$value[0].'</option>'; | ||
61 | + } | ||
62 | + echo "</select></td>"; | ||
63 | + echo "<td><input type='text' name='ip' required></td>"; | ||
64 | + echo "<td><input type='text' name='name' required></td>"; | ||
65 | + echo "<td><input type='text' name='type' required></td>"; | ||
66 | + echo "<td><button class='btn-lg btn-success' type='submit'>Ajouter l'appareil</button></td>"; | ||
67 | + echo "</tr>"; | ||
68 | + echo "</tbody>"; | ||
69 | + echo "</table>"; | ||
70 | + echo "</form>"; | ||
71 | + ?> | ||
72 | + </body> | ||
73 | +</html> | ||
74 | + | ||
75 | + |
html/menu.php
@@ -38,6 +38,13 @@ | @@ -38,6 +38,13 @@ | ||
38 | <form method="POST" action="mesReservations.php"> | 38 | <form method="POST" action="mesReservations.php"> |
39 | <button class="btn-lg btn-success" type="submit">Mes Reservations</button> | 39 | <button class="btn-lg btn-success" type="submit">Mes Reservations</button> |
40 | </form> | 40 | </form> |
41 | + <?php | ||
42 | + if($identifiant=="admin"){ | ||
43 | + echo "<form method='POST' action='gestionAppareil.php'>"; | ||
44 | + echo "<button class='btn-lg btn-warning' type='submit'>Gestion des appareils</button>"; | ||
45 | + echo "</form>"; | ||
46 | + } | ||
47 | + ?> | ||
41 | </div> | 48 | </div> |
42 | </body> | 49 | </body> |
43 | </html> | 50 | </html> |
@@ -0,0 +1,14 @@ | @@ -0,0 +1,14 @@ | ||
1 | +<?php | ||
2 | +if(isset($_GET['ip'])){ | ||
3 | + include("connexion.php"); | ||
4 | + $ip = $_GET['ip']; | ||
5 | + $requete = | ||
6 | + include("connexion.php"); | ||
7 | + $requete = "DELETE FROM equipement WHERE | ||
8 | + ip='$ip'"; | ||
9 | + $exec_requete = mysqli_query($db,$requete); | ||
10 | + $reponse = mysqli_fetch_array($exec_requete); | ||
11 | + echo "<meta http-equiv=\"refresh\" content=\"0;url=gestionAppareil.php\">"; | ||
12 | + mysqli_close($db); | ||
13 | +} | ||
14 | +?> |