From 5b7dba97a0de66ab4e93a0dc384c24fe5dbbf5b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20MARQUET?= Date: Wed, 17 Apr 2024 17:27:31 +0200 Subject: [PATCH 1/5] I'M A TEAPOT (no fix affichage) --- src/API/src/response.php | 2 +- src/js/AJAX/home.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/API/src/response.php b/src/API/src/response.php index a886a02..733ed64 100644 --- a/src/API/src/response.php +++ b/src/API/src/response.php @@ -73,6 +73,6 @@ class Response header('Cache-control: no-store, no-cache, must-revalidate'); header('Pragma: no-cache'); http_response_code(418); - echo json_encode($data); + echo json_encode($data); // I'm a teapot } } \ No newline at end of file diff --git a/src/js/AJAX/home.js b/src/js/AJAX/home.js index b67568f..2ce4fb1 100644 --- a/src/js/AJAX/home.js +++ b/src/js/AJAX/home.js @@ -45,7 +45,7 @@ function displayHomeTopBar() { - + `; @@ -70,7 +70,7 @@ function displayHomeTopBar() { - + `; From 2cb70e81b0e148186c5f21403122c0bcf01fcccf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20MARQUET?= Date: Wed, 17 Apr 2024 17:33:33 +0200 Subject: [PATCH 2/5] Index from php to html --- forgotPassword-praticien.php | 2 +- forgotPassword.php | 2 +- index.php => index.html | 2 +- login-praticien.php | 2 +- login.php | 4 ++-- signup-praticien.php | 4 ++-- signup.php | 4 ++-- src/php/components/check.php | 8 ++++---- src/php/db/scripts/deconnexion.php | 2 +- 9 files changed, 15 insertions(+), 15 deletions(-) rename index.php => index.html (99%) diff --git a/forgotPassword-praticien.php b/forgotPassword-praticien.php index a8c3bdd..f83065d 100644 --- a/forgotPassword-praticien.php +++ b/forgotPassword-praticien.php @@ -21,7 +21,7 @@ $pdo = dbConnect(); ?>
- +

Doct'ISEN

diff --git a/forgotPassword.php b/forgotPassword.php index 09030c7..a1f3016 100644 --- a/forgotPassword.php +++ b/forgotPassword.php @@ -21,7 +21,7 @@ $pdo = dbConnect(); ?>
- +

Doct'ISEN

diff --git a/index.php b/index.html similarity index 99% rename from index.php rename to index.html index 314c3b3..79f6e2d 100644 --- a/index.php +++ b/index.html @@ -2,7 +2,7 @@ - Acceuil + Accueil diff --git a/login-praticien.php b/login-praticien.php index 459df1d..0b3a931 100644 --- a/login-praticien.php +++ b/login-praticien.php @@ -22,7 +22,7 @@ ?>
- +

Doct'ISEN

diff --git a/login.php b/login.php index 9913c67..c564acc 100644 --- a/login.php +++ b/login.php @@ -23,7 +23,7 @@
- +

Doct'ISEN

@@ -60,7 +60,7 @@ if($login != false){ error_log("Login success"); $_SESSION['token'] = base64_encode("patient:".strval($login)); - echo ''; + echo ''; } else { error_log('Erreur de connexion'); } diff --git a/signup-praticien.php b/signup-praticien.php index 7cfb68d..87ba5de 100644 --- a/signup-praticien.php +++ b/signup-praticien.php @@ -23,7 +23,7 @@ session_start(); ?>
- +

Doct'ISEN

@@ -98,7 +98,7 @@ session_start(); if(SignupMedecin::insertMedecin($pdo,$name,$surname,$mail, $password,$specialite,$phone,$codePostal)){ error_log("Signup success"); $_SESSION['id'] = $mail; - echo ''; + echo ''; } else { error_log("Erreur d'inscription"); } diff --git a/signup.php b/signup.php index 44d3b94..c354103 100644 --- a/signup.php +++ b/signup.php @@ -23,7 +23,7 @@ session_start(); ?>
- +

Doct'ISEN

@@ -88,7 +88,7 @@ session_start(); if(SignupPatient::Insert($pdo,$name,$surname,$mail,$password,$phone)){ error_log("Signup success"); $_SESSION['id'] = $mail; - echo ''; + echo ''; } else { error_log('Erreur de connexion'); } diff --git a/src/php/components/check.php b/src/php/components/check.php index df3c54f..732ea7a 100644 --- a/src/php/components/check.php +++ b/src/php/components/check.php @@ -14,7 +14,7 @@ function checkMedecin(){ return true; } else { if($token[0] == "patient"){ - echo ''; + echo ''; return false; } else { echo ''; @@ -22,7 +22,7 @@ function checkMedecin(){ } } } else { - echo ''; + echo ''; return false; } } @@ -34,7 +34,7 @@ function checkPatient(){ return true; } else { if($token[0] == "medecin"){ - echo ''; + echo ''; return false; } else { echo ''; @@ -42,7 +42,7 @@ function checkPatient(){ } } } else { - echo ''; + echo ''; return false; } } diff --git a/src/php/db/scripts/deconnexion.php b/src/php/db/scripts/deconnexion.php index 97001dd..1aa0918 100644 --- a/src/php/db/scripts/deconnexion.php +++ b/src/php/db/scripts/deconnexion.php @@ -4,6 +4,6 @@ error_reporting(E_ALL); session_start(); unset($_SESSION["token"]); //Redirect to the rdv.php page -echo ''; +echo ''; ?> \ No newline at end of file From 871cfb49b8ff117281802e811879058529c87547 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20MARQUET?= Date: Wed, 17 Apr 2024 17:35:41 +0200 Subject: [PATCH 3/5] Readd a fucking margin (I'm still a teapot) --- index.html | 12 ------------ src/js/AJAX/home.js | 4 ++-- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/index.html b/index.html index 79f6e2d..152c927 100644 --- a/index.html +++ b/index.html @@ -21,18 +21,6 @@

