diff --git a/Request_Test/testHTTP.http b/Request_Test/testHTTP.http index e4e1141..7ebcd87 100644 --- a/Request_Test/testHTTP.http +++ b/Request_Test/testHTTP.http @@ -1,93 +1,4 @@ -GET http://serveur-projet-s4.felix/src/API/requests.php/api/search?type=Généraliste&location=35 +GET http://ajax.yanisrff/src/API/requests.php/api/rdv-praticient?id=1 Accept: application/json -### -GET http://serveur-projet-s4.felix/src/API/requests.php/api/search-postal?postal=44 -Accept: application/json - -### -GET http://serveur-projet-s4.felix/src/API/requests.php/api/search-type?type=Généraliste -Accept: application/json - -### - -GET http://serveur-projet-s4.felix/src/API/requests.php/api/rdv-available?id=1 -Accept: application/json - -### -GET http://serveur-projet-s4.felix/src/API/requests.php/api/rdv-date?date=2024-03-18&id=1 -Accept: application/json - -### - -GET http://serveur-projet-s4.felix/src/API/requests.php/api/search?type=G%C3%A9n%C3%A9raliste&postal=35 -Accept: application/json - -### - -GET http://serveur-projet-s4.felix/src/API/requests.php/api/praticien?id=1 -Accept: application/json - -### - -PUT http://serveur-projet-s4.felix/src/API/requests.php/api/rdv -Content-Type: application/x-www-form-urlencoded - -rdv_id = 46792 & -patient_id = 1 - -### - -PUT http://serveur-projet-s4.felix/src/API/requests.php/api/requests -Content-Type: application/x-www-form-urlencoded - -test = "coucou" - -### - -POST http://serveur-projet-s4.felix/src/API/requests.php/api/requests -Content-Type: application/x-www-form-urlencoded - -test = "coucou" - -### - -POST http://serveur-projet-s4.felix/src/API/requests.php/api/login/patient -Content-Type: application/x-www-form-urlencoded - -mail = nicolasgrenier@example.com & -password = a - -### - -POST http://serveur-projet-s4.felix/src/API/requests.php/api/login/medecin -Content-Type: application/x-www-form-urlencoded - -mail = cberger@example.org & -password = a - -### - -PUT http://serveur-projet-s4.felix/src/API/requests.php/api/signup/patient -Content-Type: application/x-www-form-urlencoded - -mail = felix.marquet@isen-ouest.yncrea.fr & -password = a & -name = Marquet & -surname = Félix & -phone = 0645383602 - -### - -PUT http://serveur-projet-s4.felix/src/API/requests.php/api/signup/medecin -Content-Type: application/x-www-form-urlencoded - -mail = felix.marquet@isen-ouest.yncrea.fr & -password = a & -name = Marquet & -surname = Félix & -phone = 0645383602 & -specialite = Test & -postal = 44470 - ### \ No newline at end of file diff --git a/rdv-praticien.php b/rdv-praticien.php index e4b8885..b37ad36 100644 --- a/rdv-praticien.php +++ b/rdv-praticien.php @@ -1,48 +1,4 @@ - - - - - RDV - - - - - - - - -
-
- -

- Doct'ISEN -

