From b59a27ec5c8e852ebf659d11e35de012cf2ee1b1 Mon Sep 17 00:00:00 2001 From: Lucas Mascaro Date: Sat, 26 Dec 2015 13:22:06 +0100 Subject: [PATCH] =?UTF-8?q?g=C3=A9n=C3=A9ration=20du=20calendrier=20SVG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- autoloader.php | 2 + coverage/StaticRepo.php.html | 42 ++--- coverage/dashboard.html | 14 +- coverage/index.html | 34 ++-- coverage/repos/MedecinRepo.php.html | 2 +- coverage/repos/PatientRepo.php.html | 2 +- coverage/repos/RDVRepo.php.html | 81 ++++----- coverage/repos/StatsRepo.php.html | 2 +- coverage/repos/dashboard.html | 14 +- coverage/repos/index.html | 38 ++--- managers/RDV.class.php | 253 ++++++++++++++++++++++++++++ repositories/repos/RDVRepo.php | 5 +- test.php | 13 +- test/RDVRepoTest.php | 5 + 14 files changed, 386 insertions(+), 121 deletions(-) diff --git a/autoloader.php b/autoloader.php index 544f1b5..9dafb43 100755 --- a/autoloader.php +++ b/autoloader.php @@ -4,6 +4,8 @@ ini_set('display_errors',1); ini_set('display_startup_errors',1); error_reporting(-1); +setlocale (LC_TIME, 'fr_FR.utf8','fra'); + /* * fonction d'autoloading : prend en paramètre le nom de la classe et s'occupe d'inclure les fichiers correspondant aux classes */ diff --git a/coverage/StaticRepo.php.html b/coverage/StaticRepo.php.html index 2de59f5..fe4dac4 100755 --- a/coverage/StaticRepo.php.html +++ b/coverage/StaticRepo.php.html @@ -201,13 +201,13 @@
12
     * @return PDO instance de la connexion a la BDD
13
     */
