mirror of
https://github.com/BreizhHardware/ProjetS4COMWEB.git
synced 2026-01-18 16:47:35 +01:00
Almost end back + start front but missing topbar for test
This commit is contained in:
@@ -67,8 +67,28 @@ $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-patient', ["id"], function($id){
|
||||
global $pdo;
|
||||
dbRequestRdvPatient($pdo, $id);
|
||||
getPastRdvByPatient($pdo, $id);
|
||||
});
|
||||
|
||||
$router->DELETE('/api/delete-empty', ["id"], function($id){
|
||||
global $pdo;
|
||||
DeleteEmptyRdv($pdo, $id);
|
||||
});
|
||||
|
||||
$router->DELETE('/api/cancel-rdv', ["id"], function($id){
|
||||
global $pdo;
|
||||
CancelRDV($pdo, $id);
|
||||
});
|
||||
|
||||
$router->POST('/api/create-rdv', ["id", "date", "time", "lieu"], function($id, $date, $time, $lieu){
|
||||
global $pdo;
|
||||
createRDV($pdo, $id, $date, $time, $lieu);
|
||||
});
|
||||
|
||||
$router->run();
|
||||
|
||||
@@ -38,6 +38,15 @@ class Response
|
||||
echo json_encode($data);
|
||||
}
|
||||
|
||||
public static function HTTP403($data): void
|
||||
{
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
header('Cache-control: no-store, no-cache, must-revalidate');
|
||||
header('Pragma: no-cache');
|
||||
http_response_code(403);
|
||||
echo json_encode($data);
|
||||
}
|
||||
|
||||
static function HTTP404($data): void
|
||||
{
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
|
||||
@@ -40,6 +40,49 @@ 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
|
||||
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
|
||||
INNER JOIN medecin ON propose.m_id = medecin.m_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");
|
||||
|
||||
$statement->bindParam(':id', $id);
|
||||
$statement->execute();
|
||||
$result = $statement->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
if (!empty($result)) {
|
||||
Response::HTTP200($result);
|
||||
} else {
|
||||
Response::HTTP404(["error" => "No data found"]);
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
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
|
||||
INNER JOIN medecin ON propose.m_id = medecin.m_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");
|
||||
$statement->bindParam(':id', $id);
|
||||
$statement->execute();
|
||||
$result = $statement->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
if (!empty($result)) {
|
||||
Response::HTTP200($result);
|
||||
} else {
|
||||
Response::HTTP404(["error" => "No data found"]);
|
||||
}
|
||||
}
|
||||
|
||||
function getLieuID($pdo, $adress, $postal, $city){
|
||||
$statement = $pdo->prepare("SELECT l_id FROM lieu WHERE l_adress = :adress AND l_city = :city AND l_postal = :postal");
|
||||
$statement->bindParam(':adress', $adress);
|
||||
@@ -61,9 +104,9 @@ function getAllLieux($pdo){
|
||||
$result = $statement->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
if (!empty($result)) {
|
||||
return $result;
|
||||
Response::HTTP200($result);
|
||||
} else {
|
||||
return null;
|
||||
Response::HTTP404(["error" => "No data found"]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,21 +129,22 @@ function CreateRDV($pdo, $medID, $date, $time, $lieu){
|
||||
$statement->bindParam(':medID', $medID);
|
||||
$statement->bindParam(':rdvID', $rdvID);
|
||||
$statement->execute();
|
||||
return true;
|
||||
Response::HTTP200(["Success" => "RDV created"]);
|
||||
}
|
||||
return false;
|
||||
Response::HTTP404(["Error" => "Lieu not found"]);
|
||||
}
|
||||
|
||||
function DeleteEmptyRdv($pdo, $id){
|
||||
function DeleteEmptyRdv($pdo, $id)
|
||||
{
|
||||
$statement = $pdo->prepare("SELECT p_id FROM rendez_vous WHERE rdv_id = :id");
|
||||
$statement->bindParam(':id', $id);
|
||||
$statement->execute();
|
||||
$result = $statement->fetch(PDO::FETCH_ASSOC);
|
||||
if($result['p_id'] == null){
|
||||
if ($result['p_id'] == null) {
|
||||
$statement = $pdo->prepare("DELETE FROM rendez_vous WHERE rdv_id = :id");
|
||||
$statement->bindParam(':id', $id);
|
||||
$statement->execute();
|
||||
return true;
|
||||
Response::HTTP200(["Success" => "RDV deleted"]);
|
||||
}
|
||||
return false;
|
||||
Response::HTTP403(["Forbidden" => "This RDV is not empty"]);
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
console.log("index.js loaded");
|
||||
|
||||
//Felix Part
|
||||
|
||||
function displaySearchResults(data) {
|
||||
let container = document.getElementById("content");
|
||||
container.innerHTML = "";
|
||||
@@ -213,4 +215,61 @@ function attachRDVEventListener() {
|
||||
});
|
||||
}
|
||||
|
||||
attachSearchEventListener();
|
||||
//Yanis Part
|
||||
|
||||
function DisplayRDVPraticient(rdv){
|
||||
let count = rdv.length;
|
||||
$('#content').empty();
|
||||
$('#content').html('<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>');
|
||||
}
|
||||
else {
|
||||
for (let i = 0; i < count; i++){
|
||||
if (rdv[i].p_mail !== "null")
|
||||
$('#content').append('' +
|
||||
'<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>' + rdv[i].rdv_date + '</p>' +
|
||||
'<p>' + rdv[i].rdv_time + '</p>' +
|
||||
'</div>' + '</div>' +
|
||||
'<div class="card-body">' +
|
||||
'<h5 class="card-title">' + rdv[i].patient + '</h5>' +
|
||||
'<a href="mailto:' + rdv[i].p_mail + '" class="card-subtitle mb-2 text-body-secondary">' + rdv[i].email + '</a>' +
|
||||
'<br>' +
|
||||
'<a href="tel:0' + rdv[i].p_phone + '" class="card-subtitle mb-2 text-body-secondary">' + '0' + rdv[i].phone + '</a>' +
|
||||
'</div>' + '</div>');
|
||||
else{
|
||||
$('#content').append('' +
|
||||
'<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>' + rdv[i].rdv_date + '</p>' +
|
||||
'<p>' + rdv[i].rdv_time + '</p>' +
|
||||
'</div>' + '</div>' +
|
||||
'<div class="card-body">' +
|
||||
'<h5 class="card-title">Vous n\'avez pas de' + '<br>' + 'patient pour ce créneau</h5>' +
|
||||
'</div>' + '</div>');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function ButtonShowRdvPraticient() {
|
||||
document.getElementById("CalendarPraticient").addEventListener("click", function () {
|
||||
ajaxRequest('GET', "src/API/requests.php/api/rdv-praticient?id=" + id, function (data) {
|
||||
DisplayRDVPraticient(data);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//End Call
|
||||
|
||||
attachSearchEventListener();
|
||||
ButtonShowRdvPraticient();
|
||||
Reference in New Issue
Block a user