From 9fe7bae29c11d366b2d76ecf5cf0e2e9a5b12f03 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Tue, 8 Dec 2015 08:50:30 +0100 Subject: [PATCH] =?UTF-8?q?Impl=C3=A9mentation=20du=20Fetch=20des=20donn?= =?UTF-8?q?=C3=A9es=20pour=20prendre=20un=20RDV=20(uniquement=20humaines)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Consultations.php | 13 +++--- css/global.css | 18 +++++--- js/adjust.js | 13 +++++- js/consultations.js | 18 ++++++-- repositories/repos/MedecinRepo.php | 8 ++++ repositories/repos/PatientRepo.php | 74 +++++++++++++++++------------- 6 files changed, 92 insertions(+), 52 deletions(-) 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 9b4d324..8dc8ea9 100755 --- a/repositories/repos/MedecinRepo.php +++ b/repositories/repos/MedecinRepo.php @@ -53,4 +53,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 2ff88f4..05be40e 100755 --- a/repositories/repos/PatientRepo.php +++ b/repositories/repos/PatientRepo.php @@ -8,63 +8,71 @@ */ 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 ); + 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, - 'adresse' => $adresse, - 'adresse2' => $adresse2, - 'ville' => $ville, - 'codePostal' => $codePostal, - 'dateNaissance' => $dateNaissance, - 'lieuNaissance' => $lieuNaissance, - 'numSecu' => $numSecu, - 'medecin' => $medecinTraitant ]); - if($result){return ['id' => $this->connexion->lastInsertId()];} - else{return false;} + 'nom' => $nom, + 'prenom' => $prenom, + 'adresse' => $adresse, + 'adresse2' => $adresse2, + 'ville' => $ville, + 'codePostal' => $codePostal, + 'dateNaissance' => $dateNaissance, + 'lieuNaissance' => $lieuNaissance, + 'numSecu' => $numSecu, + 'medecin' => $medecinTraitant ]); + 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){ + public static 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]); + $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()); + 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() ); }