mirror of
https://github.com/BreizhHardware/ProjetS4COMWEB.git
synced 2026-01-18 16:47:35 +01:00
Page praticient finito pipo
This commit is contained in:
@@ -128,7 +128,6 @@ $router->DELETE('/api/requests', ["test"], function($test){
|
||||
$router->GET('/api/rdv-praticient', ["id"], function($id){
|
||||
global $pdo;
|
||||
dbRequestRdvPraticien($pdo, $id);
|
||||
//getAllLieux($pdo);
|
||||
});
|
||||
|
||||
$router->GET('/api/rdv-praticient/getAllLieux', [], function(){
|
||||
|
||||
@@ -111,6 +111,7 @@ function getAllLieux($pdo){
|
||||
}
|
||||
|
||||
function CreateRDV($pdo, $medID, $date, $time, $lieu){
|
||||
error_log($lieu. ', ' . $date . ', ' . $time . ', ' . $medID);
|
||||
$lieu = explode(', ', $lieu);
|
||||
$adress = $lieu[0] . ', ' . $lieu[1];
|
||||
$postal = $lieu[2];
|
||||
@@ -131,7 +132,9 @@ function CreateRDV($pdo, $medID, $date, $time, $lieu){
|
||||
$statement->execute();
|
||||
Response::HTTP200(["Success" => "RDV created"]);
|
||||
}
|
||||
Response::HTTP404(["Error" => "Lieu not found"]);
|
||||
else {
|
||||
Response::HTTP404(["Error" => "Lieu not found"]);
|
||||
}
|
||||
}
|
||||
|
||||
function DeleteEmptyRdv($pdo, $id)
|
||||
|
||||
@@ -2,10 +2,10 @@ import {attachSearchEventListener} from "./search.js";
|
||||
import {attachLoginUserDisplayEventListener, attachLoginPraticienDisplayEventListener, attachDisconnectEventListener} from "./login.js";
|
||||
import {TokenDecode} from "./lib.js";
|
||||
import {displayHome, displayHomeTopBar, attachReturnHomeEventListener} from "./home.js";
|
||||
import {ButtonShowRdvPraticient} from "./rdv-praticien.js";
|
||||
|
||||
console.log("index.js loaded");
|
||||
|
||||
|
||||
//Felix Part
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
@@ -14,116 +14,12 @@ document.addEventListener("DOMContentLoaded", function() {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
//Yanis Part
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
ButtonShowRdvPraticient();
|
||||
});
|
||||
|
||||
function ButtonShowRdvPraticient() {
|
||||
try {
|
||||
document.getElementById("praticien-calendar").addEventListener("click", function () {
|
||||
let user = TokenDecode(sessionStorage.getItem("token"));
|
||||
ajaxRequest('GET', "src/API/requests.php/api/rdv-praticient?id=" + user.id, function (data) {
|
||||
DisplayRDVPraticient(data);
|
||||
});
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
//Do nothing
|
||||
//console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
function DisplayRDVPraticient(rdv){
|
||||
let count = rdv.length;
|
||||
let content = document.getElementById("content");
|
||||
content.innerHTML = "";
|
||||
content.innerHTML = '<div class="h-100"> <div class="d-flex flex-row flex-wrap my-5 mx-5 gap-5 justify-content-center text-center">';
|
||||
if(count === 0){
|
||||
content.append('<h1>Vous n\'avez pas de rendez-vous</h1>');
|
||||
}
|
||||
else {
|
||||
for (let i = 0; i < count; i++) {
|
||||
console.log(rdv[i]);
|
||||
if (rdv[i].p_mail !== null) {
|
||||
content.innerHTML = '' +
|
||||
'<div class="card rounded-4 mx-2 pointer">' +
|
||||
'<div class="card-header bg-danger">' +
|
||||
'<div class="d-flex flex-row justify-content-between text-white">' +
|
||||
'<p>' + rdv[i].rdv_date + '</p>' +
|
||||
'<p>' + rdv[i].rdv_time + '</p>' +
|
||||
'</div>' + '</div>' +
|
||||
'<div class="card-body">' +
|
||||
'<h5 class="card-title">' + rdv[i].patient + '</h5>' +
|
||||
'<a href="mailto:' + rdv[i].p_mail + '" class="card-subtitle mb-2 text-body-secondary">' + rdv[i].email + '</a>' +
|
||||
'<br>' +
|
||||
'<a href="tel:0' + rdv[i].p_phone + '" class="card-subtitle mb-2 text-body-secondary">' + '0' + rdv[i].phone + '</a>' +
|
||||
'</div>' + '</div>';
|
||||
} else {
|
||||
content.innerHTML = '' +
|
||||
'<div class="card rounded-4 mx-2 pointer">' +
|
||||
'<div class="card-header bg-danger">' +
|
||||
'<div class="d-flex flex-row justify-content-between text-white">' +
|
||||
'<p>' + rdv[i].rdv_date + '</p>' +
|
||||
'<p>' + rdv[i].rdv_time + '</p>' +
|
||||
'</div>' + '</div>' +
|
||||
'<div class="card-body">' +
|
||||
'<h5 class="card-title">Vous n\'avez pas de' + '<br>' + 'patient pour ce créneau</h5>' +
|
||||
'</div>' + '</div>';
|
||||
}
|
||||
content.innerHTML = '</div> <div id="addRDV" class="d-flex flex-row flex-wrap my-5 mx-5 gap-5 justify-content-center text-center" >';
|
||||
ShowAddRDV();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function ShowAddRDV() {
|
||||
ajaxRequest('GET', "src/API/requests.php/api/rdv-praticient/getAllLieux", function (data) {
|
||||
DisplayAddRDV(data);
|
||||
});
|
||||
}
|
||||
|
||||
function DisplayAddRDV(lieux) {
|
||||
let user = TokenDecode(sessionStorage.getItem("token"));
|
||||
let medID = user.id;
|
||||
let addRDV = document.getElementById("addRDV");
|
||||
addRDV.innerHTML = "";
|
||||
addRDV.innerHTML = '';
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
function DisplayRDVPatient(rdv){
|
||||
let rdvPatient = rdv[0];
|
||||
let lieux = rdv[1];
|
||||
|
||||
let count = $rdvPatient.length;
|
||||
$('#content').empty();
|
||||
$('#content').html('<div class="h-100"> <div class="row"> <div class="col-3 border-end border-dark border-3 h-100 mt-2 text-center d-flex flex-column justify-content-center"> <div class="d-flex flex-column"> <div class="border-bottom pb-3 border-dark border-3 align-self-center"> <h5 class="text-center">Vos rendez-vous à venir</h5>');
|
||||
if(count === 0){
|
||||
$('#content').append('<h1>Bienvenue sur Doct\'ISEN, veuillez prendre un rendez-vous en allant à l\'acceuil et en recherchant un praticient!</h1>');
|
||||
}
|
||||
else {
|
||||
for (let i = 0; i < count; i++){
|
||||
if($rdvPatient !== "null")
|
||||
$('#content').append('' +
|
||||
'<div class="card rounded-4 mx-2 pointer">' +
|
||||
'<div class="card-header bg-danger">' +
|
||||
'<div class="d-flex flex-row justify-content-between text-white">' +
|
||||
'<p>' + $rdvPatient[i].rdv_date + '</p>' +
|
||||
'<p>' + $rdvPatient[i].rdv_time + '</p>' +
|
||||
'</div>' + '</div>' +
|
||||
'<div class="card-body">' +
|
||||
'<h5 class="card-title"
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
//End Call
|
||||
|
||||
ButtonShowRdvPraticient();
|
||||
|
||||
@@ -1,15 +1,34 @@
|
||||
function DisplayRDV(rdv){
|
||||
import {TokenDecode} from "./lib";
|
||||
|
||||
function ButtonShowRdvPraticient() {
|
||||
try {
|
||||
document.getElementById("praticien-calendar").addEventListener("click", function () {
|
||||
let user = TokenDecode(sessionStorage.getItem("token"));
|
||||
ajaxRequest('GET', "src/API/requests.php/api/rdv-praticient?id=" + user.id, function (data) {
|
||||
DisplayRDVPraticient(data);
|
||||
console.log(data);
|
||||
});
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
//Do nothing
|
||||
//console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
function DisplayRDVPraticient(rdv){
|
||||
let count = rdv.length;
|
||||
$('#content').empty();
|
||||
$('#content').html('<div class="h-100"> <div class="d-flex flex-row flex-wrap my-5 mx-5 gap-5 justify-content-center text-center">');
|
||||
let content = document.getElementById("content");
|
||||
content.innerHTML = "";
|
||||
content.innerHTML = '<div class="h-100"> <div class="d-flex flex-row flex-wrap my-5 mx-5 gap-5 justify-content-center text-center">';
|
||||
if(count === 0){
|
||||
$('#content').append('<h1>Vous n\'avez pas de rendez-vous</h1>');
|
||||
content.append('<h1>Vous n\'avez pas de rendez-vous</h1>');
|
||||
}
|
||||
else {
|
||||
for (let i = 0; i < count; i++){
|
||||
if (rdv[i].p_mail !== "null")
|
||||
$('#content').append('' +
|
||||
'<div class="card rounded-4 mx-2 pointer">' +
|
||||
for (let i = 0; i < count; i++) {
|
||||
console.log(rdv[i]);
|
||||
if (rdv[i].p_mail !== null) {
|
||||
content.innerHTML += '<div class="card rounded-4 mx-2 pointer">' +
|
||||
'<div class="card-header bg-danger">' +
|
||||
'<div class="d-flex flex-row justify-content-between text-white">' +
|
||||
'<p>' + rdv[i].rdv_date + '</p>' +
|
||||
@@ -17,13 +36,12 @@ function DisplayRDV(rdv){
|
||||
'</div>' + '</div>' +
|
||||
'<div class="card-body">' +
|
||||
'<h5 class="card-title">' + rdv[i].patient + '</h5>' +
|
||||
'<a href="mailto:' + rdv[i].p_mail + '" class="card-subtitle mb-2 text-body-secondary">' + rdv[i].email + '</a>' +
|
||||
'<a href="mailto:' + rdv[i].p_mail + '" class="card-subtitle mb-2 text-body-secondary">' + rdv[i].p_mail + '</a>' +
|
||||
'<br>' +
|
||||
'<a href="tel:0' + rdv[i].p_phone + '" class="card-subtitle mb-2 text-body-secondary">' + '0' + rdv[i].phone + '</a>' +
|
||||
'</div>' + '</div>');
|
||||
else{
|
||||
$('#content').append('' +
|
||||
'<div class="card rounded-4 mx-2 pointer">' +
|
||||
'<a href="tel:0' + rdv[i].p_phone + '" class="card-subtitle mb-2 text-body-secondary">' + '0' + rdv[i].p_phone + '</a>' +
|
||||
'</div>' + '</div>';
|
||||
} else {
|
||||
content.innerHTML += '<div class="card rounded-4 mx-2 pointer">' +
|
||||
'<div class="card-header bg-danger">' +
|
||||
'<div class="d-flex flex-row justify-content-between text-white">' +
|
||||
'<p>' + rdv[i].rdv_date + '</p>' +
|
||||
@@ -31,9 +49,63 @@ function DisplayRDV(rdv){
|
||||
'</div>' + '</div>' +
|
||||
'<div class="card-body">' +
|
||||
'<h5 class="card-title">Vous n\'avez pas de' + '<br>' + 'patient pour ce créneau</h5>' +
|
||||
'</div>' + '</div>');
|
||||
'</div>' + '</div>';
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
content.innerHTML += '<div id="addRDV" class="d-flex flex-row flex-wrap my-5 mx-5 gap-5 justify-content-center text-center" >';
|
||||
ShowAddRDV();
|
||||
}
|
||||
|
||||
function ShowAddRDV() {
|
||||
ajaxRequest('GET', "src/API/requests.php/api/rdv-praticient/getAllLieux", function (data) {
|
||||
DisplayAddRDV(data);
|
||||
});
|
||||
}
|
||||
|
||||
function DisplayAddRDV(lieux) {
|
||||
let user = TokenDecode(sessionStorage.getItem("token"));
|
||||
let medID = user.id;
|
||||
let addRDV = document.getElementById("addRDV");
|
||||
addRDV.innerHTML = '';
|
||||
|
||||
let options ='';
|
||||
lieux.forEach(function (row) {
|
||||
console.log(row);
|
||||
let adress = row["l_adress"];
|
||||
let postal = row["l_postal"];
|
||||
let city = row["l_city"];
|
||||
let lieu = adress + ', ' + postal + ', ' + city;
|
||||
options += "<option value='" + lieu + "'>" + adress + ", " + postal + ", " + city + "</option>";
|
||||
});
|
||||
console.log(options);
|
||||
addRDV.innerHTML += '<form>' +
|
||||
"<input type='hidden' name='medID' value='" + medID + "'>" +
|
||||
"<input class='form-control' type='date' name='date'>" +
|
||||
"<input class='form-control' type='time' name='time'>" +
|
||||
"<select class='form-select' name='lieu' id='lieu'>" +
|
||||
"<option value=''>Choisissez un lieu</option>" +
|
||||
options +
|
||||
"</select>" +
|
||||
"<br><br>" +
|
||||
"<button type='submit' name='createRDV' class='btn btn-danger' id='addRDVbutton'>Créer un rendez-vous</button>" +
|
||||
"</form>";
|
||||
document.getElementById("addRDVbutton").addEventListener("click", function (event) {
|
||||
event.preventDefault();
|
||||
let medID = document.querySelector("input[name='medID']").value;
|
||||
let date = document.querySelector("input[name='date']").value;
|
||||
let time = document.querySelector("input[name='time']").value;
|
||||
let lieu = document.querySelector("select[name='lieu']").value;
|
||||
let data = 'medID=' + medID + '&date=' + date + '&time=' + time + '&lieu=' + lieu;
|
||||
ajaxRequest('POST', "src/API/requests.php/api/create-rdv", function (data) {
|
||||
console.log(data);
|
||||
ButtonShowRdvPraticient();
|
||||
}, data);
|
||||
ajaxRequest('GET', "src/API/requests.php/api/rdv-praticient?id=" + user.id, function (data) {
|
||||
DisplayRDVPraticient(data);
|
||||
console.log(data);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export {ButtonShowRdvPraticient};
|
||||
Reference in New Issue
Block a user