-
85.45% covered (warning)
+
RDVRepo.php
+
+
+ 94.64% covered (success)
-
85.45%
-
47 / 55
+
94.64%
+
53 / 56
-
-
62.50% covered (warning)
+
+ 75.00% covered (warning)
-
62.50%
-
5 / 8
+
75.00%
+
6 / 8
diff --git a/managers/RDV.class.php b/managers/RDV.class.php
index 33024ab..d6ac348 100755
--- a/managers/RDV.class.php
+++ b/managers/RDV.class.php
@@ -120,7 +120,260 @@ class RDV
}
public function getSVG($params){
+ $days = ['Mon'=>0,'Tue'=>1,'Wed'=>2,'Thu'=>3,'Fri'=>4,'Sat'=>5,'Sun'=>6];
+ $svgCalendar = "
+
+
+
+
+
+ image/svg+xml
+
+ Calendar
+
+
+
+ ";
+
+ $current = strtotime($params['mois']);
+
+
+ //on range les rendez-vous dans un tableau avec leur jour comme clé
+ $RDVTemp = RDVRepo::getByMonth($params['mois'].'-01');
+ $RDVs = [];
+ foreach($RDVTemp as $rdv){
+ if(!isset($RDVs[date('j',strtotime($rdv['DateRDV']))])){
+ $RDVs[date('j',strtotime($rdv['DateRDV']))] = [];
+ }
+
+ array_push($RDVs[date('j',strtotime($rdv['DateRDV']))],$rdv);
+ }
+ foreach(range(1,date('t',strtotime($params['mois']))) as $day) {
+
+ //génération du SVG de la journée
+
+ //selon si on a une date sur un ou deux chiffres, on adapte
+ $date = strftime("%B %Y", $current);
+ if ($day >= 10) {
+ $xDate = 1500;
+ } else {
+ $xDate = 1000;
+ }
+
+ //fond général + affichage de la date
+ $svgCalendar .= '
+
+
+
+
+ ' . $day . '
+
+
+
+ ' . $date . '
+
+
+ ';
+
+ //on défini le tableau si jamais
+ if (!isset($RDVs[$day])) {
+ $RDVs[$day] = [];
+ }
+
+ //on parcours les consultations du jour pour les afficher
+ foreach ($RDVs[$day] as $key => $rdv) {
+ $patient = PatientRepo::getById(intval($rdv['Patient_Id']));
+ $medecin = MedecinRepo::getById(intval($rdv['Medecin_id']));
+
+ //couleur suivant le nombre de consultation
+ if ($key % 2 == 0) {
+ $color = 'f9f9f9';
+ } else {
+ $color = 'ececec';
+ }
+
+ //du svg blablabla
+ $yConsult = 1500 + 700 * $key;
+ $svgCalendar .= '
+
+ ' . date('G:i', strtotime($rdv['DateRDV'])) . '
+
+ ' . $rdv['Minute'] . 'mn
+
+ ' . $medecin['Prenom'] . '
+ ' . $medecin['Nom'] . '
+
+
+ ' . $patient['Prenom'] . '
+ ' . $patient['Nom'] . '
+
+ ';
+ }
+ $svgCalendar .= ' ';
+
+ }
+
+ //on met u fond (sinon on voit les consultation en arrière plan)
+ $svgCalendar .= '';
+ $svgCalendar.=' ';
+
+ //position x;y de base des jours du calendrier
+ $x=1100*$days[date('D',$current)];
+ $y=0;
+
+ //initialisation de variables
+ $cal = [];
+ $week=[];
+
+
+ //obligé de séparer la génération des consultation et du calendrier pour organiser le svg
+ foreach(range(1,date('t',strtotime($params['mois']))) as $day){
+ //génération du svg du calendrier
+ $day = date('D',$current);
+ $day_nbr = date('d',$current);
+ $week[$days[$day]] = date('d',$current);
+ $current = strtotime("+1 day",$current);
+ if($y/1100 % 2 == 0){
+ if($days[$day] % 2 == 0){$color='f0f0f0';}else{$color='fff';}
+ $svgCalendar.=' ';
+ }else{
+ if($days[$day] % 2 != 0){$color='f0f0f0';}else{$color='fff';}
+ $svgCalendar.=' ';
+ }
+ $svgCalendar.=''.$day_nbr.' ';
+ $x+=1100;
+ if($days[$day] == 6){
+ $i=0;
+ array_push($cal,$week);
+ $week = [];
+ $y+=1100;
+ $x=0;
+ }
+ }
+ $svgCalendar .= ' ';
+ return $svgCalendar;
}
}
\ No newline at end of file
diff --git a/repositories/repos/RDVRepo.php b/repositories/repos/RDVRepo.php
index 8b26025..80eb277 100755
--- a/repositories/repos/RDVRepo.php
+++ b/repositories/repos/RDVRepo.php
@@ -104,8 +104,9 @@ class RDVRepo
if(!StaticRepo::checkParam($date,'Date')){return false;}
$date = date('Y-m-d',strtotime($date));
- $req = StaticRepo::getConnexion()->prepare('SELECT * FROM RDV WHERE DATE(DateRDV) = :date ORDER BY DateRDV ASC');
- $req->execute(['date' => $date]);
+ $req = StaticRepo::getConnexion()->prepare('SELECT *, ((HOUR(Duree)*60)+MINUTE(Duree)) AS Minute FROM RDV WHERE MONTH(DateRDV) = :month AND YEAR(DateRDV) = :year ORDER BY DateRDV ASC');
+ $req->execute(['month' => date('m',strtotime($date)),
+ 'year' => date('Y',strtotime($date))]);
return StaticRepo::delNumeric($req->fetchAll());
}
diff --git a/test.php b/test.php
index be09c42..9d96d0f 100755
--- a/test.php
+++ b/test.php
@@ -6,5 +6,16 @@
* Time: 11:40
*/
require_once('autoloader.php');
+$rdv=new RDV();
+?>
+
+
+
-Response::quickResponse(200,'lol');
+
+
+getSVG(['mois' => '2015-11']);
+?>
+
+
diff --git a/test/RDVRepoTest.php b/test/RDVRepoTest.php
index 33dee1e..aca1c52 100755
--- a/test/RDVRepoTest.php
+++ b/test/RDVRepoTest.php
@@ -60,4 +60,9 @@ class RDVRepoTest extends PHPUnit_Framework_TestCase
$this->assertEquals(count($this->repo->getAll(1)),1);
}
+ public function testGetByMonth(){
+ $date = '2015-12-00 00:00:00';
+ $this->assertEquals(count($this->repo->getByMonth(date('Y-m-d',strtotime($date)))),13);
+ }
+
}