diff --git a/Consultations.php b/Consultations.php
index ca90eaf..d283a2b 100755
--- a/Consultations.php
+++ b/Consultations.php
@@ -25,7 +25,7 @@ $answerType = (isset($_GET['type'])) ? $_GET['type'] : null;
-
+
@@ -35,7 +35,7 @@ $answerType = (isset($_GET['type'])) ? $_GET['type'] : null;
diff --git a/Medecins.php b/Medecins.php
index 55b26a5..7894038 100755
--- a/Medecins.php
+++ b/Medecins.php
@@ -11,7 +11,7 @@ $managerTitle = (isset($_GET['title'])) ? $_GET['title'] : 'Oups!';
$managerMessage = (isset($_GET['message'])) ? $_GET['message'] : 'Erreur interne!';
// on récupère la liste des médecins si donnée
-$medecinsSearch = ( isset($_GET['medecins']) ) ? json_decode($_GET['medecins'], true) : [];
+$medecinsSearch = ( isset($_GET['medecins']) ) ? json_decode(base64_decode($_GET['medecins']), true) : [];
?>
@@ -32,7 +32,7 @@ $medecinsSearch = ( isset($_GET['medecins']) ) ? json_decode($_GET['medecins'],
-
+
@@ -42,7 +42,7 @@ $medecinsSearch = ( isset($_GET['medecins']) ) ? json_decode($_GET['medecins'],
@@ -82,7 +82,7 @@ $medecinsSearch = ( isset($_GET['medecins']) ) ? json_decode($_GET['medecins'],
Résultats:
-
+
@@ -27,17 +32,17 @@ $answerType = (isset($_GET['type'])) ? $_GET['type'] : null;
-
+
-
+
'>
-
Oups!
-
Certains champs sont incorrects. Veuillez réessayer.
-
+
+
+
@@ -56,25 +61,53 @@ $answerType = (isset($_GET['type'])) ? $_GET['type'] : null;
-
- ';
- switch($answerType){
- case 'creation': echo 'Patient créé.'; break;
- case 'error': echo 'Une erreur est survenue.'; break;
- default: echo 'rien à déclarer ? Non!'; break;
- }
- echo '';
- }
- /*************************************/
+
+
+
+ Résultats:
+
+ ';
+
+ echo ''.(($PAT['Civilite']=='M')?'Monsieur':'Madame').' | ';
+ echo ''.$PAT['Prenom'].' | ';
+ echo ''.strtoupper($PAT['Nom']).' | ';
+ echo ''.$PAT['DateNaissance'].' | ';
+ echo ''.$PAT['NumSecuriteSociale'].' | ';
+
+ echo '';
+ }}
+
+ ?>
+
+
+
+
+
+
+
+
+
diff --git a/css/global.css b/css/global.css
index 7218cc2..9f7338d 100755
--- a/css/global.css
+++ b/css/global.css
@@ -434,6 +434,7 @@ body{
/* border */
border: 1px solid #f09108;
+
}
#CONTAINER > article[data-title]:before{
@@ -732,3 +733,39 @@ input[type=radio]:checked + label:before{
+
+
+
+/* TABLEAU DE RESULTAT DE RECHERCHE */
+#CONTAINER > article table{
+ /* position */
+ width: 100%;
+
+ /* border */
+ border-spacing: 0;
+
+}
+
+#CONTAINER > article table > tbody,
+#CONTAINER > article table > tbody > tr{
+ /* position */
+ width: 100%;
+}
+
+#CONTAINER > article table td{
+ /* position */
+ max-width: calc( 100% / 5% );
+ padding: .5em 0;
+
+ /* border */
+ border-bottom: 1px solid #cacaca;
+}
+
+#CONTAINER > article table#searchResultMedecin td{
+ /* position */
+ max-width: calc( 100% / 3% );
+ padding: .5em 0;
+
+ /* border */
+ border-bottom: 1px solid #cacaca;
+}
\ No newline at end of file
diff --git a/js/consultations.js b/js/consultations.js
index 785d5ae..933deb9 100755
--- a/js/consultations.js
+++ b/js/consultations.js
@@ -1,5 +1,6 @@
var notifBar = document.getElementById('NOTIFBAR');
- notifBar.children[1].children[2].addEventListener('click', function(e){
+notifBar.children[1].children[2].addEventListener('click', function(e){
+ e.preventDefault();
remClass(notifBar, 'active');
}, false);
diff --git a/js/lib/adjust.js b/js/lib/adjust.js
index 2ad2f3f..4793979 100755
--- a/js/lib/adjust.js
+++ b/js/lib/adjust.js
@@ -83,7 +83,7 @@ function notif(pType, pTitle, pMessage){
var pTitle = (arguments.length>1) ? pTitle : null;
var pMessage = (arguments.length>2) ? pMessage : null;
- var index = ['error', 'success', 'info'].indexOf(pType)
+ var index = ['error', 'success', 'info'].indexOf(pType);
if( index == -1 ) return false; // si pType incorrect, on quitte
diff --git a/js/input-checker.js b/js/lib/input-checker.js
similarity index 100%
rename from js/input-checker.js
rename to js/lib/input-checker.js
diff --git a/js/medecins.js b/js/medecins.js
index 028a1f7..7c9eb72 100755
--- a/js/medecins.js
+++ b/js/medecins.js
@@ -1,5 +1,6 @@
var notifBar = document.getElementById('NOTIFBAR');
- notifBar.children[1].children[2].addEventListener('click', function(e){
+notifBar.children[1].children[2].addEventListener('click', function(e){
+ e.preventDefault();
remClass(notifBar, 'active');
}, false);
@@ -128,9 +129,9 @@ sbCherche.addEventListener('click', function(e){
notif(e.status, e.title, e.message);
if( e.hasOwnProperty('medecins') )
- displaySearchedMedecins(e.medecins);
+ displayFoundMedecins(e.medecins);
else
- displaySearchedMedecins([]);
+ displayFoundMedecins([]);
if( e.status == 'success' ) // on vide le formulaire si on a 'success'
sbCreer.parentNode.reset();
@@ -147,8 +148,8 @@ sbCherche.addEventListener('click', function(e){
////////////////////////////////////////////
// AFFICHAGE DES MEDECINS DE LA RECHERCHE //
////////////////////////////////////////////
-function displaySearchedMedecins(foundMedecins){
- var container = document.getElementById('searchResult');
+function displayFoundMedecins(foundMedecins){
+ var container = document.getElementById('searchResultMedecin');
var content = '';
for( var i = 0 ; i < foundMedecins.length ; i++ ){
diff --git a/js/patients.js b/js/patients.js
index 8765129..8f5df52 100755
--- a/js/patients.js
+++ b/js/patients.js
@@ -1,5 +1,6 @@
var notifBar = document.getElementById('NOTIFBAR');
- notifBar.children[1].children[2].addEventListener('click', function(e){
+notifBar.children[1].children[2].addEventListener('click', function(e){
+ e.preventDefault();
remClass(notifBar, 'active');
}, false);
@@ -160,4 +161,89 @@ sbCreer.addEventListener('click', function(e){
}else{ // sinon on affiche l'erreur
notif('error', 'Oups!', 'Certains champs sont requis ou incorrects.');
}
-}, false);
\ No newline at end of file
+}, false);
+
+
+
+
+
+
+
+
+
+
+
+
+
+/* RECHERCHE DE MEDECINS */
+var srPrenom = document.getElementById('srPrenom');
+var srNom = document.getElementById('srNom');
+var sbCherche = document.getElementById('sbCherche');
+
+
+//////////////////////////////
+// PRENOM & NOM (VARCHAR 45)//
+//////////////////////////////
+srPrenom.addEventListener('keyup', function(e){ checkVARCHAR(e.target, 1, 45, true); }, false);
+srNom.addEventListener('keyup', function(e){ checkVARCHAR(e.target, 1, 45, true); }, false);
+
+//////////////
+// SUBMIT() //
+//////////////
+sbCherche.addEventListener('click', function(e){
+ e.preventDefault(); // on annule le submit()
+
+ var correctNom = srNom.className.indexOf('validated') > -1 && srNom.value.length > 0;
+ var correctPrenom = srPrenom.className.indexOf('validated') > -1 && srPrenom.value.length > 0;
+
+ if( correctPrenom || correctNom ){ // si tout es ok uniquement, on submit()
+
+ var request = {
+ prenom: (correctPrenom) ? srPrenom.value : null,
+ nom: (correctNom) ? srNom.value : null
+ };
+
+ API.send('Patient:search', request, function(e){
+ if( e.status != 'success' )
+ notif(e.status, e.title, e.message);
+
+ if( e.hasOwnProperty('patients') )
+ displayFoundPatients(e.patients);
+ else
+ displayFoundPatients([]);
+
+ if( e.status == 'success' ) // on vide le formulaire si on a 'success'
+ sbCreer.parentNode.reset();
+ }, false);
+
+
+ }else // sinon on affiche l'erreur
+ notif('error', 'Oups!', 'Certains champs sont requis ou incorrects.');
+
+}, false);
+
+
+
+////////////////////////////////////////////
+// AFFICHAGE DES MEDECINS DE LA RECHERCHE //
+////////////////////////////////////////////
+function displayFoundPatients(foundPatients){
+ var container = document.getElementById('searchResultPatient');
+ var content = '';
+
+ for( var i = 0 ; i < foundPatients.length ; i++ ){
+ content += '';
+ content += ''+ ((foundPatients[i].Civilite=='M')?'Monsieur':'Madame') + ' | ';
+ content += ''+ foundPatients[i].Prenom + ' | ';
+ content += ''+ foundPatients[i].Nom.toUpperCase() + ' | ';
+ content += ''+ foundPatients[i].DateNaissance + ' | ';
+ content += ''+ foundPatients[i].NumSecuriteSociale + ' | ';
+ content += '
';
+ }
+
+ content += '
';
+
+
+ // on vide le container
+ container.innerHTML = content;
+}
\ No newline at end of file
diff --git a/managers/Medecin.class.php b/managers/Medecin.class.php
index edd7f3f..737b902 100755
--- a/managers/Medecin.class.php
+++ b/managers/Medecin.class.php
@@ -54,7 +54,7 @@ class Medecin
Response::quickResponse(200, json_encode([ 'status' => $_status, 'title' => $_title, 'message' => $_message, 'medecins' => $_medecins ]));
else{
$response = new Response();
- $response->setHeader('Location','http://'.$_SERVER['HTTP_HOST'].'/Medecins.php?status='.$_status.'&title='.$_title.'&message='.$_message.'&medecins='.json_encode($_medecins));
+ $response->setHeader('Location','http://'.$_SERVER['HTTP_HOST'].'/Medecins.php?status='.$_status.'&title='.$_title.'&message='.$_message.'&medecins='.base64_encode(json_encode($_medecins)));
$response->send();
}
}else{
@@ -62,13 +62,9 @@ class Medecin
$_title = 'Erreur lors de la recherche!';
$_message = 'Certains champs étaient incorrects. Réessayez!';
- if( !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ){
- Response::quickResponse(200, json_encode([
- 'status' => 'error',
- 'title' => 'Oups!',
- 'message' => 'Aucun médecin trouvé.'
- ]));
- }else{
+ if( !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' )
+ Response::quickResponse(200, json_encode([ 'status' => $_status, 'title' => $_title, 'message' => $_message ]));
+ else{
$response = new Response();
$response->setHeader('Location','http://'.$_SERVER['HTTP_HOST'].'/Medecins.php?status='.$_status.'&title='.$_title.'&message='.$_message);
$response->send();
diff --git a/managers/Patient.class.php b/managers/Patient.class.php
index 91e5f91..219afd9 100755
--- a/managers/Patient.class.php
+++ b/managers/Patient.class.php
@@ -22,7 +22,7 @@ class Patient
Response::quickResponse(200, json_encode([ 'status' => $_status, 'title' => $_title, 'message' => $_message ]));
else{
$response = new Response();
- $response->setHeader('Location','http://'.$_SERVER['HTTP_HOST'].'/Medecins.php?status='.$_status.'&title='.$_title.'&message='.$_message);
+ $response->setHeader('Location','http://'.$_SERVER['HTTP_HOST'].'/Patients.php?status='.$_status.'&title='.$_title.'&message='.$_message);
$response->send();
}
}else{
@@ -34,7 +34,7 @@ class Patient
Response::quickResponse(200, json_encode([ 'status' => $_status, 'title' => $_title, 'message' => $_message ]));
else{
$response = new Response();
- $response->setHeader('Location','http://'.$_SERVER['HTTP_HOST'].'/Medecins.php?status='.$_status.'&title='.$_title.'&message='.$_message);
+ $response->setHeader('Location','http://'.$_SERVER['HTTP_HOST'].'/Patients.php?status='.$_status.'&title='.$_title.'&message='.$_message);
$response->send();
}
@@ -48,13 +48,44 @@ class Patient
Response::quickResponse(200, json_encode([ 'status' => $_status, 'title' => $_title, 'message' => $_message ]));
else{
$response = new Response();
- $response->setHeader('Location','http://'.$_SERVER['HTTP_HOST'].'/Medecins.php?status='.$_status.'&title='.$_title.'&message='.$_message);
+ $response->setHeader('Location','http://'.$_SERVER['HTTP_HOST'].'/Patients.php?status='.$_status.'&title='.$_title.'&message='.$_message);
$response->send();
}
}
}
+ public function search($params){
+
+ /* RECHERCHE REUSSIE */
+ if( ($patList=PatientRepo::search(strtolower($params['nom']), strtolower($params['prenom']))) !== FALSE ){
+ $_status = 'success';
+ $_title = 'Recherche effectuée!';
+ $_message = ''.count($patList).' patient(s) trouvé(s)!';
+ $_patients = $patList;
+
+ if( !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' )
+ Response::quickResponse(200, json_encode([ 'status' => $_status, 'title' => $_title, 'message' => $_message, 'patients' => $_patients ]));
+ else{
+ $response = new Response();
+ $response->setHeader('Location','http://'.$_SERVER['HTTP_HOST'].'/Patients.php?status='.$_status.'&title='.$_title.'&message='.$_message.'&patients='.base64_encode(json_encode($_patients)));
+ $response->send();
+ }
+ }else{
+ $_status = 'error';
+ $_title = 'Erreur lors de la recherche!';
+ $_message = 'Certains champs étaient incorrects. Réessayez!';
+
+ if( !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' )
+ Response::quickResponse(200, json_encode([ 'status' => $_status, 'title' => $_title, 'message' => $_message ]));
+ else{
+ $response = new Response();
+ $response->setHeader('Location','http://'.$_SERVER['HTTP_HOST'].'/Patients.php?status='.$_status.'&title='.$_title.'&message='.$_message);
+ $response->send();
+ }
+ }
+ }
+
public function update($params){
if(StaticRepo::checkParam($params['date_naissance'],'Date')){
$params['num_secu'] = str_replace(' ','',$params['num_secu']);
@@ -70,7 +101,7 @@ class Patient
Response::quickResponse(200, json_encode([ 'status' => $_status, 'title' => $_title, 'message' => $_message ]));
else{
$response = new Response();
- $response->setHeader('Location','http://'.$_SERVER['HTTP_HOST'].'/Medecins.php?status='.$_status.'&title='.$_title.'&message='.$_message);
+ $response->setHeader('Location','http://'.$_SERVER['HTTP_HOST'].'/Patients.php?status='.$_status.'&title='.$_title.'&message='.$_message);
$response->send();
}
@@ -83,7 +114,7 @@ class Patient
Response::quickResponse(200, json_encode([ 'status' => $_status, 'title' => $_title, 'message' => $_message ]));
else{
$response = new Response();
- $response->setHeader('Location','http://'.$_SERVER['HTTP_HOST'].'/Medecins.php?status='.$_status.'&title='.$_title.'&message='.$_message);
+ $response->setHeader('Location','http://'.$_SERVER['HTTP_HOST'].'/Patients.php?status='.$_status.'&title='.$_title.'&message='.$_message);
$response->send();
}
}
@@ -96,7 +127,7 @@ class Patient
Response::quickResponse(200, json_encode([ 'status' => $_status, 'title' => $_title, 'message' => $_message ]));
else{
$response = new Response();
- $response->setHeader('Location','http://'.$_SERVER['HTTP_HOST'].'/Medecins.php?status='.$_status.'&title='.$_title.'&message='.$_message);
+ $response->setHeader('Location','http://'.$_SERVER['HTTP_HOST'].'/Patients.php?status='.$_status.'&title='.$_title.'&message='.$_message);
$response->send();
}
}
@@ -113,7 +144,7 @@ class Patient
Response::quickResponse(200, json_encode([ 'status' => $_status, 'title' => $_title, 'message' => $_message ]));
else{
$response = new Response();
- $response->setHeader('Location','http://'.$_SERVER['HTTP_HOST'].'/Medecins.php?status='.$_status.'&title='.$_title.'&message='.$_message);
+ $response->setHeader('Location','http://'.$_SERVER['HTTP_HOST'].'/Patients.php?status='.$_status.'&title='.$_title.'&message='.$_message);
$response->send();
}
@@ -126,7 +157,7 @@ class Patient
Response::quickResponse(200, json_encode([ 'status' => $_status, 'title' => $_title, 'message' => $_message ]));
else{
$response = new Response();
- $response->setHeader('Location','http://'.$_SERVER['HTTP_HOST'].'/Medecins.php?status='.$_status.'&title='.$_title.'&message='.$_message);
+ $response->setHeader('Location','http://'.$_SERVER['HTTP_HOST'].'/Patients.php?status='.$_status.'&title='.$_title.'&message='.$_message);
$response->send();
}
}
diff --git a/managers/config/managers.json b/managers/config/managers.json
index caed29b..eff48c2 100755
--- a/managers/config/managers.json
+++ b/managers/config/managers.json
@@ -3,6 +3,9 @@
"add":{"method": "add",
"role": 0,
"strict": false},
+ "search":{"method":"search",
+ "role":0,
+ "strict":false},
"delete":{"method": "delete",
"role": 0,
"strict": false},
diff --git a/repositories/repos/PatientRepo.php b/repositories/repos/PatientRepo.php
index bec3383..74ba310 100755
--- a/repositories/repos/PatientRepo.php
+++ b/repositories/repos/PatientRepo.php
@@ -123,16 +123,26 @@ class PatientRepo
}
- public static function search($nom,$prenom){
- if(!StaticRepo::checkParam($prenom,'String45') && !StaticRepo::checkParam($nom,'String45')){return false;}
+ public static function search($nom, $prenom){
- $req = StaticRepo::getConnexion()->prepare('SELECT * FROM Patient WHERE Nom LIKE :nom AND Prenom LIKE :prenom');
- $req->execute(['nom' => $nom, 'prenom' => $prenom]);
- return StaticRepo::delNumeric($req->fetchAll());
+ if( !StaticRepo::checkParam($prenom,'String45') && !StaticRepo::checkParam($nom,'String45') ) return false;
+ // on définit les valeurs (peuvent être nulles)
+ $optPrenom = ( $prenom != 'null' && StaticRepo::checkParam($prenom,'String45') ) ? '%'.$prenom.'%' : '%';
+ $optNom = ( $nom != 'null' && StaticRepo::checkParam($nom, 'String45') ) ? '%'.$nom.'%' : '%';
+
+ $req = StaticRepo::getConnexion()->query("SELECT Civilite, Nom, Prenom, DateNaissance, NumSecuriteSociale
+ FROM Patient
+ WHERE Nom LIKE '".$optNom."'
+ AND Prenom LIKE '".$optPrenom."'
+ ORDER BY Nom, Prenom ASC");
+
+
+ return StaticRepo::delNumeric( $req->fetchAll() );
}
+
public static function getAll(){
$req = StaticRepo::getConnexion()->query('SELECT * FROM Patient ORDER BY nom, prenom ASC');