Merge branch 'main' of github.com:BreizhHardware/ProjetS4COMWEB into cfouche

This commit is contained in:
Clément Fouché
2024-05-14 11:11:09 +02:00
15 changed files with 117 additions and 141 deletions

View File

@@ -21,7 +21,7 @@ $pdo = dbConnect();
?>
<body style="background-color: #EEF2F7">
<div id="topbar">
<a href="index.php">
<a href="index.html">
<p id="DoctISEN" class="top-0">
Doct'ISEN
</p>

View File

@@ -21,7 +21,7 @@ $pdo = dbConnect();
?>
<body style="background-color: #EEF2F7">
<div id="topbar">
<a href="index.php">
<a href="index.html">
<p id="DoctISEN" class="top-0">
Doct'ISEN
</p>

View File

@@ -2,7 +2,7 @@
<html lang="fr">
<head>
<meta charset="utf-8">
<title> Acceuil </title>
<title> Accueil </title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
@@ -21,18 +21,6 @@
</p>
</a>
<div class="d-flex position-fixed end-0 flex-row align-items-center gap-3 mt-2 top-0">
<?php
//loginUI($pdo);
?>
<!--
<div class="d-flex flex-row align-items-center gap-3 me-2">
<img src="https://1.gravatar.com/avatar/4d43af207280d1d23e2a2905577c7b6167723fec2d33f946cc86f114c1a85b8d?size=64" alt="avatar" id="avatar" style="width: 14.3%; height: auto; border-radius: 50%">
<div>
<a href="src/php/db/scripts/deconnexion.php" class="text-white fw-bold mt-3 link-underline-opacity-75-hover link-underline link-underline-opacity-0 link-offset-3-hover link-underline-light">Test Test</a>
</div>
<a class="text-white fw-bold link-underline-opacity-75-hover link-underline link-underline-opacity-0 link-offset-3-hover link-underline-light" id="praticien-calendar">Mon calendrier</a>
</div>
-->
<button type="button" class="btn btn-danger" style="top: 0.4375em;" id="login-praticien">Vous êtes praticien ?</button> <button type="button" class="btn btn-danger" style="top: 0.4375em;" id="login-user">Se connecter</button><p> </p>
</div>
</div>

View File

@@ -22,7 +22,7 @@
?>
<body style="background-color: #EEF2F7">
<div id="topbar">
<a href="index.php">
<a href="index.html">
<p id="DoctISEN" class="top-0">
Doct'ISEN
</p>

View File

@@ -23,7 +23,7 @@
<body style="background-color: #EEF2F7">
<div id="topbar">
<a href="index.php">
<a href="index.html">
<p id="DoctISEN" class="top-0">
Doct'ISEN
</p>
@@ -60,7 +60,7 @@
if($login != false){
error_log("Login success");
$_SESSION['token'] = base64_encode("patient:".strval($login));
echo '<meta http-equiv="refresh" content="0;url=index.php">';
echo '<meta http-equiv="refresh" content="0;url=index.html">';
} else {
error_log('Erreur de connexion');
}

View File

@@ -23,7 +23,7 @@ session_start();
?>
<body style="background-color: #EEF2F7">
<div id="topbar">
<a href="index.php">
<a href="index.html">
<p id="DoctISEN" class="top-0">
Doct'ISEN
</p>
@@ -98,7 +98,7 @@ session_start();
if(SignupMedecin::insertMedecin($pdo,$name,$surname,$mail, $password,$specialite,$phone,$codePostal)){
error_log("Signup success");
$_SESSION['id'] = $mail;
echo '<meta http-equiv="refresh" content="0;url=index.php">';
echo '<meta http-equiv="refresh" content="0;url=index.html">';
} else {
error_log("Erreur d'inscription");
}

View File

@@ -23,7 +23,7 @@ session_start();
?>
<body style="background-color: #EEF2F7">
<div id="topbar">
<a href="index.php">
<a href="index.html">
<p id="DoctISEN" class="top-0">
Doct'ISEN
</p>
@@ -88,7 +88,7 @@ session_start();
if(SignupPatient::Insert($pdo,$name,$surname,$mail,$password,$phone)){
error_log("Signup success");
$_SESSION['id'] = $mail;
echo '<meta http-equiv="refresh" content="0;url=index.php">';
echo '<meta http-equiv="refresh" content="0;url=index.html">';
} else {
error_log('Erreur de connexion');
}

View File

@@ -128,7 +128,11 @@ $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-praticient/getAllLieux', [], function(){
global $pdo;
getAllLieux($pdo);
});
$router->GET('/api/rdv-patient', ["id"], function($id){

View File

@@ -73,6 +73,6 @@ class Response
header('Cache-control: no-store, no-cache, must-revalidate');
header('Pragma: no-cache');
http_response_code(418);
echo json_encode($data);
echo json_encode($data); // I'm a teapot
}
}

View File

