diff --git a/src/API/requests.php b/src/API/requests.php
index c5b7b0e..3d2fd02 100644
--- a/src/API/requests.php
+++ b/src/API/requests.php
@@ -21,14 +21,19 @@ $router->GET('/api/search-type', ["type"], function($type){
searchDoctor($pdo, $type);
});
-$router->GET('/api/search-location', ["location"], function($location){
+$router->GET('/api/search-postal', ["postal"], function($postal){
global $pdo;
- searchDoctorByLocation($pdo, $location);
+ searchDoctorByLocation($pdo, $postal);
});
-$router->GET('/api/search', ["type", "location"], function($type, $location){
+$router->GET('/api/search', ["type", "postal"], function($type, $postal){
global $pdo;
- searchDoctorByLocation($pdo, $location, $type);
+ searchDoctorByLocation($pdo, $postal, $type);
+});
+
+$router->GET('/api/rdv', ["id"], function($id){
+ global $pdo;
+ getNumberOfRDVByMedecin($pdo, $id);
});
$router->GET('/api/rdv-time', ["id"], function($id){
diff --git a/src/css/styles.css b/src/css/styles.css
index 959a2e4..6e5385c 100644
--- a/src/css/styles.css
+++ b/src/css/styles.css
@@ -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{
diff --git a/src/js/AJAX/index.js b/src/js/AJAX/index.js
index 7f3de02..50f3098 100644
--- a/src/js/AJAX/index.js
+++ b/src/js/AJAX/index.js
@@ -1,19 +1,10 @@
console.log("index.js loaded");
-//Search
-type = document.getElementById("nom").value;
-postal = document.getElementById("postal").value;
-document.getElementById("button-addon2").addEventListener("click", function() {
- ajaxRequest('GET',"src/API/requests.php/api/search?type=" + type + "&postal=" + postal, displaySearchResults);
-});
-
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");
+ let 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 count = 0;
data.forEach(function(element) {
count++;
@@ -27,20 +18,83 @@ function displaySearchResults(data) {
-
${element.name}
-
${element.type}
-
Disponibilité: ${element.disponibility}
+
${element.m_surname} ${element.m_name}
+
${element.m_specialty}
+
Code Postal: ${element.m_postal}
+
+
Disponibilités: ${element.m_availabilities}
`;
mainDiv.appendChild(card);
});
+ container.appendChild(mainDiv);
if(count === 0) {
mainDiv.innerHTML = "
Aucun résultats
";
}
else {
- mainDiv.innerHTML = "
" + count + " résultats
";
- container.appendChild(mainDiv);
+ let resultText = document.createElement("h1");
+ resultText.textContent = count + " résultats";
+ container.insertBefore(resultText, mainDiv);
}
-}
\ No newline at end of file
+}
+
+function displaySearchTopBar(){
+ let topbar = document.getElementById("topbar");
+ let searchbar = document.getElementById("searchbar");
+
+ let form = topbar.querySelector("form");
+ if (form) {
+ topbar.removeChild(form);
+ }
+
+ searchbar.innerHTML = `
+
`;
+
+ attachSearchEventListener();
+}
+
+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() {
+ document.getElementById("recherche").addEventListener("click", function(event) {
+ performSearch(event);
+ });
+}
+
+
+
+attachSearchEventListener();
\ No newline at end of file
diff --git a/src/php/db/Search.php b/src/php/db/Search.php
index 8a4a294..d77ea96 100644
--- a/src/php/db/Search.php
+++ b/src/php/db/Search.php
@@ -296,5 +296,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]);
+ }
+}
?>
\ No newline at end of file