- -

diff --git a/src/js/AJAX/home.js b/src/js/AJAX/home.js index b67568f..2ce4fb1 100644 --- a/src/js/AJAX/home.js +++ b/src/js/AJAX/home.js @@ -45,7 +45,7 @@ function displayHomeTopBar() {
- +
`; @@ -70,7 +70,7 @@ function displayHomeTopBar() {
- + `; From 505389ccdfc2b816552e09afaed3b3892c43cc78 Mon Sep 17 00:00:00 2001 From: sinbad Date: Wed, 17 Apr 2024 17:41:19 +0200 Subject: [PATCH 4/5] FIn de cours --- src/API/requests.php | 5 +++++ src/js/AJAX/index.js | 29 +++++++++++++++++++++-------- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/API/requests.php b/src/API/requests.php index 90f2464..7d918c9 100644 --- a/src/API/requests.php +++ b/src/API/requests.php @@ -131,6 +131,11 @@ $router->GET('/api/rdv-praticient', ["id"], function($id){ //getAllLieux($pdo); }); +$router->GET('/api/rdv-praticient/getAllLieux', [], function(){ + global $pdo; + getAllLieux($pdo); +}); + $router->GET('/api/rdv-patient', ["id"], function($id){ global $pdo; dbRequestRdvPatient($pdo, $id); diff --git a/src/js/AJAX/index.js b/src/js/AJAX/index.js index 1f85725..99397fd 100644 --- a/src/js/AJAX/index.js +++ b/src/js/AJAX/index.js @@ -23,11 +23,9 @@ document.addEventListener("DOMContentLoaded", function() { 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"); + let user = TokenDecode(sessionStorage.getItem("token")); + ajaxRequest('GET', "src/API/requests.php/api/rdv-praticient?id=" + user.id, function (data) { DisplayRDVPraticient(data); }); }); @@ -47,9 +45,9 @@ function DisplayRDVPraticient(rdv){ content.append('

Vous n\'avez pas de rendez-vous

'); } else { - for (let i = 0; i < count; i++){ + for (let i = 0; i < count; i++) { console.log(rdv[i]); - if (rdv[i].p_mail !== null){ + if (rdv[i].p_mail !== null) { content.innerHTML = '' + '
' + '
' + @@ -63,8 +61,7 @@ function DisplayRDVPraticient(rdv){ '
' + '' + '0' + rdv[i].phone + '' + '
' + '
'; - } - else{ + } else { content.innerHTML = '' + '
' + '
' + @@ -76,11 +73,27 @@ function DisplayRDVPraticient(rdv){ '
Vous n\'avez pas de' + '
' + 'patient pour ce créneau
' + '
' + '
'; } + content.innerHTML = '
'; + ShowAddRDV(); } } } +function ShowAddRDV() { + ajaxRequest('GET', "src/API/requests.php/api/rdv-praticient/getAllLieux", function (data) { + DisplayAddRDV(data); + }); +} + +function DisplayAddRDV(lieux) { + let user = TokenDecode(sessionStorage.getItem("token")); + let medID = user.id; + let addRDV = document.getElementById("addRDV"); + addRDV.innerHTML = ""; + addRDV.innerHTML = ''; +} + /* function DisplayRDVPatient(rdv){ From 433c186f9e9c2fc48f2e85c3041d43f042aec144 Mon Sep 17 00:00:00 2001 From: sinbad Date: Tue, 14 May 2024 10:30:11 +0200 Subject: [PATCH 5/5] Page praticient finito pipo --- src/API/requests.php | 1 - src/API/test/database.php | 5 +- src/js/AJAX/index.js | 106 +---------------------------------- src/js/AJAX/rdv-praticien.js | 106 +++++++++++++++++++++++++++++------ 4 files changed, 94 insertions(+), 124 deletions(-) diff --git a/src/API/requests.php b/src/API/requests.php index 7d918c9..42e4ae4 100644 --- a/src/API/requests.php +++ b/src/API/requests.php @@ -128,7 +128,6 @@ $router->DELETE('/api/requests', ["test"], function($test){ $router->GET('/api/rdv-praticient', ["id"], function($id){ global $pdo; dbRequestRdvPraticien($pdo, $id); - //getAllLieux($pdo); }); $router->GET('/api/rdv-praticient/getAllLieux', [], function(){ diff --git a/src/API/test/database.php b/src/API/test/database.php index cbdca98..6c0b3e8 100644 --- a/src/API/test/database.php +++ b/src/API/test/database.php @@ -111,6 +111,7 @@ function getAllLieux($pdo){ } function CreateRDV($pdo, $medID, $date, $time, $lieu){ + error_log($lieu. ', ' . $date . ', ' . $time . ', ' . $medID); $lieu = explode(', ', $lieu); $adress = $lieu[0] . ', ' . $lieu[1]; $postal = $lieu[2]; @@ -131,7 +132,9 @@ function CreateRDV($pdo, $medID, $date, $time, $lieu){ $statement->execute(); Response::HTTP200(["Success" => "RDV created"]); } - Response::HTTP404(["Error" => "Lieu not found"]); + else { + Response::HTTP404(["Error" => "Lieu not found"]); + } } function DeleteEmptyRdv($pdo, $id) diff --git a/src/js/AJAX/index.js b/src/js/AJAX/index.js index 99397fd..e335569 100644 --- a/src/js/AJAX/index.js +++ b/src/js/AJAX/index.js @@ -2,10 +2,10 @@ import {attachSearchEventListener} from "./search.js"; import {attachLoginUserDisplayEventListener, attachLoginPraticienDisplayEventListener, attachDisconnectEventListener} from "./login.js"; import {TokenDecode} from "./lib.js"; import {displayHome, displayHomeTopBar, attachReturnHomeEventListener} from "./home.js"; +import {ButtonShowRdvPraticient} from "./rdv-praticien.js"; console.log("index.js loaded"); - //Felix Part document.addEventListener("DOMContentLoaded", function() { @@ -14,116 +14,12 @@ document.addEventListener("DOMContentLoaded", function() { } }); - //Yanis Part document.addEventListener("DOMContentLoaded", function() { ButtonShowRdvPraticient(); }); -function ButtonShowRdvPraticient() { - try { - document.getElementById("praticien-calendar").addEventListener("click", function () { - let user = TokenDecode(sessionStorage.getItem("token")); - ajaxRequest('GET', "src/API/requests.php/api/rdv-praticient?id=" + user.id, function (data) { - DisplayRDVPraticient(data); - }); - }); - } - catch (e) { - //Do nothing - //console.error(e); - } -} - -function DisplayRDVPraticient(rdv){ - let count = rdv.length; - let content = document.getElementById("content"); - content.innerHTML = ""; - content.innerHTML = '
'; - if(count === 0){ - content.append('

Vous n\'avez pas de rendez-vous

'); - } - else { - for (let i = 0; i < count; i++) { - console.log(rdv[i]); - if (rdv[i].p_mail !== null) { - content.innerHTML = '' + - '
' + - '
' + - '
' + - '

' + rdv[i].rdv_date + '

' + - '

' + rdv[i].rdv_time + '

' + - '
' + '
' + - '
' + - '
' + rdv[i].patient + '
' + - '' + rdv[i].email + '' + - '
' + - '' + '0' + rdv[i].phone + '' + - '
' + '
'; - } else { - content.innerHTML = '' + - '
' + - '
' + - '
' + - '

' + rdv[i].rdv_date + '

' + - '

' + rdv[i].rdv_time + '

' + - '
' + '
' + - '
' + - '
Vous n\'avez pas de' + '
' + 'patient pour ce créneau
' + - '
' + '
'; - } - content.innerHTML = '
'; - ShowAddRDV(); - - } - } -} - -function ShowAddRDV() { - ajaxRequest('GET', "src/API/requests.php/api/rdv-praticient/getAllLieux", function (data) { - DisplayAddRDV(data); - }); -} - -function DisplayAddRDV(lieux) { - let user = TokenDecode(sessionStorage.getItem("token")); - let medID = user.id; - let addRDV = document.getElementById("addRDV"); - addRDV.innerHTML = ""; - addRDV.innerHTML = ''; -} - - -/* -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!

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

' + $rdvPatient[i].rdv_date + '

' + - '

' + $rdvPatient[i].rdv_time + '

' + - '
' + '
' + - '
' + - '
'); + 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('' + - '
' + + for (let i = 0; i < count; i++) { + console.log(rdv[i]); + if (rdv[i].p_mail !== null) { + content.innerHTML += '
' + '
' + '
' + '

' + rdv[i].rdv_date + '

' + @@ -17,13 +36,12 @@ function DisplayRDV(rdv){ '
' + '
' + '
' + '
' + rdv[i].patient + '
' + - '' + rdv[i].email + '' + + '' + rdv[i].p_mail + '' + '
' + - '' + '0' + rdv[i].phone + '' + - '
' + '
'); - else{ - $('#content').append('' + - '' + '
'; + } else { + content.innerHTML += '
' + '
' + '
' + '

' + rdv[i].rdv_date + '

' + @@ -31,9 +49,63 @@ function DisplayRDV(rdv){ '
' + '
' + '
' + '
Vous n\'avez pas de' + '
' + 'patient pour ce créneau
' + - '
' + '
'); + '
' + '
'; } - } } -} \ No newline at end of file + content.innerHTML += '
'; + ShowAddRDV(); +} + +function ShowAddRDV() { + ajaxRequest('GET', "src/API/requests.php/api/rdv-praticient/getAllLieux", function (data) { + DisplayAddRDV(data); + }); +} + +function DisplayAddRDV(lieux) { + let user = TokenDecode(sessionStorage.getItem("token")); + let medID = user.id; + let addRDV = document.getElementById("addRDV"); + addRDV.innerHTML = ''; + + let options =''; + lieux.forEach(function (row) { + console.log(row); + let adress = row["l_adress"]; + let postal = row["l_postal"]; + let city = row["l_city"]; + let lieu = adress + ', ' + postal + ', ' + city; + options += ""; + }); + console.log(options); + addRDV.innerHTML += '
' + + "" + + "" + + "" + + "" + + "

" + + "" + + "
"; + document.getElementById("addRDVbutton").addEventListener("click", function (event) { + event.preventDefault(); + let medID = document.querySelector("input[name='medID']").value; + let date = document.querySelector("input[name='date']").value; + let time = document.querySelector("input[name='time']").value; + let lieu = document.querySelector("select[name='lieu']").value; + let data = 'medID=' + medID + '&date=' + date + '&time=' + time + '&lieu=' + lieu; + ajaxRequest('POST', "src/API/requests.php/api/create-rdv", function (data) { + console.log(data); + ButtonShowRdvPraticient(); + }, data); + ajaxRequest('GET', "src/API/requests.php/api/rdv-praticient?id=" + user.id, function (data) { + DisplayRDVPraticient(data); + console.log(data); + }); + }); +} + +export {ButtonShowRdvPraticient}; \ No newline at end of file