mirror of
https://github.com/BreizhHardware/ProjetS4COMWEB.git
synced 2026-01-18 16:47:35 +01:00
Merge branch 'main' into cfouche
This commit is contained in:
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
Request_Test
|
||||
Request_Test/testHTTP.http
|
||||
@@ -1,4 +1,54 @@
|
||||
GET http://serveur-projet-s4.felix/src/API/requests.php/api/search?type=Généraliste
|
||||
GET http://serveur-projet-s4.felix/src/API/requests.php/api/search?type=Généraliste&location=35
|
||||
Accept: application/json
|
||||
|
||||
###
|
||||
GET http://serveur-projet-s4.felix/src/API/requests.php/api/search-postal?postal=44
|
||||
Accept: application/json
|
||||
|
||||
###
|
||||
GET http://serveur-projet-s4.felix/src/API/requests.php/api/search-type?type=Généraliste
|
||||
Accept: application/json
|
||||
|
||||
###
|
||||
|
||||
GET http://serveur-projet-s4.felix/src/API/requests.php/api/rdv-available?id=1
|
||||
Accept: application/json
|
||||
|
||||
###
|
||||
GET http://serveur-projet-s4.felix/src/API/requests.php/api/rdv-date?date=2024-03-18&id=1
|
||||
Accept: application/json
|
||||
|
||||
###
|
||||
|
||||
GET http://serveur-projet-s4.felix/src/API/requests.php/api/search?type=G%C3%A9n%C3%A9raliste&postal=35
|
||||
Accept: application/json
|
||||
|
||||
###
|
||||
|
||||
GET http://serveur-projet-s4.felix/src/API/requests.php/api/praticien?id=1
|
||||
Accept: application/json
|
||||
|
||||
###
|
||||
|
||||
PUT http://serveur-projet-s4.felix/src/API/requests.php/api/rdv
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
|
||||
rdv_id = 46792 &
|
||||
patient_id = 1
|
||||
|
||||
###
|
||||
|
||||
PUT http://serveur-projet-s4.felix/src/API/requests.php/api/requests
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
|
||||
test = "coucou"
|
||||
|
||||
###
|
||||
|
||||
POST http://serveur-projet-s4.felix/src/API/requests.php/api/requests
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
|
||||
test = "coucou"
|
||||
|
||||
###
|
||||
|
||||
|
||||
90
calendrier.php
Normal file
90
calendrier.php
Normal file
@@ -0,0 +1,90 @@
|
||||
<!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>
|
||||
28
index.php
28
index.php
@@ -28,28 +28,32 @@
|
||||
$pdo = dbConnect();
|
||||
?>
|
||||
<div id="topbar">
|
||||
<a href="index.php">
|
||||
<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">
|
||||
<?php
|
||||
loginUI($pdo);
|
||||
?>
|
||||
<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>
|
||||
</div>
|
||||
<div id="content">
|
||||
<div class="d-flex justify-content-center align-items-center" id="Alert"></div>
|
||||
<div style="background-color: red; height: 50vh;">
|
||||
<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="search.php" class="input-group" method="post">
|
||||
<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="button-addon2">Rechercher</button>
|
||||
<button class="btn btn-success" type="submit" id="recherche">Rechercher</button>
|
||||
</form>
|
||||
</div>
|
||||
<img src="src/img/img_index.png" alt="img_index" id="img_index">
|
||||
<div class="d-flex justify-content-center gap-5 w-100" id="cardPos">
|
||||
<div class="card" style="width: 18rem;">
|
||||
<div class="card-body">
|
||||
|
||||
@@ -5,6 +5,8 @@ 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/Calendrier.php';
|
||||
require_once 'test/database.php';
|
||||
ini_set('display_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
$pdo = dbConnect();
|
||||
@@ -16,22 +18,44 @@ $router->GET('/api/requests', ["test"], function($test){
|
||||
echo json_encode($test);
|
||||
});
|
||||
|
||||
$router->GET('/api/search', ["type"], function($type){
|
||||
$router->GET('/api/search-type', ["type"], function($type){
|
||||
global $pdo;
|
||||
searchDoctor($pdo, $type);
|
||||
});
|
||||
|
||||
/*
|
||||
$router->GET('/api/search', ["type", "location"], function($type, $location){
|
||||
$router->GET('/api/search-postal', ["postal"], function($postal){
|
||||
global $pdo;
|
||||
searchDoctorByLocation($pdo, $location, $type);
|
||||
searchDoctorByLocation($pdo, $postal);
|
||||
});
|
||||
|
||||
$router->GET('/api/search', ["location"], function($location){
|
||||
$router->GET('/api/search', ["type", "postal"], function($type, $postal){
|
||||
global $pdo;
|
||||
searchDoctorByLocation($pdo, $location);
|
||||
searchDoctorByLocation($pdo, $postal, $type);
|
||||
})
|
||||
|
||||
$router->GET('/api/rdv', ["id"], function($id){
|
||||
global $pdo;
|
||||
getNumberOfRDVByMedecin($pdo, $id);
|
||||
});
|
||||
|
||||
$router->GET('/api/rdv-available', ["id"], function($id){
|
||||
global $pdo;
|
||||
selectRDVTimeByID($pdo, $id);
|
||||
});
|
||||
|
||||
$router->GET('/api/rdv-date', ["date", "id"], function($date, $id){
|
||||
global $pdo;
|
||||
selectRDVForDate($pdo, $date, $id);
|
||||
});
|
||||
|
||||
$router->GET('/api/praticien', ["id"], function($id){
|
||||
global $pdo;
|
||||
getPraticienDetails($pdo, $id);
|
||||
});
|
||||
|
||||
$router->PUT('/api/rdv', ["rdv_id", "patient_id"], function($rdv_id, $patient_id){
|
||||
global $pdo;
|
||||
takeRDV($pdo, $rdv_id, $patient_id);
|
||||
});
|
||||
*/
|
||||
$router->POST('/api/requests', ["test"], function($test){
|
||||
echo json_encode($test);
|
||||
});
|
||||
@@ -53,4 +77,31 @@ $router->DELETE('/api/requests', ["test"], function($test){
|
||||
echo json_encode($test);
|
||||
});
|
||||
|
||||
$router->GET('/api/rdv-praticient', ["id"], function($id){
|
||||
global $pdo;
|
||||
dbRequestRdvPraticien($pdo, $id);
|
||||
getAllLieux($pdo);
|
||||
});
|
||||
|
||||
$router->GET('/api/rdv-patient', ["id"], function($id){
|
||||
global $pdo;
|
||||
dbRequestRdvPatient($pdo, $id);
|
||||
getPastRdvByPatient($pdo, $id);
|
||||
});
|
||||
|
||||
$router->DELETE('/api/delete-empty', ["id"], function($id){
|
||||
global $pdo;
|
||||
DeleteEmptyRdv($pdo, $id);
|
||||
});
|
||||
|
||||
$router->DELETE('/api/cancel-rdv', ["id"], function($id){
|
||||
global $pdo;
|
||||
CancelRDV($pdo, $id);
|
||||
});
|
||||
|
||||
$router->POST('/api/create-rdv', ["id", "date", "time", "lieu"], function($id, $date, $time, $lieu){
|
||||
global $pdo;
|
||||
createRDV($pdo, $id, $date, $time, $lieu);
|
||||
});
|
||||
|
||||
$router->run();
|
||||
|
||||
@@ -38,6 +38,15 @@ class Response
|
||||
echo json_encode($data);
|
||||
}
|
||||
|
||||
public static function HTTP403($data): void
|
||||
{
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
header('Cache-control: no-store, no-cache, must-revalidate');
|
||||
header('Pragma: no-cache');
|
||||
http_response_code(403);
|
||||
echo json_encode($data);
|
||||
}
|
||||
|
||||
static function HTTP404($data): void
|
||||
{
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
require('src/php/constants.php');
|
||||
require_once('src/response.php');
|
||||
|
||||
function dbConnect()
|
||||
/*function dbConnect()
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -14,7 +14,7 @@ function dbConnect()
|
||||
return false;
|
||||
}
|
||||
return $db;
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
function dbRequestRdvPraticien($pdo, $id){
|
||||
@@ -33,13 +33,56 @@ function dbRequestRdvPraticien($pdo, $id){
|
||||
$result = $statement->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
if (!empty($result)) {
|
||||
return $result;
|
||||
Response::HTTP200($result);
|
||||
} else {
|
||||
return null;
|
||||
Response::HTTP404(["error" => "No data found"]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function dbRequestRdvPatient($pdo, $id){
|
||||
$statement = $pdo->prepare("SELECT rdv_date, rdv_time, concat(m_name, ' ', m_surname) as medecin, medecin.m_specialty, medecin.m_id, concat(p_name, ' ', p_surname) as patient, l_adress as adresse, concat(l_postal, ' ', l_city) as ville
|
||||
FROM rendez_vous
|
||||
INNER JOIN patient ON rendez_vous.p_id = patient.p_id
|
||||
INNER JOIN propose ON rendez_vous.rdv_id = propose.rdv_id
|
||||
INNER JOIN medecin ON propose.m_id = medecin.m_id
|
||||
INNER JOIN lieu on lieu.l_id = rendez_vous.l_id
|
||||
|
||||
WHERE NOW() <= (rdv_date + rdv_time) AND patient.p_id = :id
|
||||
ORDER BY rdv_date, rdv_time ASC");
|
||||
|
||||
$statement->bindParam(':id', $id);
|
||||
$statement->execute();
|
||||
$result = $statement->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
if (!empty($result)) {
|
||||
Response::HTTP200($result);
|
||||
} else {
|
||||
Response::HTTP404(["error" => "No data found"]);
|
||||
}
|
||||
}
|
||||
|
||||
function getPastRdvByPatient($pdo, $id){
|
||||
$statement = $pdo->prepare("SELECT rdv_date, rdv_time, concat(m_name, ' ', m_surname) as medecin, medecin.m_specialty, medecin.m_id, concat(p_name, ' ', p_surname) as patient, l_adress as adresse, concat(l_postal, ' ', l_city) as ville
|
||||
FROM rendez_vous
|
||||
INNER JOIN patient ON rendez_vous.p_id = patient.p_id
|
||||
INNER JOIN propose ON rendez_vous.rdv_id = propose.rdv_id
|
||||
INNER JOIN medecin ON propose.m_id = medecin.m_id
|
||||
INNER JOIN lieu on lieu.l_id = rendez_vous.l_id
|
||||
|
||||
WHERE NOW() > (rdv_date + rdv_time) AND patient.p_id = :id
|
||||
ORDER BY rdv_date, rdv_time ASC");
|
||||
$statement->bindParam(':id', $id);
|
||||
$statement->execute();
|
||||
$result = $statement->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
if (!empty($result)) {
|
||||
Response::HTTP200($result);
|
||||
} else {
|
||||
Response::HTTP404(["error" => "No data found"]);
|
||||
}
|
||||
}
|
||||
|
||||
function getLieuID($pdo, $adress, $postal, $city){
|
||||
$statement = $pdo->prepare("SELECT l_id FROM lieu WHERE l_adress = :adress AND l_city = :city AND l_postal = :postal");
|
||||
$statement->bindParam(':adress', $adress);
|
||||
@@ -61,9 +104,9 @@ function getAllLieux($pdo){
|
||||
$result = $statement->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
if (!empty($result)) {
|
||||
return $result;
|
||||
Response::HTTP200($result);
|
||||
} else {
|
||||
return null;
|
||||
Response::HTTP404(["error" => "No data found"]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,21 +129,22 @@ function CreateRDV($pdo, $medID, $date, $time, $lieu){
|
||||
$statement->bindParam(':medID', $medID);
|
||||
$statement->bindParam(':rdvID', $rdvID);
|
||||
$statement->execute();
|
||||
return true;
|
||||
Response::HTTP200(["Success" => "RDV created"]);
|
||||
}
|
||||
return false;
|
||||
Response::HTTP404(["Error" => "Lieu not found"]);
|
||||
}
|
||||
|
||||
function DeleteEmptyRdv($pdo, $id){
|
||||
function DeleteEmptyRdv($pdo, $id)
|
||||
{
|
||||
$statement = $pdo->prepare("SELECT p_id FROM rendez_vous WHERE rdv_id = :id");
|
||||
$statement->bindParam(':id', $id);
|
||||
$statement->execute();
|
||||
$result = $statement->fetch(PDO::FETCH_ASSOC);
|
||||
if($result['p_id'] == null){
|
||||
if ($result['p_id'] == null) {
|
||||
$statement = $pdo->prepare("DELETE FROM rendez_vous WHERE rdv_id = :id");
|
||||
$statement->bindParam(':id', $id);
|
||||
$statement->execute();
|
||||
return true;
|
||||
Response::HTTP200(["Success" => "RDV deleted"]);
|
||||
}
|
||||
return false;
|
||||
Response::HTTP403(["Forbidden" => "This RDV is not empty"]);
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
<?php
|
||||
ini_set('display_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
require_once "../../php/constants.php";
|
||||
require_once '../../php/db/dbconnect.php';
|
||||
require_once '../../php/db/Search.php';
|
||||
$pdo = dbConnect();
|
||||
$request = $_SERVER['PATH_INFO'];
|
||||
$request = explode('/', $request);
|
||||
$requestRessource = array_shift($request);
|
||||
$method = $_SERVER["REQUEST_METHOD"];
|
||||
|
||||
parse_str(file_get_contents("php://input"), $_PUT);
|
||||
|
||||
// Check if the request is a GET request and if the request is for a specific doctor or for a speciality or for a location
|
||||
if ($method == "GET" && isset($_GET)){
|
||||
// Type is Either the name of a doctor or a Speciality
|
||||
if (isset($_GET['type'])){
|
||||
$type = $_GET['type'];
|
||||
if (isset($_GET['location'])){
|
||||
$location = $_GET['location'];
|
||||
$doctors = searchDoctorByLocation($pdo, $location, $type);
|
||||
echo json_encode($doctors);
|
||||
} else {
|
||||
$doctors = searchDoctor($pdo, $type);
|
||||
echo json_encode($doctors);
|
||||
}
|
||||
}
|
||||
// Location is the location of the doctor
|
||||
if (isset($_GET['location'])){
|
||||
$location = $_GET['location'];
|
||||
$doctors = searchDoctorByLocation($pdo, $location);
|
||||
echo json_encode($doctors);
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,31 @@
|
||||
body{
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-family: 'Roboto', sans-serif;
|
||||
}
|
||||
|
||||
#DoctISEN{
|
||||
font-family: 'Just Me Again Down Here', cursive;
|
||||
color: white;
|
||||
font-size: 36px
|
||||
font-size: 36px;
|
||||
margin-left: 0.5rem;
|
||||
margin-top: 0;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#topbar{
|
||||
background-color: #ff0000;
|
||||
height: 6vh;
|
||||
height: 22vh;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1em;
|
||||
}
|
||||
|
||||
#topInfo{
|
||||
height: 5vh;
|
||||
}
|
||||
|
||||
#acceuil{
|
||||
@@ -30,7 +48,7 @@
|
||||
max-height: 100%;
|
||||
position: fixed;
|
||||
right: 0;
|
||||
top: 6vh;
|
||||
top: 9vh;
|
||||
}
|
||||
|
||||
#cardPos{
|
||||
@@ -114,4 +132,10 @@ a{
|
||||
|
||||
a:hover{
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
#Alert{
|
||||
position: fixed;
|
||||
top: 7%;
|
||||
width: 100%;
|
||||
}
|
||||
@@ -1,44 +1,379 @@
|
||||
//Search
|
||||
type = document.getElementById("nom").value;
|
||||
postal = document.getElementById("postal").value;
|
||||
document.getElementById("button-addon2").addEventListener("click", function() {
|
||||
ajaxRequest('GET',"src/API/test/search.php?type=" + type + "&postal=" + postal, displaySearchResults);
|
||||
});
|
||||
console.log("index.js loaded");
|
||||
|
||||
//Felix Part
|
||||
|
||||
function displaySearchResults(data) {
|
||||
container = document.getElementById("content");
|
||||
let container = document.getElementById("content");
|
||||
container.innerHTML = "";
|
||||
// Create a div for the result with the following classes d-flex flex-row flex-wrap mx-5 gap-5
|
||||
mainDiv = document.createElement("div");
|
||||
mainDiv.classList.add("d-flex", "flex-row", "flex-wrap", "mx-5", "gap-5");
|
||||
// for each data of the json, create a card and append it to the mainDiv and count the number of results
|
||||
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="card mb-3">
|
||||
<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.name}</h5>
|
||||
<h6 class="card-subtitle mb-2 text-body-secondary">${element.type}</h6>
|
||||
<p class="card-text">Disponibilité: ${element.disponibility}</p>
|
||||
<button type="submit" class="btn btn-danger">Prendre rendez-vous</button>
|
||||
<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>
|
||||
</div>`;
|
||||
</div>`;
|
||||
mainDiv.appendChild(card);
|
||||
});
|
||||
container.appendChild(mainDiv);
|
||||
if(count === 0) {
|
||||
mainDiv.innerHTML = "<h1>Aucun résultats</h1>";
|
||||
}
|
||||
else {
|
||||
mainDiv.innerHTML = "<h1>" + count + " résultats</h1>";
|
||||
container.appendChild(mainDiv);
|
||||
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");
|
||||
console.log(text);
|
||||
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);
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
//Do nothing
|
||||
//console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
function DisplayRDVPraticient(rdv){
|
||||
let count = rdv.length;
|
||||
$('#content').empty();
|
||||
$('#content').html('<div class="h-100"> <div class="d-flex flex-row flex-wrap my-5 mx-5 gap-5 justify-content-center text-center">');
|
||||
if(count === 0){
|
||||
$('#content').append('<h1>Vous n\'avez pas de rendez-vous</h1>');
|
||||
}
|
||||
else {
|
||||
for (let i = 0; i < count; i++){
|
||||
if (rdv[i].p_mail !== "null")
|
||||
$('#content').append('' +
|
||||
'<div class="card rounded-4 mx-2 pointer">' +
|
||||
'<div class="card-header bg-danger">' +
|
||||
'<div class="d-flex flex-row justify-content-between text-white">' +
|
||||
'<p>' + rdv[i].rdv_date + '</p>' +
|
||||
'<p>' + rdv[i].rdv_time + '</p>' +
|
||||
'</div>' + '</div>' +
|
||||
'<div class="card-body">' +
|
||||
'<h5 class="card-title">' + rdv[i].patient + '</h5>' +
|
||||
'<a href="mailto:' + rdv[i].p_mail + '" class="card-subtitle mb-2 text-body-secondary">' + rdv[i].email + '</a>' +
|
||||
'<br>' +
|
||||
'<a href="tel:0' + rdv[i].p_phone + '" class="card-subtitle mb-2 text-body-secondary">' + '0' + rdv[i].phone + '</a>' +
|
||||
'</div>' + '</div>');
|
||||
else{
|
||||
$('#content').append('' +
|
||||
'<div class="card rounded-4 mx-2 pointer">' +
|
||||
'<div class="card-header bg-danger">' +
|
||||
'<div class="d-flex flex-row justify-content-between text-white">' +
|
||||
'<p>' + rdv[i].rdv_date + '</p>' +
|
||||
'<p>' + rdv[i].rdv_time + '</p>' +
|
||||
'</div>' + '</div>' +
|
||||
'<div class="card-body">' +
|
||||
'<h5 class="card-title">Vous n\'avez pas de' + '<br>' + 'patient pour ce créneau</h5>' +
|
||||
'</div>' + '</div>');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function ButtonShowRdvPraticient() {
|
||||
document.getElementById("CalendarPraticient").addEventListener("click", function () {
|
||||
ajaxRequest('GET', "src/API/requests.php/api/rdv-praticient?id=" + id, function (data) {
|
||||
DisplayRDVPraticient(data);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
//End Call
|
||||
|
||||
ButtonShowRdvPraticient();
|
||||
attachSearchEventListener();
|
||||
@@ -1,53 +1,34 @@
|
||||
console.log("utils.js loaded");
|
||||
|
||||
|
||||
function ajaxRequest(type, url, callback, data = null){
|
||||
let xhr = new XMLHttpRequest();
|
||||
function ajaxRequest(type, url, callback, data = null)
|
||||
{
|
||||
let xhr;
|
||||
// Create XML HTTP request.
|
||||
xhr = new XMLHttpRequest();
|
||||
if (type == 'GET' && data != null)
|
||||
url += '?' + data;
|
||||
xhr.open(type, url, true);
|
||||
xhr.setRequestHeader('Content-Type', 'application/json');
|
||||
xhr.onload = function() {
|
||||
switch (xhr.status) {
|
||||
xhr.open(type, url);
|
||||
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
||||
|
||||
// Add the onload function.
|
||||
xhr.onload = () =>
|
||||
{
|
||||
switch (xhr.status)
|
||||
{
|
||||
case 200:
|
||||
case 201:
|
||||
//console.log(xhr.responseText);
|
||||
callback(JSON.parse(xhr.responseText));
|
||||
break;
|
||||
case 404:
|
||||
alert("404");
|
||||
break;
|
||||
case 403:
|
||||
alert("403");
|
||||
break;
|
||||
case 500:
|
||||
console.log("server error");
|
||||
break;
|
||||
default:
|
||||
httpErrors(xhr.status);
|
||||
console.log("Error: " + xhr.status);
|
||||
alert("Error: " + xhr.status);
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
// Send XML HTTP request.
|
||||
xhr.send(data);
|
||||
}
|
||||
|
||||
function httpErrors(errorCode)
|
||||
{
|
||||
let messages = {
|
||||
400: 'Requête incorrecte',
|
||||
401: 'Authentifiez vous',
|
||||
403: 'Accès refusé',
|
||||
404: 'Page non trouvée',
|
||||
500: 'Erreur interne du serveur',
|
||||
503: 'Service indisponible'
|
||||
};
|
||||
|
||||
// Display error.
|
||||
if (errorCode in messages)
|
||||
{
|
||||
$('#errors').html('<strong>' + messages[errorCode] + '</strong>');
|
||||
$('#errors').show();
|
||||
setTimeout(() =>
|
||||
{
|
||||
$('#errors').hide();
|
||||
}, 5000);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,32 +1,68 @@
|
||||
<?php
|
||||
|
||||
function selectRDVTimeByID($pdo, $id){
|
||||
$query = $pdo->prepare("SELECT * FROM rendez_vous WHERE rdv_id = :id");
|
||||
require_once '../API/src/response.php';
|
||||
|
||||
function selectRDVTimeByID($pdo, $id): void
|
||||
{
|
||||
// Display all the RDV from a medecin from today date
|
||||
$query = $pdo->prepare("SELECT * FROM propose WHERE m_id = :id");
|
||||
$query->bindParam(':id', $id);
|
||||
$query->execute();
|
||||
$result = $query->fetchAll();
|
||||
|
||||
if (!empty($result)) {
|
||||
return $result[0]['rdv_time'];
|
||||
} else {
|
||||
return null;
|
||||
if (empty($result)) {
|
||||
Response::HTTP404(['error' => 'No RDV found']);
|
||||
}
|
||||
Response::HTTP200($result);
|
||||
}
|
||||
|
||||
|
||||
function selectRDVForDate($pdo, $date, $medecin){
|
||||
$availableHours = array();
|
||||
$query = $pdo->prepare("select * from rendez_vous rdv join public.propose p using (rdv_id) where p.m_id = :m_id and rdv.rdv_date = :date AND rdv.p_id IS NULL ORDER BY rdv_time ASC");
|
||||
function selectRDVForDate($pdo, $date, $medecin): void
|
||||
{
|
||||
$query = $pdo->prepare("SELECT rdv.rdv_id, rdv.rdv_date, l.l_adress, l.l_city, l.l_postal, m.m_id, m.m_name, m.m_surname, m.m_specialty, m.m_phone, rdv.rdv_time
|
||||
FROM rendez_vous rdv
|
||||
JOIN public.propose p USING (rdv_id)
|
||||
JOIN public.lieu l ON rdv.l_id = l.l_id
|
||||
JOIN public.medecin m ON p.m_id = m.m_id
|
||||
WHERE p.m_id = :m_id AND rdv.rdv_date = :date AND rdv.p_id IS NULL
|
||||
ORDER BY rdv_time ASC;");
|
||||
$query->bindParam(':date', $date);
|
||||
$query->bindParam(':m_id', $medecin);
|
||||
$query->execute();
|
||||
$outerResult = $query->fetchAll();
|
||||
foreach ($outerResult as $row) {
|
||||
array_push($availableHours, $row['rdv_id']);
|
||||
$result = $query->fetchAll();
|
||||
if (empty($result)) {
|
||||
$query = $pdo->prepare("SELECT m_id, m_name, m_surname, m_specialty, m_phone, m_postal FROM medecin WHERE m_id = :id");
|
||||
$query->bindParam(':id', $medecin);
|
||||
$query->execute();
|
||||
$result = $query->fetchAll();
|
||||
// Put the result in a JSON format
|
||||
Response::HTTP200($result);
|
||||
return;
|
||||
}
|
||||
return $availableHours;
|
||||
Response::HTTP200($result);
|
||||
}
|
||||
|
||||
function getPraticienDetails($pdo, $id): void
|
||||
{
|
||||
$query = $pdo->prepare("SELECT * FROM medecin WHERE m_id = :id");
|
||||
$query->bindParam(':id', $id);
|
||||
$query->execute();
|
||||
$result = $query->fetchAll();
|
||||
if (empty($result)) {
|
||||
Response::HTTP404(['error' => 'Praticien not found']);
|
||||
}
|
||||
Response::HTTP200($result);
|
||||
}
|
||||
|
||||
function takeRDV($pdo, $rdv_id, $patient_id): void
|
||||
{
|
||||
$query = $pdo->prepare("UPDATE rendez_vous SET p_id = :p_id WHERE rdv_id = :rdv_id");
|
||||
$query->bindParam(':p_id', $patient_id);
|
||||
$query->bindParam(':rdv_id', $rdv_id);
|
||||
$query->execute();
|
||||
Response::HTTP200(['success' => 'RDV taken']);
|
||||
}
|
||||
|
||||
/*
|
||||
function displayRDVForDate($pdo, $date, $medecin){
|
||||
$availableHours = selectRDVForDate($pdo, $date, $medecin);
|
||||
if(!$availableHours){
|
||||
@@ -78,5 +114,6 @@ function addRDVToDBThenRedirect($pdo, $rdv, $patient){
|
||||
//Redirect to the rdv.php page
|
||||
echo '<meta http-equiv="refresh" content="0;URL=../../../rdv.php">';
|
||||
}
|
||||
*/
|
||||
|
||||
?>
|
||||
@@ -1,239 +1,10 @@
|
||||
<?php
|
||||
|
||||
require_once '../API/src/response.php';
|
||||
/*
|
||||
function search($pdo, $nom, $postal){
|
||||
if($_POST["nom"] == null && $_POST["postal"] == null){
|
||||
echo '<p class="ms-5 mt-2 fw-bold">Veuillez entrer un nom ou un lieu</p>';
|
||||
}
|
||||
else if($_POST['postal'] == null){
|
||||
$query = $pdo->prepare("SELECT * FROM medecin WHERE m_name = :nom");
|
||||
$query->bindParam(':nom', $_POST['nom']);
|
||||
$query->execute();
|
||||
$result = $query->fetchAll();
|
||||
|
||||
if($result == null){
|
||||
$query = $pdo->prepare("SELECT * FROM medecin WHERE m_specialty = :specialite");
|
||||
$query->bindParam(':specialite', $_POST['nom']);
|
||||
$query->execute();
|
||||
$result = $query->fetchAll();
|
||||
}
|
||||
|
||||
$count = 0;
|
||||
foreach($result as $row){
|
||||
$count++;
|
||||
}
|
||||
|
||||
echo '<p class="ms-5 mt-2 fw-bold">'.$count.' Résultats</p>';
|
||||
|
||||
if($count == 0){
|
||||
echo '<p class="ms-5 mt-2 fw-bold">Aucun résultat</p>';
|
||||
}
|
||||
else{
|
||||
echo '<div class="d-flex flex-row flex-wrap mx-5 gap-5">';
|
||||
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>';
|
||||
$query = $pdo->prepare("SELECT * FROM propose WHERE m_id = :id");
|
||||
$query->bindParam(':id', $row['m_id']);
|
||||
$query->execute();
|
||||
$result = $query->fetchAll();
|
||||
$count = 0;
|
||||
foreach($result as $row2){
|
||||
$count++;
|
||||
}
|
||||
echo '<p class="card-text">Disponiblilité :'. $count .'</p>';
|
||||
echo '<form method="post" action="../../../calendrier.php">';
|
||||
echo '<input type="hidden" name="id" id="id" value="'.$row['m_id'].'">';
|
||||
echo '<input type="hidden" name="start" id="start" value="'.date("Y-m-d").'">';
|
||||
echo '<button type="submit" class="btn btn-danger">Prendre rendez-vous</button>';
|
||||
echo '</form>';
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
}
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
else if($_POST['nom'] == null){
|
||||
if(strlen($_POST['postal']) != 5){
|
||||
$postal = substr($_POST['postal'], 0, 2);
|
||||
$postal = $postal.'%';
|
||||
$query = $pdo->prepare("SELECT * FROM medecin WHERE CAST(m_postal AS TEXT) LIKE :postal");
|
||||
$query->bindParam(':postal', $postal);
|
||||
$query->execute();
|
||||
$result = $query->fetchAll();
|
||||
|
||||
$count = 0;
|
||||
foreach($result as $row){
|
||||
$count++;
|
||||
}
|
||||
|
||||
echo '<p class="ms-5 mt-2 fw-bold">'.$count.' Résultats</p>';
|
||||
|
||||
if($count == 0){
|
||||
echo '<p class="ms-5 mt-2 fw-bold">Aucun résultat</p>';
|
||||
}
|
||||
else{
|
||||
echo '<div class="d-flex flex-row flex-wrap mx-5 gap-5">';
|
||||
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 '<p class="card-text">Disponiblilité :'. $count .'</p>';
|
||||
echo '<form method="post" action="../../../calendrier.php">';
|
||||
echo '<input type="hidden" name="id" id="id" value="'.$row['m_id'].'">';
|
||||
echo '<input type="hidden" name="start" id="start" value="'.date("Y-m-d").'">';
|
||||
echo '<button type="submit" class="btn btn-danger">Prendre rendez-vous</button>';
|
||||
echo '</form>';
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
}
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
else{
|
||||
$query = $pdo->prepare("SELECT * FROM medecin WHERE m_postal = :postal");
|
||||
$query->bindParam(':postal', $_POST['postal']);
|
||||
$query->execute();
|
||||
$result = $query->fetchAll();
|
||||
|
||||
$count = 0;
|
||||
foreach($result as $row){
|
||||
$count++;
|
||||
}
|
||||
|
||||
echo '<p class="ms-5 mt-2 fw-bold">'.$count.' Résultats</p>';
|
||||
|
||||
if($count == 0){
|
||||
echo '<p class="ms-5 mt-2 fw-bold">Aucun résultat</p>';
|
||||
}
|
||||
else{
|
||||
echo '<div class="d-flex flex-row flex-wrap mx-5 gap-5">';
|
||||
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 '<p class="card-text">Disponiblilité :'. $count .'</p>';
|
||||
echo '<form method="post" action="../../../calendrier.php">';
|
||||
echo '<input type="hidden" name="id" id="id" value="'.$row['m_id'].'">';
|
||||
echo '<input type="hidden" name="start" id="start" value="'.date("Y-m-d").'">';
|
||||
echo '<button type="submit" class="btn btn-danger">Prendre rendez-vous</button>';
|
||||
echo '</form>';
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
}
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(strlen($_POST['postal']) != 5){
|
||||
$postal = substr($_POST['postal'], 0, 2);
|
||||
$postal = $postal.'%';
|
||||
$query = $pdo->prepare("SELECT * FROM medecin WHERE CAST(m_postal AS TEXT) LIKE :postal AND m_name = :nom");
|
||||
$query->bindParam(':postal', $postal);
|
||||
$query->bindParam(':nom', $_POST['nom']);
|
||||
$query->execute();
|
||||
$result = $query->fetchAll();
|
||||
}
|
||||
else{
|
||||
$query = $pdo->prepare("SELECT * FROM medecin WHERE m_name = :nom AND m_postal = :postal");
|
||||
$query->bindParam(':nom', $_POST['nom']);
|
||||
$query->bindParam(':postal', $_POST['postal']);
|
||||
$query->execute();
|
||||
$result = $query->fetchAll();
|
||||
}
|
||||
if ($result == null) {
|
||||
if(strlen($_POST['postal']) != 5){
|
||||
$postal = substr($_POST['postal'], 0, 2);
|
||||
$postal = $postal.'%';
|
||||
$query = $pdo->prepare("SELECT * FROM medecin WHERE CAST(m_postal AS TEXT) LIKE :postal AND m_specialty = :specialite");
|
||||
$query->bindParam(':postal', $postal);
|
||||
$query->bindParam(':specialite', $_POST['nom']);
|
||||
$query->execute();
|
||||
$result = $query->fetchAll();
|
||||
}
|
||||
else{
|
||||
$query = $pdo->prepare("SELECT * FROM medecin WHERE m_specialty = :specialite AND m_postal = :postal");
|
||||
$query->bindParam(':specialite', $_POST['nom']);
|
||||
$query->bindParam(':postal', $_POST['postal']);
|
||||
$query->execute();
|
||||
$result = $query->fetchAll();
|
||||
}
|
||||
}
|
||||
|
||||
$count = 0;
|
||||
foreach ($result as $row) {
|
||||
$count++;
|
||||
}
|
||||
|
||||
echo '<p class="ms-5 mt-2 fw-bold">' . $count . ' Résultats</p>';
|
||||
|
||||
if ($count == 0) {
|
||||
echo '<p class="ms-5 mt-2 fw-bold">Aucun résultat</p>';
|
||||
} else {
|
||||
echo '<div class="d-flex flex-row flex-wrap mx-5 gap-5">';
|
||||
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 '<p class="card-text">Disponiblilité :'. $count .'</p>';
|
||||
echo '<form method="post" action="../../../calendrier.php">';
|
||||
echo '<input type="hidden" name="id" id="id" value="'.$row['m_id'].'">';
|
||||
echo '<input type="hidden" name="start" id="start" value="'.date("Y-m-d").'">';
|
||||
echo '<button type="submit" class="btn btn-danger">Prendre rendez-vous</button>';
|
||||
echo '</form>';
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
}
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
*/
|
||||
// searchDoctor search doctor by name or specialty and return the result in JSON format
|
||||
function searchDoctor($pdo, $type): void
|
||||
{
|
||||
$query = $pdo->prepare("SELECT m_name, m_surname, m_postal, m_specialty, m_phone FROM medecin WHERE m_specialty = :type");
|
||||
$query = $pdo->prepare("SELECT m_name, m_surname, m_postal, m_specialty, m_phone, m_id FROM medecin WHERE m_specialty = :type");
|
||||
$query->bindParam(':type', $type);
|
||||
$query->execute();
|
||||
$result = $query->fetchAll();
|
||||
@@ -243,7 +14,7 @@ function searchDoctor($pdo, $type): void
|
||||
$count++;
|
||||
}
|
||||
if($count == 0){
|
||||
$query = $pdo->prepare("SELECT m_name, m_surname, m_postal, m_specialty, m_phone FROM medecin WHERE m_name = :type");
|
||||
$query = $pdo->prepare("SELECT m_name, m_surname, m_postal, m_specialty, m_phone, m_id FROM medecin WHERE m_name = :type");
|
||||
$query->bindParam(':type', $type);
|
||||
$query->execute();
|
||||
$result = $query->fetchAll();
|
||||
@@ -278,10 +49,10 @@ function searchDoctorByLocation($pdo, $location, $type = null): void
|
||||
}
|
||||
|
||||
if($type == null){
|
||||
$query = $pdo->prepare("SELECT m_name, m_surname, m_postal, m_specialty, m_phone FROM medecin WHERE CAST(m_postal AS TEXT) LIKE :postal");
|
||||
$query = $pdo->prepare("SELECT m_name, m_surname, m_postal, m_specialty, m_phone, m_id FROM medecin WHERE CAST(m_postal AS TEXT) LIKE :postal");
|
||||
$query->bindParam(':postal', $postal);
|
||||
} else {
|
||||
$query = $pdo->prepare("SELECT m_name, m_surname, m_postal, m_specialty, m_phone FROM medecin WHERE (m_specialty = :type OR m_name = :type) AND CAST(m_postal AS TEXT) LIKE :postal");
|
||||
$query = $pdo->prepare("SELECT m_name, m_surname, m_postal, m_specialty, m_phone, m_id FROM medecin WHERE (m_specialty = :type OR m_name = :type) AND CAST(m_postal AS TEXT) LIKE :postal");
|
||||
$query->bindParam(':type', $type);
|
||||
$query->bindParam(':postal', $postal);
|
||||
}
|
||||
@@ -296,5 +67,22 @@ function searchDoctorByLocation($pdo, $location, $type = null): void
|
||||
}
|
||||
}
|
||||
|
||||
function getNumberOfRDVByMedecin($pdo, $id): void
|
||||
{
|
||||
$query = $pdo->prepare("SELECT * FROM propose WHERE m_id = :id");
|
||||
$query->bindParam(':id', $id);
|
||||
$query->execute();
|
||||
$result = $query->fetchAll();
|
||||
$count = 0;
|
||||
foreach($result as $row){
|
||||
$count++;
|
||||
}
|
||||
if($count == 0){
|
||||
Response::HTTP404(['error' => "Aucun rendez-vous"]);
|
||||
}
|
||||
else {
|
||||
Response::HTTP200(['count' => $count]);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user