mirror of
https://github.com/BreizhHardware/ProjetS4COMWEB.git
synced 2026-01-18 16:47:35 +01:00
@@ -16,10 +16,6 @@ $pdo = dbConnect();
|
||||
|
||||
$router = new Router();
|
||||
|
||||
$router->GET('/api/requests', ["test"], function($test){
|
||||
echo json_encode($test);
|
||||
});
|
||||
|
||||
$router->GET('/api/search-type', ["type"], function($type){
|
||||
global $pdo;
|
||||
searchDoctor($pdo, $type);
|
||||
@@ -58,9 +54,6 @@ $router->PUT('/api/rdv', ["rdv_id", "patient_id"], function($rdv_id, $patient_id
|
||||
global $pdo;
|
||||
takeRDV($pdo, $rdv_id, $patient_id);
|
||||
});
|
||||
$router->POST('/api/requests', ["test"], function($test){
|
||||
echo json_encode($test);
|
||||
});
|
||||
|
||||
$router->POST('/api/login/patient', ["mail", "password"], function($mail, $password){
|
||||
global $pdo;
|
||||
@@ -117,13 +110,10 @@ $router->PUT('/api/change/mail', ["id", "currentMail", "newMail"], function($id,
|
||||
Patient::updateMail($pdo, $id, $currentMail, $newMail);
|
||||
});
|
||||
|
||||
$router->PUT('/api/requests', ["test"], function($test){
|
||||
echo json_encode($test);
|
||||
});
|
||||
|
||||
$router->DELETE('/api/requests', ["test"], function($test){
|
||||
echo json_encode($test);
|
||||
});
|
||||
//Yanis Part
|
||||
|
||||
|
||||
|
||||
$router->GET('/api/rdv-praticient', ["id"], function($id){
|
||||
global $pdo;
|
||||
@@ -135,9 +125,13 @@ $router->GET('/api/rdv-praticient/getAllLieux', [], function(){
|
||||
getAllLieux($pdo);
|
||||
});
|
||||
|
||||
$router->GET('/api/rdv-patient', ["id"], function($id){
|
||||
$router->GET('/api/next-rdv-patient', ["id"], function($id){
|
||||
global $pdo;
|
||||
dbRequestRdvPatient($pdo, $id);
|
||||
});
|
||||
|
||||
$router->GET('/api/past-rdv-patient', ["id"], function($id){
|
||||
global $pdo;
|
||||
getPastRdvByPatient($pdo, $id);
|
||||
});
|
||||
|
||||
@@ -156,4 +150,7 @@ $router->POST('/api/create-rdv', ["medID", "date", "time", "lieu"], function($me
|
||||
CreateRDV($pdo, $medID, $date, $time, $lieu);
|
||||
});
|
||||
|
||||
|
||||
//End of Yanis Part
|
||||
|
||||
$router->run();
|
||||
|
||||
@@ -41,7 +41,7 @@ function dbRequestRdvPraticien($pdo, $id){
|
||||
}
|
||||
|
||||
function dbRequestRdvPatient($pdo, $id){
|
||||
$statement = $pdo->prepare("SELECT rdv_date, rdv_time, concat(m_name, ' ', m_surname) as medecin, medecin.m_specialty, medecin.m_id, concat(p_name, ' ', p_surname) as patient, l_adress as adresse, concat(l_postal, ' ', l_city) as ville
|
||||
$statement = $pdo->prepare("SELECT rdv_date, rdv_time, concat(m_name, ' ', m_surname) as medecin, medecin.m_specialty as med_spe, medecin.m_id, concat(p_name, ' ', p_surname) as patient, l_adress as adresse, concat(l_postal, ' ', l_city) as ville
|
||||
FROM rendez_vous
|
||||
INNER JOIN patient ON rendez_vous.p_id = patient.p_id
|
||||
INNER JOIN propose ON rendez_vous.rdv_id = propose.rdv_id
|
||||
@@ -49,7 +49,8 @@ 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 ASC, rdv_time ASC");
|
||||
ORDER BY rdv_date ASC, rdv_time ASC
|
||||
LIMIT 5");
|
||||
|
||||
$statement->bindParam(':id', $id);
|
||||
$statement->execute();
|
||||
@@ -63,7 +64,7 @@ function dbRequestRdvPatient($pdo, $id){
|
||||
}
|
||||
|
||||
function getPastRdvByPatient($pdo, $id){
|
||||
$statement = $pdo->prepare("SELECT rdv_date, rdv_time, concat(m_name, ' ', m_surname) as medecin, medecin.m_specialty, medecin.m_id, concat(p_name, ' ', p_surname) as patient, l_adress as adresse, concat(l_postal, ' ', l_city) as ville
|
||||
$statement = $pdo->prepare("SELECT rdv_date, rdv_time, concat(m_name, ' ', m_surname) as medecin, medecin.m_specialty as med_spe, medecin.m_id as med_id, concat(p_name, ' ', p_surname) as patient, l_adress as adresse, concat(l_postal, ' ', l_city) as ville
|
||||
FROM rendez_vous
|
||||
INNER JOIN patient ON rendez_vous.p_id = patient.p_id
|
||||
INNER JOIN propose ON rendez_vous.rdv_id = propose.rdv_id
|
||||
|
||||
@@ -3,6 +3,7 @@ import {attachLoginUserDisplayEventListener, attachLoginPraticienDisplayEventLis
|
||||
//import {TokenDecode} from "./lib.js";
|
||||
import {displayHome, displayHomeTopBar, attachReturnHomeEventListener} from "./home.js";
|
||||
import {ButtonShowRdvPraticient} from "./rdv-praticien.js";
|
||||
import {ButtonShowRdvPatient} from "./rdv-patient.js";
|
||||
|
||||
console.log("index.js loaded");
|
||||
|
||||
@@ -20,6 +21,10 @@ document.addEventListener("DOMContentLoaded", function() {
|
||||
ButtonShowRdvPraticient();
|
||||
});
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
ButtonShowRdvPatient();
|
||||
});
|
||||
|
||||
//End Call
|
||||
|
||||
ButtonShowRdvPraticient();
|
||||
|
||||
169
src/js/AJAX/rdv-patient.js
Normal file
169
src/js/AJAX/rdv-patient.js
Normal file
@@ -0,0 +1,169 @@
|
||||
import {TokenDecode} from "./lib.js";
|
||||
import {displayCalendar} from "./take-rdv.js";
|
||||
|
||||
function ButtonShowRdvPatient() {
|
||||
try {
|
||||
document.getElementById("user-calendar").addEventListener("click", function () {
|
||||
let content = document.getElementById("content");
|
||||
let nextRDV;
|
||||
let user = TokenDecode(sessionStorage.getItem("token"));
|
||||
ajaxRequest('GET', "src/API/requests.php/api/next-rdv-patient?id=" + user.id, function (data) {
|
||||
nextRDV = data
|
||||
content.innerHTML = "";
|
||||
content.innerHTML += '<div class="h-100"> <div class="row"> <div class="col-3 border-end border-dark border-3 h-100 mt-2 text-center d-flex flex-column justify-content-center"> <div class="d-flex flex-column"> <div id="next-rdv" class="border-bottom pb-3 border-dark border-3 align-self-center">';
|
||||
|
||||
DisplayNextRDVPatient(data);
|
||||
content.innerHTML += "</div> <div id='past-rdv' class=\'mt-3 align-self-center d-flex flex-column gap-2\'>";
|
||||
|
||||
ajaxRequest('GET', "src/API/requests.php/api/past-rdv-patient?id=" + user.id, function (data) {
|
||||
DisplayPastRDVPatient(data);
|
||||
content.innerHTML += "</div> </div> </div> <div id='zoom' class=\"col border-end border-dark border-3 h-100 mt-2 text-center d-flex flex-column justify-content-center\">";
|
||||
DisplayRDV(nextRDV);
|
||||
content.innerHTML += "</div> <div class=\"col h-100\"></div>";
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
//Do nothing
|
||||
//console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
function DisplayNextRDVPatient(rdv){
|
||||
let content = document.getElementById("next-rdv");
|
||||
content.innerHTML = "";
|
||||
content.innerHTML += "<h5 class=\"text-center\">Vos rendez-vous à venir</h5>";
|
||||
if(rdv.length === 0){
|
||||
content.innerHTML += "<p class=\"text-center\">Vous n'avez pas de rendez-vous à venir</p>";
|
||||
}
|
||||
else{
|
||||
for(let i = 0; i < rdv.length; i++) {
|
||||
content.innerHTML += "<div class='card rounded-4 mx-2'> " +
|
||||
"<div class='card-header bg-danger'> " +
|
||||
"<div class='d-flex flex-row justify-content-between text-white'> " +
|
||||
"<p>" + rdv[i].rdv_date + "</p> " +
|
||||
"<p>" + rdv[i].rdv_time + "</p>" +
|
||||
"</div> </div> <div class='card-body'> " +
|
||||
"<h5 class='card-title'>" + rdv[i].medecin + "</h5>" +
|
||||
"<h6 class='card-subtitle mb-2 text-body-secondary'>" + rdv[i].med_spe + "</h6>" +
|
||||
"</div> <div class=\"card-footer\"> <p>Preparer la consulation</p> </div> </div>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function attachEventListener(i, rdv) {
|
||||
document.getElementById("retake-rdv-" + i + "-" + rdv[i].med_id).addEventListener("click", function () {
|
||||
let id = rdv[i].med_id;
|
||||
let today = new Date();
|
||||
let date = today.getFullYear() + "-" + (today.getMonth() + 1).toString().padStart(2, "0") + "-" + today.getDate().toString().padStart(2, "0");
|
||||
ajaxRequest('GET', "src/API/requests.php/api/rdv-date?date=" + date + "&id=" + id, function (data) {
|
||||
displayCalendar(data);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function DisplayPastRDVPatient(rdv) {
|
||||
let content = document.getElementById("past-rdv");
|
||||
content.innerHTML = "";
|
||||
content.innerHTML += "<h5 class=\"text-center\">Vos rendez-vous passés</h5>";
|
||||
if(rdv.length === 0){
|
||||
content.innerHTML += "<p class=\"text-center\">Vous n'avez pas de rendez-vous passé</p>";
|
||||
}
|
||||
else{
|
||||
for(let i = 0; i < rdv.length; i++) {
|
||||
content.innerHTML += "<div class='card rounded-4 mx-2'> " +
|
||||
"<div class='card-header bg-danger'> " +
|
||||
"<div class='d-flex flex-row justify-content-between text-white'> " +
|
||||
"<p>" + rdv[i].rdv_date + "</p> " +
|
||||
"<p>" + rdv[i].rdv_time + "</p>" +
|
||||
"</div> </div> <div class='card-body'> " +
|
||||
"<h5 class='card-title'>" + rdv[i].medecin + "</h5>" +
|
||||
"<h6 class='card-subtitle mb-2 text-body-secondary'>" + rdv[i].med_spe + "</h6>" +
|
||||
"</div> <div class=\"card-footer\"> " +
|
||||
"<button id='retake-rdv-" + i + "-" + rdv[i].med_id + "'>Reprendre rendez-vous</button> " +
|
||||
"</div> </div>";
|
||||
attachEventListener(i, rdv);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function attachEventListenerDeplacer(rdv){
|
||||
document.getElementById("deplacer_button").addEventListener("click", function () {
|
||||
let id = rdv[i].med_id;
|
||||
let today = new Date();
|
||||
let date = today.getFullYear() + "-" + (today.getMonth() + 1).toString().padStart(2, "0") + "-" + today.getDate().toString().padStart(2, "0");
|
||||
ajaxRequest('GET', "src/API/requests.php/api/rdv-date?date=" + date + "&id=" + id, function (data) {
|
||||
displayCalendar(data);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function attachEventListenerAnnuler(rdv){
|
||||
document.getElementById("cancel_button").addEventListener("click", function () {
|
||||
let id = rdv.rdv_id;
|
||||
ajaxRequest('POST', "src/API/requests.php/api/cancel-rdv", function (data) {
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
function DisplayRDV(rdv){
|
||||
let content = document.getElementById("zoom");
|
||||
content.innerHTML = ""
|
||||
if(rdv.length === 0){
|
||||
content.innerHTML += "<div class=\"card rounded-4 mx-2 pointer\"> <div class=\"card-header bg-danger\"> <div class=\"d-flex flex-row justify-content-between text-white\"> <p>Vous n'avez pas de rendez-vous à venir</p> </div> </div> </div>"
|
||||
}
|
||||
else{
|
||||
content.innerHTML += "<div class=\"card rounded-4 mx-2\">" +
|
||||
"<div class=\"card-header bg-danger\">" +
|
||||
"<div class=\"d-flex flex-row justify-content-between text-white\">" +
|
||||
"<p>" + rdv[0].rdv_date + "</p>" +
|
||||
"<p>" + rdv[0].rdv_time + "</p>" +
|
||||
"</div>" +
|
||||
"</div>" +
|
||||
"<div class=\"card-body\">" +
|
||||
"<h5 class='card-title'>" + rdv[0].medecin + "</h5>" +
|
||||
"<h6 class='card-subtitle mb-2 text-body-secondary'>" + rdv[0].med_spe + "</h6>" +
|
||||
"<h6 id='deplacer_button'> Déplacer le rendez-vous </h6>" +
|
||||
"<h6 id='cancel_button'> Annuler le rendez-vous" +
|
||||
"</div>" +
|
||||
"</div>" +
|
||||
"<div class=\"card rounded-4 mx-2 mt-3\">" +
|
||||
"<div class=\"card-body\">" +
|
||||
"<h5 class=\"card-title\">Préparer la consulation</h5>" +
|
||||
"<h6 class=\"card-subtitle mb-2 text-body-secondary\">Pour gagner du temps et améliorer votre prise en charge.</h6>" +
|
||||
"<form action=\"src/php/db/scripts/uploadFile.php\" method=\"post\" enctype=\"multipart/form-data\">" +
|
||||
"<label for=\"file\">Sélectionner un fichier :</label>" +
|
||||
"<input type=\"hidden\" name=\"rdv_id\" value=" + rdv[0].rdv_id + ">" +
|
||||
"<input type=\"file\" class=\"form-control\" name=\"file\" id=\"file\" accept=\".pdf, .jpeg, .jpg, .png\" disabled>" +
|
||||
"<br><br>" +
|
||||
"<input type=\"submit\" class=\"btn border-black border-1 disabled\" name=\"submit\" value=\"Envoyer le fichier\">" +
|
||||
"<h6 class=\"card-subtitle text-danger\">Maintenance en cours.</h6>" +
|
||||
"</form>" +
|
||||
"</div>" +
|
||||
"</div>" +
|
||||
"<div class=\"card rounded-4 mx-2 mt-3\">" +
|
||||
"<div class=\"card-body\">" +
|
||||
"<h5 class=\"card-title\">Patient</h5>" +
|
||||
"<h6 class='card-subtitle mb-2 text-body-secondary'>" + rdv[0].patient + "</h6>" +
|
||||
"</div>" +
|
||||
"</div>" +
|
||||
"<div class=\"card rounded-4 mx-2 mt-3\">" +
|
||||
"<div class=\"card-body\">" +
|
||||
"<h5 class=\"card-title\">Lieu de la consulation</h5>" +
|
||||
"<h6 class='card-subtitle mb-2 text-body-secondary'>" + rdv[0].adresse + "<br>" +
|
||||
rdv[0].ville + "</br></h6>" +
|
||||
"</div>" +
|
||||
"</div>"
|
||||
attachEventListenerDeplacer(rdv);
|
||||
attachEventListenerAnnuler(rdv);
|
||||
}
|
||||
}
|
||||
|
||||
export {ButtonShowRdvPatient};
|
||||
@@ -156,4 +156,4 @@ function attachPrendreRDVEventListener() {
|
||||
});
|
||||
}
|
||||
|
||||
export {attachRDVEventListener};
|
||||
export {attachRDVEventListener, displayCalendar};
|
||||
Reference in New Issue
Block a user