-
-
-
-
- -
-
-
diff --git a/src/API/requests.php b/src/API/requests.php index 50d3b3b..90f2464 100644 --- a/src/API/requests.php +++ b/src/API/requests.php @@ -128,7 +128,7 @@ $router->DELETE('/api/requests', ["test"], function($test){ $router->GET('/api/rdv-praticient', ["id"], function($id){ global $pdo; dbRequestRdvPraticien($pdo, $id); - getAllLieux($pdo); + //getAllLieux($pdo); }); $router->GET('/api/rdv-patient', ["id"], function($id){ diff --git a/src/API/test/database.php b/src/API/test/database.php index d596c37..cbdca98 100644 --- a/src/API/test/database.php +++ b/src/API/test/database.php @@ -49,7 +49,7 @@ function dbRequestRdvPatient($pdo, $id){ INNER JOIN lieu on lieu.l_id = rendez_vous.l_id WHERE NOW() <= (rdv_date + rdv_time) AND patient.p_id = :id - ORDER BY rdv_date, rdv_time ASC"); + ORDER BY rdv_date ASC, rdv_time ASC"); $statement->bindParam(':id', $id); $statement->execute(); @@ -71,7 +71,7 @@ function getPastRdvByPatient($pdo, $id){ INNER JOIN lieu on lieu.l_id = rendez_vous.l_id WHERE NOW() > (rdv_date + rdv_time) AND patient.p_id = :id - ORDER BY rdv_date, rdv_time ASC"); + ORDER BY rdv_date DESC, rdv_time DESC LIMIT 5"); $statement->bindParam(':id', $id); $statement->execute(); $result = $statement->fetchAll(PDO::FETCH_ASSOC); diff --git a/src/js/AJAX/index.js b/src/js/AJAX/index.js index 184fe79..1f85725 100644 --- a/src/js/AJAX/index.js +++ b/src/js/AJAX/index.js @@ -1,6 +1,8 @@ import {attachSearchEventListener} from "./search.js"; import {attachLoginUserDisplayEventListener, attachLoginPraticienDisplayEventListener, attachDisconnectEventListener} from "./login.js"; +import {TokenDecode} from "./lib.js"; import {displayHome, displayHomeTopBar, attachReturnHomeEventListener} from "./home.js"; + console.log("index.js loaded"); @@ -15,17 +17,40 @@ document.addEventListener("DOMContentLoaded", function() { //Yanis Part +document.addEventListener("DOMContentLoaded", function() { + ButtonShowRdvPraticient(); +}); + +function ButtonShowRdvPraticient() { + try { + console.log("test1"); + document.getElementById("praticien-calendar").addEventListener("click", function () { + console.log("test2"); + ajaxRequest('GET', "src/API/requests.php/api/rdv-praticient?id=" + 1, function (data) { + console.log("test3"); + DisplayRDVPraticient(data); + }); + }); + } + catch (e) { + //Do nothing + //console.error(e); + } +} + function DisplayRDVPraticient(rdv){ let count = rdv.length; - $('#content').empty(); - $('#content').html('
'); + let content = document.getElementById("content"); + content.innerHTML = ""; + content.innerHTML = '
'; if(count === 0){ - $('#content').append('

Vous n\'avez pas de rendez-vous

'); + content.append('

Vous n\'avez pas de rendez-vous

'); } else { for (let i = 0; i < count; i++){ - if (rdv[i].p_mail !== "null") - $('#content').append('' + + console.log(rdv[i]); + if (rdv[i].p_mail !== null){ + content.innerHTML = '' + '
' + '
' + '
' + @@ -37,9 +62,10 @@ function DisplayRDVPraticient(rdv){ '' + rdv[i].email + '' + '
' + '' + '0' + rdv[i].phone + '' + - '
' + '
'); + '
' + '
'; + } else{ - $('#content').append('' + + content.innerHTML = '' + '
' + '
' + '
' + @@ -48,26 +74,40 @@ function DisplayRDVPraticient(rdv){ '
' + '
' + '
' + '
Vous n\'avez pas de' + '
' + 'patient pour ce créneau
' + - '
' + '
'); + '
' + '
'; } } } } -function ButtonShowRdvPraticient() { - try { - document.getElementById("CalendarPraticient").addEventListener("click", function () { - ajaxRequest('GET', "src/API/requests.php/api/rdv-praticient?id=" + 1, function (data) { - DisplayRDVPraticient(data); - }); - }); + +/* +function DisplayRDVPatient(rdv){ + let rdvPatient = rdv[0]; + let lieux = rdv[1]; + + let count = $rdvPatient.length; + $('#content').empty(); + $('#content').html('
Vos rendez-vous à venir
'); + if(count === 0){ + $('#content').append('

Bienvenue sur Doct\'ISEN, veuillez prendre un rendez-vous en allant à l\'acceuil et en recherchant un praticient!

'); } - catch (e) { - //Do nothing - //console.error(e); + else { + for (let i = 0; i < count; i++){ + if($rdvPatient !== "null") + $('#content').append('' + + '
' + + '
' + + '
' + + '

' + $rdvPatient[i].rdv_date + '

' + + '

' + $rdvPatient[i].rdv_time + '

' + + '
' + '
' + + '
' + + '