diff --git a/Consultations.php b/Consultations.php
index 6e5c4c6..d283a2b 100755
--- a/Consultations.php
+++ b/Consultations.php
@@ -18,13 +18,14 @@ $answerType = (isset($_GET['type'])) ? $_GET['type'] : null;
+
-
+
@@ -34,7 +35,7 @@ $answerType = (isset($_GET['type'])) ? $_GET['type'] : null;
@@ -65,13 +66,48 @@ $answerType = (isset($_GET['type'])) ? $_GET['type'] : null;
echo '';
switch($answerType){
case 'creation': echo 'Patient créé.'; break;
+ case 'modification': echo 'Patient modifié.'; break;
+ case 'suppression': echo 'Patient supprimé.'; break;
case 'error': echo 'Une erreur est survenue.'; break;
default: echo 'rien à déclarer ? Non!'; break;
}
echo '';
- }
- /*************************************/
+ }/************************************/
+ /* CONSULTER LES RENDEZ-VOUS */
+ /*************************************/ ?>
+
+
+ Mois à afficher.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -105,23 +141,6 @@ $answerType = (isset($_GET['type'])) ? $_GET['type'] : null;
-
-
-
-
-
-
-
-
-
-
-
- Clé de contrôle invalide.
-
-
-
diff --git a/Dashboard.php b/Dashboard.php
index 583ed34..72d3234 100755
--- a/Dashboard.php
+++ b/Dashboard.php
@@ -14,6 +14,7 @@ if(!Authentification::checkUser(0)){
+
diff --git a/Medecins.php b/Medecins.php
index f6d909c..57c5fc7 100755
--- a/Medecins.php
+++ b/Medecins.php
@@ -5,8 +5,19 @@ if(!Authentification::checkUser(0)){
die();
};
-// formattage $_GET['type']
-$answerType = (isset($_GET['type'])) ? $_GET['type'] : null;
+
+function customCompression($input, $compression){
+ if( $compression ) return strtr(base64_encode(addslashes(gzcompress(serialize($input),9))), '+/=', '-_,');
+ else return unserialize(gzuncompress(stripslashes(base64_decode(strtr($input, '-_,', '+/=')))));
+}
+
+/* REPONSE DU MANAGER */
+$managerStatus = (isset($_GET['status'])) ? $_GET['status'] : null;
+$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( customCompression($_GET['medecins'], false) , true) : [];
?>
@@ -19,6 +30,7 @@ $answerType = (isset($_GET['type'])) ? $_GET['type'] : null;
+
@@ -26,17 +38,17 @@ $answerType = (isset($_GET['type'])) ? $_GET['type'] : null;
-
+
-
+
'>
-
Oups!
-
Certains champs sont incorrects. Veuillez réessayer.
-
+
+
+
@@ -62,18 +74,56 @@ $answerType = (isset($_GET['type'])) ? $_GET['type'] : null;
- ';
- switch($answerType){
- case 'creation': echo 'Médecin créé.'; break;
- case 'error': echo 'Une erreur est survenue.'; break;
- default: echo 'rien à déclarer ? Non!'; break;
- }
- echo '';
+
+
+
+ Résultats:
+
+ ';
+
+ echo ''.(($MED['Civilite']=='M')?'Monsieur':'Madame').' | ';
+ echo ''.$MED['Prenom'].' | ';
+ echo ''.strtoupper($MED['Nom']).' | ';
+
+ // début modification
+ echo " | ';
+ // fin modification
+
+ // début suppression
+ echo " | ';
+ // fin suppression
+
+ echo '';
+ }}
+
+ ?>
+
+
+
+
+
diff --git a/Patients.php b/Patients.php
index 48caa84..bc97ed5 100755
--- a/Patients.php
+++ b/Patients.php
@@ -5,9 +5,19 @@ if(!Authentification::checkUser(0)){
die();
};
-// formattage $_GET['type']
-$answerType = (isset($_GET['type'])) ? $_GET['type'] : null;
+function customCompression($input, $compression){
+ if( $compression ) return strtr(base64_encode(addslashes(gzcompress(serialize($input),9))), '+/=', '-_,');
+ else return unserialize(gzuncompress(stripslashes(base64_decode(strtr($input, '-_,', '+/=')))));
+}
+
+/* REPONSE DU MANAGER */
+$managerStatus = (isset($_GET['status'])) ? $_GET['status'] : null;
+$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
+$patientsSearch = ( isset($_GET['patients']) ) ? json_decode( customCompression($_GET['patients'], false) , true) : [];
?>
@@ -19,6 +29,7 @@ $answerType = (isset($_GET['type'])) ? $_GET['type'] : null;
+
@@ -26,17 +37,17 @@ $answerType = (isset($_GET['type'])) ? $_GET['type'] : null;
-
+
-
+
'>
-
Oups!
-
Certains champs sont incorrects. Veuillez réessayer.
-
+
+
+
@@ -55,25 +66,69 @@ $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:
+
+ ';
+ // début modification
+ echo " | ';
+ // fin modification
+
+ // début suppression
+ echo " | ';
+ // fin suppression
+
+ echo '';
+ }}
+
+ ?>
+
+
+
+
+
+
+
+
+
diff --git a/css/font.css b/css/font.css
new file mode 100755
index 0000000..bc2609a
--- /dev/null
+++ b/css/font.css
@@ -0,0 +1,23 @@
+/***************************/
+/**********Open Sans********/
+/***************************/
+
+@font-face{ /* REGULAR */
+ font-family: 'Open Sans';
+ src: url('./font/Open Sans/8.ttf');
+}
+
+
+@font-face{ /* BOLD */
+ font-family: 'Open Sans';
+ src: url('./font/Open Sans/9.ttf');
+ font-weight: bold;
+}
+
+
+
+@font-face{ /* ITALIC */
+ font-family: 'Open Sans';
+ src: url('./font/Open Sans/7.ttf');
+ font-style: italic;
+}
\ No newline at end of file
diff --git a/css/font/Open Sans/1.ttf b/css/font/Open Sans/1.ttf
new file mode 100755
index 0000000..fd79d43
Binary files /dev/null and b/css/font/Open Sans/1.ttf differ
diff --git a/css/font/Open Sans/10.ttf b/css/font/Open Sans/10.ttf
new file mode 100755
index 0000000..59b6d16
Binary files /dev/null and b/css/font/Open Sans/10.ttf differ
diff --git a/css/font/Open Sans/2.ttf b/css/font/Open Sans/2.ttf
new file mode 100755
index 0000000..9bc8009
Binary files /dev/null and b/css/font/Open Sans/2.ttf differ
diff --git a/css/font/Open Sans/3.ttf b/css/font/Open Sans/3.ttf
new file mode 100755
index 0000000..21f6f84
Binary files /dev/null and b/css/font/Open Sans/3.ttf differ
diff --git a/css/font/Open Sans/4.ttf b/css/font/Open Sans/4.ttf
new file mode 100755
index 0000000..31cb688
Binary files /dev/null and b/css/font/Open Sans/4.ttf differ
diff --git a/css/font/Open Sans/5.ttf b/css/font/Open Sans/5.ttf
new file mode 100755
index 0000000..c90da48
Binary files /dev/null and b/css/font/Open Sans/5.ttf differ
diff --git a/css/font/Open Sans/6.ttf b/css/font/Open Sans/6.ttf
new file mode 100755
index 0000000..0d38189
Binary files /dev/null and b/css/font/Open Sans/6.ttf differ
diff --git a/css/font/Open Sans/7.ttf b/css/font/Open Sans/7.ttf
new file mode 100755
index 0000000..68299c4
Binary files /dev/null and b/css/font/Open Sans/7.ttf differ
diff --git a/css/font/Open Sans/8.ttf b/css/font/Open Sans/8.ttf
new file mode 100755
index 0000000..db43334
Binary files /dev/null and b/css/font/Open Sans/8.ttf differ
diff --git a/css/font/Open Sans/9.ttf b/css/font/Open Sans/9.ttf
new file mode 100755
index 0000000..1a7679e
Binary files /dev/null and b/css/font/Open Sans/9.ttf differ
diff --git a/css/global.css b/css/global.css
index 7218cc2..aa9be64 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,78 @@ 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% / 6% );
+
+ /* border */
+ border-bottom: 1px solid #cacaca;
+}
+
+#CONTAINER > article table#searchResultMedecin td{
+ /* position */
+ max-width: calc( 100% / 5% );
+
+ /* border */
+ border-bottom: 1px solid #cacaca;
+}
+
+
+/* Suppression champ de recherche (patient/médecin/consultation) */
+#CONTAINER > article .delPatient input[type=submit],
+#CONTAINER > article .delMedecin input[type=submit]{
+ /* position */
+ padding: .5em 1em;
+
+ /* border */
+ border: 0;
+
+ /* background */
+ background-image: url(../src/svg/invalid.svg);
+ background-position: center center;
+}
+
+/* Modification champ de recherche (patient/médecin/consultation) */
+
+#CONTAINER > article .updPatient input[type=text],
+#CONTAINER > article .updMedecin input[type=text]{
+ width: 6em;
+ padding: .1em;
+ margin: 0 .2em;
+
+ border: 0;
+}
+
+
+
+#CONTAINER > article .updPatient input[type=submit],
+#CONTAINER > article .updMedecin input[type=submit]{
+ /* position */
+ padding: .5em 1em;
+
+ /* border */
+ border: 0;
+
+ /* background */
+ background-image: url(../src/svg/edit.svg);
+ background-position: center center;
+}
\ No newline at end of file
diff --git a/index.php b/index.php
index d464072..ce1e9e2 100755
--- a/index.php
+++ b/index.php
@@ -29,6 +29,7 @@ if(Authentification::checkUser(0)){
+
diff --git a/js/consultations.js b/js/consultations.js
index e376dc7..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);
@@ -41,35 +42,28 @@ if( newRDVPatient != null && newRDVMedecin != null ){
-/* VERIFICATION DES CHAMPS */
+
+
+/* [1] VERIFICATION DES CHAMPS DE LA CREATION
+======================================================*/
var inCk = new inputChecker();
var inDate = document.getElementById('inDate');
var inHeure = document.getElementById('inHeure');
- var inSecu = document.getElementById('inSecu');
var sbCreer = document.getElementById('sbCreer');
// format de date simplifié
var dateFormat = new formatChecker(null,
- 'Ji/Mi/2iii', { 'J': '[0-3]', 'M': '[0-1]' }
+ 'Ji/Mi/iiii', { 'J': '[0-3]', 'M': '[0-1]' }
);
// format de temps simplifié
var timeFormat = new formatChecker(null,
'Hi:Mi', { 'H': '[0-2]', 'M': '[0-6]' }
);
-// format numéro SECU simplifié
-var secuFormat = new formatChecker(null,
- 'S ii Mi ii iii iii ii', { 'S': '[0-1]', 'M': '[0-1]' }
-);
-
-
-var now = new Date();
inCk.append( inDate, dateFormat, '01/01/2015' );
inCk.append( inHeure, timeFormat, '23:59' );
-inCk.append( inSecu, secuFormat, inSecu.placeholder );
-
inDate.addEventListener('keyup', function(e){
if( inCk.check(inDate) ) addClass(inDate, 'validated'); // on active la classe si correct
@@ -98,48 +92,6 @@ inDuree.addEventListener('keyup', function(e){
remClass(inDuree, 'validated'); // on désactive la classe
}, false);
-function checkSecuControlKey(pNumSecu){
- var NIR = pNumSecu.slice(0,-2).replace(/ /g, '');
- var key = pNumSecu.slice(-2);
-
- return 97-(NIR%97) == key;
-}
-
-inSecu.addEventListener('keyup', function(e){
- if( inCk.check(inSecu) ){
-
- if( checkSecuControlKey(inSecu.value) ){ // si la clé est correcte
- addClass(inSecu, 'validated'); // on dis que le champ est valide
- remClass(inSecu, 'invalid'); // on dis qu'il n'est pas invalide
- }else{
- remClass(inSecu, 'validated'); // on dis que le champ n'est pas valide
- addClass(inSecu, 'invalid'); // on dis qu'il est invalide
- }
-
- }else{ // si incorrect
-
- remClass(inSecu, 'validated'); // on désactive la classe
- remClass(inSecu, 'invalid'); // on dis qu'il n'est pas invalide
-
- inCk.correct(inSecu, false); // on corrige partiellement
- if( inCk.check(inSecu) ){
-
- if( checkSecuControlKey(inSecu.value) ){ // si la clé est correcte
- addClass(inSecu, 'validated'); // on dis que le champ est valide
- remClass(inSecu, 'invalid'); // on dis qu'il n'est pas invalide
- }else{
- remClass(inSecu, 'validated'); // on dis que le champ n'est pas valide
- addClass(inSecu, 'invalid'); // on dis qu'il est invalide
- }
- }
- }
-}, false);
-
-
-// inDate.value = 'x3 F3/a8';
-// inHeure.value = 'x3 F3/a8';
-inSecu.value = '1 96 01 31 555 861';
-
@@ -166,11 +118,62 @@ sbCreer.addEventListener('click', function(e){
var inputCheckerValid = inCk.check(inDate) && inCk.check(inHeure);
var selectNoDefault = newRDVPatient.value != '*' && newRDVMedecin.value != '*';
- console.log( inputCheckerValid );
- console.log( checker );
- console.log( selectNoDefault );
-
- if( inputCheckerValid && checker && selectNoDefault ) // si tout es ok uniquement, on submit()
- sbCreer.parentNode.submit();
-}, false);
\ No newline at end of file
+ if( inputCheckerValid && checker && selectNoDefault ){ // si tout es ok uniquement, on submit()
+ var request = {
+ id_patient: newRDVPatient.value,
+ id_medecin: newRDVMedecin.value,
+ date: inDate.value,
+ heure: inHeure.value,
+ duree: inDuree.value
+ };
+
+ API.send('RDV:add', request, function(e){
+ notif(e.status, e.title, e.message);
+
+ 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);
+
+
+
+
+
+
+
+
+/* [2] Verification des champs de la consultation
+======================================================*/
+var inCk2 = new inputChecker();
+ var csMonth = document.getElementById('csMonth');
+ var csPatient = document.getElementById('csPatient');
+ var csMedecin = document.getElementById('csMedecin');
+
+
+// format de mois simplifié
+var monthFormat = new formatChecker(null, 'Mi/iiii', { 'M': '[0-1]' } );
+inCk2.append( csMonth, monthFormat, csMonth.placeholder );
+
+csMonth.addEventListener('keyup', function(e){
+ if( inCk2.check(csMonth) ) addClass(csMonth, 'validated'); // on active la classe si correct
+ else{ // si incorrect
+ remClass(csMonth, 'validated'); // on désactive la classe
+ inCk2.correct(csMonth, false); // on corrige partiellement
+ if( inCk2.check(csMonth) ) addClass(csMonth, 'validated'); // mise à jour de la classe après correction
+ }
+}, false);
+
+
+
+
+
+
+
+/* [3] Affinage du calendrier
+======================================================*/
diff --git a/js/lib/API.js b/js/lib/API.js
index 82b8b71..012f567 100755
--- a/js/lib/API.js
+++ b/js/lib/API.js
@@ -53,7 +53,7 @@ APIClass.prototype = {
if( ptrAPI.xhr[i].readyState == 4 ){ // si la requête est terminée
/* DEBUG : affiche la réponse BRUTE de API.php */
- console.log('managers/ => '+ptrAPI.xhr[i].responseText);
+ // console.log('managers/ => '+ptrAPI.xhr[i].responseText);
console.log( JSON.parse(ptrAPI.xhr[i].responseText) );
/* si success de requête */
@@ -77,7 +77,7 @@ APIClass.prototype = {
this.xhr[i].open('POST', '/managers/', true);
// on définit le HEADER
- this.xhr[i].setRequestHeader('X-Requested-With', 'XMLHttpRequest');
+ this.xhr[i].setRequestHeader('X-REQUESTED-WITH', 'XMLHttpRequest');
this.xhr[i].send( form );
}
diff --git a/js/lib/adjust.js b/js/lib/adjust.js
index d7cfe3e..4793979 100755
--- a/js/lib/adjust.js
+++ b/js/lib/adjust.js
@@ -26,6 +26,40 @@ function remClass(el, pClass){
+// var completeAccentList = "àAAÀAAÁÂÒÓÔÕÖØòÒÓÔÕ-ÖØòó_ôõöøÈÉÊËèéêëÇçÒÓÔÕÖØòÌÍÎÏìíîïÙÚÛÜùúûüÿÑñ";
+var accentList = 'àÀÈÉÊËèéêëçîïúû';
+
+/* Met à jour l'état visuel d'un si sa valeur correspond aux initères
+*
+* @pInputElement l'élément en question
+* @pMinLength la taille minimum autorisée
+* @pMaxLength la taille maximum autorisée
+* @optAlpha [OPT] TRUE si uniquement alphanumérique
+*/
+function checkVARCHAR(pInputElement, pMinLength, pMaxLength, optAlpha){
+ var optAlpha = (arguments.length > 3) ? optAlpha : false;
+ optAlpha = (typeof optAlpha == 'boolean') ? optAlpha : false;
+
+ var varcharRegExp;
+
+ if( optAlpha ) varcharRegExp = new RegExp('^(['+accentList+'a-z]{'+pMinLength+','+pMaxLength+'})$', 'i'); // only alpha characters
+ else varcharRegExp = new RegExp('^(['+accentList+'\\w -]{'+ pMinLength+','+pMaxLength+'})$', 'i'); // any word character
+
+ if( pInputElement.value.match(varcharRegExp) != null || pInputElement.value == '' ){ // si champ correct
+ addClass(pInputElement, 'validated');
+ if( pInputElement.required ) remClass(pInputElement, 'invalid');
+ }else{
+ remClass(pInputElement, 'validated');
+
+ if( pInputElement.required ) addClass(pInputElement, 'invalid');
+ }
+}
+
+
+
+
+
+
var notifState = false; // VRAI si affiché, sinon FAUX
function notif(pType, pTitle, pMessage){
/* [0] Variables globales
@@ -49,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 dfbf9aa..8aa0ee1 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);
@@ -85,4 +86,98 @@ 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('Medecin:search', request, function(e){
+ if( e.status != 'success' )
+ notif(e.status, e.title, e.message);
+
+ if( e.hasOwnProperty('medecins') )
+ displayFoundMedecins(e.medecins);
+ else
+ displayFoundMedecins([]);
+
+ 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 displayFoundMedecins(foundMedecins){
+ var container = document.getElementById('searchResultMedecin');
+ var content = '';
+
+ for( var i = 0 ; i < foundMedecins.length ; i++ ){
+ content += '';
+ content += ''+ ((foundMedecins[i].Civilite=='M')?'Monsieur':'Madame') + ' | ';
+ content += ''+ foundMedecins[i].Prenom + ' | ';
+ content += ''+ foundMedecins[i].Nom.toUpperCase() + ' | ';
+ // début modification
+ content += " | ';
+ // fin modification
+
+ // début suppression
+ content += " | ';
+ // fin suppression
+ content += '
';
+ }
+
+ content += '
';
+
+
+ // on vide le container
+ container.innerHTML = content;
+}
\ No newline at end of file
diff --git a/js/patients.js b/js/patients.js
index 2cf2a28..f3daeec 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);
@@ -30,34 +31,6 @@ inCk.append( inSecu, secuFormat, '1 99 19 99 999 999 99'); // on ajoute le
-// var completeAccentList = "àAAÀAAÁÂÒÓÔÕÖØòÒÓÔÕ-ÖØòó_ôõöøÈÉÊËèéêëÇçÒÓÔÕÖØòÌÍÎÏìíîïÙÚÛÜùúûüÿÑñ";
-var accentList = 'àÀÈÉÊËèéêëçîïúû';
-
-/* Met à jour l'état visuel d'un si sa valeur correspond aux initères
-*
-* @pInputElement l'élément en question
-* @pMinLength la taille minimum autorisée
-* @pMaxLength la taille maximum autorisée
-* @optAlpha [OPT] TRUE si uniquement alphanumérique
-*/
-function checkVARCHAR(pInputElement, pMinLength, pMaxLength, optAlpha){
- var optAlpha = (arguments.length > 3) ? optAlpha : false;
- optAlpha = (typeof optAlpha == 'boolean') ? optAlpha : false;
-
- var varcharRegExp;
-
- if( optAlpha ) varcharRegExp = new RegExp('^(['+accentList+'a-z]{'+pMinLength+','+pMaxLength+'})$', 'i'); // only alpha characters
- else varcharRegExp = new RegExp('^(['+accentList+'\\w -]{'+ pMinLength+','+pMaxLength+'})$', 'i'); // any word character
-
- if( pInputElement.value.match(varcharRegExp) != null || pInputElement.value == '' ){ // si champ correct
- addClass(pInputElement, 'validated');
- if( pInputElement.required ) remClass(pInputElement, 'invalid');
- }else{
- remClass(pInputElement, 'validated');
-
- if( pInputElement.required ) addClass(pInputElement, 'invalid');
- }
-}
//////////////////////////////
// PRENOM & NOM (VARCHAR 45)//
@@ -188,4 +161,104 @@ 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 += '';
+ // début modification
+ content += " | ';
+ // fin modification
+
+ // début suppression
+ content += " | ';
+ // fin suppression
+ 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 0b2436a..df77a08 100755
--- a/managers/Medecin.class.php
+++ b/managers/Medecin.class.php
@@ -1,5 +1,8 @@
'.$params['prenom'].' '.$params['nom'].' a bien été créé.';
+
+ 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?type=creation");
+ $response->setHeader('Location','http://'.$_SERVER['HTTP_HOST'].'/Medecins.php?status='.$_status.'&title='.$_title.'&message='.$_message);
+ $response->send();
+ }
+
+ /* ERREUR DE CREATION */
+ }else{
+ $_status = 'error';
+ $_title = 'Erreur de création!';
+ $_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'].'/Medecins.php?status='.$_status.'&title='.$_title.'&message='.$_message);
+ $response->send();
+ }
+ }
+ }
+
+
+ public function search($params){
+
+ /* RECHERCHE REUSSIE */
+ if( ($medList=MedecinRepo::search(strtolower($params['nom']), strtolower($params['prenom']))) !== FALSE ){
+ $_status = 'success';
+ $_title = 'Recherche effectuée!';
+ $_message = ''.count($medList).' médecin(s) trouvé(s)!';
+ $_medecins = $medList;
+
+ 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, 'medecins' => $_medecins ]));
+ else{
+ $response = new Response();
+ $response->setHeader('Location','http://'.$_SERVER['HTTP_HOST'].'/Medecins.php?status='.$_status.'&title='.$_title.'&message='.$_message.'&medecins='.customCompression(json_encode($_medecins), true));
$response->send();
- }else{
- Response::quickResponse(200, json_encode([
- 'status' => 'success',
- 'title' => 'Création effectuée!',
- 'message' => 'Le médecin '.$params['prenom'].' '.$params['nom'].' a bien été créé.'
- ]));
}
}else{
- if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ){
+ $_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']."/Medecins.php?type=error");
+ $response->setHeader('Location','http://'.$_SERVER['HTTP_HOST'].'/Medecins.php?status='.$_status.'&title='.$_title.'&message='.$_message);
$response->send();
- }else{
- Response::quickResponse(200, json_encode([
- 'status' => 'error',
- 'title' => 'Erreur de création!'
- ]));
}
}
}
public function delete($params){
- if(MedecinRepo::delete($params['id_medecin']) !==FALSE){
- if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ){
+ if( MedecinRepo::delete($params['id_medecin']) !== FALSE ){
+
+ $_status = 'success';
+ $_title = 'Médecin supprimé!';
+ $_message = 'Le médecin a bien été supprimé de la base de données! ';
+
+ 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?type=supression");
+ $response->setHeader('Location','http://'.$_SERVER['HTTP_HOST'].'/Medecins.php?status='.$_status.'&title='.$_title.'&message='.$_message);
$response->send();
- }else{
- Response::quickResponse(200, json_encode([
- 'status' => 'success',
- 'title' => 'Médecin supprimé!',
- 'message' => ''
- ]));
}
+
}else{
- if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ){
+
+ $_status = 'error';
+ $_title = 'Erreur de suppression!';
+ $_message = 'Erreur lors de la suppression. 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']."/Medecins.php?type=error");
+ $response->setHeader('Location','http://'.$_SERVER['HTTP_HOST'].'/Medecins.php?status='.$_status.'&title='.$_title.'&message='.$_message);
$response->send();
- }else{
- Response::quickResponse(200, json_encode([
- 'status' => 'error',
- 'title' => 'Erreur lors de la supression!'
- ]));
}
+
}
}
diff --git a/managers/Patient.class.php b/managers/Patient.class.php
index 23ea4d8..6d008c6 100755
--- a/managers/Patient.class.php
+++ b/managers/Patient.class.php
@@ -1,4 +1,8 @@
format('Y-m-d'),$params['lieu_naissance'],$params['num_secu'],$params['medecin_traitant']) !== FALSE){
- if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'){
+ $_status = 'success';
+ $_title = 'Création effectuée!';
+ $_message = 'Le patient '.$params['prenom'].' '.$params['nom'].' a bien été créé.';
+
+ 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?type=creation");
+ $response->setHeader('Location', 'http://'.$_SERVER['HTTP_HOST'].'/Patients.php?status='.$_status.'&title='.$_title.'&message='.$_message);
$response->send();
- }else{
- Response::quickResponse(200, json_encode([
- 'status' => 'success',
- 'title' => 'Création effectuée!',
- 'message' => 'Le patient '.$params['prenom'].' '.$params['nom'].' a bien été créé.'
- ]));
}
}else{
- if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'){
+ $_status = 'error';
+ $_title = 'Erreur de création!';
+ $_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?type=error");
+ $response->setHeader('Location', 'http://'.$_SERVER['HTTP_HOST'].'/Patients.php?status='.$_status.'&title='.$_title.'&message='.$_message);
$response->send();
- }else{
- Response::quickResponse(200, json_encode([
- 'status' => 'error',
- 'title' => 'Erreur de création!'
- ]));
}
+
}
}else{
- if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'){
+ $_status = 'error';
+ $_title = 'Erreur de création!';
+ $_message = 'Le format de la date est incorrect. 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?type=error");
+ $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->write("patients=".$compressed_json);
+ $response->setHeader('Location', 'http://'.$_SERVER['HTTP_HOST'].'/Patients.php?status='.$_status.'&title='.$_title.'&message='.$_message.'&patients='.customCompression( json_encode($_patients), true));
+ $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();
- }else{
- Response::quickResponse(200, json_encode([
- 'status' => 'error',
- 'title' => 'Erreur de paramètre',
- 'message' => 'Date incorrecte'
- ]));
}
}
}
@@ -58,67 +97,73 @@ class Patient
$params['date_naissance'] = DateTime::createFromFormat('d/m/Y', $params['date_naissance']);
if(PatientRepo::update($params['id_patient'],$params['civilite'],strtolower($params['prenom']),strtolower($params['nom']),$params['adresse'],$params['adresse2'],$params['ville'],$params['cope_postal'],
$params['date_naissance']->format('Y-m-d'),$params['lieu_naissance'],$params['num_secu'],$params['medecin_traitant']) !==FALSE){
- if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'){
+
+ $_status = 'success';
+ $_title = 'Modification effectuée!';
+ $_message = 'Le patient '.$params['prenom'].' '.$params['nom'].' a bien été modifié.';
+
+ 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?type=maj");
+ $response->setHeader('Location', 'http://'.$_SERVER['HTTP_HOST'].'/Patients.php?status='.$_status.'&title='.$_title.'&message='.$_message);
$response->send();
- }else{
- Response::quickResponse(200, json_encode([
- 'status' => 'success',
- 'title' => 'Modification effectuée!',
- 'message' => 'Le patient '.$params['prenom'].' '.$params['nom'].' a bien été modifié.'
- ]));
}
+
}else{
- if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'){
+ $_status = 'error';
+ $_title = 'Erreur de modification!';
+ $_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?type=error");
+ $response->setHeader('Location', 'http://'.$_SERVER['HTTP_HOST'].'/Patients.php?status='.$_status.'&title='.$_title.'&message='.$_message);
$response->send();
- }else{
- Response::quickResponse(200, json_encode([
- 'status' => 'error',
- 'title' => 'Erreur de création!'
- ]));
}
}
}else{
- if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'){
+ $_status = 'error';
+ $_title = 'Erreur de modification!';
+ $_message = 'Le format de la date est incorrect. 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?type=error");
+ $response->setHeader('Location', 'http://'.$_SERVER['HTTP_HOST'].'/Patients.php?status='.$_status.'&title='.$_title.'&message='.$_message);
$response->send();
- }else{
- Response::quickResponse(200, json_encode([
- 'status' => 'error',
- 'title' => 'Erreur de paramètre',
- 'message' => 'Date incorrecte'
- ]));
}
}
}
public function delete($params){
- if(PatientRepo::delete($params['id_patient']) !==FALSE){
- if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'){
+ if( PatientRepo::delete($params['id_patient']) !== FALSE ){
+
+ $_status = 'success';
+ $_title = 'Patient supprimé!';
+ $_message = 'Le patient a bien été supprimé de la base de données!';
+
+ 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?type=supression");
+ $response->setHeader('Location', 'http://'.$_SERVER['HTTP_HOST'].'/Patients.php?status='.$_status.'&title='.$_title.'&message='.$_message);
$response->send();
- }else{
- Response::quickResponse(200, json_encode([
- 'status' => 'success',
- 'title' => 'Supression effectuée!',
- 'message' => 'Le patient a bien été supprimé.'
- ]));
}
+
}else{
- if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'){
+ $_status = 'error';
+ $_title = 'Erreur de suppression!';
+ $_message = 'Erreur lors de la suppression. 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?type=error");
+ $response->setHeader('Location', 'http://'.$_SERVER['HTTP_HOST'].'/Patients.php?status='.$_status.'&title='.$_title.'&message='.$_message);
$response->send();
- }else{
- Response::quickResponse(200, json_encode([
- 'status' => 'error',
- 'title' => 'Erreur lors de la supression!'
- ]));
}
}
}
diff --git a/managers/RDV.class.php b/managers/RDV.class.php
index d6ac348..f34d5d9 100755
--- a/managers/RDV.class.php
+++ b/managers/RDV.class.php
@@ -9,70 +9,70 @@
class RDV
{
public function add($params){
- if(StaticRepo::checkParam($params['date_naissance'],'Date')) {
+ if(StaticRepo::checkParam($params['date'],'Date')) {
$params['date'] = DateTime::createFromFormat('d/m/Y', $params['date']);
if (RDVRepo::add($params['date']->format('Y-m-d') . ' ' . $params['heure'] . ':00', $params['duree'], $params['id_patient'], $params['id_medecin']) !== FALSE) {
- if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ){
- $response = new Response();
- $response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Consultations.php?type=creation");
- $response->send();
- }else{
+ if( !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ){
Response::quickResponse(200, json_encode([
'status' => 'success',
'title' => 'Création effectuée!',
'message' => 'La consultation du '.$params['date']->format('d/m/Y').' à '.$params['heure'].' a bien été créée.'
]));
+ }else{
+ $response = new Response();
+ $response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Consultations.php?type=creation");
+ $response->send();
}
}else{
- if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ){
- $response = new Response();
- $response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Consultations.php?type=error");
- $response->send();
- }else{
+ if( !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ){
Response::quickResponse(200, json_encode([
'status' => 'error',
'title' => 'Erreur de création!'
]));
+ }else{
+ $response->send();
+ $response = new Response();
+ $response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Consultations.php?type=error");
}
}
}else{
- if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ){
- $response = new Response();
- $response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Consultations.php?type=error");
- $response->send();
- }else{
+ if( !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ){
Response::quickResponse(200, json_encode([
'status' => 'error',
'title' => 'Erreur de paramètre',
'message' => 'Date incorrecte'
]));
+ }else{
+ $response = new Response();
+ $response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Consultations.php?type=error");
+ $response->send();
}
}
}
public function delete($params){
if(RDVRepo::delete($params['id_consultation']) !==FALSE){
- if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ){
- $response = new Response();
- $response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Consultations.php?type=supression");
- $response->send();
- }else{
+ if( !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ){
Response::quickResponse(200, json_encode([
'status' => 'success',
'title' => 'Supression effectuée!',
'message' => 'La consultation a bien été supprimée.'
]));
+ }else{
+ $response = new Response();
+ $response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Consultations.php?type=supression");
+ $response->send();
}
}else{
- if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ){
- $response = new Response();
- $response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Consultations.php?type=error");
- $response->send();
- }else{
+ if( !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ){
Response::quickResponse(200, json_encode([
'status' => 'error',
'title' => 'Erreur lors de la supression!'
]));
+ }else{
+ $response = new Response();
+ $response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Consultations.php?type=error");
+ $response->send();
}
}
}
diff --git a/managers/config/managers.json b/managers/config/managers.json
index 407b7ab..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},
@@ -26,6 +29,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/StaticRepo.php b/repositories/StaticRepo.php
index 34c68b4..6cd1239 100755
--- a/repositories/StaticRepo.php
+++ b/repositories/StaticRepo.php
@@ -63,13 +63,13 @@ class StaticRepo{
}else{
// on supprime les doublons des entrées (indice numérique)
- foreach($fetchData as $i=>$val){ // pour toutes les entrées
+ foreach($fetchData as $i=>$val){ // pour toutes les entrées
if( !mb_detect_encoding($val, 'UTF-8') )
$fetchData[$i] = utf8_encode($val);
- if( is_int($i) ) // si l'indice est un entier
- unset( $fetchData[$i] ); // on le supprime
+ if( is_int($i) ) // si l'indice est un entier
+ unset( $fetchData[$i] ); // on le supprime
}
}
@@ -120,36 +120,40 @@ class StaticRepo{
switch($dbtype){
// [1] 'M' / 'F'
case 'Civilite':
- $checker = $checker && is_string($variable) && in_array($variable, ['M','F']);
+ $checker = $checker && !is_null($variable) && is_string($variable) && in_array($variable, ['M','F']);
break;
// [2] Chaine de caractère (longueur variable)
case 'String':
- $checker = $checker && is_string($variable) && strlen($variable) <= $len;
+ $checker = $checker && !is_null($variable) && is_string($variable) && strlen($variable) > 0 && strlen($variable) <= $len;
break;
case 'Integer':
- $checker = $checker && is_int($variable) && $variableprepare('SELECT * FROM Medecin WHERE Id = :id');
$req->execute(['id' => $id]);
@@ -21,41 +21,52 @@ class MedecinRepo
public static function add($civilite,$prenom,$nom){
- if(!StaticRepo::checkParam($civilite,'Civilite') && !StaticRepo::checkParam($prenom,'String45') && !StaticRepo::checkParam($nom,'String45')){return false;}
+ if(!StaticRepo::checkParam($civilite,'Civilite') && !StaticRepo::checkParam($prenom,'String45') && !StaticRepo::checkParam($nom,'String45')) return false;
$req = StaticRepo::getConnexion()->prepare('INSERT INTO Medecin VALUES (DEFAULT,:civilite,:prenom,:nom)');
$result = $req->execute(['civilite' => $civilite,
'nom' => $nom,
- 'prenom' => $prenom]);
+ 'prenom' => $prenom
+ ]);
+
//PDO renvoie un ID sous forme de char, on transtype
$id = StaticRepo::getConnexion()->lastInsertId();
- settype($id,'integer');
- if($result){return $id;}
- else{return false;}
+ settype($id, 'integer');
+
+
+ if($result) return $id;
+ else return false;
}
public static function delete($idMedecin){
- if(!StaticRepo::checkParam($idMedecin,'Integer')){return false;}
+ if(!StaticRepo::checkParam($idMedecin,'Numeric')) return false;
$req = StaticRepo::getConnexion()->prepare('DELETE FROM Medecin WHERE Id = :id');
return $req->execute(['id' => $idMedecin]);
}
- public static function search($nom,$prenom){
+ public static function search($nom, $prenom){
- if(!StaticRepo::checkParam($prenom,'String45') && !StaticRepo::checkParam($nom,'String45')){return false;}
+ if( !StaticRepo::checkParam($prenom,'String45') && !StaticRepo::checkParam($nom,'String45') ) return false;
- $req = StaticRepo::getConnexion()->prepare('SELECT * FROM Medecin WHERE Nom LIKE :nom AND Prenom LIKE :prenom');
- $req->execute(['nom' => $nom,
- 'prenom' => $prenom]);
+ // on définit les valeurs (peuvent être nulles)
+ $optPrenom = ( $prenom != 'null' && StaticRepo::checkParam($prenom,'String45') ) ? '%'.$prenom.'%' : '%';
+ $optNom = ( $nom != 'null' && StaticRepo::checkParam($nom, 'String45') ) ? '%'.$nom.'%' : '%';
- return StaticRepo::delNumeric($req->fetchAll());
+ $req = StaticRepo::getConnexion()->query("SELECT Id, Civilite, Prenom, Nom
+ FROM Medecin
+ WHERE Nom LIKE '".$optNom."'
+ AND Prenom LIKE '".$optPrenom."'
+ ORDER BY Nom, Prenom ASC");
+
+
+ return StaticRepo::delNumeric( $req->fetchAll() );
}
public static function getPatients($idMedecin){
- if(!StaticRepo::checkParam($idMedecin,'Integer')){return false;}
+ if(!StaticRepo::checkParam($idMedecin,'Numeric')) return false;
$req = StaticRepo::getConnexion()->prepare('SELECT Patient.* FROM Patient,Medecin
WHERE Medecin.Id = :id
diff --git a/repositories/repos/PatientRepo.php b/repositories/repos/PatientRepo.php
index 193684c..edc3743 100755
--- a/repositories/repos/PatientRepo.php
+++ b/repositories/repos/PatientRepo.php
@@ -28,11 +28,11 @@ class PatientRepo
$correctTypes = $correctTypes && StaticRepo::checkParam($codePostal,'String');
$correctTypes = $correctTypes && StaticRepo::checkParam($dateNaissance,'Date');
$correctTypes = $correctTypes && StaticRepo::checkParam($lieuNaissance,'String50');
- $correctTypes = $correctTypes && ( $medecinTraitant == 'null' || $medecinTraitant === null ||StaticRepo::checkParam($medecinTraitant, 'Integer') );
+ $correctTypes = $correctTypes && ( $medecinTraitant == 'null' || StaticRepo::checkParam($medecinTraitant, 'Numeric'));
if( !$correctTypes ) return false;
$dateNaissance = strtotime($dateNaissance);
- $dateNaissance = Date('o-m-d',$dateNaissance);
+ $dateNaissance = Date('o-m-d', $dateNaissance);
$req = StaticRepo::getConnexion()->prepare("INSERT INTO Patient
VALUES(DEFAULT,
@@ -112,10 +112,12 @@ class PatientRepo
public static function delete($idPatient){
- if(!StaticRepo::checkParam($idPatient,'Integer')){ return false;}
+ // si format erroné, retourne FALSE
+ if( !StaticRepo::checkParam($idPatient, 'Numeric') ) return false;
$req = StaticRepo::getConnexion()->prepare('DELETE FROM Patient WHERE Patient.Id = :id');
- return $req->execute(['id' => $idPatient]);
+
+ return $req->execute([':id' => $idPatient]);
}
@@ -128,16 +130,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 Id, Civilite, Nom, Prenom, DATE_FORMAT(DateNaissance, '%d/%m/%Y') as 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');
diff --git a/src/calendrier.svg b/src/calendrier.svg
old mode 100644
new mode 100755
diff --git a/src/calendrier_code.svg b/src/calendrier_code.svg
old mode 100644
new mode 100755
diff --git a/src/svg/edit.svg b/src/svg/edit.svg
new file mode 100755
index 0000000..41ae019
--- /dev/null
+++ b/src/svg/edit.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/test.php b/test.php
index 9d96d0f..d45232b 100755
--- a/test.php
+++ b/test.php
@@ -6,12 +6,10 @@
* Time: 11:40
*/
require_once('autoloader.php');
-$rdv=new RDV();
?>
-
getSVG(['mois' => '2015-11']);
?>
+// Response::quickResponse(200,'lol');
+$json = [
+ [
+ "nom" => "Alex",
+ "prenom" => "Alex",
+ ],
+
+ [
+ "nom" => "Alex",
+ "prenom" => "Alex",
+ ],
+
+ [
+ "nom" => "Alex",
+ "prenom" => "Alex",
+ ],
+
+ [
+ "nom" => "Alex",
+ "prenom" => "Alex",
+ ],
+
+ [
+ "nom" => "Alex",
+ "prenom" => "Alex",
+ ],
+
+ [
+ "nom" => "Alex",
+ "prenom" => "Alex",
+ ],
+
+ [
+ "nom" => "Alex",
+ "prenom" => "Alex",
+ ],
+
+ [
+ "nom" => "Alex",
+ "prenom" => "Alex",
+ ],
+
+ [
+ "nom" => "Alex",
+ "prenom" => "Alex",
+ ],
+
+ [
+ "nom" => "Alex",
+ "prenom" => "Alex",
+ ]
+];
+
+$compressed = compress( json_encode($json) );
+$uncompressed = uncompress( $compressed );
+
+echo $compressed.'
';
+echo $uncompressed.'
';
+
+
+
+
+
+
+
+
+
+
+
+
+function customCompression($input, compression){
+ if( $compression ) return strtr(base64_encode(addslashes(gzcompress(serialize($input),9))), '+/=', '-_,');
+ else return unserialize(gzuncompress(stripslashes(base64_decode(strtr($input, '-_,', '+/=')))));
+}
+
+function uncompress($input){
+
+}