Commit c1606691e1d88445ee5c9bd32a9fa49b786d0554
1 parent
46de4374
feat(gestionBanc.php): ajout de la gestion des bancs par un administrateur
Showing
5 changed files
with
126 additions
and
1 deletions
Show diff stats
... | ... | @@ -0,0 +1,36 @@ |
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($_GET['banc'])){ | |
24 | + $banc = $_GET['banc']; | |
25 | + echo "banc = ".$banc."<br>"; | |
26 | + $requete = "INSERT INTO banc VALUES($banc)"; | |
27 | + $exec_requete = mysqli_query($db,$requete); | |
28 | + echo "<meta http-equiv=\"refresh\" content=\"0;url=gestionBanc.php\">"; | |
29 | + }else{ | |
30 | + //echo "L'ajout n'a pas fonctionné"; | |
31 | + echo "<meta http-equiv=\"refresh\" content=\"0;url=gestionBanc.php?erreur=1\">"; | |
32 | + } | |
33 | + mysqli_close($db); | |
34 | + ?> | |
35 | + </body> | |
36 | +</html> | ... | ... |
html/gestionAppareil.php
... | ... | @@ -2,7 +2,7 @@ |
2 | 2 | <html> |
3 | 3 | <head> |
4 | 4 | <meta charset="utf-8"/> |
5 | - <title>Mes réservations</title> | |
5 | + <title>Gestion des appareils</title> | |
6 | 6 | <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css" |
7 | 7 | rel="stylesheet" |
8 | 8 | integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" | ... | ... |
... | ... | @@ -0,0 +1,73 @@ |
1 | +<!DOCTYPE html> | |
2 | +<html> | |
3 | + <head> | |
4 | + <meta charset="utf-8"/> | |
5 | + <title>Gestion des bancs</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 banc"; | |
28 | + $exec_requete = mysqli_query($db,$requete); | |
29 | + $banc = mysqli_fetch_all($exec_requete); | |
30 | + $requete = "SELECT count(*) FROM banc"; | |
31 | + $exec_requete = mysqli_query($db,$requete); | |
32 | + $nb_banc = mysqli_fetch_all($exec_requete); | |
33 | + $nouv_banc = $nb_banc[0][0]+1; | |
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>Nombre d'appareil</th>"; | |
40 | + echo "<th></th>"; | |
41 | + echo "</tr>"; | |
42 | + echo "</thead>"; | |
43 | + echo "<tbody>"; | |
44 | + foreach($banc as $value){ | |
45 | + echo "<tr>"; | |
46 | + echo "<td>".$value[0]."</td>"; | |
47 | + $requete = "SELECT count(*) FROM equipement WHERE num=$value[0]"; | |
48 | + $exec_requete = mysqli_query($db,$requete); | |
49 | + $reponse = mysqli_fetch_all($exec_requete); | |
50 | + echo "<td>".$reponse[0][0]."</td>"; | |
51 | + echo "<td>"; | |
52 | + if($value[0]==$nouv_banc-1){ | |
53 | + echo "<form method='POST' action='supprBanc.php?banc=".$value[0]."'><button class='btn-lg btn-danger' type='submit'>Supprimer le banc</button></form>"; | |
54 | + } | |
55 | + echo "</td>"; | |
56 | + echo "</tr>"; | |
57 | + } | |
58 | + /* Ajout appareil */ | |
59 | + echo "<form method='POST' action='ajoutBanc.php?banc=$nouv_banc'>"; | |
60 | + echo "<tr>"; | |
61 | + echo "<td>$nouv_banc</td>"; | |
62 | + echo "<td></td>"; | |
63 | + echo "<td><button class='btn-lg btn-success' type='submit'>Ajouter le banc</button></td>"; | |
64 | + echo "</tr>"; | |
65 | + echo "</tbody>"; | |
66 | + echo "</table>"; | |
67 | + echo "</form>"; | |
68 | + mysqli_close($db); | |
69 | + ?> | |
70 | + </body> | |
71 | +</html> | |
72 | + | |
73 | + | ... | ... |
html/menu.php
... | ... | @@ -40,6 +40,9 @@ |
40 | 40 | </form> |
41 | 41 | <?php |
42 | 42 | if($identifiant=="admin"){ |
43 | + echo "<form method='POST' action='gestionBanc.php'>"; | |
44 | + echo "<button class='btn-lg btn-warning' type='submit'>Gestion des bancs</button>"; | |
45 | + echo "</form>"; | |
43 | 46 | echo "<form method='POST' action='gestionAppareil.php'>"; |
44 | 47 | echo "<button class='btn-lg btn-warning' type='submit'>Gestion des appareils</button>"; |
45 | 48 | echo "</form>"; | ... | ... |
... | ... | @@ -0,0 +1,13 @@ |
1 | +<?php | |
2 | +if(isset($_GET['banc'])){ | |
3 | + include("connexion.php"); | |
4 | + $banc = $_GET['banc']; | |
5 | + include("connexion.php"); | |
6 | + $requete = "DELETE FROM banc WHERE | |
7 | + numero=$banc"; | |
8 | + $exec_requete = mysqli_query($db,$requete); | |
9 | + $reponse = mysqli_fetch_array($exec_requete); | |
10 | + echo "<meta http-equiv=\"refresh\" content=\"0;url=gestionBanc.php\">"; | |
11 | + mysqli_close($db); | |
12 | +} | |
13 | +?> | ... | ... |