mirror of
https://github.com/BreizhHardware/ProjetS4COMWEB.git
synced 2026-01-18 16:47:35 +01:00
@@ -135,14 +135,9 @@ $router->GET('/api/past-rdv-patient', ["id"], function($id){
|
||||
getPastRdvByPatient($pdo, $id);
|
||||
});
|
||||
|
||||
$router->DELETE('/api/delete-empty', ["id"], function($id){
|
||||
$router->DELETE('/api/cancel-empty-rdv', ["id"], function($id){
|
||||
global $pdo;
|
||||
DeleteEmptyRdv($pdo, $id);
|
||||
});
|
||||
|
||||
$router->DELETE('/api/cancel-rdv', ["id"], function($id){
|
||||
global $pdo;
|
||||
CancelRDV($pdo, $id);
|
||||
CancelEmptyRDV($pdo, $id);
|
||||
});
|
||||
|
||||
$router->POST('/api/create-rdv', ["medID", "date", "time", "lieu"], function($medID, $date, $time, $lieu){
|
||||
|
||||
@@ -1,22 +1,6 @@
|
||||
<?php
|
||||
require_once('src/response.php');
|
||||
|
||||
/*function dbConnect()
|
||||
{
|
||||
try
|
||||
{
|
||||
$db = new PDO('pgsql:host='.DB_SERVER.';port='.DB_PORT.';dbname='.DB_NAME, DB_USER, DB_PASSWORD);
|
||||
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
}
|
||||
catch (PDOException $exception)
|
||||
{
|
||||
error_log('Connection error: '.$exception->getMessage());
|
||||
return false;
|
||||
}
|
||||
return $db;
|
||||
}*/
|
||||
|
||||
|
||||
function dbRequestRdvPraticien($pdo, $id){
|
||||
$statement = $pdo->prepare("SELECT rdv_date, rdv_time, concat(p_name,' ', p_surname) as patient, p_mail, p_phone
|
||||
FROM rendez_vous
|
||||
@@ -129,19 +113,14 @@ function CreateRDV($pdo, $medID, $date, $time, $lieu){
|
||||
}
|
||||
}
|
||||
|
||||
function DeleteEmptyRdv($pdo, $id)
|
||||
{
|
||||
$statement = $pdo->prepare("SELECT p_id FROM rendez_vous WHERE rdv_id = :id");
|
||||
function CancelEmptyRDV($pdo, $id){
|
||||
$statement = $pdo->prepare("DELETE FROM propose WHERE rdv_id = :id");
|
||||
$statement->bindParam(':id', $id);
|
||||
$statement->execute();
|
||||
$result = $statement->fetch(PDO::FETCH_ASSOC);
|
||||
if ($result['p_id'] == null) {
|
||||
$statement = $pdo->prepare("DELETE FROM rendez_vous WHERE rdv_id = :id");
|
||||
$statement->bindParam(':id', $id);
|
||||
$statement->execute();
|
||||
Response::HTTP200(["Success" => "RDV deleted"]);
|
||||
}
|
||||
Response::HTTP403(["Forbidden" => "This RDV is not empty"]);
|
||||
$statement = $pdo->prepare("DELETE FROM rendez_vous WHERE rdv_id = :id");
|
||||
$statement->bindParam(':id', $id);
|
||||
$statement->execute();
|
||||
Response::HTTP200(["Success" => "RDV deleted"]);
|
||||
}
|
||||
|
||||
function CancelRDVFromPatient($pdo, $id){
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
<?php
|
||||
require_once "database.php";
|
||||
$PDO = dbConnect();
|
||||
$request = substr($_SERVER['PATH_INFO'], 1);
|
||||
$request = explode('/', $request);
|
||||
$requestRessource = array_shift($request);
|
||||
$method = $_SERVER["REQUEST_METHOD"];
|
||||
|
||||
parse_str(file_get_contents('php://input'), $_PUT);
|
||||
|
||||
if($method === "GET" && isset($_GET)){ // Want tweets of a specific user
|
||||
$rdvOfPraticien = dbRequestRdvPraticien($PDO, $_GET["login"]);
|
||||
echo json_encode($rdvOfPraticien);
|
||||
}
|
||||
|
||||
if($method === "POST" && isset($_POST)){
|
||||
$success = CreateRDV($PDO, $_POST["login"], $_POST["date"], $_POST["time"], $_POST["lieu"]);
|
||||
echo json_encode($success);
|
||||
}
|
||||
|
||||
if($method === "DELETE" && isset($_GET)){
|
||||
$id = array_shift($request);
|
||||
$success = DeleteEmptyRdv($PDO, $_GET["rdv"]);
|
||||
echo json_encode($success);
|
||||
}
|
||||
|
||||
@@ -59,11 +59,11 @@ function displayHomeTopBar() {
|
||||
topbar.innerHTML = `
|
||||
<div id="topInfo">
|
||||
<a id="home">
|
||||
<p id="DoctISEN" class="top-0 position-fixed">
|
||||
<p id="DoctISEN" class="top-0">
|
||||
Doct'ISEN
|
||||
</p>
|
||||
</a>
|
||||
<div class="d-flex position-fixed end-0 flex-row align-items-center gap-3 mt-2 top-0">
|
||||
<div class="d-flex position-absolute end-0 flex-row align-items-center gap-3 mt-2 top-0">
|
||||
<img src="https://www.gravatar.com/avatar/${mailMD5}?s=64" alt="avatar" id="avatar" style="width: 14.3%; height: auto; border-radius: 50%">
|
||||
<div class="dropdown">
|
||||
<a class="text-white dropdown-toggle" id="user-name-dropdown" data-bs-toggle="dropdown">${user.name} ${user.surname}</a>
|
||||
|
||||
@@ -133,8 +133,8 @@ function DisplayPastRDVPatient(past_rdv, rdv) {
|
||||
document.getElementById("retake-rdv-" + i + "-" + rdv[i].m_id).addEventListener("click", function () {
|
||||
attachEventListener(i, rdv[i].m_id);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import {TokenDecode} from "./lib.js";
|
||||
import {attachReturnHomeEventListener} from "./home.js";
|
||||
|
||||
function ButtonShowRdvPraticient() {
|
||||
try {
|
||||
@@ -6,6 +7,7 @@ function ButtonShowRdvPraticient() {
|
||||
let user = TokenDecode(sessionStorage.getItem("token"));
|
||||
ajaxRequest('GET', "src/API/requests.php/api/rdv-praticient?id=" + user.id, function (data) {
|
||||
DisplayRDVPraticient(data);
|
||||
attachReturnHomeEventListener();
|
||||
console.log(data);
|
||||
});
|
||||
});
|
||||
@@ -16,27 +18,62 @@ function ButtonShowRdvPraticient() {
|
||||
}
|
||||
}
|
||||
|
||||
function attachCancelEventListener(rdv_id, i) {
|
||||
const idBtn = "cancel_button" + i;
|
||||
console.log(idBtn);
|
||||
console.log(i);
|
||||
let Btn = document.getElementById(idBtn);
|
||||
if(Btn !== null){
|
||||
console.log("je suis là");
|
||||
console.log(Btn);
|
||||
Btn.addEventListener("click", function (event) {
|
||||
console.log("hello");
|
||||
let data = 'rdv_id=' + rdv_id;
|
||||
console.log(data);
|
||||
/*
|
||||
ajaxRequest('DELETE', "src/API/requests.php/api/cancel-rdv", function (data) {
|
||||
console.log(data);
|
||||
ButtonShowRdvPraticient();
|
||||
attachReturnHomeEventListener();
|
||||
ajaxRequest('GET', "src/API/requests.php/api/rdv-praticient?id=" + user.id, function (data) {
|
||||
DisplayRDVPraticient(data);
|
||||
console.log(data);
|
||||
});
|
||||
}, data);*/
|
||||
});
|
||||
}
|
||||
else{
|
||||
console.log("je suis pas là")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function DisplayRDVPraticient(rdv){
|
||||
let count = rdv.length;
|
||||
let content = document.getElementById("content");
|
||||
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">';
|
||||
let h100 = document.createElement("div");
|
||||
h100.classList.add("h-100");
|
||||
let container = document.createElement("div");
|
||||
container.classList.add("d-flex", "flex-row", "flex-wrap", "my-5", "mx-5", "gap-5", "justify-content-center", "text-center");
|
||||
if(count === 0){
|
||||
content.innerHTML += '<div class="card rounded-4 mx-2 pointer">' +
|
||||
container.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>' +
|
||||
'<h5 class="card-title"> Vous n\'avez pas de créneaux de planifié </h5>' +
|
||||
'</div>' + '</div>';
|
||||
}
|
||||
else {
|
||||
for (let i = 0; i < count; i++) {
|
||||
console.log(rdv[i]);
|
||||
|
||||
let card = document.createElement("div");
|
||||
card.classList.add("card", "rounded-4", "mx-2", "pointer");
|
||||
if (rdv[i].p_mail !== null) {
|
||||
content.innerHTML += '<div class="card rounded-4 mx-2 pointer">' +
|
||||
'<div class="card-header bg-danger">' +
|
||||
card.innerHTML += '<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>' +
|
||||
@@ -48,18 +85,27 @@ function DisplayRDVPraticient(rdv){
|
||||
'<a href="tel:0' + rdv[i].p_phone + '" class="card-subtitle mb-2 text-body-secondary">' + '0' + rdv[i].p_phone + '</a>' +
|
||||
'</div>' + '</div>';
|
||||
} else {
|
||||
content.innerHTML += '<div class="card rounded-4 mx-2 pointer">' +
|
||||
'<div class="card-header bg-danger">' +
|
||||
card.innerHTML += '<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>' +
|
||||
'<input type="button" id="cancel_button' + i + '"' +
|
||||
/*'class="btn btn-link link-danger link-offset-2 link-underline-opacity-25 link-underline-opacity-100-hover"*/'value="Annuler le créneau"></input>' +
|
||||
'</div>' + '</div>';
|
||||
}
|
||||
container.appendChild(card);
|
||||
}
|
||||
|
||||
}
|
||||
h100.appendChild(container);
|
||||
content.appendChild(h100);
|
||||
for (let i = 0; i < count; i++) {
|
||||
attachCancelEventListener(rdv[i].rdv_id, i);
|
||||
}
|
||||
|
||||
content.innerHTML += '<div id="addRDV" class="d-flex flex-row flex-wrap my-5 mx-5 gap-5 justify-content-center text-center" >';
|
||||
ShowAddRDV();
|
||||
}
|
||||
@@ -107,11 +153,13 @@ function DisplayAddRDV(lieux) {
|
||||
ajaxRequest('POST', "src/API/requests.php/api/create-rdv", function (data) {
|
||||
console.log(data);
|
||||
ButtonShowRdvPraticient();
|
||||
attachReturnHomeEventListener();
|
||||
ajaxRequest('GET', "src/API/requests.php/api/rdv-praticient?id=" + user.id, function (data) {
|
||||
DisplayRDVPraticient(data);
|
||||
console.log(data);
|
||||
});
|
||||
}, data);
|
||||
ajaxRequest('GET', "src/API/requests.php/api/rdv-praticient?id=" + user.id, function (data) {
|
||||
DisplayRDVPraticient(data);
|
||||
console.log(data);
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user