Finished !!!! (Juste il faut tester quand un medecin n'a pas de créneau car moi ça me met un ancien code que j'ai supprimé)

This commit is contained in:
sinbad
2024-05-20 15:32:04 +02:00
parent 32971ad40d
commit ab48753cba
4 changed files with 106 additions and 83 deletions

View File

@@ -32,12 +32,7 @@ function dbRequestRdvPraticien($pdo, $id){
$statement->execute();
$result = $statement->fetchAll(PDO::FETCH_ASSOC);
if (!empty($result)) {
Response::HTTP200($result);
} else {
Response::HTTP404(["error" => "No data found"]);
}
Response::HTTP200($result);
}
function dbRequestRdvPatient($pdo, $id){
@@ -56,15 +51,11 @@ function dbRequestRdvPatient($pdo, $id){
$statement->execute();
$result = $statement->fetchAll(PDO::FETCH_ASSOC);
if (!empty($result)) {
Response::HTTP200($result);
} else {
Response::HTTP404(["error" => "No data found"]);
}
Response::HTTP200($result);
}
function getPastRdvByPatient($pdo, $id){
$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
$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

View File

@@ -2,6 +2,8 @@ import {TokenDecode} from "./lib.js";
import {attachSearchEventListener, removeSearchTopBar} from "./search.js";
import {displayAlert} from "./alert.js";
import {attachLoginPraticienDisplayEventListener, attachLoginUserDisplayEventListener, attachDisconnectEventListener} from "./login.js";
import {ButtonShowRdvPraticient} from "./rdv-praticien.js";
import {ButtonShowRdvPatient} from "./rdv-patient.js";
console.log("home.js loaded");
function displayHomeTopBar() {
@@ -137,6 +139,8 @@ function displayHome(text) {
</footer>`;
attachSearchEventListener();
attachLoginUserDisplayEventListener();
ButtonShowRdvPraticient();
ButtonShowRdvPatient();
if(text !== ""){
displayAlert(text);
}

View File

@@ -5,63 +5,7 @@ import {attachReturnHomeEventListener, attachProfileEventListener, horizontalDro
function ButtonShowRdvPatient() {
try {
document.getElementById("user-calendar").addEventListener("click", function () {
let content = document.getElementById("content");
content.innerHTML = "";
let h100 = document.createElement("div");
h100.classList.add("h-100");
let row = document.createElement("div");
row.classList.add("row");
let column = document.createElement("div");
column.classList.add("col-3", "border-end", "border-dark", "border-3", "h-100", "mt-2", "text-center", "d-flex", "flex-column", "justify-content-center");
let column2 =document.createElement("div");
column2.classList.add("d-flex", "flex-column");
let next_rdv = document.createElement("div");
next_rdv.classList.add("border-bottom", "pb-3", "border-dark", "border-3", "align-self-center");
let nextRDV;
let past_rdv = document.createElement("div");
let the_rdv = document.createElement("div");
let searchbar = document.createElement("div")
let user = TokenDecode(sessionStorage.getItem("token"));
ajaxRequest('GET', "src/API/requests.php/api/next-rdv-patient?id=" + user.id, function (data) {
nextRDV = data
DisplayNextRDVPatient(next_rdv, data);
past_rdv.classList.add("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(past_rdv, data);
the_rdv.classList.add("col", "border-end", "border-dark", "border-3", "h-100", "mt-2", "text-center", "d-flex", "flex-column", "justify-content-center");
DisplayRDV(the_rdv, nextRDV);
searchbar.classList.add("col", "h-100");
searchbar.innerHTML = `
<form class="input-group p-5" onsubmit="performSearch(event)" method="post">
<input type="text" aria-label="First name" class="form-control" id="nom" name="nom" placeholder="Nom, spécialité">
<input type="text" aria-label="Last name" class="form-control" id="postal" name="postal" placeholder="Où ?">
<button class="btn btn-danger" type="submit" id="recherche">Rechercher</button>
</form>`;
attachSearchEventListener();
attachReturnHomeEventListener();
attachProfileEventListener();
horizontalDropdown();
});
});
column2.append(next_rdv)
column2.append(past_rdv)
column.append(column2)
row.append(column)
row.append(the_rdv)
row.append(searchbar)
h100.appendChild(row);
content.appendChild(h100);
});
document.getElementById("user-calendar").addEventListener("click", DisplayRDVPatientPage);
}
catch (e) {
//Do nothing
@@ -69,10 +13,74 @@ function ButtonShowRdvPatient() {
}
}
function DisplayRDVPatientPage(){
let content = document.getElementById("content");
content.innerHTML = "";
let h100 = document.createElement("div");
h100.classList.add("h-100");
let row = document.createElement("div");
row.classList.add("row");
let column = document.createElement("div");
column.classList.add("col-3", "border-end", "border-dark", "border-3", "h-100", "mt-2", "text-center", "d-flex", "flex-column", "justify-content-center");
let column2 =document.createElement("div");
column2.classList.add("d-flex", "flex-column");
let next_rdv = document.createElement("div");
next_rdv.classList.add("border-bottom", "pb-3", "border-dark", "border-3", "align-self-center");
let nextRDV;
let past_rdv = document.createElement("div");
let the_rdv = document.createElement("div");
let searchbar = document.createElement("div")
let user = TokenDecode(sessionStorage.getItem("token"));
ajaxRequest('GET', "src/API/requests.php/api/next-rdv-patient?id=" + user.id, function (data) {
nextRDV = data
DisplayNextRDVPatient(next_rdv, data);
past_rdv.classList.add("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(past_rdv, data);
the_rdv.classList.add("col", "border-end", "border-dark", "border-3", "h-100", "mt-2", "text-center", "d-flex", "flex-column", "justify-content-center");
DisplayRDV(the_rdv, nextRDV);
searchbar.classList.add("col", "h-100");
searchbar.innerHTML = `
<form class="input-group p-5" onsubmit="performSearch(event)" method="post">
<input type="text" aria-label="First name" class="form-control" id="nom" name="nom" placeholder="Nom, spécialité">
<input type="text" aria-label="Last name" class="form-control" id="postal" name="postal" placeholder="Où ?">
<button class="btn btn-danger" type="submit" id="recherche">Rechercher</button>
</form>`;
attachSearchEventListener();
attachReturnHomeEventListener();
attachProfileEventListener();
horizontalDropdown();
});
});
column2.append(next_rdv)
column2.append(past_rdv)
column.append(column2)
row.append(column)
row.append(the_rdv)
row.append(searchbar)
h100.appendChild(row);
content.appendChild(h100);
}
function DisplayNextRDVPatient(next_rdv, rdv){
next_rdv.innerHTML = "<h5 class=\"text-center\">Vos rendez-vous à venir</h5>";
if(rdv.length === 0){
next_rdv.innerHTML += "<p class=\"text-center\">Vous n'avez pas de rendez-vous à venir</p>";
if(rdv === null || rdv.length === 0){
next_rdv.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> </p>" +
"</div> </div> <div class='card-body'>" +
"<h5 class='card-title'>Vous n'avez pas de rendez-vous à venir</h5>" +
"</div> </div>";
}
else{
for(let i = 0; i < rdv.length; i++) {
@@ -91,10 +99,8 @@ function DisplayNextRDVPatient(next_rdv, rdv){
}
function attachEventListener(i, rdv) {
document.getElementById("retake-rdv-" + i + "-" + rdv[i].m_id).addEventListener("click", function () {
console.log("Retake RDV")
let id = rdv[i].m_id;
function attachEventListener(i, id) {
document.getElementById("retake-rdv-" + i + "-" + id).addEventListener("click", function () {
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) {
@@ -122,23 +128,31 @@ function DisplayPastRDVPatient(past_rdv, rdv) {
"</div> <div class=\"card-footer\"> " +
"<button id='retake-rdv-" + i + "-" + rdv[i].m_id + "'>Reprendre rendez-vous</button> " +
"</div> </div>";
attachEventListener(i, rdv);
}
}
for(let i = 0; i < rdv.length; i++) {
document.getElementById("retake-rdv-" + i + "-" + rdv[i].m_id).addEventListener("click", function () {
attachEventListener(i, rdv[i].m_id);
});
}
}
}
function attachEventListenerDeplacer(rdv){
document.getElementById("deplacer_button").addEventListener("click", function () {
let id = rdv[0].m_id;
let rdv_id = rdv[0].rdv_id;
let data = "id=" + rdv_id
let today = new Date();
let date = today.getFullYear() + "-" + (today.getMonth() + 1).toString().padStart(2, "0") + "-" + today.getDate().toString().padStart(2, "0");
ajaxRequest('DELETE', "src/API/requests.php/api/cancel-rdv-patient?id=" + id, function () {
console.log(data);
ajaxRequest('PUT', "src/API/requests.php/api/cancel-rdv-patient", function () {
console.log("Rendez-vous annulé");
ajaxRequest('GET', "src/API/requests.php/api/rdv-date?date=" + date + "&id=" + id, function (data) {
displayCalendar(data);
});
});
}, data);
});
}
@@ -147,8 +161,9 @@ function attachEventListenerAnnuler(rdv){
let id = rdv[0].rdv_id;
let data = "id=" + id
console.log(data);
ajaxRequest('DELETE', "src/API/requests.php/api/cancel-rdv-patient", function (id) {
ajaxRequest('PUT', "src/API/requests.php/api/cancel-rdv-patient", function (id) {
console.log("Rendez-vous annulé");
DisplayRDVPatientPage();
},data);
});
@@ -156,7 +171,13 @@ function attachEventListenerAnnuler(rdv){
function DisplayRDV(the_rdv, rdv){
if(rdv.length === 0){
the_rdv.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>"
the_rdv.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> </p>" +
"</div> </div> <div class='card-body'>" +
"<h5 class='card-title'>Vous n'avez pas de rendez-vous à venir</h5>" +
"</div> </div>";
}
else{
the_rdv.innerHTML += "<div class=\"card rounded-4 mx-2\">" +

View File

@@ -22,7 +22,14 @@ function DisplayRDVPraticient(rdv){
content.innerHTML = "";
content.innerHTML = '<div class="h-100"> <div class="d-flex flex-row flex-wrap my-5 mx-5 gap-5 justify-content-center text-center">';
if(count === 0){
content.append('<h1>Vous n\'avez pas de rendez-vous</h1>');
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> </p>' +
'</div>' + '</div>' +
'<div class="card-body">' +
'<h5 class="card-title"> Vous n\'avez pas de rendez-vous de planifié </h5>' +
'</div>' + '</div>';
}
else {
for (let i = 0; i < count; i++) {