From 4926f1aac137284b9a1cfc15bb3122b316ed2253 Mon Sep 17 00:00:00 2001 From: sinbad Date: Mon, 8 Apr 2024 10:01:48 +0200 Subject: [PATCH 1/2] Pas encore good mais j'avance --- Request_Test/testHTTP.http | 44 +------------------------------------- rdv-praticien.php | 44 -------------------------------------- src/js/AJAX/index.js | 29 ++++++++++++++++++++++++- 3 files changed, 29 insertions(+), 88 deletions(-) diff --git a/Request_Test/testHTTP.http b/Request_Test/testHTTP.http index 4f99b02..6091c94 100644 --- a/Request_Test/testHTTP.http +++ b/Request_Test/testHTTP.http @@ -1,48 +1,6 @@ -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 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/js/AJAX/index.js b/src/js/AJAX/index.js index 919777b..cb8dee6 100644 --- a/src/js/AJAX/index.js +++ b/src/js/AJAX/index.js @@ -333,6 +333,7 @@ function DisplayRDVPraticient(rdv){ } else { for (let i = 0; i < count; i++){ + date = Date(rdv[i].rdv_date).toDateString(); if (rdv[i].p_mail !== "null") $('#content').append('' + '
' + @@ -366,7 +367,7 @@ function DisplayRDVPraticient(rdv){ function ButtonShowRdvPraticient() { try { - document.getElementById("CalendarPraticient").addEventListener("click", function () { + document.getElementById("PraticientCalendar").addEventListener("click", function () { ajaxRequest('GET', "src/API/requests.php/api/rdv-praticient?id=" + 1, function (data) { DisplayRDVPraticient(data); }); @@ -378,6 +379,32 @@ function ButtonShowRdvPraticient() { } } +function DisplayRDVPatient(rdv){ + $rdvPatient = rdv[0]; + $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!

'); + } + else { + for (let i = 0; i < count; i++){ + if($rdvPatient !== "null") + $('#content').append('' + + '
' + + '
' + + '
' + + '

' + $rdvPatient[i].rdv_date + '

' + + '

' + $rdvPatient[i].rdv_time + '

' + + '
' + '
' + + '
' + + '
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 573c65b..4b78cb1 100644 --- a/src/js/AJAX/index.js +++ b/src/js/AJAX/index.js @@ -1,6 +1,7 @@ import {attachSearchEventListener} from "./search.js"; import {attachLoginUserDisplayEventListener, attachLoginPraticienDisplayEventListener, attachDisconnectEventListener} from "./login.js"; import {displayHome, displayHomeTopBar} from "./home.js"; +import {TokenDecode} from "./lib.js"; console.log("index.js loaded"); @@ -27,18 +28,40 @@ function attachReturnHomeEventListener() { //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++){ - date = Date(rdv[i].rdv_date).toDateString(); - if (rdv[i].p_mail !== "null") - $('#content').append('' + + console.log(rdv[i]); + if (rdv[i].p_mail !== null){ + content.innerHTML = '' + '
' + '
' + '
' + @@ -50,9 +73,10 @@ function DisplayRDVPraticient(rdv){ '' + rdv[i].email + '' + '
' + '' + '0' + rdv[i].phone + '' + - '
' + '
'); + '
' + '
'; + } else{ - $('#content').append('' + + content.innerHTML = '' + '
' + '
' + '
' + @@ -61,30 +85,18 @@ function DisplayRDVPraticient(rdv){ '
' + '
' + '
' + '
Vous n\'avez pas de' + '
' + 'patient pour ce créneau
' + - '
' + '
'); + '
' + '
'; } } } } -function ButtonShowRdvPraticient() { - try { - document.getElementById("PraticientCalendar").addEventListener("click", function () { - ajaxRequest('GET', "src/API/requests.php/api/rdv-praticient?id=" + 1, function (data) { - DisplayRDVPraticient(data); - }); - }); - } - catch (e) { - //Do nothing - //console.error(e); - } -} +/* function DisplayRDVPatient(rdv){ - $rdvPatient = rdv[0]; - $lieux = rdv[1]; + let rdvPatient = rdv[0]; + let lieux = rdv[1]; let count = $rdvPatient.length; $('#content').empty(); @@ -103,10 +115,10 @@ function DisplayRDVPatient(rdv){ '

' + $rdvPatient[i].rdv_time + '

' + '
' + '
' + '
' + - '