mirror of
https://github.com/BreizhHardware/ProjetS4COMWEB.git
synced 2026-01-18 16:47:35 +01:00
Merge branch 'main' into Yanis
This commit is contained in:
@@ -10,3 +10,42 @@ test = "coucou"
|
||||
|
||||
###
|
||||
|
||||
POST http://serveur-projet-s4.felix/src/API/requests.php/api/login/patient
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
|
||||
mail = nicolasgrenier@example.com &
|
||||
password = a
|
||||
|
||||
###
|
||||
|
||||
POST http://serveur-projet-s4.felix/src/API/requests.php/api/login/medecin
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
|
||||
mail = cberger@example.org &
|
||||
password = a
|
||||
|
||||
###
|
||||
|
||||
PUT http://serveur-projet-s4.felix/src/API/requests.php/api/signup/patient
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
|
||||
mail = felix.marquet@isen-ouest.yncrea.fr &
|
||||
password = a &
|
||||
name = Marquet &
|
||||
surname = Félix &
|
||||
phone = 0645383602
|
||||
|
||||
###
|
||||
|
||||
PUT http://serveur-projet-s4.felix/src/API/requests.php/api/signup/medecin
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
|
||||
mail = felix.marquet@isen-ouest.yncrea.fr &
|
||||
password = a &
|
||||
name = Marquet &
|
||||
surname = Félix &
|
||||
phone = 0645383602 &
|
||||
specialite = Test &
|
||||
postal = 44470
|
||||
|
||||
###
|
||||
@@ -1,90 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title> Oui....Stiti </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>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Just+Me+Again+Down+Here&family=Open+Sans&display=swap" rel="stylesheet">
|
||||
<link rel="stylesheet" href="src/css/styles.css">
|
||||
<link rel="icon" href="src/img/favicon.png" type="image/x-icon"/>
|
||||
<?php
|
||||
require('src/php/db/dbconnect.php');
|
||||
require('src/php/constants.php');
|
||||
require('src/php/components/token.php');
|
||||
require('src/php/components/check.php');
|
||||
require('src/php/components/user-login.php');
|
||||
require('src/php/db/Patient.php');
|
||||
require('src/php/db/Medecin.php');
|
||||
require('src/php/db/Calendrier.php');
|
||||
ini_set('display_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
$pdo = dbConnect();
|
||||
session_start();
|
||||
checkPatient();
|
||||
?>
|
||||
</head>
|
||||
<body>
|
||||
<div id="topbar" class="d-flex justify-content-between flex-row">
|
||||
<div>
|
||||
<a href="index.php">
|
||||
<p id="DoctISEN" class="top-0">
|
||||
Doct'ISEN
|
||||
</p>
|
||||
</a>
|
||||
</div>
|
||||
<div class="d-flex flex-row align-items-center gap-3 me-2">
|
||||
<div class="d-flex flex-row align-items-center gap-3 me-2">
|
||||
<?php
|
||||
loginUI($pdo);
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="searchbar">
|
||||
<form action="search.php" class="input-group p-5" method="post">
|
||||
<input type="text" aria-label="First name" class="form-control" id="nom" name="nom" placeholder="Nom, spécialité, établissement ...">
|
||||
<input type="text" aria-label="Last name" class="form-control" id="postal" name="postal" placeholder="Où ?">
|
||||
<button class="btn btn-danger" type="submit" id="button-addon2">Rechercher</button>
|
||||
</form>
|
||||
</div>
|
||||
<div class="h-100">
|
||||
<div class="row">
|
||||
<div class="col h-100 border-dark border-3 justify-content-center text-center ms-3 ">
|
||||
<div class="d-flex flex-column justify-content-center gap-6">
|
||||
<div>
|
||||
<form class="mt-3" method="post">
|
||||
<label for="date">Choisissez une date :</label>
|
||||
<br>
|
||||
<?php
|
||||
echo '<input type="hidden" name="id" id="id" value="' . $_POST['id'] . '">';
|
||||
echo '<input type="date" name="start" id="date" class="mt-2 form-control" value="' . $_POST['start'] . '">';
|
||||
?>
|
||||
<br>
|
||||
<input type="submit" value="Valider" class="mt-2 btn btn-outline-danger">
|
||||
</form>
|
||||
</div>
|
||||
<div>
|
||||
<?php
|
||||
DisplayMedecinCard($pdo, $_POST['id']);
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-8 h-100 border-start border-dark border-3 me-3">
|
||||
<div class="mt-3 d-flex flex-column gap-3">
|
||||
<?php
|
||||
if(!isset($_POST['start']) || $_POST['start'] == null){
|
||||
echo '<p class="ms-5 mt-2 fw-bold">Veuillez choisir une date</p>';
|
||||
}
|
||||
else{
|
||||
displayRDVForDate($pdo, $_POST['start'], $_POST['id']);
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
32
index.php
32
index.php
@@ -9,35 +9,31 @@
|
||||
<link href="https://fonts.googleapis.com/css2?family=Just+Me+Again+Down+Here&family=Open+Sans&display=swap" rel="stylesheet">
|
||||
<link rel="stylesheet" href="src/css/styles.css">
|
||||
<script src="src/js/AJAX/utils.js" defer></script>
|
||||
<script src="src/js/AJAX/index.js" defer></script>
|
||||
<script src="src/js/AJAX/index.js" defer type="module"></script>
|
||||
<link rel="icon" href="src/img/favicon.png" type="image/x-icon"/>
|
||||
</head>
|
||||
<body>
|
||||
<?php
|
||||
require('src/php/db/dbconnect.php');
|
||||
require('src/php/db/Patient.php');
|
||||
require('src/php/db/Medecin.php');
|
||||
require('src/php/constants.php');
|
||||
require('src/php/components/check.php');
|
||||
require('src/php/components/token.php');
|
||||
require('src/php/components/user-login.php');
|
||||
|
||||
ini_set('display_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
session_start();
|
||||
$pdo = dbConnect();
|
||||
?>
|
||||
<div id="topbar">
|
||||
<div id="topInfo">
|
||||
<a href="index.php">
|
||||
<a id="home">
|
||||
<p id="DoctISEN" class="top-0 position-fixed">
|
||||
Doct'ISEN
|
||||
</p>
|
||||
</a>
|
||||
<div class="d-flex position-fixed end-0 flex-row align-items-center gap-3 mt-2 top-0">
|
||||
<?php
|
||||
loginUI($pdo);
|
||||
//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>
|
||||
<div id="searchbar"></div>
|
||||
@@ -86,5 +82,7 @@
|
||||
</footer>
|
||||
</div>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.0.0/core.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.9-1/md5.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
65
search.php
65
search.php
@@ -1,65 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title> Recherche </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>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Just+Me+Again+Down+Here&family=Open+Sans&display=swap" rel="stylesheet">
|
||||
<link rel="stylesheet" href="src/css/styles.css">
|
||||
<script src="src/js/AJAX/utils.js" defer></script>
|
||||
<script src="src/js/AJAX/index.js" defer></script>
|
||||
<link rel="icon" href="src/img/favicon.png" type="image/x-icon"/>
|
||||
<?php
|
||||
require('src/php/db/dbconnect.php');
|
||||
require('src/php/constants.php');
|
||||
require('src/php/components/token.php');
|
||||
require('src/php/components/check.php');
|
||||
require('src/php/components/user-login.php');
|
||||
require('src/php/db/Patient.php');
|
||||
require('src/php/db/Medecin.php');
|
||||
require ('src/php/db/Search.php');
|
||||
ini_set('display_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
$pdo = dbConnect();
|
||||
?>
|
||||
</head>
|
||||
<body>
|
||||
<div id="searchtopbar">
|
||||
<div id="topbar" class="d-flex justify-content-between flex-row">
|
||||
<div>
|
||||
<a href="index.php">
|
||||
<p id="DoctISEN">
|
||||
Doct'ISEN
|
||||
</p>
|
||||
</a>
|
||||
</div>
|
||||
<div class="d-flex flex-row align-items-center gap-3 me-2">
|
||||
<div class="d-flex flex-row align-items-center gap-3 me-2">
|
||||
<?php
|
||||
loginUI($pdo);
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="searchbar">
|
||||
<form class="input-group p-5" action="search.php" 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="button-addon2">Rechercher</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div id="content">
|
||||
<!--
|
||||
<?php
|
||||
//search($pdo, $_POST['nom'], $_POST['postal']);
|
||||
// Old native PHP code
|
||||
?>
|
||||
Switch to AJAX with APIREST
|
||||
--->
|
||||
</div>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL" crossorigin="anonymous"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -5,6 +5,7 @@ require_once '../php/constants.php';
|
||||
require_once '../php/db/dbconnect.php';
|
||||
require_once '../php/db/Search.php';
|
||||
require_once '../php/db/Login.php';
|
||||
require_once '../php/db/Signup.php';
|
||||
require_once '../php/db/Calendrier.php';
|
||||
require_once 'test/database.php';
|
||||
ini_set('display_errors', 1);
|
||||
@@ -65,10 +66,21 @@ $router->POST('/api/login/patient', ["mail", "password"], function($mail, $passw
|
||||
loginPatient::Login($pdo, $mail, $password);
|
||||
});
|
||||
|
||||
$router->PUT('/api/signup/patient', ["mail", "password", "name", "surname", "phone"], function($mail, $password, $name, $surname, $phone){
|
||||
global $pdo;
|
||||
SignupPatient::Insert($pdo, $mail, $password, $name, $surname, $phone);
|
||||
});
|
||||
|
||||
$router->POST('/api/login/medecin', ["mail", "password"], function($mail, $password){
|
||||
global $pdo;
|
||||
loginMedecin::Login($pdo, $mail, $password);
|
||||
});
|
||||
|
||||
$router->PUT('/api/signup/medecin', ["name", "surname", "mail", "password", "specialite", "phone", "postal"], function($name, $surname, $mail, $password, $specialite, $phone, $postal){
|
||||
global $pdo;
|
||||
SignupMedecin::insertMedecin($pdo, $name, $surname, $mail, $password, $specialite, $phone, $postal);
|
||||
});
|
||||
|
||||
$router->PUT('/api/requests', ["test"], function($test){
|
||||
echo json_encode($test);
|
||||
});
|
||||
|
||||
@@ -4,6 +4,7 @@ body{
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-family: 'Roboto', sans-serif;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
#DoctISEN{
|
||||
@@ -15,6 +16,53 @@ body{
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.login-ui{
|
||||
height: 78vh;
|
||||
background-color: #EEF2F7;
|
||||
}
|
||||
|
||||
.signup-ui{
|
||||
height: 100vh;
|
||||
background-color: #EEF2F7;
|
||||
}
|
||||
|
||||
.signup-ui-praticien{
|
||||
height: 125vh;
|
||||
background-color: #EEF2F7;
|
||||
}
|
||||
|
||||
#signup-sign-part{
|
||||
background-color: white;
|
||||
height: 80%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1em;
|
||||
border-radius: 20px;
|
||||
box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
|
||||
#login-part{
|
||||
background-color: white;
|
||||
height: 45%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1em;
|
||||
border-radius: 20px;
|
||||
box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.1);
|
||||
margin-top: 10%;
|
||||
}
|
||||
|
||||
#signup-part{
|
||||
background-color: white;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1em;
|
||||
border-radius: 20px;
|
||||
box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.1);
|
||||
margin-top: 10%;
|
||||
}
|
||||
|
||||
#topbar{
|
||||
background-color: #ff0000;
|
||||
height: 22vh;
|
||||
@@ -78,13 +126,7 @@ body{
|
||||
padding-top: 5%;
|
||||
}
|
||||
|
||||
.logButton{
|
||||
width: 30%;
|
||||
height: 100%;
|
||||
background-color: #ff0000;
|
||||
color: white;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
|
||||
.pointer{
|
||||
cursor: pointer;
|
||||
@@ -117,6 +159,11 @@ margin-left: 6rem !important;
|
||||
margin-right: 24rem !important;
|
||||
}
|
||||
|
||||
.mx-25{
|
||||
margin-left: 25% !important;
|
||||
margin-right: 25% !important;
|
||||
}
|
||||
|
||||
.thumbnail{
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
|
||||
18
src/js/AJAX/alert.js
Normal file
18
src/js/AJAX/alert.js
Normal file
@@ -0,0 +1,18 @@
|
||||
console.log("alert.js loaded");
|
||||
|
||||
function displayAlert(text) {
|
||||
let alert = document.getElementById("Alert");
|
||||
alert.innerHTML = "";
|
||||
alert.innerHTML = `
|
||||
<div class="alert alert-success" role="alert">
|
||||
${text}
|
||||
</div>`;
|
||||
setTimeout(clearAlert, 5000);
|
||||
}
|
||||
|
||||
function clearAlert() {
|
||||
let alert = document.getElementById("Alert");
|
||||
alert.innerHTML = "";
|
||||
}
|
||||
|
||||
export {displayAlert};
|
||||
130
src/js/AJAX/home.js
Normal file
130
src/js/AJAX/home.js
Normal file
@@ -0,0 +1,130 @@
|
||||
import {TokenDecode} from "./lib.js";
|
||||
import {attachSearchEventListener, removeSearchTopBar} from "./search.js";
|
||||
import {displayAlert} from "./alert.js";
|
||||
import {attachLoginPraticienDisplayEventListener, attachLoginUserDisplayEventListener, attachDisconnectEventListener} from "./login.js";
|
||||
console.log("home.js loaded");
|
||||
|
||||
function displayHomeTopBar() {
|
||||
let topbar = document.getElementById("topbar");
|
||||
topbar.innerHTML = "";
|
||||
if(sessionStorage.getItem("token") === null) {
|
||||
topbar.innerHTML = `
|
||||
<div id="topInfo">
|
||||
<a id="home">
|
||||
<p id="DoctISEN" class="top-0 position-fixed">
|
||||
Doct'ISEN
|
||||
</p>
|
||||
</a>
|
||||
<div class="d-flex position-fixed end-0 flex-row align-items-center gap-3 mt-2 top-0">
|
||||
<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>
|
||||
`;
|
||||
attachLoginUserDisplayEventListener();
|
||||
attachLoginPraticienDisplayEventListener();
|
||||
}
|
||||
else {
|
||||
let token = sessionStorage.getItem("token");
|
||||
let user = TokenDecode(token);
|
||||
const mailMD5 = CryptoJS.MD5(user.mail);
|
||||
if(user.type === "patient") {
|
||||
topbar.innerHTML = `
|
||||
<div id="topInfo">
|
||||
<a id="home">
|
||||
<p id="DoctISEN" class="top-0 position-fixed">
|
||||
Doct'ISEN
|
||||
</p>
|
||||
</a>
|
||||
<div class="d-flex position-fixed 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>
|
||||
<a class="text-white" id="user-name-disconect">${user.name} ${user.surname}</a>
|
||||
</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="my-rdv">Mes rendez-vous</p>
|
||||
</div>
|
||||
</div>`;
|
||||
attachDisconnectEventListener();
|
||||
}
|
||||
else if (user.type === "medecin") {
|
||||
topbar.innerHTML = `
|
||||
<div id="topInfo">
|
||||
<a id="home">
|
||||
<p id="DoctISEN" class="top-0 position-fixed">
|
||||
Doct'ISEN
|
||||
</p>
|
||||
</a>
|
||||
<div class="d-flex position-fixed 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>
|
||||
<a class="text-white" id="user-name-disconect">${user.name} ${user.surname}</a>
|
||||
</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="my-rdv-medecin">Mes rendez-vous practicien</p>
|
||||
</div>
|
||||
</div>`;
|
||||
attachDisconnectEventListener();
|
||||
}
|
||||
else {
|
||||
topbar.innerHTML = `
|
||||
<div id="topInfo">
|
||||
<p class="alert-danger">Erreur</p>
|
||||
</div>`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function displayHome(text) {
|
||||
removeSearchTopBar();
|
||||
displayHomeTopBar();
|
||||
let container = document.getElementById("content");
|
||||
container.classList = "";
|
||||
container.innerHTML = "";
|
||||
container.innerHTML = `
|
||||
<div style="background-color: red; height: 50vh;">
|
||||
<div class="d-flex justify-content-center align-items-center" style="background-color: red;" id="Alert"></div>
|
||||
<img src="src/img/img_index.png" alt="img_index" id="img_index">
|
||||
<div id="rdv">
|
||||
<p class="text-white fw-bold fs-3">Trouvez un rendez vous avec un medecin</p>
|
||||
<form action="" class="input-group" 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-success" type="submit" id="recherche">Rechercher</button>
|
||||
</form>
|
||||
</div>
|
||||
<div class="d-flex justify-content-center gap-5 w-100" id="cardPos">
|
||||
<div class="card" style="width: 18rem;">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Information</h5>
|
||||
<h6 class="card-subtitle mb-2 text-body-secondary">Ligue contre le cancer</h6>
|
||||
<p class="card-text">Mois sans tabac: c’est le moment d’arrêter !</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card" style="width: 18rem;">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Information</h5>
|
||||
<h6 class="card-subtitle mb-2 text-body-secondary">Pharmacie Sanchez</h6>
|
||||
<p class="card-text">Le rôle du phramacien évolue: Venez nous voir.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card" style="width: 18rem;">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Information</h5>
|
||||
<h6 class="card-subtitle mb-2 text-body-secondary">Doct’ISEN</h6>
|
||||
<p class="card-text">Un empechement: Prevenez votre soignant.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<footer class="fixed-bottom m-2 mx-4">
|
||||
<p>Recherche de praticiens</p>
|
||||
<p>Doct’ISEN, 33 QUATER Av. du Champ de Manœuvre, 44470 Carquefou</p>
|
||||
<p class="text-secondary">Conditions générales d'utilisation • Conditions d'utilisation du site Doct'ISEN • Politique relative à la protection des données personnelles • Politique en matière de cookies • Gestion des cookies et consentement • Règles de référencement • Mentions légales</p>
|
||||
<p class="text-secondary">Annuaire des médecins du CNOM • Annuaire des chirurgiens-dentistes de l'ONCD • Ordre National des Médecins • Ordre National des Chirurgiens-Dentistes</p>
|
||||
</footer>`;
|
||||
attachSearchEventListener();
|
||||
attachLoginUserDisplayEventListener();
|
||||
if(text !== ""){
|
||||
displayAlert(text);
|
||||
}
|
||||
}
|
||||
|
||||
export {displayHome, displayHomeTopBar};
|
||||
@@ -1,288 +1,21 @@
|
||||
import {attachSearchEventListener} from "./search.js";
|
||||
import {attachLoginUserDisplayEventListener, attachLoginPraticienDisplayEventListener, attachDisconnectEventListener} from "./login.js";
|
||||
import {displayHome, displayHomeTopBar} from "./home.js";
|
||||
console.log("index.js loaded");
|
||||
|
||||
|
||||
//Felix Part
|
||||
|
||||
function displaySearchResults(data) {
|
||||
let container = document.getElementById("content");
|
||||
container.innerHTML = "";
|
||||
let mainDiv = document.createElement("div");
|
||||
mainDiv.classList.add("d-flex", "flex-row", "flex-wrap", "mx-5", "gap-5", "justify-content-center");
|
||||
let count = 0;
|
||||
data.forEach(function(element) {
|
||||
count++;
|
||||
let card = document.createElement("div");
|
||||
card.classList.add("card", "w-25");
|
||||
card.innerHTML = `
|
||||
<div class="row g-0">
|
||||
<div class="col-md-4">
|
||||
<img src="src/img/Medecin_test.jpeg" alt="doctor" class="img-fluid rounded-start" width="300" height="300">
|
||||
</div>
|
||||
<div class="col-md-8">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">${element.m_surname} ${element.m_name}</h5>
|
||||
<h6 class="card-subtitle mb-2 text-body-secondary">${element.m_specialty}</h6>
|
||||
<p class="card-text">Code Postal: ${element.m_postal}</p>
|
||||
<button type="submit" class="btn btn-danger" id="m-id-${element.m_id}">Prendre rendez-vous</button>
|
||||
</div>
|
||||
</div>`;
|
||||
mainDiv.appendChild(card);
|
||||
});
|
||||
container.appendChild(mainDiv);
|
||||
if(count === 0) {
|
||||
mainDiv.innerHTML = "<h1>Aucun résultats</h1>";
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
if(sessionStorage.getItem("token") !== null) {
|
||||
displayHomeTopBar();
|
||||
}
|
||||
else {
|
||||
let resultText = document.createElement("h1");
|
||||
resultText.textContent = count + " résultats";
|
||||
container.insertBefore(resultText, mainDiv);
|
||||
attachRDVEventListener();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function displaySearchTopBar(){
|
||||
let topbar = document.getElementById("topbar");
|
||||
let searchbar = document.getElementById("searchbar");
|
||||
|
||||
let form = topbar.querySelector("form");
|
||||
if (form) {
|
||||
topbar.removeChild(form);
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
function removeSearchTopBar(){
|
||||
let topbar = document.getElementById("topbar");
|
||||
topbar.innerHTML = "";
|
||||
topbar.innerHTML = `
|
||||
<div id="topInfo">
|
||||
<a href="index.php">
|
||||
<p id="DoctISEN" class="top-0 position-fixed">
|
||||
Doct'ISEN
|
||||
</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>
|
||||
</div>
|
||||
<div id="searchbar"></div>`;
|
||||
}
|
||||
|
||||
function displayRDVForDate(data) {
|
||||
let container = document.getElementById("rdv-list");
|
||||
container.innerHTML = "";
|
||||
let count = 0;
|
||||
data.forEach(function(element) {
|
||||
try{
|
||||
let card = document.createElement("div");
|
||||
card.classList.add("card");
|
||||
element.rdv_time = element.rdv_time.slice(0, 5);
|
||||
card.innerHTML = `
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">${element.rdv_time}</h5>
|
||||
<p class="card-text">Adresse: ${element.l_adress} <br>
|
||||
Ville: ${element.l_city} ${element.l_postal}</p>
|
||||
<button type="submit" class="btn btn-danger" id="rdv-id-${element.rdv_id}">Prendre ce rendez-vous</button>
|
||||
</div>`;
|
||||
container.appendChild(card);
|
||||
count++;
|
||||
} catch (e) {
|
||||
//Do nothing
|
||||
//console.error(e);
|
||||
}
|
||||
});
|
||||
if(count === 0) {
|
||||
container.innerHTML = "<h1>Aucun rendez-vous</h1>";
|
||||
}
|
||||
else {
|
||||
let resultText = document.createElement("h1");
|
||||
resultText.textContent = count + " rendez-vous";
|
||||
container.insertBefore(resultText, container.firstChild);
|
||||
attachPrendreRDVEventListener();
|
||||
}
|
||||
}
|
||||
|
||||
function displayCalendar(data) {
|
||||
let container = document.getElementById("content");
|
||||
container.innerHTML = "";
|
||||
let mainDiv = document.createElement("div");
|
||||
mainDiv.classList.add("row");
|
||||
|
||||
// Colonne de gauche
|
||||
let leftCol = document.createElement("div");
|
||||
leftCol.classList.add("col", "h-100", "border-dark", "border-3", "justify-content-center", "text-center", "ms-3");
|
||||
let leftDiv = document.createElement("div");
|
||||
leftDiv.classList.add("d-flex", "flex-column", "justify-content-center", "gap-6");
|
||||
|
||||
// Calendrier de sélection de date
|
||||
let form = document.createElement("form");
|
||||
form.classList.add("mt-3");
|
||||
form.id = "date-selection-form";
|
||||
let label = document.createElement("label");
|
||||
label.setAttribute("for", "date");
|
||||
label.textContent = "Choisissez une date :";
|
||||
form.appendChild(label);
|
||||
let input = document.createElement("input");
|
||||
input.setAttribute("type", "date");
|
||||
input.setAttribute("name", "start");
|
||||
input.setAttribute("id", "date");
|
||||
input.classList.add("mt-2", "form-control");
|
||||
form.appendChild(input);
|
||||
let submit = document.createElement("input");
|
||||
submit.setAttribute("type", "submit");
|
||||
submit.setAttribute("value", "Valider");
|
||||
submit.classList.add("mt-2", "btn", "btn-outline-danger");
|
||||
form.appendChild(submit);
|
||||
leftDiv.appendChild(form);
|
||||
|
||||
// Carte du médecin
|
||||
let medecinCard = document.createElement("div");
|
||||
medecinCard.classList.add("card", "mx-auto", "d-flex", "flex-row");
|
||||
medecinCard.innerHTML = `
|
||||
<div class="row g-0">
|
||||
<div class="col-md-4">
|
||||
<img src="src/img/Medecin_test.jpeg" class="img-fluid rounded-start" alt="doctor" width="300" height="300">
|
||||
</div>
|
||||
<div class="col-md-8">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">${data[0].m_surname} ${data[0].m_name}</h5>
|
||||
<h6 class="card-subtitle mb-2 text-body-secondary">${data[0].m_specialty}</h6>
|
||||
</div>
|
||||
</div>
|
||||
</div>`;
|
||||
leftDiv.appendChild(medecinCard);
|
||||
|
||||
leftCol.appendChild(leftDiv);
|
||||
mainDiv.appendChild(leftCol);
|
||||
|
||||
// Colonne de droite
|
||||
let rightCol = document.createElement("div");
|
||||
rightCol.classList.add("col-8", "h-100", "border-start", "border-dark", "border-3", "me-3");
|
||||
|
||||
// Liste des rendez-vous
|
||||
let rdvList = document.createElement("div");
|
||||
rdvList.classList.add("mt-3", "d-flex", "flex-column", "gap-3");
|
||||
rdvList.id = "rdv-list";
|
||||
rightCol.appendChild(rdvList);
|
||||
|
||||
mainDiv.appendChild(rightCol);
|
||||
container.appendChild(mainDiv);
|
||||
displayRDVForDate(data);
|
||||
document.getElementById("date-selection-form").addEventListener("submit", function(event) {
|
||||
event.preventDefault();
|
||||
let date = document.getElementById("date").value;
|
||||
let id = data[0].m_id; // Assuming 'data' is accessible in this scope and contains the doctor's details
|
||||
ajaxRequest('GET', "src/API/requests.php/api/rdv-date?date=" + date + "&id=" + id, function (data) {
|
||||
displayRDVForDate(data);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function displayAlert(text) {
|
||||
let alert = document.getElementById("Alert");
|
||||
alert.innerHTML = "";
|
||||
alert.innerHTML = `
|
||||
<div class="alert alert-success" role="alert">
|
||||
${text}
|
||||
</div>`;
|
||||
setTimeout(clearAlert, 5000);
|
||||
}
|
||||
|
||||
function clearAlert() {
|
||||
let alert = document.getElementById("Alert");
|
||||
alert.innerHTML = "";
|
||||
}
|
||||
|
||||
function displayHome() {
|
||||
removeSearchTopBar();
|
||||
let container = document.getElementById("content");
|
||||
container.innerHTML = "";
|
||||
container.innerHTML = `
|
||||
<div style="background-color: red; height: 50vh;">
|
||||
<div class="d-flex justify-content-center align-items-center" id="Alert"></div>
|
||||
<img src="src/img/img_index.png" alt="img_index" id="img_index">
|
||||
<div id="rdv">
|
||||
<p class="text-white fw-bold fs-3">Trouvez un rendez vous avec un medecin</p>
|
||||
<form action="" class="input-group" 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-success" type="submit" id="recherche">Rechercher</button>
|
||||
</form>
|
||||
</div>
|
||||
<div class="d-flex justify-content-center gap-5 w-100" id="cardPos">
|
||||
<div class="card" style="width: 18rem;">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Information</h5>
|
||||
<h6 class="card-subtitle mb-2 text-body-secondary">Ligue contre le cancer</h6>
|
||||
<p class="card-text">Mois sans tabac: c’est le moment d’arrêter !</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card" style="width: 18rem;">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Information</h5>
|
||||
<h6 class="card-subtitle mb-2 text-body-secondary">Pharmacie Sanchez</h6>
|
||||
<p class="card-text">Le rôle du phramacien évolue: Venez nous voir.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card" style="width: 18rem;">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Information</h5>
|
||||
<h6 class="card-subtitle mb-2 text-body-secondary">Doct’ISEN</h6>
|
||||
<p class="card-text">Un empechement: Prevenez votre soignant.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<footer class="fixed-bottom m-2 mx-4">
|
||||
<p>Recherche de praticiens</p>
|
||||
<p>Doct’ISEN, 33 QUATER Av. du Champ de Manœuvre, 44470 Carquefou</p>
|
||||
<p class="text-secondary">Conditions générales d'utilisation • Conditions d'utilisation du site Doct'ISEN • Politique relative à la protection des données personnelles • Politique en matière de cookies • Gestion des cookies et consentement • Règles de référencement • Mentions légales</p>
|
||||
<p class="text-secondary">Annuaire des médecins du CNOM • Annuaire des chirurgiens-dentistes de l'ONCD • Ordre National des Médecins • Ordre National des Chirurgiens-Dentistes</p>
|
||||
</footer>`;
|
||||
attachSearchEventListener();
|
||||
displayAlert("Rendez-vous pris avec succès");
|
||||
}
|
||||
|
||||
function performSearch(event) {
|
||||
event.preventDefault();
|
||||
let type = document.getElementById("nom").value;
|
||||
let postal = document.getElementById("postal").value;
|
||||
if (postal === "") {
|
||||
if (type === "") {
|
||||
alert("Veuillez remplir au moins un champ");
|
||||
return;
|
||||
} else {
|
||||
ajaxRequest('GET', "src/API/requests.php/api/search-type?type=" + type, function (data) {
|
||||
displaySearchResults(data);
|
||||
displaySearchTopBar();
|
||||
})
|
||||
}
|
||||
} else if (type === "") {
|
||||
ajaxRequest('GET', "src/API/requests.php/api/search-postal?postal=" + postal, function (data) {
|
||||
displaySearchResults(data);
|
||||
displaySearchTopBar();
|
||||
});
|
||||
} else {
|
||||
ajaxRequest('GET', "src/API/requests.php/api/search?type=" + type + "&postal=" + postal, function (data) {
|
||||
displaySearchResults(data);
|
||||
displaySearchTopBar();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function attachSearchEventListener() {
|
||||
try{
|
||||
document.getElementById("recherche").addEventListener("click", function (event) {
|
||||
performSearch(event);
|
||||
function attachReturnHomeEventListener() {
|
||||
try {
|
||||
document.getElementById("home").addEventListener("click", function (event) {
|
||||
displayHome("");
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
@@ -291,36 +24,6 @@ function attachSearchEventListener() {
|
||||
}
|
||||
}
|
||||
|
||||
function attachRDVEventListener() {
|
||||
let buttons = document.querySelectorAll("button[id^='m-id-']");
|
||||
buttons.forEach(function (button) {
|
||||
button.addEventListener("click", function (event) {
|
||||
let id = event.target.id.split("-")[2]
|
||||
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);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function attachPrendreRDVEventListener() {
|
||||
let buttons = document.querySelectorAll("button[id^='rdv-id-']");
|
||||
buttons.forEach(function (button) {
|
||||
button.addEventListener("click", function (event) {
|
||||
let RDVid = event.target.id.split("-")[2];
|
||||
data = "rdv_id=" + RDVid + "&patient_id=" + 1;
|
||||
ajaxRequest('PUT', "src/API/requests.php/api/rdv", function (returnData){
|
||||
if (returnData.success) {
|
||||
displayHome();
|
||||
} else {
|
||||
alert("Erreur lors de la prise de rendez-vous");
|
||||
}
|
||||
}, data);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
//Yanis Part
|
||||
|
||||
@@ -410,4 +113,8 @@ function DisplayRDVPatient(rdv){
|
||||
//End Call
|
||||
|
||||
ButtonShowRdvPraticient();
|
||||
attachSearchEventListener();
|
||||
attachSearchEventListener();
|
||||
attachLoginUserDisplayEventListener();
|
||||
attachLoginPraticienDisplayEventListener();
|
||||
attachReturnHomeEventListener();
|
||||
attachDisconnectEventListener();
|
||||
15
src/js/AJAX/lib.js
Normal file
15
src/js/AJAX/lib.js
Normal file
@@ -0,0 +1,15 @@
|
||||
console.log("lib.js loaded");
|
||||
|
||||
function TokenDecode(token){
|
||||
let decodedToken = decodeURIComponent(atob(token).replace(/\s+/g, '').replace(/[0-9a-f]{2}/g, '%$&'));
|
||||
decodedToken = decodedToken.split(":");
|
||||
return {
|
||||
type: decodedToken[0],
|
||||
id: decodedToken[1],
|
||||
name: decodedToken[2],
|
||||
surname: decodedToken[3],
|
||||
mail: decodedToken[4]
|
||||
|
||||
};
|
||||
}
|
||||
export {TokenDecode};
|
||||
343
src/js/AJAX/login.js
Normal file
343
src/js/AJAX/login.js
Normal file
@@ -0,0 +1,343 @@
|
||||
import {displayHome, displayHomeTopBar} from "./home.js";
|
||||
console.log("login.js loaded");
|
||||
|
||||
function displayLoginUser() {
|
||||
if (sessionStorage.getItem("token") === null) {
|
||||
let container = document.getElementById("content");
|
||||
container.innerHTML = "";
|
||||
container.className = 'd-flex flex-column justify-content-center text-center w-100 login-ui';
|
||||
container.innerHTML = `
|
||||
<div class="h-100 d-flex flex-column gap-0 justify-content-center text-center w-50 mx-25">
|
||||
<div class="p-3 m-0 border-0 bd-example m-0 border-0" id="login-part">
|
||||
<div class="text-center align-content-center">
|
||||
<h5 class="text-center fw-bold">J'ai déjà un compte Doct'ISEN</h5>
|
||||
<form class="px-4 py-3">
|
||||
<div class="mb-3">
|
||||
<label for="user-login-mail" class="form-label">Adresse mail</label>
|
||||
<input type="email" class="form-control" id="user-login-mail" placeholder="email@example.com" name="mail">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="user-login-password" class="form-label">Mot de passe</label>
|
||||
<input type="password" class="form-control" id="user-login-password" placeholder="********" name="password">
|
||||
</div>
|
||||
<div class="text-center justify-content-center">
|
||||
<button type="submit" class="btn btn-danger logButton" id="user-login-button">Se connecter</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="p-3 m-0 border-0 bd-example m-0 border-0 text-center justify-content-center mt-5" id="signup-part">
|
||||
<div class="text-center align-content-center">
|
||||
<h5 class="fw-bold">Nouveau sur Doct'ISEN?</h5>
|
||||
<a id="signup-user">
|
||||
<button class="btn btn-danger logButton">S'inscrire</button>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>`;
|
||||
document.getElementById("user-login-button").addEventListener("click", function (event) {
|
||||
event.preventDefault();
|
||||
let mail = document.getElementById("user-login-mail").value;
|
||||
let password = document.getElementById("user-login-password").value;
|
||||
let data = "mail=" + mail + "&password=" + password;
|
||||
ajaxRequest('POST', "src/API/requests.php/api/login/patient", function (data) {
|
||||
if (data.message === "Login success") {
|
||||
sessionStorage.setItem("token", data.token);
|
||||
displayHome("Vous êtes connecté");
|
||||
} else {
|
||||
alert("Erreur lors de la connexion");
|
||||
}
|
||||
}, data);
|
||||
});
|
||||
document.getElementById("signup-user").addEventListener("click", function (event) {
|
||||
displaySignUpUser();
|
||||
});
|
||||
}
|
||||
else {
|
||||
displayHome("Vous êtes déjà connecté");
|
||||
}
|
||||
}
|
||||
|
||||
function displayLoginPraticien() {
|
||||
let container = document.getElementById("content");
|
||||
if (sessionStorage.getItem("token") === null) {
|
||||
container.innerHTML = "";
|
||||
container.className = 'd-flex flex-column justify-content-center text-center w-100 login-ui';
|
||||
container.innerHTML = `
|
||||
<div class="h-100 d-flex flex-column gap-0 justify-content-center text-center w-50 mx-25">
|
||||
<div class="p-3 m-0 border-0 bd-example m-0 border-0" id="login-part">
|
||||
<div class="text-center align-content-center">
|
||||
<h5 class="text-center fw-bold">J'ai déjà un compte praticien Doct'ISEN</h5>
|
||||
<form class="px-4 py-3">
|
||||
<div class="mb-3">
|
||||
<label for="praticien-login-mail" class="form-label">Adresse mail</label>
|
||||
<input type="email" class="form-control" id="praticien-login-mail" placeholder="email@example.com" name="mail">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="praticien-login-password" class="form-label">Mot de passe</label>
|
||||
<input type="password" class="form-control" id="praticien-login-password" placeholder="********" name="password">
|
||||
</div>
|
||||
<div class="text-center justify-content-center">
|
||||
<button type="submit" class="btn btn-danger logButton" id="praticien-login-button">Se connecter</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="p-3 m-0 border-0 bd-example m-0 border-0 text-center justify-content-center mt-5" id="signup-part">
|
||||
<div class="text-center align-content-center">
|
||||
<h5 class="fw-bold">Nouveau praticien sur Doct'ISEN?</h5>
|
||||
<a id="signup-praticien">
|
||||
<button class="btn btn-danger logButton">S'inscrire</button>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>`;
|
||||
document.getElementById("praticien-login-button").addEventListener("click", function (event) {
|
||||
event.preventDefault();
|
||||
let mail = document.getElementById("praticien-login-mail").value;
|
||||
let password = document.getElementById("praticien-login-password").value;
|
||||
let data = "mail=" + mail + "&password=" + password;
|
||||
ajaxRequest('POST', "src/API/requests.php/api/login/medecin", function (data) {
|
||||
if (data.message === "Login success") {
|
||||
sessionStorage.setItem("token", data.token)
|
||||
displayHome("Vous êtes connecté");
|
||||
} else {
|
||||
alert("Erreur lors de la connexion");
|
||||
}
|
||||
}, data);
|
||||
});
|
||||
document.getElementById("signup-praticien").addEventListener("click", function (event) {
|
||||
displaySignUpPraticien();
|
||||
});
|
||||
}
|
||||
else {
|
||||
displayHome("Vous êtes déjà connecté");
|
||||
}
|
||||
}
|
||||
|
||||
function displaySignUpPraticien() {
|
||||
if (sessionStorage.getItem("token") === null) {
|
||||
let container = document.getElementById("content");
|
||||
container.innerHTML = "";
|
||||
container.className = 'd-flex flex-column justify-content-center text-center w-100 signup-ui-praticien';
|
||||
container.innerHTML = `
|
||||
<div class="h-100 d-flex flex-column gap-0 justify-content-center text-center w-50 mx-25" style="margin-top: -15%;">
|
||||
<div class="p-3 m-0 border-0 bd-example border-0" id="signup-sign-part">
|
||||
<div class="text-center align-content-center">
|
||||
<h5 class="text-center fw-bold">Inscription praticien sur Doct'ISEN</h5>
|
||||
<form class="px-4 py-3">
|
||||
<div class="mb-3">
|
||||
<label for="praticien-signup-name" class="form-label">Nom</label>
|
||||
<input type="text" class="form-control" id="praticien-signup-name" placeholder="Nom" name="name">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="praticien-signup-surname" class="form-label">Prénom</label>
|
||||
<input type="text" class="form-control" id="praticien-signup-surname" placeholder="Prénom" name="surname">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="praticien-signup-mail" class="form-label">Adresse mail</label>
|
||||
<input type="email" class="form-control" id="praticien-signup-mail" placeholder="example@example.com" name="mail">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="praticien-signup-mail-confirm" class="form-label">Confirmer adresse mail</label>
|
||||
<input type="email" class="form-control" id="praticien-signup-mail-confirm" placeholder="example@example.com" name="mail-confirm">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="praticien-signup-password" class="form-label">Mot de passe</label>
|
||||
<input type="password" class="form-control" id="praticien-signup-password" placeholder="********" name="password">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="praticien-signup-password-confirm" class="form-label">Confirmer mot de passe</label>
|
||||
<input type="password" class="form-control" id="praticien-signup-password-confirm" placeholder="********" name="password-confirm">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="praticien-signup-phone" class="form-label">Numéro de téléphone</label>
|
||||
<input type="tel" class="form-control" id="praticien-signup-phone" placeholder="06********" name="phone">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="praticien-signup-specialty" class="form-label">Spécialité</label>
|
||||
<input type="text" class="form-control" id="praticien-signup-specialty" placeholder="Spécialité" name="specialty">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="praticien-signup-postal" class="form-label">Code postal</label>
|
||||
<input type="text" class="form-control" id="praticien-signup-postal" placeholder="Code postal" name="postal">
|
||||
</div>
|
||||
<div class="text-center justify-content-center">
|
||||
<button type="submit" class="btn btn-danger logButton" id="praticien-signup-button">S'inscrire</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="p-3 m-0 border-0 bd-example m-0 border-0 text-center justify-content-center mt-5" id="signup-part">
|
||||
<div class="text-center align-content-center">
|
||||
<h5 class="fw-bold">Déjà inscrit en tant que praticien ?</h5>
|
||||
<a id="login-praticien2">
|
||||
<button class="btn btn-danger logButton">Se connecter</button>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>`;
|
||||
document.getElementById("login-praticien2").addEventListener("click", function (event) {
|
||||
displayLoginPraticien();
|
||||
});
|
||||
document.getElementById("praticien-signup-button").addEventListener("click", function (event) {
|
||||
event.preventDefault();
|
||||
let name = document.getElementById("praticien-signup-name").value;
|
||||
let surname = document.getElementById("praticien-signup-surname").value;
|
||||
let mail = document.getElementById("praticien-signup-mail").value;
|
||||
let mailConfirm = document.getElementById("praticien-signup-mail-confirm").value;
|
||||
let password = document.getElementById("praticien-signup-password").value;
|
||||
let passwordConfirm = document.getElementById("praticien-signup-password-confirm").value;
|
||||
let phone = document.getElementById("praticien-signup-phone").value;
|
||||
let specialty = document.getElementById("praticien-signup-specialty").value;
|
||||
let postal = document.getElementById("praticien-signup-postal").value;
|
||||
if (mail !== mailConfirm) {
|
||||
alert("Les adresses mail ne correspondent pas");
|
||||
return;
|
||||
}
|
||||
if (password !== passwordConfirm) {
|
||||
alert("Les mots de passe ne correspondent pas");
|
||||
return;
|
||||
}
|
||||
let data = "name=" + name + "&surname=" + surname + "&mail=" + mail + "&password=" + password + "&specialite=" + specialty + "&phone=" + phone + "&postal=" + postal;
|
||||
ajaxRequest('PUT', "src/API/requests.php/api/signup/medecin", function (data) {
|
||||
if (data.success) {
|
||||
displayLoginPraticien();
|
||||
} else {
|
||||
alert("Erreur lors de l'inscription");
|
||||
}
|
||||
}, data);
|
||||
});
|
||||
}
|
||||
else {
|
||||
displayHome("Vous êtes déjà connecté");
|
||||
}
|
||||
}
|
||||
|
||||
function displaySignUpUser() {
|
||||
if (sessionStorage.getItem("token") === null) {
|
||||
let container = document.getElementById("content");
|
||||
container.innerHTML = "";
|
||||
container.className = 'd-flex flex-column justify-content-center text-center w-100 signup-ui';
|
||||
container.innerHTML = `
|
||||
<div class="h-100 d-flex flex-column gap-0 justify-content-center text-center w-50 mx-25" style="margin-top: -15%;">
|
||||
<div class="p-3 m-0 border-0 bd-example border-0" id="signup-sign-part">
|
||||
<div class="text-center align-content-center">
|
||||
<h5 class="text-center fw-bold">Inscription sur Doct'ISEN</h5>
|
||||
<form class="px-4 py-3">
|
||||
<div class="mb-3">
|
||||
<label for="user-signup-name" class="form-label">Nom</label>
|
||||
<input type="text" class="form-control" id="user-signup-name" placeholder="Nom" name="name">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="user-signup-surname" class="form-label">Prénom</label>
|
||||
<input type="text" class="form-control" id="user-signup-surname" placeholder="Prénom" name="surname">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="user-signup-mail" class="form-label">Adresse mail</label>
|
||||
<input type="email" class="form-control" id="user-signup-mail" placeholder="email@example.com" name="mail">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="user-signup-mail-confirm" class="form-label">Confirmer adresse mail</label>
|
||||
<input type="email" class="form-control" id="user-signup-mail-confirm" placeholder="email@example.com" name="mail-confirm">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="user-signup-password" class="form-label">Mot de passe</label>
|
||||
<input type="password" class="form-control" id="user-signup-password" placeholder="********" name="password">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="user-signup-password-confirm" class="form-label">Confirmer mot de passe</label>
|
||||
<input type="password" class="form-control" id="user-signup-password-confirm" placeholder="********" name="password-confirm">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="user-signup-phone" class="form-label">Numéro de téléphone</label>
|
||||
<input type="tel" class="form-control" id="user-signup-phone" placeholder="06********" name="phone">
|
||||
</div>
|
||||
<div class="text-center justify-content-center">
|
||||
<button type="submit" class="btn btn-danger logButton" id="user-signup-button">S'inscrire</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="p-3 m-0 border-0 bd-example m-0 border-0 text-center justify-content-center mt-5" id="signup-part">
|
||||
<div class="text-center align-content-center">
|
||||
<h5 class="fw-bold">Déjà inscrit ?</h5>
|
||||
<a id="login-user2">
|
||||
<button class="btn btn-danger logButton">Se connecter</button>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>`;
|
||||
document.getElementById("login-user2").addEventListener("click", function (event) {
|
||||
displayLoginUser();
|
||||
});
|
||||
document.getElementById("user-signup-button").addEventListener("click", function (event) {
|
||||
event.preventDefault();
|
||||
let name = document.getElementById("user-signup-name").value;
|
||||
let surname = document.getElementById("user-signup-surname").value;
|
||||
let mail = document.getElementById("user-signup-mail").value;
|
||||
let mailConfirm = document.getElementById("user-signup-mail-confirm").value;
|
||||
let password = document.getElementById("user-signup-password").value;
|
||||
let passwordConfirm = document.getElementById("user-signup-password-confirm").value;
|
||||
let phone = document.getElementById("user-signup-phone").value;
|
||||
if (mail !== mailConfirm) {
|
||||
alert("Les adresses mail ne correspondent pas");
|
||||
return;
|
||||
}
|
||||
if (password !== passwordConfirm) {
|
||||
alert("Les mots de passe ne correspondent pas");
|
||||
return;
|
||||
}
|
||||
let data = "name=" + name + "&surname=" + surname + "&mail=" + mail + "&password=" + password + "&phone=" + phone;
|
||||
ajaxRequest('PUT', "src/API/requests.php/api/signup/patient", function (data) {
|
||||
if (data.success) {
|
||||
displayLoginUser();
|
||||
} else {
|
||||
alert("Erreur lors de l'inscription");
|
||||
}
|
||||
}, data);
|
||||
});
|
||||
}
|
||||
else {
|
||||
displayHome("Vous êtes déjà connecté");
|
||||
}
|
||||
}
|
||||
|
||||
function disconnect() {
|
||||
sessionStorage.removeItem("token");
|
||||
displayHome("Vous êtes déconnecté");
|
||||
}
|
||||
|
||||
function attachLoginUserDisplayEventListener() {
|
||||
try {
|
||||
document.getElementById("login-user").addEventListener("click", function (event) {
|
||||
displayLoginUser();
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
//Do nothing
|
||||
//console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
function attachLoginPraticienDisplayEventListener() {
|
||||
try {
|
||||
document.getElementById("login-praticien").addEventListener("click", function (event) {
|
||||
displayLoginPraticien();
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
//Do nothing
|
||||
//console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
function attachDisconnectEventListener() {
|
||||
try {
|
||||
document.getElementById("user-name-disconect").addEventListener("click", function (event) {
|
||||
disconnect();
|
||||
});
|
||||
} catch (e) {
|
||||
//Do nothing
|
||||
}
|
||||
}
|
||||
|
||||
export {attachLoginUserDisplayEventListener, attachLoginPraticienDisplayEventListener, disconnect, attachDisconnectEventListener};
|
||||
118
src/js/AJAX/search.js
Normal file
118
src/js/AJAX/search.js
Normal file
@@ -0,0 +1,118 @@
|
||||
console.log("search.js loaded");
|
||||
import {attachRDVEventListener} from "./take-rdv.js";
|
||||
|
||||
function displaySearchResults(data) {
|
||||
let container = document.getElementById("content");
|
||||
container.innerHTML = "";
|
||||
let mainDiv = document.createElement("div");
|
||||
mainDiv.classList.add("d-flex", "flex-row", "flex-wrap", "mx-5", "gap-5", "justify-content-center");
|
||||
let count = 0;
|
||||
data.forEach(function(element) {
|
||||
count++;
|
||||
let card = document.createElement("div");
|
||||
card.classList.add("card", "w-25");
|
||||
card.innerHTML = `
|
||||
<div class="row g-0">
|
||||
<div class="col-md-4">
|
||||
<img src="src/img/Medecin_test.jpeg" alt="doctor" class="img-fluid rounded-start" width="300" height="300">
|
||||
</div>
|
||||
<div class="col-md-8">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">${element.m_surname} ${element.m_name}</h5>
|
||||
<h6 class="card-subtitle mb-2 text-body-secondary">${element.m_specialty}</h6>
|
||||
<p class="card-text">Code Postal: ${element.m_postal}</p>
|
||||
<button type="submit" class="btn btn-danger" id="m-id-${element.m_id}">Prendre rendez-vous</button>
|
||||
</div>
|
||||
</div>`;
|
||||
mainDiv.appendChild(card);
|
||||
});
|
||||
container.appendChild(mainDiv);
|
||||
if(count === 0) {
|
||||
mainDiv.innerHTML = "<h1>Aucun résultats</h1>";
|
||||
}
|
||||
else {
|
||||
let resultText = document.createElement("h1");
|
||||
resultText.textContent = count + " résultats";
|
||||
container.insertBefore(resultText, mainDiv);
|
||||
attachRDVEventListener();
|
||||
}
|
||||
}
|
||||
|
||||
function displaySearchTopBar(){
|
||||
let topbar = document.getElementById("topbar");
|
||||
let searchbar = document.getElementById("searchbar");
|
||||
|
||||
let form = topbar.querySelector("form");
|
||||
if (form) {
|
||||
topbar.removeChild(form);
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
function removeSearchTopBar(){
|
||||
let topbar = document.getElementById("topbar");
|
||||
topbar.innerHTML = "";
|
||||
topbar.innerHTML = `
|
||||
<div id="topInfo">
|
||||
<a id="home">
|
||||
<p id="DoctISEN" class="top-0 position-fixed">
|
||||
Doct'ISEN
|
||||
</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>
|
||||
</div>
|
||||
<div id="searchbar"></div>`;
|
||||
}
|
||||
|
||||
function performSearch(event) {
|
||||
event.preventDefault();
|
||||
let type = document.getElementById("nom").value;
|
||||
let postal = document.getElementById("postal").value;
|
||||
if (postal === "") {
|
||||
if (type === "") {
|
||||
alert("Veuillez remplir au moins un champ");
|
||||
return;
|
||||
} else {
|
||||
ajaxRequest('GET', "src/API/requests.php/api/search-type?type=" + type, function (data) {
|
||||
displaySearchResults(data);
|
||||
displaySearchTopBar();
|
||||
})
|
||||
}
|
||||
} else if (type === "") {
|
||||
ajaxRequest('GET', "src/API/requests.php/api/search-postal?postal=" + postal, function (data) {
|
||||
displaySearchResults(data);
|
||||
displaySearchTopBar();
|
||||
});
|
||||
} else {
|
||||
ajaxRequest('GET', "src/API/requests.php/api/search?type=" + type + "&postal=" + postal, function (data) {
|
||||
displaySearchResults(data);
|
||||
displaySearchTopBar();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function attachSearchEventListener() {
|
||||
try{
|
||||
document.getElementById("recherche").addEventListener("click", function (event) {
|
||||
performSearch(event);
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
//Do nothing
|
||||
//console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
export {removeSearchTopBar, attachSearchEventListener};
|
||||
150
src/js/AJAX/take-rdv.js
Normal file
150
src/js/AJAX/take-rdv.js
Normal file
@@ -0,0 +1,150 @@
|
||||
console.log("take-rdv.js loaded");
|
||||
import {displayHome} from "./home.js";
|
||||
|
||||
function displayRDVForDate(data) {
|
||||
let container = document.getElementById("rdv-list");
|
||||
container.innerHTML = "";
|
||||
let count = 0;
|
||||
data.forEach(function(element) {
|
||||
try{
|
||||
let card = document.createElement("div");
|
||||
card.classList.add("card");
|
||||
element.rdv_time = element.rdv_time.slice(0, 5);
|
||||
card.innerHTML = `
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">${element.rdv_time}</h5>
|
||||
<p class="card-text">Adresse: ${element.l_adress} <br>
|
||||
Ville: ${element.l_city} ${element.l_postal}</p>
|
||||
<button type="submit" class="btn btn-danger" id="rdv-id-${element.rdv_id}">Prendre ce rendez-vous</button>
|
||||
</div>`;
|
||||
container.appendChild(card);
|
||||
count++;
|
||||
} catch (e) {
|
||||
//Do nothing
|
||||
//console.error(e);
|
||||
}
|
||||
});
|
||||
if(count === 0) {
|
||||
container.innerHTML = "<h1>Aucun rendez-vous</h1>";
|
||||
}
|
||||
else {
|
||||
let resultText = document.createElement("h1");
|
||||
resultText.textContent = count + " rendez-vous";
|
||||
container.insertBefore(resultText, container.firstChild);
|
||||
attachPrendreRDVEventListener();
|
||||
}
|
||||
}
|
||||
|
||||
function displayCalendar(data) {
|
||||
let container = document.getElementById("content");
|
||||
container.innerHTML = "";
|
||||
let mainDiv = document.createElement("div");
|
||||
mainDiv.classList.add("row");
|
||||
|
||||
// Colonne de gauche
|
||||
let leftCol = document.createElement("div");
|
||||
leftCol.classList.add("col", "h-100", "border-dark", "border-3", "justify-content-center", "text-center", "ms-3");
|
||||
let leftDiv = document.createElement("div");
|
||||
leftDiv.classList.add("d-flex", "flex-column", "justify-content-center", "gap-6");
|
||||
|
||||
// Calendrier de sélection de date
|
||||
let form = document.createElement("form");
|
||||
form.classList.add("mt-3");
|
||||
form.id = "date-selection-form";
|
||||
let label = document.createElement("label");
|
||||
label.setAttribute("for", "date");
|
||||
label.textContent = "Choisissez une date :";
|
||||
form.appendChild(label);
|
||||
let input = document.createElement("input");
|
||||
input.setAttribute("type", "date");
|
||||
input.setAttribute("name", "start");
|
||||
input.setAttribute("id", "date");
|
||||
input.classList.add("mt-2", "form-control");
|
||||
form.appendChild(input);
|
||||
let submit = document.createElement("input");
|
||||
submit.setAttribute("type", "submit");
|
||||
submit.setAttribute("value", "Valider");
|
||||
submit.classList.add("mt-2", "btn", "btn-outline-danger");
|
||||
form.appendChild(submit);
|
||||
leftDiv.appendChild(form);
|
||||
|
||||
// Carte du médecin
|
||||
let medecinCard = document.createElement("div");
|
||||
medecinCard.classList.add("card", "mx-auto", "d-flex", "flex-row");
|
||||
medecinCard.innerHTML = `
|
||||
<div class="row g-0">
|
||||
<div class="col-md-4">
|
||||
<img src="src/img/Medecin_test.jpeg" class="img-fluid rounded-start" alt="doctor" width="300" height="300">
|
||||
</div>
|
||||
<div class="col-md-8">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">${data[0].m_surname} ${data[0].m_name}</h5>
|
||||
<h6 class="card-subtitle mb-2 text-body-secondary">${data[0].m_specialty}</h6>
|
||||
</div>
|
||||
</div>
|
||||
</div>`;
|
||||
leftDiv.appendChild(medecinCard);
|
||||
|
||||
leftCol.appendChild(leftDiv);
|
||||
mainDiv.appendChild(leftCol);
|
||||
|
||||
// Colonne de droite
|
||||
let rightCol = document.createElement("div");
|
||||
rightCol.classList.add("col-8", "h-100", "border-start", "border-dark", "border-3", "me-3");
|
||||
|
||||
// Liste des rendez-vous
|
||||
let rdvList = document.createElement("div");
|
||||
rdvList.classList.add("mt-3", "d-flex", "flex-column", "gap-3");
|
||||
rdvList.id = "rdv-list";
|
||||
rightCol.appendChild(rdvList);
|
||||
|
||||
mainDiv.appendChild(rightCol);
|
||||
container.appendChild(mainDiv);
|
||||
displayRDVForDate(data);
|
||||
document.getElementById("date-selection-form").addEventListener("submit", function(event) {
|
||||
event.preventDefault();
|
||||
let date = document.getElementById("date").value;
|
||||
let id = data[0].m_id; // Assuming 'data' is accessible in this scope and contains the doctor's details
|
||||
ajaxRequest('GET', "src/API/requests.php/api/rdv-date?date=" + date + "&id=" + id, function (data) {
|
||||
displayRDVForDate(data);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function attachRDVEventListener() {
|
||||
let buttons = document.querySelectorAll("button[id^='m-id-']");
|
||||
buttons.forEach(function (button) {
|
||||
button.addEventListener("click", function (event) {
|
||||
let id = event.target.id.split("-")[2]
|
||||
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);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function attachPrendreRDVEventListener() {
|
||||
let buttons = document.querySelectorAll("button[id^='rdv-id-']");
|
||||
buttons.forEach(function (button) {
|
||||
button.addEventListener("click", function (event) {
|
||||
if(sessionStorage.getItem("token") === null) {
|
||||
displayHome("Vous devez être connecté pour prendre un rendez-vous");
|
||||
}
|
||||
else{
|
||||
let RDVid = event.target.id.split("-")[2];
|
||||
let data = "rdv_id=" + RDVid + "&patient_id=" + 1;
|
||||
ajaxRequest('PUT', "src/API/requests.php/api/rdv", function (returnData){
|
||||
if (returnData.success) {
|
||||
displayHome("Rendez-vous pris avec succès");
|
||||
} else {
|
||||
alert("Erreur lors de la prise de rendez-vous");
|
||||
}
|
||||
}, data);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export {attachRDVEventListener};
|
||||
@@ -24,7 +24,7 @@
|
||||
echo '<a href="rdv-praticien.php" class="text-white fw-bold link-underline-opacity-75-hover link-underline link-underline-opacity-0 link-offset-3-hover link-underline-light">Mon calendrier</a></div>';
|
||||
}
|
||||
} else {
|
||||
echo '<a href="login-praticien.php"> <button type="button" class="btn btn-danger" style="top: 0.4375em;">Vous êtes praticien ?</button> </a><a href="login.php"> <button type="button" class="btn btn-danger" style="top: 0.4375em;">Se connecter</button></a><p> </p>';
|
||||
echo '<a href="login-praticien.php"> <button type="button" class="btn btn-danger" style="top: 0.4375em;" id="login-praticien">Vous êtes praticien ?</button> </a><a href="login.php"> <button type="button" class="btn btn-danger" style="top: 0.4375em;" id="login-user">Se connecter</button></a><p> </p>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -61,59 +61,4 @@ function takeRDV($pdo, $rdv_id, $patient_id): void
|
||||
$query->execute();
|
||||
Response::HTTP200(['success' => 'RDV taken']);
|
||||
}
|
||||
|
||||
/*
|
||||
function displayRDVForDate($pdo, $date, $medecin){
|
||||
$availableHours = selectRDVForDate($pdo, $date, $medecin);
|
||||
if(!$availableHours){
|
||||
echo '<p class="ms-5 mt-2 fw-bold">Aucun rendez-vous disponible</p>';
|
||||
}
|
||||
else{
|
||||
echo '<p class="ms-5 mt-2 fw-bold">Rendez-vous disponible :</p>';
|
||||
foreach ($availableHours as $hour){
|
||||
$hourValue = selectRDVTimeByID($pdo, $hour);
|
||||
$hourValue = substr($hourValue, 0, 5);
|
||||
$token = tokenDecode();
|
||||
$patient = $token[1];
|
||||
echo '<a href="./src/php/db/scripts/addRDVToDB.php?id='.$hour.'&patient='.$patient.'" class="btn btn-danger w-100">'.$hourValue.'</a>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function DisplayMedecinCard($pdo, $medecin){
|
||||
$query = $pdo->prepare("SELECT * FROM medecin WHERE m_id = :id");
|
||||
$query->bindParam(':id', $medecin);
|
||||
$query->execute();
|
||||
$result = $query->fetchAll();
|
||||
foreach ($result as $row){
|
||||
echo '<div class="card mb-3">';
|
||||
echo '<div class="row g-0">';
|
||||
echo '<div class="col-md-4">';
|
||||
$imageUrl = 'https://thispersondoesnotexist.com';
|
||||
echo '<img src="' . $imageUrl . '" alt="doctor" class="img-fluid rounded-start" width="300" height="300">';
|
||||
echo '</div>';
|
||||
echo '<div class="col-md-8">';
|
||||
echo '<div class="card-body">';
|
||||
echo '<h5 class="card-title">'.$row['m_name'].' '.$row['m_surname'].'</h5>';
|
||||
echo '<h6 class="card-subtitle mb-2 text-body-secondary">'.$row['m_specialty'].'</h6>';
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
function addRDVToDBThenRedirect($pdo, $rdv, $patient){
|
||||
$query = $pdo->prepare("UPDATE rendez_vous SET p_id = :p_id WHERE rdv_id = :rdv_id");
|
||||
$query->bindParam(':p_id', $patient);
|
||||
$query->bindParam(':rdv_id', $rdv);
|
||||
$query->execute();
|
||||
//Redirect to the rdv.php page
|
||||
echo '<meta http-equiv="refresh" content="0;URL=../../../rdv.php">';
|
||||
}
|
||||
*/
|
||||
|
||||
?>
|
||||
@@ -92,6 +92,7 @@ class LoginPatient {
|
||||
$result = $query->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if ($result['count'] == 0) {
|
||||
Response::HTTP404(['message' => 'Mail not found']);
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
@@ -101,15 +102,15 @@ class LoginPatient {
|
||||
public static function Login($pdo,$mail,$password) : void
|
||||
{
|
||||
if(LoginPatient::checkMail($pdo,$mail)){
|
||||
$query = $pdo->prepare("SELECT p_id,p_password FROM patient where p_mail = :mail");
|
||||
$query = $pdo->prepare("SELECT p_id,p_password,p_name,p_surname,p_mail FROM patient where p_mail = :mail");
|
||||
$query->bindParam(':mail', $mail);
|
||||
$query->execute();
|
||||
$result = $query->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if(password_verify($password,$result['p_password'])){
|
||||
Response::HTTP200(['message' => 'Login success', 'id' => $result['p_id']]);
|
||||
Response::HTTP200(['message' => 'Login success', 'token' => base64_encode(bin2hex("patient:".strval($result['p_id']).":".$result['p_name'].":".$result['p_surname'].":".$result['p_mail']))]);
|
||||
} else {
|
||||
Response::HTTP401(['message' => 'Login failed', 'id' => 0]);
|
||||
Response::HTTP401(['message' => 'Login failed', 'token' => 0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -124,6 +125,7 @@ class LoginMedecin {
|
||||
$result = $query->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if ($result['count'] == 0) {
|
||||
Response::HTTP404(['message' => 'Mail not found']);
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
@@ -133,15 +135,15 @@ class LoginMedecin {
|
||||
public static function Login($pdo,$mail,$password) : void
|
||||
{
|
||||
if(LoginMedecin::checkMail($pdo,$mail)){
|
||||
$query = $pdo->prepare("SELECT m_id, m_password FROM medecin where m_mail = :mail");
|
||||
$query = $pdo->prepare("SELECT m_id, m_password,m_name,m_surname,m_mail FROM medecin where m_mail = :mail");
|
||||
$query->bindParam(':mail', $mail);
|
||||
$query->execute();
|
||||
$result = $query->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if(password_verify($password,$result['m_password'])){
|
||||
Response::HTTP200(['message' => 'Login success', 'id' => $result['m_id']]);
|
||||
Response::HTTP200(['message' => 'Login success', 'token' => base64_encode(bin2hex("medecin:".strval($result['m_id']).":".$result['m_name'].":".$result['m_surname'].":".$result['m_mail']))]);
|
||||
} else {
|
||||
Response::HTTP401(['message' => 'Login failed', 'id' => 0]);
|
||||
Response::HTTP401(['message' => 'Login failed', 'token' => 0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
|
||||
class SignupPatient
|
||||
{
|
||||
public static function Insert($pdo,$name,$surname,$mail,$password,$phone){
|
||||
public static function Insert($pdo, $mail, $password, $name, $surname, $phone): void
|
||||
{
|
||||
$password = password_hash($password, PASSWORD_ARGON2ID);
|
||||
$query = $pdo->prepare("INSERT INTO patient (p_name,p_surname,p_mail,p_password,p_phone) VALUES (:name,:surname,:mail,:password,:phone)");
|
||||
$query->bindParam(':name', $name);
|
||||
@@ -17,9 +18,9 @@ class SignupPatient
|
||||
$query->execute();
|
||||
$result = $query->fetch(PDO::FETCH_ASSOC);
|
||||
if ($result['count'] == 0) {
|
||||
return false;
|
||||
Response::HTTP401(['message' => 'Signup failed', 'token' => 0]);
|
||||
} else {
|
||||
return true;
|
||||
Response::HTTP200(['message' => 'Signup success', 'success' => true]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +28,7 @@ class SignupPatient
|
||||
|
||||
class SignupMedecin
|
||||
{
|
||||
public static function insertMedecin($pdo,$name,$surname,$mail,$password,$specialite,$phone,$postal) {
|
||||
public static function insertMedecin($pdo, $name, $surname, $mail, $password, $specialite, $phone, $postal) {
|
||||
$password = password_hash($password, PASSWORD_ARGON2ID);
|
||||
$query = $pdo->prepare("INSERT INTO medecin (m_name,m_surname,m_mail,m_password,m_specialty,m_phone,m_postal) VALUES (:name,:surname,:mail,:password,:specialite,:phone,:postal)");
|
||||
$query->bindParam(':name', $name);
|
||||
@@ -44,9 +45,9 @@ class SignupMedecin
|
||||
$query->execute();
|
||||
$result = $query->fetch(PDO::FETCH_ASSOC);
|
||||
if ($result['count'] == 0) {
|
||||
return false;
|
||||
Response::HTTP401(['message' => 'Signup failed', 'token' => 0]);
|
||||
} else {
|
||||
return true;
|
||||
Response::HTTP200(['message' => 'Signup success', 'success' => true]);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user