diff --git a/Consultations.php b/Consultations.php index 064d455..3b985a6 100755 --- a/Consultations.php +++ b/Consultations.php @@ -41,22 +41,21 @@ if(!Authentification::checkUser(0)){ -
Choix du patient
Le médecin traitant se selectionne par défaut
diff --git a/css/global.css b/css/global.css index 1828c13..b1248e3 100755 --- a/css/global.css +++ b/css/global.css @@ -276,6 +276,13 @@ body{ -webkit-appearance: none; -ms-appearance: none; -o-appearance: none; + + /* animation */ + transition: all .2s ease-in-out; + -moz-transition: all .2s ease-in-out; + -webkit-transition: all .2s ease-in-out; + -ms-transition: all .2s ease-in-out; + -o-transition: all .2s ease-in-out; } /* */ #CONTAINER > article input{ @@ -304,13 +315,6 @@ body{ /* border */ border: 1px solid #e5e5e5; - - /* animation */ - transition: all .2s ease-in-out; - -moz-transition: all .2s ease-in-out; - -webkit-transition: all .2s ease-in-out; - -ms-transition: all .2s ease-in-out; - -o-transition: all .2s ease-in-out; } /* @focus */ diff --git a/js/adjust.js b/js/adjust.js index 81f3a9b..ce85847 100755 --- a/js/adjust.js +++ b/js/adjust.js @@ -6,4 +6,15 @@ NodeList.prototype.indexOf = HTMLCollection.prototype.indexOf = function(searche // si on a rien trouvé, on retourne -1 return -1; -}; \ No newline at end of file +}; + + +function addClass(el, pClass){ + if( el.className.length > 0 && el.className != pClass ) el.className = el.className + ' ' + pClass; + else el.className = pClass; +} + +function remClass(el, pClass){ + if( el.className.indexOf(pClass) > -1 ) // si la class de l'élement contient la classe à enlever + el.className = el.className.substr(0, el.className.indexOf(pClass)) + '' + el.className.substr(el.className.indexOf(pClass)+pClass.length); +} \ No newline at end of file diff --git a/js/consultations.js b/js/consultations.js index 8c3131b..20c9a7a 100755 --- a/js/consultations.js +++ b/js/consultations.js @@ -7,17 +7,27 @@ var newRDVMedecin = document.getElementById('newRDVMedecin'); ===============================================================*/ if( newRDVPatient != null && newRDVMedecin != null ){ - - // on selectionne dynamiquement le médecin traitant associé + /* [1] On selectionne dynamiquement le médecin traitant associé + =======================================================================*/ newRDVPatient.addEventListener('change', function(e){ - var value = e.target.value; - var child = document.querySelector("#newRDVPatient > option[value='"+value+"'][data-medecin]"); + var child = document.querySelector("#newRDVPatient > option[value='"+newRDVPatient.value+"'][data-medecin]"); // on selectionne le medecin associé newRDVMedecin.value = child.dataset.medecin; + addClass(newRDVMedecin, 'associated'); }, false); + // [1] On met en valeur le médecin traitant associé (class=associated) + // ======================================================================= + newRDVMedecin.addEventListener('change', function(e){ + var child = document.querySelector("#newRDVPatient > option[value='"+newRDVPatient.value+"'][data-medecin]"); + if( newRDVMedecin.value == child.dataset.medecin ) // si c'est le medecin traitant, on met en valeur l'association + addClass(newRDVMedecin, 'associated'); + else + remClass(newRDVMedecin, 'associated'); + + }, false); } diff --git a/repositories/repos/MedecinRepo.php b/repositories/repos/MedecinRepo.php index 61df40e..f5dfa0c 100755 --- a/repositories/repos/MedecinRepo.php +++ b/repositories/repos/MedecinRepo.php @@ -48,4 +48,12 @@ class MedecinRepo return StaticRepo::delNumeric($req->fetchAll()); } + public static function getAll(){ + + $req = StaticRepo::getConnexion()->query('SELECT * FROM Medecin ORDER BY nom, prenom ASC'); + + return StaticRepo::delNumeric( $req->fetchAll() ); + + } + } diff --git a/repositories/repos/PatientRepo.php b/repositories/repos/PatientRepo.php index d5bc239..f947092 100755 --- a/repositories/repos/PatientRepo.php +++ b/repositories/repos/PatientRepo.php @@ -8,25 +8,25 @@ */ class PatientRepo { - private $connexion; + // private $connexion; - public function __construct(){ - $this->connexion = StaticRepo::getConnexion(); - } + // public function __construct(){ + // StaticRepo::getConnexion() = StaticRepo::getConnexion(); + // } - public function getById($id){ - $req = $this->connexion->prepare('SELECT * FROM Patient WHERE Id = :id'); + public static function getById($id){ + $req = StaticRepo::getConnexion()->prepare('SELECT * FROM Patient WHERE Id = :id'); $req->execute(['id' => $id]); return StaticRepo::delNumeric( $req->fetch(), true ); } - public function add($civilite,$prenom,$nom,$adresse,$adresse2,$ville,$codePostal,$dateNaissance,$lieuNaissance,$numSecu,$medecinTraitant = null){ + public static function add($civilite,$prenom,$nom,$adresse,$adresse2,$ville,$codePostal,$dateNaissance,$lieuNaissance,$numSecu,$medecinTraitant = null){ $dateNaissance = strtotime($dateNaissance); $dateNaissance = Date('o-m-d',$dateNaissance); - $req = $this->connexion->prepare('INSERT INTO Patient VALUES (:civilite,:nom,:prenom,:adresse,:adresse2,:ville,:codePostal,:dateNaissance,:lieuNaissance,:numSecu,DEFAULT,:medecin)'); + $req = StaticRepo::getConnexion()->prepare('INSERT INTO Patient VALUES (:civilite,:nom,:prenom,:adresse,:adresse2,:ville,:codePostal,:dateNaissance,:lieuNaissance,:numSecu,DEFAULT,:medecin)'); $result = $req->execute(['civilite' => $civilite, 'nom' => $nom, 'prenom' => $prenom, @@ -38,34 +38,39 @@ class PatientRepo 'lieuNaissance' => $lieuNaissance, 'numSecu' => $numSecu, 'medecin' => $medecinTraitant ]); - if($result != false){return $this->connexion->lastInsertId();} + if($result){return ['id' => StaticRepo::getConnexion()->lastInsertId()];} else{return false;} } - public function delete($idPatient){ + public static function delete($idPatient){ - $req = $this->connexion->prepare('DELETE FROM Patient WHERE Id = :id'); - return $req->execute(['id' => $idPatient]); + $req = StaticRepo::getConnexion()->prepare('DELETE FROM Patient WHERE Id = :id'); + return $req->execute(['id' => $idPatient]); } - public function updateMedecinTraitant($idPatient,$idMedecin){ + public static function updateMedecinTraitant($idPatient,$idMedecin){ - $req = $this->connexion->prepare('UPDATE Patient SET MedecinTraitant = :medecin WHERE Id = :id'); - return $req->execute(['medecin' => $idMedecin, - 'id' => $idPatient]); + $req = StaticRepo::getConnexion()->prepare('UPDATE Patient SET MedecinTraitant = :medecin WHERE Id = :id'); + return $req->execute(['medecin' => $idMedecin, 'id' => $idPatient]); } - public function search($nom,$prenom){ - - $req = $this->connexion->prepare('SELECT * FROM Patient WHERE Nom LIKE :nom AND Prenom LIKE :prenom'); - $req->execute(['nom' => $nom, - 'prenom' => $prenom]); + 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()); } + public static function getAll(){ + + $req = StaticRepo::getConnexion()->query('SELECT * FROM Patient ORDER BY nom, prenom ASC'); + + return StaticRepo::delNumeric( $req->fetchAll() ); + + } + }