Commit 9de9bb41d8803e73550219cfe13d4df3ee7df9de

Authored by lwadbled
1 parent 8d481333

feat(html): Ajout des reservations + voir ses reservations + supprimer ses reservations

html/ajoutReservation.php 0 → 100644
... ... @@ -0,0 +1,58 @@
  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['txtDate']) && isset($_POST['banc']) && isset($_POST['heure'])){
  24 + $date = $_POST['txtDate'];
  25 + $banc = $_POST['banc'];
  26 + $heure = $_POST['heure'];
  27 + echo "date = ".$date." // banc = ".$banc." // heure = ".$heure."<br>" ;
  28 + $explosion = explode('-',$date);
  29 + $annee = $explosion[0];
  30 + $mois = $explosion[1];
  31 + $jour = $explosion[2];
  32 + $date = $jour."/".$mois."/".$annee;
  33 + echo "New date = ".$date."<br>";
  34 + $heurefin = (int)$heure + 1;
  35 + if($heurefin==24){
  36 + $heurefin = 0;
  37 + }
  38 + if(strlen($heurefin)==1){
  39 + $heurefin = "0".$heurefin;
  40 + }
  41 + if(strlen($heure)==1){
  42 + $heure = "0".$heure;
  43 + }
  44 + $heure = $heure.":00";
  45 + $heurefin = $heurefin.":00";
  46 + echo "Heure = ".$heure."<br>";
  47 + echo "Heure de fin = ".$heurefin."<br>";
  48 +
  49 + $requete = "INSERT INTO reservation VALUES($banc,'$date','$login','$heure','$heurefin')";
  50 + $exec_requete = mysqli_query($db,$requete);
  51 +
  52 + }else{
  53 + echo "Pas marché";
  54 + }
  55 + mysqli_close($db);
  56 + ?>
  57 + </body>
  58 +</html>
... ...
html/connexion.php 0 → 100644
... ... @@ -0,0 +1,9 @@
  1 +<?php
  2 + //Connexion à la base de données
  3 + $db_user = 'lwadbled';
  4 + $db_mdp = 'glopglop';
  5 + $db_nom = 'lwadbled';
  6 + $db_host = 'localhost';
  7 + $db = mysqli_connect($db_host, $db_user, $db_mdp, $db_nom)
  8 + or die('could not connect to database');
  9 +?>