@@ -111,6 +111,7 @@ function getAllLieux($pdo){
}
function CreateRDV($pdo, $medID, $date, $time, $lieu){
error_log($lieu. ', ' . $date . ', ' . $time . ', ' . $medID);
$lieu = explode(', ', $lieu);
$adress = $lieu[0] . ', ' . $lieu[1];
$postal = $lieu[2];
@@ -131,7 +132,9 @@ function CreateRDV($pdo, $medID, $date, $time, $lieu){
$statement->execute();
Response::HTTP200(["Success" => "RDV created"]);
}
Response::HTTP404(["Error" => "Lieu not found"]);
else {
Response::HTTP404(["Error" => "Lieu not found"]);
}
}
function DeleteEmptyRdv($pdo, $id)

View File

@@ -45,7 +45,7 @@ function displayHomeTopBar() {
<button class="dropdown-item z-3" id="user-name-profile">Profil</button>
</div>
</div>
<p class="text-white fw-bold link-underline-opacity-75-hover link-underline link-underline-opacity-0 link-offset-3-hover link-underline-light" id="user-calendar">Mes rendez-vous</p>
<p class="text-white fw-bold link-underline-opacity-75-hover link-underline link-underline-opacity-0 link-offset-3-hover link-underline-light mt-3" id="user-calendar">Mes rendez-vous</p>
</div>
</div>
<div id="searchbar"></div>`;
@@ -70,7 +70,7 @@ function displayHomeTopBar() {
<button class="dropdown-item z-3" id="user-name-profile">Profil</button>
</div>
</div>
<p class="text-white fw-bold link-underline-opacity-75-hover link-underline link-underline-opacity-0 link-offset-3-hover link-underline-light" id="praticien-calendar">Mes rendez-vous practicien</p>
<p class="text-white fw-bold link-underline-opacity-75-hover link-underline link-underline-opacity-0 link-offset-3-hover link-underline-light mt-3" id="praticien-calendar">Mes rendez-vous practicien</p>
</div>
</div>
<div id="searchbar"></div>`;

View File

@@ -2,10 +2,10 @@ import {attachSearchEventListener} from "./search.js";
import {attachLoginUserDisplayEventListener, attachLoginPraticienDisplayEventListener, attachDisconnectEventListener} from "./login.js";
import {TokenDecode} from "./lib.js";
import {displayHome, displayHomeTopBar, attachReturnHomeEventListener} from "./home.js";
import {ButtonShowRdvPraticient} from "./rdv-praticien.js";
console.log("index.js loaded");
//Felix Part
document.addEventListener("DOMContentLoaded", function() {
@@ -14,103 +14,12 @@ document.addEventListener("DOMContentLoaded", function() {
}
});
//Yanis Part
document.addEventListener("DOMContentLoaded", function() {
ButtonShowRdvPraticient();
});
function ButtonShowRdvPraticient() {
try {
console.log("test1");
document.getElementById("praticien-calendar").addEventListener("click", function () {
console.log("test2");
ajaxRequest('GET', "src/API/requests.php/api/rdv-praticient?id=" + 1, function (data) {
console.log("test3");
DisplayRDVPraticient(data);
});
});
}
catch (e) {
//Do nothing
//console.error(e);
}
}
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">';
if(count === 0){
content.append('<h1>Vous n\'avez pas de rendez-vous</h1>');
}
else {
for (let i = 0; i < count; i++){
console.log(rdv[i]);
if (rdv[i].p_mail !== null){
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>' + 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.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>' + 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 DisplayRDVPatient(rdv){
let rdvPatient = rdv[0];
let lieux = rdv[1];
let count = $rdvPatient.length;
$('#content').empty();
$('#content').html('<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 class="border-bottom pb-3 border-dark border-3 align-self-center"> <h5 class="text-center">Vos rendez-vous à venir</h5>');
if(count === 0){
$('#content').append('<h1>Bienvenue sur Doct\'ISEN, veuillez prendre un rendez-vous en allant à l\'acceuil et en recherchant un praticient!</h1>');
}
else {
for (let i = 0; i < count; i++){
if($rdvPatient !== "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>' + $rdvPatient[i].rdv_date + '</p>' +
'<p>' + $rdvPatient[i].rdv_time + '</p>' +
'</div>' + '</div>' +
'<div class="card-body">' +
'<h5 class="card-title"
}
}
}*/
//End Call
ButtonShowRdvPraticient();

View File

@@ -1,15 +1,34 @@
function DisplayRDV(rdv){
import {TokenDecode} from "./lib";
function ButtonShowRdvPraticient() {
try {
document.getElementById("praticien-calendar").addEventListener("click", function () {
let user = TokenDecode(sessionStorage.getItem("token"));
ajaxRequest('GET', "src/API/requests.php/api/rdv-praticient?id=" + user.id, function (data) {
DisplayRDVPraticient(data);
console.log(data);
});
});
}
catch (e) {
//Do nothing
//console.error(e);
}
}
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">');
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">';
if(count === 0){
$('#content').append('<h1>Vous n\'avez pas de rendez-vous</h1>');
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">' +
for (let i = 0; i < count; i++) {
console.log(rdv[i]);
if (rdv[i].p_mail !== null) {
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>' + rdv[i].rdv_date + '</p>' +
@@ -17,13 +36,12 @@ function DisplayRDV(rdv){
'</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>' +
'<a href="mailto:' + rdv[i].p_mail + '" class="card-subtitle mb-2 text-body-secondary">' + rdv[i].p_mail + '</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">' +
'<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">' +
'<div class="d-flex flex-row justify-content-between text-white">' +
'<p>' + rdv[i].rdv_date + '</p>' +
@@ -31,9 +49,63 @@ function DisplayRDV(rdv){
'</div>' + '</div>' +
'<div class="card-body">' +
'<h5 class="card-title">Vous n\'avez pas de' + '<br>' + 'patient pour ce créneau</h5>' +
'</div>' + '</div>');
'</div>' + '</div>';
}
}
}
}
content.innerHTML += '<div id="addRDV" class="d-flex flex-row flex-wrap my-5 mx-5 gap-5 justify-content-center text-center" >';
ShowAddRDV();
}
function ShowAddRDV() {
ajaxRequest('GET', "src/API/requests.php/api/rdv-praticient/getAllLieux", function (data) {
DisplayAddRDV(data);
});
}
function DisplayAddRDV(lieux) {
let user = TokenDecode(sessionStorage.getItem("token"));
let medID = user.id;
let addRDV = document.getElementById("addRDV");
addRDV.innerHTML = '';
let options ='';
lieux.forEach(function (row) {
console.log(row);
let adress = row["l_adress"];
let postal = row["l_postal"];
let city = row["l_city"];
let lieu = adress + ', ' + postal + ', ' + city;
options += "<option value='" + lieu + "'>" + adress + ", " + postal + ", " + city + "</option>";
});
console.log(options);
addRDV.innerHTML += '<form>' +
"<input type='hidden' name='medID' value='" + medID + "'>" +
"<input class='form-control' type='date' name='date'>" +
"<input class='form-control' type='time' name='time'>" +
"<select class='form-select' name='lieu' id='lieu'>" +
"<option value=''>Choisissez un lieu</option>" +
options +
"</select>" +
"<br><br>" +
"<button type='submit' name='createRDV' class='btn btn-danger' id='addRDVbutton'>Créer un rendez-vous</button>" +
"</form>";
document.getElementById("addRDVbutton").addEventListener("click", function (event) {
event.preventDefault();
let medID = document.querySelector("input[name='medID']").value;
let date = document.querySelector("input[name='date']").value;
let time = document.querySelector("input[name='time']").value;
let lieu = document.querySelector("select[name='lieu']").value;
let data = 'medID=' + medID + '&date=' + date + '&time=' + time + '&lieu=' + lieu;
ajaxRequest('POST', "src/API/requests.php/api/create-rdv", function (data) {
console.log(data);
ButtonShowRdvPraticient();
}, data);
ajaxRequest('GET', "src/API/requests.php/api/rdv-praticient?id=" + user.id, function (data) {
DisplayRDVPraticient(data);
console.log(data);
});
});
}
export {ButtonShowRdvPraticient};

View File

@@ -14,7 +14,7 @@ function checkMedecin(){
return true;
} else {
if($token[0] == "patient"){
echo '<meta http-equiv="refresh" content="0;url=index.php">';
echo '<meta http-equiv="refresh" content="0;url=index.html">';
return false;
} else {
echo '<meta http-equiv="refresh" content="0;url=login-praticien.php">';
@@ -22,7 +22,7 @@ function checkMedecin(){
}
}
} else {
echo '<meta http-equiv="refresh" content="0;url=index.php">';
echo '<meta http-equiv="refresh" content="0;url=index.html">';
return false;
}
}
@@ -34,7 +34,7 @@ function checkPatient(){
return true;
} else {
if($token[0] == "medecin"){
echo '<meta http-equiv="refresh" content="0;url=index.php">';
echo '<meta http-equiv="refresh" content="0;url=index.html">';
return false;
} else {
echo '<meta http-equiv="refresh" content="0;url=login.php">';
@@ -42,7 +42,7 @@ function checkPatient(){
}
}
} else {
echo '<meta http-equiv="refresh" content="0;url=index.php">';
echo '<meta http-equiv="refresh" content="0;url=index.html">';
return false;
}
}

View File

@@ -4,6 +4,6 @@ error_reporting(E_ALL);
session_start();
unset($_SESSION["token"]);
//Redirect to the rdv.php page
echo '<meta http-equiv="refresh" content="0;URL=../../../../index.php">';
echo '<meta http-equiv="refresh" content="0;URL=../../../../index.html">';
?>