From b35ddf61b4e325141a669b1c76fe67504dfc7c4c Mon Sep 17 00:00:00 2001 From: jdelabre Date: Wed, 24 Nov 2021 16:15:48 +0100 Subject: [PATCH] feat(*): verification disponibilité créneaux + bouton accès au banc selon créneau et heure actuelle --- bdd.sql | 4 ++-- html/ajoutReservation.php | 2 +- html/dispoCreneau.php | 15 +++++++++++++++ html/login.php | 1 + html/menu.php | 5 +++-- html/mesReservations.php | 43 +++++++++++++++++++++++++++++++------------ html/reservation.php | 104 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------- 7 files changed, 128 insertions(+), 46 deletions(-) create mode 100644 html/dispoCreneau.php diff --git a/bdd.sql b/bdd.sql index b8a9213..30544fb 100644 --- a/bdd.sql +++ b/bdd.sql @@ -33,8 +33,8 @@ create table reservation personne char(8) REFERENCES utilisateur, HEUREDEBUT char(5), HEUREFIN char(5), - UNIQUE(moment,personne), - PRIMARY KEY(reserve,moment)); + /*UNIQUE(moment,HEUREDEBUT),*/ + PRIMARY KEY(reserve,moment,HEUREDEBUT)); /* Insertions des donnees dans la BDD */ diff --git a/html/ajoutReservation.php b/html/ajoutReservation.php index 717c8df..cc295b2 100644 --- a/html/ajoutReservation.php +++ b/html/ajoutReservation.php @@ -48,7 +48,7 @@ $requete = "INSERT INTO reservation VALUES($banc,'$date','$login','$heure','$heurefin')"; $exec_requete = mysqli_query($db,$requete); - + echo ""; }else{ echo "Pas marché"; } diff --git a/html/dispoCreneau.php b/html/dispoCreneau.php new file mode 100644 index 0000000..c96c0da --- /dev/null +++ b/html/dispoCreneau.php @@ -0,0 +1,15 @@ + diff --git a/html/login.php b/html/login.php index 1dd3da4..ecbcf5c 100644 --- a/html/login.php +++ b/html/login.php @@ -21,6 +21,7 @@ if(isset($_POST['identifiant']) && isset($_POST['mdp'])){ //header('Location : index.html'); } }else{ + /* Ne devrait pas pouvoir arriver mais j'ajoute une double sécurité */ echo ""; //header('Location : index.html'); } diff --git a/html/menu.php b/html/menu.php index 137adff..df04cc0 100644 --- a/html/menu.php +++ b/html/menu.php @@ -22,10 +22,11 @@ echo ""; //header('Location : index.html'); } - } - if(isset($_SESSION['identifiant'])){ + }elseif(isset($_SESSION['identifiant'])){ $identifiant = $_SESSION['identifiant']; echo "Bonjour $identifiant, vous êtes connecté
"; + }else{ + echo ""; } ?>
diff --git a/html/mesReservations.php b/html/mesReservations.php index 2fb4612..63fe222 100644 --- a/html/mesReservations.php +++ b/html/mesReservations.php @@ -14,13 +14,14 @@ - +
"; + }else{ + echo ""; } include("connexion.php"); $requete = "SELECT count(*) FROM reservation WHERE @@ -29,29 +30,47 @@ $reponse = mysqli_fetch_array($exec_requete); $count = $reponse['count(*)']; if($count == 0){ - echo "Aucun banc d'essai n'a ete reservé"; + echo "Aucun banc d'essai n'a été réservé"; }else{ - echo "Vos reservations :
"; + echo "
"; + echo "Vos reservations ($identifiant) :
"; + echo "
"; $requete = "SELECT * FROM reservation WHERE personne = '".$identifiant."'"; $exec_requete = mysqli_query($db,$requete); $reponse = mysqli_fetch_all($exec_requete); foreach($reponse as $creneau){ - echo "
"; + echo "
"; echo "Banc : $creneau[0] | Date : $creneau[1] $creneau[3]-$creneau[4]"; echo "
"; - echo ""; + echo ""; + echo "
"; + /* Utilisation pour accès aux reservations */ + echo "
"; + date_default_timezone_set('Europe/Paris'); + $ActualDate = date("d/m/Y",time()); + if($ActualDate==$creneau[1]){ + $ActualHour = date("h:i",time()); + $Periode = date("a",time()); + if($Periode=="pm"){ + $newHour = explode(":",$ActualHour); + $Heure = $newHour[0]+12; + $ActualHour = "".$Heure.":".$newHour[1]; + } + if(!($creneau[3]<=$ActualHour && $ActualHour<$creneau[4])){ + echo ""; echo "
"; echo "
"; } } mysqli_close($db); - /* Utilisation pour accès aux reservations - date_default_timezone_set('Europe/Paris'); - $ActualDate = date("d/m/Y",time()); - $ActualHour = date("h:i",time()); - $Periode = date("a",time()); - echo "Vrai date : ".$ActualDate." / Vrai heure = ".$ActualHour.$Periode."
"; */ ?> diff --git a/html/reservation.php b/html/reservation.php index 515a93b..3e2b109 100644 --- a/html/reservation.php +++ b/html/reservation.php @@ -14,6 +14,12 @@ "; + } include("connexion.php"); $requete = "SELECT * FROM banc ORDER BY numero"; $exec_requete = mysqli_query($db,$requete); @@ -21,16 +27,16 @@ mysqli_close($db); ?>
- +
- +
Banc choisi : - '.$value[0].''; @@ -42,30 +48,30 @@
Heure de début du créneau :
@@ -74,7 +80,7 @@
- +
@@ -90,7 +96,6 @@ day='0'+day.toString(); var minDate=year.toString()+'-'+month+'-'+day; - console.log(minDate); var txtdate=document.getElementById('txtDate'); txtdate.min=minDate; } @@ -106,6 +111,47 @@ var h=valeur.toString(); lafin.textContent=h+"h00"; } + function dispo_creneau(){ + var txtDate = document.getElementById('txtDate'); + var newBanc = document.getElementById('banc'); + var realBanc = newBanc.value; + var valDate = txtDate.value.split("-"); + var year = valDate[0]; + var month = valDate[1]; + var day = valDate[2]; + var realDate = day+"/"+month+"/"+year; + var xhttp = new XMLHttpRequest(); + var params = "date="+realDate+"&banc="+realBanc; + console.log(params); + xhttp.onreadystatechange=function(){ + if(xhttp.readyState==4){ + // Si requete faite, on modifie les horaires non dispo + var elemId; + var texte=xhttp.responseText.split("-"); + if(texte.length>1){ + for(var i=0;i -- libgit2 0.21.2