mirror of
https://github.com/BreizhHardware/ProjetS4COMWEB.git
synced 2026-01-18 16:47:35 +01:00
error in cancel rdv
This commit is contained in:
@@ -150,6 +150,10 @@ $router->POST('/api/create-rdv', ["medID", "date", "time", "lieu"], function($me
|
||||
CreateRDV($pdo, $medID, $date, $time, $lieu);
|
||||
});
|
||||
|
||||
$router->PUT('/api/cancel-rdv-patient', ["id"], function($id){
|
||||
global $pdo;
|
||||
CancelRDVFromPatient($pdo, $id);
|
||||
});
|
||||
|
||||
//End of Yanis Part
|
||||
|
||||
|
||||
@@ -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 as med_spe, 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 rendez_vous.rdv_id, 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
|
||||
@@ -151,4 +151,11 @@ function DeleteEmptyRdv($pdo, $id)
|
||||
Response::HTTP200(["Success" => "RDV deleted"]);
|
||||
}
|
||||
Response::HTTP403(["Forbidden" => "This RDV is not empty"]);
|
||||
}
|
||||
|
||||
function CancelRDVFromPatient($pdo, $id){
|
||||
$statement = $pdo->prepare("UPDATE public.rendez_vous SET p_id = null WHERE rdv_id = :id");
|
||||
$statement->bindParam(':id', $id);
|
||||
$statement->execute();
|
||||
Response::HTTP200(["Success" => "RDV deleted"]);
|
||||
}
|
||||
@@ -39,8 +39,6 @@ function ButtonShowRdvPatient() {
|
||||
DisplayRDV(the_rdv, nextRDV);
|
||||
|
||||
searchbar.classList.add("col", "h-100");
|
||||
|
||||
displaySearchTopBar();
|
||||
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é">
|
||||
@@ -94,8 +92,9 @@ function DisplayNextRDVPatient(next_rdv, rdv){
|
||||
|
||||
|
||||
function attachEventListener(i, rdv) {
|
||||
document.getElementById("retake-rdv-" + i + "-" + rdv[i].med_id).addEventListener("click", function () {
|
||||
let id = rdv[i].med_id;
|
||||
document.getElementById("retake-rdv-" + i + "-" + rdv[i].m_id).addEventListener("click", function () {
|
||||
console.log("Retake RDV")
|
||||
let id = rdv[i].m_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) {
|
||||
@@ -121,7 +120,7 @@ function DisplayPastRDVPatient(past_rdv, rdv) {
|
||||
"<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> " +
|
||||
"<button id='retake-rdv-" + i + "-" + rdv[i].m_id + "'>Reprendre rendez-vous</button> " +
|
||||
"</div> </div>";
|
||||
attachEventListener(i, rdv);
|
||||
}
|
||||
@@ -132,20 +131,25 @@ function DisplayPastRDVPatient(past_rdv, rdv) {
|
||||
|
||||
function attachEventListenerDeplacer(rdv){
|
||||
document.getElementById("deplacer_button").addEventListener("click", function () {
|
||||
let id = rdv[i].med_id;
|
||||
let id = rdv[0].m_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);
|
||||
ajaxRequest('DELETE', "src/API/requests.php/api/cancel-rdv-patient?id=" + id, function () {
|
||||
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) {
|
||||
});
|
||||
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) {
|
||||
console.log("Rendez-vous annulé");
|
||||
},data);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user