resolution de conflit

This commit is contained in:
Lucas Mascaro 2015-12-08 09:34:46 +01:00
commit 08b72c9ae8
6 changed files with 77 additions and 40 deletions

View File

@ -41,22 +41,21 @@ if(!Authentification::checkUser(0)){
<!-- FIL D'ARIANE --> <!-- FIL D'ARIANE -->
<div id='BREADCRUMB'><a href='Dashboard.php'>Accueil</a> <a href='Consultations.php'>Consultations</a></a> </div> <div id='BREADCRUMB'><a href='Dashboard.php'>Accueil</a> <a href='Consultations.php'>Consultations</a></a> </div>
<article data-title="Saisir un rendez-vous"> <article data-title="Saisir un rendez-vous">
<div> <div>
<select id='newRDVPatient'> <select id='newRDVPatient'>
<option value='*'>Patients:</option> <option value='*'>Patients:</option>
<?php $patients = json_decode( file_get_contents('Docs/PatientExemple.json') ); <?php
foreach($patients as $PATIENT) foreach(PatientRepo::getAll() as $PATIENT)
echo "<option value='".$PATIENT->Id."' data-medecin='".$PATIENT->MedecinTraitant."'>".$PATIENT->Nom." ".$PATIENT->Prenom."</option>"; echo "<option value='".$PATIENT['Id']."' data-medecin='".$PATIENT['MedecinTraitant']."'>".$PATIENT['Nom']." ".$PATIENT['Prenom']."</option>";
?> ?>
</select>Choix du patient </select>Choix du patient
</div><div> </div><div>
<select id='newRDVMedecin'> <select id='newRDVMedecin'>
<option value='*'>Medecins:</option> <option value='*'>Medecins:</option>
<?php $medecins = json_decode( file_get_contents('Docs/MedecinExemple.json') ); <?php
foreach($medecins as $MEDECIN) foreach(MedecinRepo::getAll() as $MEDECIN)
echo "<option value='".$MEDECIN->Id."'>".$MEDECIN->Nom." ".$MEDECIN->Prenom."</option>"; echo "<option value='".$MEDECIN['Id']."'>".$MEDECIN['Nom']." ".$MEDECIN['Prenom']."</option>";
?> ?>
</select>Le médecin traitant se selectionne par défaut </select>Le médecin traitant se selectionne par défaut
</div> </div>

View File

@ -276,6 +276,13 @@ body{
-webkit-appearance: none; -webkit-appearance: none;
-ms-appearance: none; -ms-appearance: none;
-o-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;
} }
/* <SELECT> <OPTION> */ /* <SELECT> <OPTION> */
@ -293,6 +300,10 @@ body{
-o-appearance: none; -o-appearance: none;
} }
/* .associated */
#CONTAINER > article select.associated{
border-color: #f09108;
}
/* <INPUT> */ /* <INPUT> */
#CONTAINER > article input{ #CONTAINER > article input{
@ -304,13 +315,6 @@ body{
/* border */ /* border */
border: 1px solid #e5e5e5; 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 */ /* @focus */

View File

@ -7,3 +7,14 @@ NodeList.prototype.indexOf = HTMLCollection.prototype.indexOf = function(searche
// si on a rien trouvé, on retourne -1 // si on a rien trouvé, on retourne -1
return -1; return -1;
}; };
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);
}

View File

@ -7,17 +7,27 @@ var newRDVMedecin = document.getElementById('newRDVMedecin');
===============================================================*/ ===============================================================*/
if( newRDVPatient != null && newRDVMedecin != null ){ if( newRDVPatient != null && newRDVMedecin != null ){
/* [1] On selectionne dynamiquement le médecin traitant associé
// on selectionne dynamiquement le médecin traitant associé =======================================================================*/
newRDVPatient.addEventListener('change', function(e){ newRDVPatient.addEventListener('change', function(e){
var value = e.target.value; var child = document.querySelector("#newRDVPatient > option[value='"+newRDVPatient.value+"'][data-medecin]");
var child = document.querySelector("#newRDVPatient > option[value='"+value+"'][data-medecin]");
// on selectionne le medecin associé // on selectionne le medecin associé
newRDVMedecin.value = child.dataset.medecin; newRDVMedecin.value = child.dataset.medecin;
addClass(newRDVMedecin, 'associated');
}, false); }, 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);
} }

View File

@ -48,4 +48,12 @@ class MedecinRepo
return StaticRepo::delNumeric($req->fetchAll()); 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() );
}
} }

View File

@ -8,25 +8,25 @@
*/ */
class PatientRepo class PatientRepo
{ {
private $connexion; // private $connexion;
public function __construct(){ // public function __construct(){
$this->connexion = StaticRepo::getConnexion(); // StaticRepo::getConnexion() = StaticRepo::getConnexion();
} // }
public function getById($id){ public static function getById($id){
$req = $this->connexion->prepare('SELECT * FROM Patient WHERE Id = :id'); $req = StaticRepo::getConnexion()->prepare('SELECT * FROM Patient WHERE Id = :id');
$req->execute(['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 = strtotime($dateNaissance);
$dateNaissance = Date('o-m-d',$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, $result = $req->execute(['civilite' => $civilite,
'nom' => $nom, 'nom' => $nom,
'prenom' => $prenom, 'prenom' => $prenom,
@ -38,34 +38,39 @@ class PatientRepo
'lieuNaissance' => $lieuNaissance, 'lieuNaissance' => $lieuNaissance,
'numSecu' => $numSecu, 'numSecu' => $numSecu,
'medecin' => $medecinTraitant ]); 'medecin' => $medecinTraitant ]);
if($result != false){return $this->connexion->lastInsertId();} if($result){return ['id' => StaticRepo::getConnexion()->lastInsertId()];}
else{return false;} else{return false;}
} }
public function delete($idPatient){ public static function delete($idPatient){
$req = $this->connexion->prepare('DELETE FROM Patient WHERE Id = :id'); $req = StaticRepo::getConnexion()->prepare('DELETE FROM Patient WHERE Id = :id');
return $req->execute(['id' => $idPatient]); 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'); $req = StaticRepo::getConnexion()->prepare('UPDATE Patient SET MedecinTraitant = :medecin WHERE Id = :id');
return $req->execute(['medecin' => $idMedecin, return $req->execute(['medecin' => $idMedecin, 'id' => $idPatient]);
'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() );
}
} }