14
    public static function getConnexion(){ -
15
        if(static::$config == null){ +
15
        if(static::$config == null){
16
            static::$config = json_decode(file_get_contents(dirname(__FILE__).DIRECTORY_SEPARATOR.'config.json'),true);
17
        } -
18
        if(static::$connexion == null){ +
18
        if(static::$connexion == null){
19
            static::$connexion = new PDO('mysql:host='.static::$config['host'].';dbname='.static::$config['database'], static::$config['login'], static::$config['password']);
20
        } -
21
        return static::$connexion; +
21
        return static::$connexion;
22
    }
23
24
    /** @@ -230,21 +230,21 @@
41
    public static function delNumeric($fetchData, $oneDimension=false){
42
    
43
    // cas où fetch renvoie FALSE -
44
    if( $fetchData === false ) return false; +
44
    if( $fetchData === false ) return false;
45
46
        /* [1] 2 dimensions
47
        ===============================================*/ -
48
        if( !$oneDimension ){ +
48
        if( !$oneDimension ){
49
50
        // on supprime les doublons des entrées (indice numérique) -
51
        for( $i = 0 ; $i < count($fetchData) ; $i++ ) // pour tout les utilisateurs -
52
            foreach($fetchData[$i] as $col => $val){  // pour toutes les entrées +
51
        for( $i = 0 ; $i < count($fetchData) ; $i++ ) // pour tout les utilisateurs +
52
            foreach($fetchData[$i] as $col => $val){  // pour toutes les entrées
53
                 -
54
                if( !mb_detect_encoding($val, 'UTF-8') ) +
54
                if( !mb_detect_encoding($val, 'UTF-8') )
55
                    $fetchData[$i][$col] = utf8_encode($val);
56
                 -
57
                if( is_int($col) )                    // si l'indice est un entier -
58
                    unset( $fetchData[$i][$col] );    // on le supprime +
57
                if( is_int($col) )                    // si l'indice est un entier +
58
                    unset( $fetchData[$i][$col] );    // on le supprime
59
            }
60
61
        /* [2] 1 dimensions @@ -263,7 +263,7 @@
74
75
        }
76
-
77
        return $fetchData; +
77
        return $fetchData;
78
    }
79
80
@@ -291,24 +291,24 @@
102
    public static function checkParam($variable, $dbtype){
103
        /* [1] on vérifie que $dbtype est un String
104
        =============================================================*/ -
105
        if( !is_string($dbtype) ) return false; +
105
        if( !is_string($dbtype) ) return false;
106
107
108
        /* [2] Vérifications
109
        =============================================================*/ -
110
        $checker = true; // contiendra VRAI si la vérification s'avère correcte -
111
        $matches = []; -
112
        $len = 8; +
110
        $checker = true; // contiendra VRAI si la vérification s'avère correcte +
111
        $matches = []; +
112
        $len = 8;
113
114
        //si on a un type scalairexlongueur, on traite -
115
        if(preg_match_all('/([A-Z][a-z]+)(\d+)/s', $dbtype,$matches)){ +
115
        if(preg_match_all('/([A-Z][a-z]+)(\d+)/s', $dbtype,$matches)){
116
            $dbtype = $matches[1][0];
117
            $len    = $matches[2][0];
118
        }
119
120
        switch($dbtype){
121
            // [1] 'M' / 'F'  -
122
            case 'Civilite': +
122
            case 'Civilite':
123
                $checker = $checker && is_string($variable) && in_array($variable, ['M','F']);
124
                break;
125
@@ -334,8 +334,8 @@
145
                break;
146
147
            case 'Date': -
148
                $checker = $checker && is_string($variable) && ( preg_match('/\d{2}\/\d{2}\/\d{4}/', $variable) || preg_match('/\d{4}-\d{2}-\d{2}/', $variable) || preg_match('/\d{4}\/\d{2}\/\d{2}/', $variable) ); -
149
                break; +
148
                $checker = $checker && is_string($variable) && ( preg_match('/\d{2}\/\d{2}\/\d{4}/', $variable) || preg_match('/\d{4}-\d{2}-\d{2}/', $variable) || preg_match('/\d{4}\/\d{2}\/\d{2}/', $variable) ); +
149
                break;
150
151
            case 'Heure':
152
                $checker = $checker && is_string($variable) && preg_match('/(\d+):(\d+)/is',$variable); @@ -348,7 +348,7 @@
159
160
        /* [3] On retourne le résultat de la vérif
161
        =============================================================*/ -
162
        return $checker; +
162
        return $checker;
163
164
    }
165
@@ -368,7 +368,7 @@ Dead Code

- Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.0 and PHPUnit 5.1.3 at Thu Dec 17 7:56:03 UTC 2015. + Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.0 and PHPUnit 5.1.3 at Thu Dec 17 8:04:45 UTC 2015.

diff --git a/coverage/dashboard.html b/coverage/dashboard.html index cfccc41..661824a 100755 --- a/coverage/dashboard.html +++ b/coverage/dashboard.html @@ -59,7 +59,6 @@ StaticRepo84% - RDVRepo85% @@ -77,7 +76,6 @@ StaticRepo49 - RDVRepo25 @@ -115,7 +113,6 @@ - getByMonth0% checkParam81% delNumeric85% getAll86% @@ -138,7 +135,6 @@ checkParam34 delNumeric10 - getByMonth6 getAll5 add5 @@ -150,7 +146,7 @@ @@ -171,7 +167,7 @@ $(document).ready(function() { .yAxis.tickFormat(d3.format('d')); d3.select('#classCoverageDistribution svg') - .datum(getCoverageDistributionData([0,0,0,0,0,0,0,0,0,2,3,0], "Class Coverage")) + .datum(getCoverageDistributionData([0,0,0,0,0,0,0,0,0,1,4,0], "Class Coverage")) .transition().duration(500).call(chart); nv.utils.windowResize(chart.update); @@ -189,7 +185,7 @@ $(document).ready(function() { .yAxis.tickFormat(d3.format('d')); d3.select('#methodCoverageDistribution svg') - .datum(getCoverageDistributionData([1,0,0,0,0,0,0,0,0,4,4,18], "Method Coverage")) + .datum(getCoverageDistributionData([0,0,0,0,0,0,0,0,0,4,4,19], "Method Coverage")) .transition().duration(500).call(chart); nv.utils.windowResize(chart.update); @@ -239,7 +235,7 @@ $(document).ready(function() { chart.yAxis.axisLabel('Cyclomatic Complexity'); d3.select('#classComplexity svg') - .datum(getComplexityData([[84.905660377358,43,"StaticRepo<\/a>"],[96.428571428571,15,"MedecinRepo<\/a>"],[97.435897435897,44,"PatientRepo<\/a>"],[85.454545454545,24,"RDVRepo<\/a>"],[92.307692307692,9,"StatsRepo<\/a>"]], 'Class Complexity')) + .datum(getComplexityData([[84.905660377358,43,"StaticRepo<\/a>"],[96.428571428571,15,"MedecinRepo<\/a>"],[97.435897435897,44,"PatientRepo<\/a>"],[94.642857142857,24,"RDVRepo<\/a>"],[92.307692307692,9,"StatsRepo<\/a>"]], 'Class Complexity')) .transition() .duration(500) .call(chart); @@ -263,7 +259,7 @@ $(document).ready(function() { chart.yAxis.axisLabel('Method Complexity'); d3.select('#methodComplexity svg') - .datum(getComplexityData([[100,3,"StaticRepo::getConnexion<\/a>"],[100,1,"StaticRepo::testConnexion<\/a>"],[85.714285714286,10,"StaticRepo::delNumeric<\/a>"],[81.818181818182,29,"StaticRepo::checkParam<\/a>"],[100,2,"MedecinRepo::getById<\/a>"],[88.888888888889,5,"MedecinRepo::add<\/a>"],[100,2,"MedecinRepo::delete<\/a>"],[100,3,"MedecinRepo::search<\/a>"],[100,2,"MedecinRepo::getPatients<\/a>"],[100,1,"MedecinRepo::getAll<\/a>"],[100,2,"PatientRepo::getById<\/a>"],[96.774193548387,17,"PatientRepo::add<\/a>"],[96.774193548387,16,"PatientRepo::update<\/a>"],[100,2,"PatientRepo::delete<\/a>"],[100,3,"PatientRepo::updateMedecinTraitant<\/a>"],[100,3,"PatientRepo::search<\/a>"],[100,1,"PatientRepo::getAll<\/a>"],[100,2,"RDVRepo::getById<\/a>"],[100,2,"RDVRepo::getByDate<\/a>"],[100,2,"RDVRepo::delete<\/a>"],[91.666666666667,6,"RDVRepo::add<\/a>"],[100,2,"RDVRepo::updateDateTime<\/a>"],[100,3,"RDVRepo::getByPatientAndDate<\/a>"],[86.666666666667,5,"RDVRepo::getAll<\/a>"],[0,2,"RDVRepo::getByMonth<\/a>"],[91.304347826087,8,"StatsRepo::getAgePatient<\/a>"],[100,1,"StatsRepo::getRDVStat<\/a>"]], 'Method Complexity')) + .datum(getComplexityData([[100,3,"StaticRepo::getConnexion<\/a>"],[100,1,"StaticRepo::testConnexion<\/a>"],[85.714285714286,10,"StaticRepo::delNumeric<\/a>"],[81.818181818182,29,"StaticRepo::checkParam<\/a>"],[100,2,"MedecinRepo::getById<\/a>"],[88.888888888889,5,"MedecinRepo::add<\/a>"],[100,2,"MedecinRepo::delete<\/a>"],[100,3,"MedecinRepo::search<\/a>"],[100,2,"MedecinRepo::getPatients<\/a>"],[100,1,"MedecinRepo::getAll<\/a>"],[100,2,"PatientRepo::getById<\/a>"],[96.774193548387,17,"PatientRepo::add<\/a>"],[96.774193548387,16,"PatientRepo::update<\/a>"],[100,2,"PatientRepo::delete<\/a>"],[100,3,"PatientRepo::updateMedecinTraitant<\/a>"],[100,3,"PatientRepo::search<\/a>"],[100,1,"PatientRepo::getAll<\/a>"],[100,2,"RDVRepo::getById<\/a>"],[100,2,"RDVRepo::getByDate<\/a>"],[100,2,"RDVRepo::delete<\/a>"],[91.666666666667,6,"RDVRepo::add<\/a>"],[100,2,"RDVRepo::updateDateTime<\/a>"],[100,3,"RDVRepo::getByPatientAndDate<\/a>"],[86.666666666667,5,"RDVRepo::getAll<\/a>"],[100,2,"RDVRepo::getByMonth<\/a>"],[91.304347826087,8,"StatsRepo::getAgePatient<\/a>"],[100,1,"StatsRepo::getRDVStat<\/a>"]], 'Method Complexity')) .transition() .duration(500) .call(chart); diff --git a/coverage/index.html b/coverage/index.html index 3879f91..2f10f89 100755 --- a/coverage/index.html +++ b/coverage/index.html @@ -43,21 +43,21 @@ Total
-
- 91.25% covered (success) +
+ 93.36% covered (success)
-
91.25%
-
219 / 240
+
93.36%
+
225 / 241
-
- 66.67% covered (warning) +
+ 70.37% covered (warning)
-
66.67%
-
18 / 27
+
70.37%
+
19 / 27
0.00% covered (danger) @@ -71,21 +71,21 @@ repos
-
- 93.05% covered (success) +
+ 95.74% covered (success)
-
93.05%
-
174 / 187
+
95.74%
+
180 / 188
-
- 69.57% covered (warning) +
+ 73.91% covered (warning)
-
69.57%
-
16 / 23
+
73.91%
+
17 / 23
0.00% covered (danger) @@ -136,7 +136,7 @@ High: 90% to 100%

- Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.0 and PHPUnit 5.1.3 at Thu Dec 17 7:56:03 UTC 2015. + Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.0 and PHPUnit 5.1.3 at Thu Dec 17 8:04:45 UTC 2015.

diff --git a/coverage/repos/MedecinRepo.php.html b/coverage/repos/MedecinRepo.php.html index 890edd0..794fa2e 100755 --- a/coverage/repos/MedecinRepo.php.html +++ b/coverage/repos/MedecinRepo.php.html @@ -318,7 +318,7 @@ Dead Code

- Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.0 and PHPUnit 5.1.3 at Thu Dec 17 7:56:03 UTC 2015. + Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.0 and PHPUnit 5.1.3 at Thu Dec 17 8:04:45 UTC 2015.

diff --git a/coverage/repos/PatientRepo.php.html b/coverage/repos/PatientRepo.php.html index f3d84a8..a39d9ff 100755 --- a/coverage/repos/PatientRepo.php.html +++ b/coverage/repos/PatientRepo.php.html @@ -412,7 +412,7 @@ Dead Code

- Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.0 and PHPUnit 5.1.3 at Thu Dec 17 7:56:03 UTC 2015. + Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.0 and PHPUnit 5.1.3 at Thu Dec 17 8:04:45 UTC 2015.

diff --git a/coverage/repos/RDVRepo.php.html b/coverage/repos/RDVRepo.php.html index 920d128..77df5ec 100755 --- a/coverage/repos/RDVRepo.php.html +++ b/coverage/repos/RDVRepo.php.html @@ -52,22 +52,22 @@
0.00%
0 / 1
-
- 62.50% covered (warning) +
+ 75.00% covered (warning)
-
62.50%
-
5 / 8
+
75.00%
+
6 / 8
CRAP -
-
- 85.45% covered (warning) +
+
+ 94.64% covered (success)
-
85.45%
-
47 / 55
+
94.64%
+
53 / 56
@@ -81,22 +81,22 @@
0.00%
0 / 1
-
- 62.50% covered (warning) +
+ 75.00% covered (warning)
-
62.50%
-
5 / 8
- 25.77 -
-
- 85.45% covered (warning) +
75.00%
+
6 / 8
+ 24.09 +
+
+ 94.64% covered (success)
-
85.45%
-
47 / 55
+
94.64%
+
53 / 56
@@ -247,24 +247,24 @@ -  getByMonth -
-
- 0.00% covered (danger) +  getByMonth +
+
+ 100.00% covered (success)
-
0.00%
-
0 / 1
- 6 -
-
- 0.00% covered (danger) +
100.00%
+
1 / 1
+ 2 +
+
+ 100.00% covered (success)
-
0.00%
-
0 / 5
+
100.00%
+
6 / 6
@@ -375,15 +375,16 @@     public static function getByMonth($date){ -         if(!StaticRepo::checkParam($date,'Date')){return false;} +         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]); -         return StaticRepo::delNumeric($req->fetchAll()); -     } - - } +         $date = date('Y-m-d',strtotime($date)); +         $req = StaticRepo::getConnexion()->prepare('SELECT * 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()); +     } + + } @@ -396,7 +397,7 @@ Dead Code

- Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.0 and PHPUnit 5.1.3 at Thu Dec 17 7:56:03 UTC 2015. + Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.0 and PHPUnit 5.1.3 at Thu Dec 17 8:04:45 UTC 2015.

diff --git a/coverage/repos/StatsRepo.php.html b/coverage/repos/StatsRepo.php.html index 19cafd2..a221471 100755 --- a/coverage/repos/StatsRepo.php.html +++ b/coverage/repos/StatsRepo.php.html @@ -213,7 +213,7 @@ Dead Code

- Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.0 and PHPUnit 5.1.3 at Thu Dec 17 7:56:03 UTC 2015. + Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.0 and PHPUnit 5.1.3 at Thu Dec 17 8:04:45 UTC 2015.

diff --git a/coverage/repos/dashboard.html b/coverage/repos/dashboard.html index ac78bbe..a8142b7 100755 --- a/coverage/repos/dashboard.html +++ b/coverage/repos/dashboard.html @@ -59,7 +59,6 @@ - RDVRepo85% @@ -76,7 +75,6 @@ - RDVRepo25 @@ -114,7 +112,6 @@ - getByMonth0% getAll86% add88% @@ -133,7 +130,6 @@ - getByMonth6 getAll5 add5 @@ -145,7 +141,7 @@
@@ -166,7 +162,7 @@ $(document).ready(function() { .yAxis.tickFormat(d3.format('d')); d3.select('#classCoverageDistribution svg') - .datum(getCoverageDistributionData([0,0,0,0,0,0,0,0,0,1,3,0], "Class Coverage")) + .datum(getCoverageDistributionData([0,0,0,0,0,0,0,0,0,0,4,0], "Class Coverage")) .transition().duration(500).call(chart); nv.utils.windowResize(chart.update); @@ -184,7 +180,7 @@ $(document).ready(function() { .yAxis.tickFormat(d3.format('d')); d3.select('#methodCoverageDistribution svg') - .datum(getCoverageDistributionData([1,0,0,0,0,0,0,0,0,2,4,16], "Method Coverage")) + .datum(getCoverageDistributionData([0,0,0,0,0,0,0,0,0,2,4,17], "Method Coverage")) .transition().duration(500).call(chart); nv.utils.windowResize(chart.update); @@ -234,7 +230,7 @@ $(document).ready(function() { chart.yAxis.axisLabel('Cyclomatic Complexity'); d3.select('#classComplexity svg') - .datum(getComplexityData([[96.428571428571,15,"MedecinRepo<\/a>"],[97.435897435897,44,"PatientRepo<\/a>"],[85.454545454545,24,"RDVRepo<\/a>"],[92.307692307692,9,"StatsRepo<\/a>"]], 'Class Complexity')) + .datum(getComplexityData([[96.428571428571,15,"MedecinRepo<\/a>"],[97.435897435897,44,"PatientRepo<\/a>"],[94.642857142857,24,"RDVRepo<\/a>"],[92.307692307692,9,"StatsRepo<\/a>"]], 'Class Complexity')) .transition() .duration(500) .call(chart); @@ -258,7 +254,7 @@ $(document).ready(function() { chart.yAxis.axisLabel('Method Complexity'); d3.select('#methodComplexity svg') - .datum(getComplexityData([[100,2,"MedecinRepo::getById<\/a>"],[88.888888888889,5,"MedecinRepo::add<\/a>"],[100,2,"MedecinRepo::delete<\/a>"],[100,3,"MedecinRepo::search<\/a>"],[100,2,"MedecinRepo::getPatients<\/a>"],[100,1,"MedecinRepo::getAll<\/a>"],[100,2,"PatientRepo::getById<\/a>"],[96.774193548387,17,"PatientRepo::add<\/a>"],[96.774193548387,16,"PatientRepo::update<\/a>"],[100,2,"PatientRepo::delete<\/a>"],[100,3,"PatientRepo::updateMedecinTraitant<\/a>"],[100,3,"PatientRepo::search<\/a>"],[100,1,"PatientRepo::getAll<\/a>"],[100,2,"RDVRepo::getById<\/a>"],[100,2,"RDVRepo::getByDate<\/a>"],[100,2,"RDVRepo::delete<\/a>"],[91.666666666667,6,"RDVRepo::add<\/a>"],[100,2,"RDVRepo::updateDateTime<\/a>"],[100,3,"RDVRepo::getByPatientAndDate<\/a>"],[86.666666666667,5,"RDVRepo::getAll<\/a>"],[0,2,"RDVRepo::getByMonth<\/a>"],[91.304347826087,8,"StatsRepo::getAgePatient<\/a>"],[100,1,"StatsRepo::getRDVStat<\/a>"]], 'Method Complexity')) + .datum(getComplexityData([[100,2,"MedecinRepo::getById<\/a>"],[88.888888888889,5,"MedecinRepo::add<\/a>"],[100,2,"MedecinRepo::delete<\/a>"],[100,3,"MedecinRepo::search<\/a>"],[100,2,"MedecinRepo::getPatients<\/a>"],[100,1,"MedecinRepo::getAll<\/a>"],[100,2,"PatientRepo::getById<\/a>"],[96.774193548387,17,"PatientRepo::add<\/a>"],[96.774193548387,16,"PatientRepo::update<\/a>"],[100,2,"PatientRepo::delete<\/a>"],[100,3,"PatientRepo::updateMedecinTraitant<\/a>"],[100,3,"PatientRepo::search<\/a>"],[100,1,"PatientRepo::getAll<\/a>"],[100,2,"RDVRepo::getById<\/a>"],[100,2,"RDVRepo::getByDate<\/a>"],[100,2,"RDVRepo::delete<\/a>"],[91.666666666667,6,"RDVRepo::add<\/a>"],[100,2,"RDVRepo::updateDateTime<\/a>"],[100,3,"RDVRepo::getByPatientAndDate<\/a>"],[86.666666666667,5,"RDVRepo::getAll<\/a>"],[100,2,"RDVRepo::getByMonth<\/a>"],[91.304347826087,8,"StatsRepo::getAgePatient<\/a>"],[100,1,"StatsRepo::getRDVStat<\/a>"]], 'Method Complexity')) .transition() .duration(500) .call(chart); diff --git a/coverage/repos/index.html b/coverage/repos/index.html index 801e50a..d575f2a 100755 --- a/coverage/repos/index.html +++ b/coverage/repos/index.html @@ -44,21 +44,21 @@ Total
-
- 93.05% covered (success) +
+ 95.74% covered (success)
-
93.05%
-
174 / 187
+
95.74%
+
180 / 188
-
- 69.57% covered (warning) +
+ 73.91% covered (warning)
-
69.57%
-
16 / 23
+
73.91%
+
17 / 23
0.00% covered (danger) @@ -126,23 +126,23 @@ - RDVRepo.php -
-
- 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
0.00% covered (danger) @@ -193,7 +193,7 @@ High: 90% to 100%

- Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.0 and PHPUnit 5.1.3 at Thu Dec 17 7:56:03 UTC 2015. + Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.0 and PHPUnit 5.1.3 at Thu Dec 17 8:04:45 UTC 2015.

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); + } + }