From 65b016b30a18f3ea83e713c55aab5b2a51dbc43c Mon Sep 17 00:00:00 2001 From: sinbad Date: Wed, 17 Apr 2024 17:23:21 +0200 Subject: [PATCH] FUCK IT !!!! (Bon j'ai enfin un peu la page rdv praticient) --- Request_Test/testHTTP.http | 47 ---------------------------- src/API/requests.php | 2 +- src/API/test/database.php | 4 +-- src/js/AJAX/index.js | 64 ++++++++++++++++++++++---------------- src/js/AJAX/utils.js | 1 + 5 files changed, 42 insertions(+), 76 deletions(-) diff --git a/Request_Test/testHTTP.http b/Request_Test/testHTTP.http index 1c42112..7ebcd87 100644 --- a/Request_Test/testHTTP.http +++ b/Request_Test/testHTTP.http @@ -1,51 +1,4 @@ GET http://ajax.yanisrff/src/API/requests.php/api/rdv-praticient?id=1 Accept: application/json -### - -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/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 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 + '

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