... ...
html/login.php
1 1 <?php
2 2 session_start();
3 3 if(isset($_POST['identifiant']) && isset($_POST['mdp'])){
4   - //Connexion à la base de données
5   - $db_user = 'lwadbled';
6   - $db_mdp = 'glopglop';
7   - $db_nom = 'lwadbled';
8   - $db_host = 'localhost';
9   - $db = mysqli_connect($db_host, $db_user, $db_mdp, $db_nom)
10   - or die('could not connect to database');
  4 + include("connexion.php");
11 5  
12 6 $identifiant = mysqli_real_escape_string($db,htmlspecialchars($_POST['identifiant']));
13 7 $mdp = mysqli_real_escape_string($db,htmlspecialchars($_POST['mdp']));
... ...
html/menu.php
... ... @@ -14,7 +14,6 @@
14 14 </head>
15 15 <body>
16 16 <div>
17   - <a href='menu.php?deconnexion=true'><span>Deconnexion</span></a>
18 17 <?php
19 18 session_start();
20 19 if(isset($_GET['deconnexion'])){
... ... @@ -26,9 +25,18 @@
26 25 }
27 26 if(isset($_SESSION['identifiant'])){
28 27 $identifiant = $_SESSION['identifiant'];
29   - echo "<br>Bonjour $identifiant, vous êtes connecté";
  28 + echo "Bonjour $identifiant, vous êtes connecté<br>";
30 29 }
31 30 ?>
  31 + <form method="POST" action="menu.php?deconnexion=true">
  32 + <button class="btn-lg btn-danger" type="submit">Deconnexion</button>
  33 + </form>
  34 + <form method="POST" action="reservation.php">
  35 + <button class="btn-lg btn-primary" type="submit">Reserver un banc</button>
  36 + </form>
  37 + <form method="POST" action="mesReservations.php">
  38 + <button class="btn-lg btn-success" type="submit">Mes Reservations</button>
  39 + </form>
32 40 </div>
33 41 </body>
34 42 </html>
... ...
html/mesReservations.php 0 → 100644
... ... @@ -0,0 +1,57 @@
  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 + <form method="POST" action="menu.php">
  17 + <button class="btn-lg btn-success" type="submit">Retour au menu</button>
  18 + </form>
  19 + <?php
  20 + session_start();
  21 + if(isset($_SESSION['identifiant'])){
  22 + $identifiant = $_SESSION['identifiant'];
  23 + echo "Bonjour $identifiant, vous êtes connecté<br>";
  24 + }
  25 + include("connexion.php");
  26 + $requete = "SELECT count(*) FROM reservation WHERE
  27 + personne = '".$identifiant."'";
  28 + $exec_requete = mysqli_query($db,$requete);
  29 + $reponse = mysqli_fetch_array($exec_requete);
  30 + $count = $reponse['count(*)'];
  31 + if($count == 0){
  32 + echo "Aucun banc d'essai n'a ete reservé";
  33 + }else{
  34 + echo "Vos reservations : <br>";
  35 + $requete = "SELECT * FROM reservation WHERE
  36 + personne = '".$identifiant."'";
  37 + $exec_requete = mysqli_query($db,$requete);
  38 + $reponse = mysqli_fetch_all($exec_requete);
  39 + foreach($reponse as $creneau){
  40 + echo "<div>";
  41 + echo "Banc : $creneau[0] | Date : $creneau[1] $creneau[3]-$creneau[4]";
  42 + echo "<form method='POST' action='supprReservation.php?banc=$creneau[0]&moment=$creneau[1]&personne=$identifiant&heuredebut=$creneau[3]&heurefin=$creneau[4]'>";
  43 + echo "<button class='btn-lg btn-success' type='submit'>Supprimer la reservation</button>";
  44 + echo "</form>";
  45 + echo "</div>";
  46 + }
  47 + }
  48 + mysqli_close($db);
  49 + /* Utilisation pour accès aux reservations
  50 + date_default_timezone_set('Europe/Paris');
  51 + $ActualDate = date("d/m/Y",time());
  52 + $ActualHour = date("h:i",time());
  53 + $Periode = date("a",time());
  54 + echo "Vrai date : ".$ActualDate." / Vrai heure = ".$ActualHour.$Periode."<br>"; */
  55 + ?>
  56 + </body>
  57 +</html>
... ...
html/reservation.php 0 → 100644
... ... @@ -0,0 +1,111 @@
  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 + include("connexion.php");
  18 + $requete = "SELECT * FROM banc ORDER BY numero";
  19 + $exec_requete = mysqli_query($db,$requete);
  20 + $reponse = mysqli_fetch_all($exec_requete);
  21 + mysqli_close($db);
  22 + ?>
  23 + <form method="POST" action="menu.php">
  24 + <button class="btn-lg btn-success" type="submit">Retour au menu</button>
  25 + </form>
  26 + <form method="POST" action="ajoutReservation.php">
  27 + <div>
  28 + <input type="date" name="txtDate" id="txtDate" onclick="minimum();" required>
  29 + </div>
  30 +
  31 + <div>
  32 + Banc choisi :
  33 + <select class="form-select" name="banc" id="banc" required>
  34 + <?php
  35 + foreach($reponse as $value){
  36 + echo '<option value="'.$value[0].'">'.$value[0].'</option>';
  37 + }
  38 + ?>
  39 + </select>
  40 + </div>
  41 +
  42 + <div>
  43 + Heure de début du créneau :
  44 + <select class="form-select" name="heure" id="heure" onchange='calcul_fin();' required>
  45 + <option value="0" selected> 00h00 </option>
  46 + <option value="1"> 01h00 </option>
  47 + <option value="2"> 02h00 </option>
  48 + <option value="3"> 03h00 </option>
  49 + <option value="4"> 04h00 </option>
  50 + <option value="5"> 05h00 </option>
  51 + <option value="6"> 06h00 </option>
  52 + <option value="7"> 07h00 </option>
  53 + <option value="8"> 08h00 </option>
  54 + <option value="9"> 09h00 </option>
  55 + <option value="10"> 10h00 </option>
  56 + <option value="11"> 11h00 </option>
  57 + <option value="12"> 12h00 </option>
  58 + <option value="13"> 13h00 </option>
  59 + <option value="14"> 14h00 </option>
  60 + <option value="15"> 15h00 </option>
  61 + <option value="16"> 16h00 </option>
  62 + <option value="17"> 17h00 </option>
  63 + <option value="18"> 18h00 </option>
  64 + <option value="19"> 19h00 </option>
  65 + <option value="20"> 20h00 </option>
  66 + <option value="21"> 21h00 </option>
  67 + <option value="22"> 22h00 </option>
  68 + <option value="23"> 23h00 </option>
  69 + </select>
  70 + </div>
  71 +
  72 + <div>
  73 + Heure de fin du créneau : <div id="fin">01h00</div>
  74 + </div>
  75 +
  76 + <div>
  77 + <button class="btn-lg btn-primary" type="submit">Reserver</button>
  78 + </div>
  79 + </form>
  80 +
  81 + <script type="text/javascript">
  82 + function minimum(){
  83 + var dtToday=new Date();
  84 + var month=dtToday.getMonth()+1;
  85 + var day=dtToday.getDate();
  86 + var year=dtToday.getFullYear();
  87 + if(month<10)
  88 + month='0'+month.toString();
  89 + if(day<10)
  90 + day='0'+day.toString();
  91 +
  92 + var minDate=year.toString()+'-'+month+'-'+day;
  93 + console.log(minDate);
  94 + var txtdate=document.getElementById('txtDate');
  95 + txtdate.min=minDate;
  96 + }
  97 + function calcul_fin(){
  98 + var test = document.getElementById('heure');
  99 + var lafin = document.getElementById('fin');
  100 + var valeur=parseInt(test.value)+1;
  101 + if(valeur==24)
  102 + valeur=0;
  103 + if(valeur<10)
  104 + var h='0'+valeur.toString();
  105 + else
  106 + var h=valeur.toString();
  107 + lafin.textContent=h+"h00";
  108 + }
  109 + </script>
  110 + </body>
  111 +</html>
... ...
html/supprReservation.php 0 → 100644
... ... @@ -0,0 +1,18 @@
  1 +<?php
  2 +if(isset($_GET['banc']) && isset($_GET['moment']) && isset($_GET['personne']) && isset($_GET['heuredebut']) && isset($_GET['heurefin'])){
  3 + include("connexion.php");
  4 + $banc = $_GET['banc'];
  5 + $moment = $_GET['moment'];
  6 + $personne = $_GET['personne'];
  7 + $heuredebut = $_GET['heuredebut'];
  8 + $heurefin = $_GET['heurefin'];
  9 + $requete =
  10 + include("connexion.php");
  11 + $requete = "DELETE FROM reservation WHERE
  12 + reserve=$banc and moment='$moment' and personne = '$personne' and heuredebut='$heuredebut' and heurefin='$heurefin'";
  13 + $exec_requete = mysqli_query($db,$requete);
  14 + $reponse = mysqli_fetch_array($exec_requete);
  15 + echo "<meta http-equiv=\"refresh\" content=\"0;url=mesReservations.php\">";
  16 + mysqli_close($db);
  17 +}
  18 +?>
... ...