Commit cdb865f10c0f56d72211a6f47ea491d6cac7eac5
1 parent
a0f8f60e
feat(Python): Ajout du code python (pour plus tard avec la raspberry) + tentativ…
…e resolution de bug sur reservation
Showing
7 changed files
with
67 additions
and
36 deletions
Show diff stats
@@ -0,0 +1,8 @@ | @@ -0,0 +1,8 @@ | ||
1 | +import socket | ||
2 | + | ||
3 | +if __name__ == '__main__': | ||
4 | + clientSocket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM); | ||
5 | + data = "Hello Server!"; | ||
6 | + clientSocket.sendto(data.encode(),("172.26.145.62",9090)); | ||
7 | + dataFromServer,sourceAddress = clientSocket.recvfrom(1024); | ||
8 | + print(dataFromServer.decode()); |
@@ -0,0 +1,9 @@ | @@ -0,0 +1,9 @@ | ||
1 | +import socket | ||
2 | + | ||
3 | +if __name__=='__main__': | ||
4 | + server.Socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM); | ||
5 | + serverSocket.bind(("172.26.145.62",9090)); # Adresse du serveur à modifer selon l'IP de la RASPBERRY (TODO : prendre un argument qui sera donné par le serveur Web) | ||
6 | + while(True): | ||
7 | + dataFromClient, sourceAddress = serverSocket.recvfrom(1024); | ||
8 | + print("Data from %s is %s"%(sourceAddress,dataFromClient.decode())); | ||
9 | + serverSocket.sendto("Hello Client!".encode(),sourceAddress); |
@@ -0,0 +1,8 @@ | @@ -0,0 +1,8 @@ | ||
1 | +import socket | ||
2 | + | ||
3 | +if __name__ == '__main__': | ||
4 | + clientSocket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM); | ||
5 | + data = "Hello Server!"; | ||
6 | + clientSocket.sendto(data.encode(),("172.26.145.62",9090)); | ||
7 | + dataFromServer,sourceAddress = clientSocket.recvfrom(1024); | ||
8 | + print(dataFromServer.decode()); |
html/gestionReservation.php
@@ -36,13 +36,18 @@ | @@ -36,13 +36,18 @@ | ||
36 | /* Verification de la syntaxe de la date */ | 36 | /* Verification de la syntaxe de la date */ |
37 | $explosion_date = explode("-",$txtDate); | 37 | $explosion_date = explode("-",$txtDate); |
38 | $jour = $explosion_date[2]; | 38 | $jour = $explosion_date[2]; |
39 | + $mois = $explosion_date[1]; | ||
40 | + $annee = $explosion_date[0]; | ||
39 | if($jour<10){ | 41 | if($jour<10){ |
40 | - $jour = "0$jour"; | ||
41 | - $mois = $explosion_date[1]; | ||
42 | - $annee = $explosion_date[0]; | 42 | + $jour = "0$jour"; |
43 | + $txtDate = "$annee-$mois-$jour"; | ||
44 | + } | ||
45 | + if($mois<10){ | ||
46 | + $mois = "0$mois"; | ||
43 | $txtDate = "$annee-$mois-$jour"; | 47 | $txtDate = "$annee-$mois-$jour"; |
44 | } | 48 | } |
45 | } | 49 | } |
50 | + echo $txtDate; | ||
46 | ?> | 51 | ?> |
47 | 52 | ||
48 | <form method="POST" action="gestionReservation.php"> | 53 | <form method="POST" action="gestionReservation.php"> |
html/index.html
@@ -18,7 +18,7 @@ | @@ -18,7 +18,7 @@ | ||
18 | <div class="container"> | 18 | <div class="container"> |
19 | <div class="row"> | 19 | <div class="row"> |
20 | <div style="margin-top: 13rem!important; padding-left: 20rem!important; padding-right: 20rem!important;"> | 20 | <div style="margin-top: 13rem!important; padding-left: 20rem!important; padding-right: 20rem!important;"> |
21 | - <div class="login-panel panel panel-default"> | 21 | + <div class="login-panel panel panel-default" style="background-color:white; padding:1em; border-radius:10px;"> |
22 | <div class="panel-heading"> | 22 | <div class="panel-heading"> |
23 | <!--Ajouter photo--> | 23 | <!--Ajouter photo--> |
24 | </div> | 24 | </div> |
html/menu.php
@@ -28,6 +28,8 @@ | @@ -28,6 +28,8 @@ | ||
28 | }else{ | 28 | }else{ |
29 | echo "<meta http-equiv=\"refresh\" content=\"0;url=index.html\">"; | 29 | echo "<meta http-equiv=\"refresh\" content=\"0;url=index.html\">"; |
30 | } | 30 | } |
31 | + //$test = shell_exec('python3 Python/client.py'); | ||
32 | + //echo "Reponse : $test"; | ||
31 | ?> | 33 | ?> |
32 | <form method="POST" action="menu.php?deconnexion=true"> | 34 | <form method="POST" action="menu.php?deconnexion=true"> |
33 | <button class="btn-lg btn-danger" type="submit">Deconnexion</button> | 35 | <button class="btn-lg btn-danger" type="submit">Deconnexion</button> |
html/reservation.php
@@ -133,6 +133,34 @@ | @@ -133,6 +133,34 @@ | ||
133 | var xhttp = new XMLHttpRequest(); | 133 | var xhttp = new XMLHttpRequest(); |
134 | var params = "date="+realDate+"&banc="+realBanc; | 134 | var params = "date="+realDate+"&banc="+realBanc; |
135 | console.log(params); | 135 | console.log(params); |
136 | + xhttp.onreadystatechange=function(){ | ||
137 | + if(xhttp.readyState==4){ | ||
138 | + // Si requete faite, on modifie les horaires non dispo | ||
139 | + var elemId; | ||
140 | + var texte=xhttp.responseText.split("-"); | ||
141 | + if(texte.length>1){ | ||
142 | + for(var i=0;i<texte.length-1;i++){ | ||
143 | + if(texte[i][0]==0){ | ||
144 | + elemId=texte[i][1]; | ||
145 | + }else{ | ||
146 | + elemId=texte[i][0]+texte[i][1]; | ||
147 | + } | ||
148 | + var chgt = document.getElementById(elemId); | ||
149 | + chgt.setAttribute('disabled','disabled'); | ||
150 | + chgt.style.color="red"; | ||
151 | + } | ||
152 | + }else{ | ||
153 | + for(var i=0;i<24;i++){ | ||
154 | + var chgt = document.getElementById(i); | ||
155 | + chgt.removeAttribute('disabled'); | ||
156 | + chgt.style.color="black"; | ||
157 | + } | ||
158 | + } | ||
159 | + } | ||
160 | + } | ||
161 | + xhttp.open('POST','dispoCreneau.php',true); | ||
162 | + xhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); | ||
163 | + xhttp.send(params); | ||
136 | /* Enleve les creneaux deja passes dans la journee pour ne plus pouvoir les reserver */ | 164 | /* Enleve les creneaux deja passes dans la journee pour ne plus pouvoir les reserver */ |
137 | var horaire = new Date(); | 165 | var horaire = new Date(); |
138 | var mois = parseInt(horaire.getMonth())+1; | 166 | var mois = parseInt(horaire.getMonth())+1; |
@@ -152,46 +180,17 @@ | @@ -152,46 +180,17 @@ | ||
152 | console.log(realDate); | 180 | console.log(realDate); |
153 | if(laDate==realDate){ | 181 | if(laDate==realDate){ |
154 | var heure = horaire.getHours(); | 182 | var heure = horaire.getHours(); |
155 | - for(var i=0;i<parseInt(heure);i++){ | 183 | + for(var i=0;i<parseInt(heure);i++){ |
156 | var chgt = document.getElementById(i); | 184 | var chgt = document.getElementById(i); |
157 | - chgt.disabled=true; | 185 | + chgt.setAttribute('disabled','disabled'); |
158 | console.log(chgt.value); | 186 | console.log(chgt.value); |
159 | - chgt.color="red"; | 187 | + chgt.style.color="red"; |
160 | } | 188 | } |
161 | var chgt = document.getElementById(heure); | 189 | var chgt = document.getElementById(heure); |
162 | chgt.selected=true; | 190 | chgt.selected=true; |
163 | calcul_fin(); | 191 | calcul_fin(); |
164 | } | 192 | } |
165 | /* */ | 193 | /* */ |
166 | - xhttp.onreadystatechange=function(){ | ||
167 | - if(xhttp.readyState==4){ | ||
168 | - // Si requete faite, on modifie les horaires non dispo | ||
169 | - var elemId; | ||
170 | - var texte=xhttp.responseText.split("-"); | ||
171 | - if(texte.length>1){ | ||
172 | - for(var i=0;i<texte.length-1;i++){ | ||
173 | - if(texte[i][0]==0){ | ||
174 | - elemId=texte[i][1]; | ||
175 | - }else{ | ||
176 | - elemId=texte[i][0]+texte[i][1]; | ||
177 | - } | ||
178 | - var chgt = document.getElementById(elemId); | ||
179 | - chgt.disabled=true; | ||
180 | - chgt.style.color="red"; | ||
181 | - } | ||
182 | - }else{ | ||
183 | - for(var i=0;i<24;i++){ | ||
184 | - var chgt = document.getElementById(i); | ||
185 | - chgt.disabled=false; | ||
186 | - chgt.style.color="black"; | ||
187 | - } | ||
188 | - } | ||
189 | - } | ||
190 | - } | ||
191 | - | ||
192 | - xhttp.open('POST','dispoCreneau.php',true); | ||
193 | - xhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); | ||
194 | - xhttp.send(params); | ||
195 | } | 194 | } |
196 | </script> | 195 | </script> |
197 | </body> | 196 | </body> |