...
This commit is contained in:
parent
4c9ed8f692
commit
0ce9ca7fd8
|
@ -65,13 +65,48 @@ $answerType = (isset($_GET['type'])) ? $_GET['type'] : null;
|
||||||
echo '<span>';
|
echo '<span>';
|
||||||
switch($answerType){
|
switch($answerType){
|
||||||
case 'creation': echo 'Patient créé.'; break;
|
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;
|
case 'error': echo 'Une erreur est survenue.'; break;
|
||||||
default: echo 'rien à déclarer ? Non!'; break;
|
default: echo 'rien à déclarer ? Non!'; break;
|
||||||
}
|
}
|
||||||
echo '</span>';
|
echo '</span>';
|
||||||
|
|
||||||
}
|
}/************************************/
|
||||||
/*************************************/
|
/* CONSULTER LES RENDEZ-VOUS */
|
||||||
|
/*************************************/ ?>
|
||||||
|
<article data-title="Calendrier des consultations">
|
||||||
|
<div>
|
||||||
|
<input type='text' id='csMonth' placeholder='12/2015'>Mois à afficher.<br>
|
||||||
|
<select id='csPatient' name='id_patient'>
|
||||||
|
<option value='*'>Tous les patients:</option>
|
||||||
|
<?php
|
||||||
|
foreach(PatientRepo::getAll() as $PATIENT)
|
||||||
|
echo "<option value='".$PATIENT['Id']."' data-medecin='".$PATIENT['MedecinTraitant']."'>".$PATIENT['Nom']." ".$PATIENT['Prenom']."</option>";
|
||||||
|
?>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
<select id='csMedecin' name='id_medecin'>
|
||||||
|
<option value='*'>Tous les médecins:</option>
|
||||||
|
<?php
|
||||||
|
foreach(MedecinRepo::getAll() as $MEDECIN)
|
||||||
|
echo "<option value='".$MEDECIN['Id']."'>".$MEDECIN['Nom']." ".$MEDECIN['Prenom']."</option>";
|
||||||
|
?>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<input type='submit' value='Affiner'>
|
||||||
|
</div><br>
|
||||||
|
|
||||||
|
<!-- HERE COMES THE SVG -->
|
||||||
|
|
||||||
|
</article>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<?php/*************************************/
|
||||||
/* SAISIR UN RENDEZ-VOUS */
|
/* SAISIR UN RENDEZ-VOUS */
|
||||||
/*************************************/ ?>
|
/*************************************/ ?>
|
||||||
<article data-title="Saisir un rendez-vous">
|
<article data-title="Saisir un rendez-vous">
|
||||||
|
@ -105,23 +140,6 @@ $answerType = (isset($_GET['type'])) ? $_GET['type'] : null;
|
||||||
|
|
||||||
</article>
|
</article>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<?php/********************************/
|
|
||||||
/* CONSULTER LES RENDEZ-VOUS */
|
|
||||||
/*************************************/ ?>
|
|
||||||
<article data-title="Numéro de sécurité sociale">
|
|
||||||
<div>
|
|
||||||
<input type='radio' name='filter_c' id='tousRDV' checked><label for='tousRDV'>Toutes les consultations</label><br>
|
|
||||||
<input type='radio' name='filter_c' id='pastRDV'><label for='pastRDV'>Consultations passées</label><br>
|
|
||||||
<input type='radio' name='filter_c' id='fturRDV'><label for='fturRDV'>Consultations à venir</label><br>
|
|
||||||
<input type='submit' value='Rechercher'>
|
|
||||||
|
|
||||||
<input type='text' id='inSecu' placeholder='1 99 19 99 999 999 99'><span class='invalid'>Clé de contrôle invalide.</span>
|
|
||||||
</div>
|
|
||||||
</article>
|
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
16
Medecins.php
16
Medecins.php
|
@ -74,6 +74,22 @@ $answerType = (isset($_GET['type'])) ? $_GET['type'] : null;
|
||||||
|
|
||||||
}
|
}
|
||||||
/*************************************/
|
/*************************************/
|
||||||
|
/* CONSULTER LES MÉDECIN */
|
||||||
|
/*************************************/ ?>
|
||||||
|
<article data-title="Rechercher un médecin">
|
||||||
|
<form method='POST' action='managers/'>
|
||||||
|
<br><h4>Recherche par nom et/ou prénom:</h4>
|
||||||
|
<input type='text' id='srPrenom' name='prenom' placeholder='Prénom' value='' required><br>
|
||||||
|
<input type='text' id='srNom' name='nom' placeholder='NOM' value='' required><br>
|
||||||
|
<br>
|
||||||
|
|
||||||
|
<input type='hidden' name='command' value='Medecin:search'>
|
||||||
|
<input type='submit' id='sbCherche' value='Lancer la recherche'>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
</article>
|
||||||
|
|
||||||
|
<?php/**********************************/
|
||||||
/* AJOUTER UN MÉDECIN */
|
/* AJOUTER UN MÉDECIN */
|
||||||
/*************************************/ ?>
|
/*************************************/ ?>
|
||||||
<article data-title="Ajouter un médecin">
|
<article data-title="Ajouter un médecin">
|
||||||
|
|
|
@ -77,7 +77,7 @@ APIClass.prototype = {
|
||||||
|
|
||||||
this.xhr[i].open('POST', '/managers/', true);
|
this.xhr[i].open('POST', '/managers/', true);
|
||||||
// on définit le HEADER
|
// 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 );
|
this.xhr[i].send( form );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,40 @@ function remClass(el, pClass){
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// var completeAccentList = "àAAÀAAÁÂÒÓÔÕÖØòÒÓÔÕ-ÖØòó_ôõöøÈÉÊËèéêëÇçÒÓÔÕÖØòÌÍÎÏìíîïÙÚÛÜùúûüÿÑñ";
|
||||||
|
var accentList = 'àÀÈÉÊËèéêëçîïúû';
|
||||||
|
|
||||||
|
/* Met à jour l'état visuel d'un <input> si sa valeur correspond aux initères
|
||||||
|
*
|
||||||
|
* @pInputElement<HTMLInputElement> l'élément <input> en question
|
||||||
|
* @pMinLength<int> la taille minimum autorisée
|
||||||
|
* @pMaxLength<int> la taille maximum autorisée
|
||||||
|
* @optAlpha<String> [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
|
var notifState = false; // VRAI si affiché, sinon FAUX
|
||||||
function notif(pType, pTitle, pMessage){
|
function notif(pType, pTitle, pMessage){
|
||||||
/* [0] Variables globales
|
/* [0] Variables globales
|
||||||
|
|
|
@ -86,3 +86,52 @@ sbCreer.addEventListener('click', function(e){
|
||||||
notif('error', 'Oups!', 'Certains champs sont requis ou incorrects.');
|
notif('error', 'Oups!', 'Certains champs sont requis ou incorrects.');
|
||||||
}
|
}
|
||||||
}, false);
|
}, 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;
|
||||||
|
var correctPrenom = srPrenom.className.indexOf('validated') > -1;
|
||||||
|
|
||||||
|
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){
|
||||||
|
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);
|
|
@ -30,34 +30,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 <input> si sa valeur correspond aux initères
|
|
||||||
*
|
|
||||||
* @pInputElement<HTMLInputElement> l'élément <input> en question
|
|
||||||
* @pMinLength<int> la taille minimum autorisée
|
|
||||||
* @pMaxLength<int> la taille maximum autorisée
|
|
||||||
* @optAlpha<String> [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)//
|
// PRENOM & NOM (VARCHAR 45)//
|
||||||
|
|
|
@ -35,6 +35,34 @@ class Medecin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function search($params){
|
||||||
|
if( ($medList=MedecinRepo::search(strtolower($params['nom']), strtolower($params['prenom']))) !== FALSE ){
|
||||||
|
if( !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ){
|
||||||
|
Response::quickResponse(200, json_encode([
|
||||||
|
'status' => 'success',
|
||||||
|
'medecins' => $medList
|
||||||
|
]));
|
||||||
|
}else{
|
||||||
|
$response = new Response();
|
||||||
|
$response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Medecins.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' => 'error',
|
||||||
|
'title' => 'Oups!',
|
||||||
|
'message' => 'Aucun médecin trouvé.'
|
||||||
|
]));
|
||||||
|
}else{
|
||||||
|
$response = new Response();
|
||||||
|
$response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Medecins.php?type=error");
|
||||||
|
$response->send();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function delete($params){
|
public function delete($params){
|
||||||
if(MedecinRepo::delete($params['id_medecin']) !==FALSE){
|
if(MedecinRepo::delete($params['id_medecin']) !==FALSE){
|
||||||
if( !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ){
|
if( !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ){
|
||||||
|
|
|
@ -26,6 +26,9 @@
|
||||||
"add":{"method":"add",
|
"add":{"method":"add",
|
||||||
"role":0,
|
"role":0,
|
||||||
"strict":false},
|
"strict":false},
|
||||||
|
"search":{"method":"search",
|
||||||
|
"role":0,
|
||||||
|
"strict":false},
|
||||||
"delete":{"method": "delete",
|
"delete":{"method": "delete",
|
||||||
"role": 0,
|
"role": 0,
|
||||||
"strict": false}
|
"strict": false}
|
||||||
|
|
|
@ -63,13 +63,13 @@ class StaticRepo{
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
// on supprime les doublons des entrées (indice numérique)
|
// 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') )
|
if( !mb_detect_encoding($val, 'UTF-8') )
|
||||||
$fetchData[$i] = utf8_encode($val);
|
$fetchData[$i] = utf8_encode($val);
|
||||||
|
|
||||||
if( is_int($i) ) // si l'indice est un entier
|
if( is_int($i) ) // si l'indice est un entier
|
||||||
unset( $fetchData[$i] ); // on le supprime
|
unset( $fetchData[$i] ); // on le supprime
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,15 +42,23 @@ class MedecinRepo
|
||||||
return $req->execute(['id' => $idMedecin]);
|
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');
|
// on définit les valeurs (peuvent être nulles)
|
||||||
$req->execute(['nom' => $nom,
|
$optPrenom = ( !StaticRepo::checkParam($prenom,'String45') ) ? '%'.$prenom.'%' : '%';
|
||||||
'prenom' => $prenom]);
|
$optNom = ( !StaticRepo::checkParam($nom, 'String45') ) ? '%'.$nom.'%' : '%';
|
||||||
|
|
||||||
return StaticRepo::delNumeric($req->fetchAll());
|
|
||||||
|
$req = StaticRepo::getConnexion()->query("SELECT *
|
||||||
|
FROM Medecin
|
||||||
|
WHERE Nom LIKE '".$optNom."'
|
||||||
|
AND Prenom LIKE '".$optPrenom."'
|
||||||
|
");
|
||||||
|
|
||||||
|
|
||||||
|
return StaticRepo::delNumeric( $req->fetchAll() );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getPatients($idMedecin){
|
public static function getPatients($idMedecin){
|
||||||
|
|
Loading…
Reference in New Issue