diff --git a/Dashboard.php b/Dashboard.php index 72d3234..21488d7 100755 --- a/Dashboard.php +++ b/Dashboard.php @@ -21,7 +21,6 @@ if(!Authentification::checkUser(0)){ - @@ -58,7 +57,97 @@ if(!Authentification::checkUser(0)){ - +
+ + +
+

Homme

+
+
'; + } + ?> + +
+

Total

+ '.$key.'

'; + } + ?> +
+ +
+

+ '.$value.'

'; + } + ?> +
+ +
+

Femme

+
+
'; + } + ?> + +
+

Total

+ '.$key.'

'; + } + ?> +
+ +
+

+ '.$value.'

'; + } + ?> +
+ +
+ +
+ + + diff --git a/Docs/Model.mwb.beforefix b/Docs/Model.mwb.beforefix new file mode 100644 index 0000000..71a3690 Binary files /dev/null and b/Docs/Model.mwb.beforefix differ diff --git a/coverage/StaticRepo.php.html b/coverage/StaticRepo.php.html index fe4dac4..7062b70 100755 --- a/coverage/StaticRepo.php.html +++ b/coverage/StaticRepo.php.html @@ -60,13 +60,13 @@
2 / 4
CRAP
-
- 84.91% covered (warning) +
+ 83.93% covered (warning)
-
84.91%
-
45 / 53
+
83.93%
+
47 / 56
@@ -87,15 +87,15 @@
50.00%
2 / 4
- 49.36 + 66.10
-
- 84.91% covered (warning) +
+ 83.93% covered (warning)
-
84.91%
-
45 / 53
+
83.93%
+
47 / 56
@@ -171,15 +171,15 @@
0.00%
0 / 1
- 34.05 + 51.76
-
- 81.82% covered (warning) +
+ 80.56% covered (warning)
-
81.82%
-
27 / 33
+
80.56%
+
29 / 36
@@ -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){ -
16
            static::$config = json_decode(file_get_contents(dirname(__FILE__).DIRECTORY_SEPARATOR.'config.json'),true); +
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){ -
19
            static::$connexion = new PDO('mysql:host='.static::$config['host'].';dbname='.static::$config['database'], static::$config['login'], static::$config['password']); +
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,11 +230,11 @@
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 @@ -252,18 +252,18 @@
63
        }else{
64
65
            // on supprime les doublons des entrées (indice numérique) -
66
            foreach($fetchData as $i=>$val){  // pour toutes les entrées +
66
            foreach($fetchData as $i=>$val){ // pour toutes les entrées
67
                 -
68
                if( !mb_detect_encoding($val, 'UTF-8') ) +
68
                if( !mb_detect_encoding($val, 'UTF-8') )
69
                    $fetchData[$i] = utf8_encode($val);
70
-
71
                if( is_int($i) )                    // si l'indice est un entier -
72
                    unset( $fetchData[$i] );    // on le supprime +
71
                if( is_int($i) )             // si l'indice est un entier +
72
                    unset( $fetchData[$i] ); // on le supprime
73
            }
74
75
        }
76
-
77
        return $fetchData; +
77
        return $fetchData;
78
    }
79
80
@@ -291,71 +291,75 @@
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)){ -
116
            $dbtype = $matches[1][0]; -
117
            $len    = $matches[2][0]; +
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': -
123
                $checker = $checker && is_string($variable) && in_array($variable, ['M','F']); -
124
                break; +
122
            case 'Civilite': +
123
                $checker = $checker && !is_null($variable) && is_string($variable) && in_array($variable, ['M','F']); +
124
                break;
125
126
            // [2] Chaine de caractère (longueur variable)
127
            case 'String': -
128
                $checker = $checker && is_string($variable) && strlen($variable) <= $len; -
129
                break; +
128
                $checker = $checker && !is_null($variable) && is_string($variable) && strlen($variable) > 0 && strlen($variable) <= $len; +
129
                break;
130
131
            case 'Integer': -
132
                $checker = $checker && is_int($variable) && $variable<pow(2, 32); -
133
                break; +
132
                $checker = $checker && !is_null($variable) && is_int($variable) && $variable<pow(2, 32); +
133
                break;
134
-
135
            case 'SmallInteger': -
136
                $checker = $checker && is_int($variable) && $variable<pow(2, 16); -
137
                break; +
135
            case 'Numeric': +
136
                $checker = $checker && !is_null($variable) && is_numeric($variable); +
137
                break;
138
-
139
            case 'TinyInteger': -
140
                $checker = $checker && is_int($variable) && $variable<pow(2, 8); +
139
            case 'SmallInteger': +
140
                $checker = $checker && !is_null($variable) && is_int($variable) && $variable<pow(2, 16);
141
                break;
142
-
143
            case 'BigInteger': -
144
                $checker = $checker && is_int($variable) && $variable<pow(2, 64); +
143
            case 'TinyInteger': +
144
                $checker = $checker && !is_null($variable) && is_int($variable) && $variable<pow(2, 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; +
147
            case 'BigInteger': +
148
                $checker = $checker && !is_null($variable) && is_int($variable) && $variable<pow(2, 64); +
149
                break;
150
-
151
            case 'Heure': -
152
                $checker = $checker && is_string($variable) && preg_match('/(\d+):(\d+)/is',$variable); -
153
                break; +
151
            case 'Date': +
152
                $checker = $checker && !is_null($variable) && is_string($variable) && ( preg_match('/^\d{2}\/\d{2}\/\d{4}$/', $variable) || preg_match('/^\d{4}-\d{2}-\d{2}$/', $variable) ); +
153
                break;
154
-
155
            // [N] Type inconnu -
156
            default: $checker = false; break; -
157
        } +
155
            case 'Heure': +
156
                $checker = $checker && !is_null($variable) && is_string($variable) && preg_match('/^\d{1,2}:\d{1,2}$/', $variable); +
157
                break;
158
-
159
-
160
        /* [3] On retourne le résultat de la vérif -
161
        =============================================================*/ -
162
        return $checker; +
159
            // [N] Type inconnu +
160
            default: $checker = false; break; +
161
        } +
162
163
-
164
    } -
165
-
166
-
167
} -
168
-
169
?> +
164
        /* [3] On retourne le résultat de la vérif +
165
        =============================================================*/ +
166
        return $checker; +
167
+
168
    } +
169
+
170
+
171
} +
172
+
173
?> @@ -368,7 +372,7 @@ Dead Code

- 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. + Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.1 and PHPUnit 5.1.3 at Sun Jan 3 17:34:44 UTC 2016.

diff --git a/coverage/dashboard.html b/coverage/dashboard.html index 661824a..f680577 100755 --- a/coverage/dashboard.html +++ b/coverage/dashboard.html @@ -58,7 +58,7 @@ - StaticRepo84% + StaticRepo83% @@ -75,7 +75,7 @@ - StaticRepo49 + StaticRepo66 @@ -113,9 +113,9 @@ - checkParam81% + checkParam80% delNumeric85% - getAll86% + getAll86% add88% @@ -133,10 +133,10 @@ - checkParam34 + checkParam51 delNumeric10 - getAll5 - add5 + getAll5 + add3 @@ -146,7 +146,7 @@
@@ -185,7 +185,7 @@ $(document).ready(function() { .yAxis.tickFormat(d3.format('d')); d3.select('#methodCoverageDistribution svg') - .datum(getCoverageDistributionData([0,0,0,0,0,0,0,0,0,4,4,19], "Method Coverage")) + .datum(getCoverageDistributionData([0,0,0,0,0,0,0,0,0,4,3,22], "Method Coverage")) .transition().duration(500).call(chart); nv.utils.windowResize(chart.update); @@ -235,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>"],[94.642857142857,24,"RDVRepo<\/a>"],[92.307692307692,9,"StatsRepo<\/a>"]], 'Class Complexity')) + .datum(getComplexityData([[83.928571428571,54,"StaticRepo<\/a>"],[97.058823529412,17,"MedecinRepo<\/a>"],[97.560975609756,46,"PatientRepo<\/a>"],[96.774193548387,25,"RDVRepo<\/a>"],[93.548387096774,9,"StatsRepo<\/a>"]], 'Class Complexity')) .transition() .duration(500) .call(chart); @@ -259,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>"],[100,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>"],[80.555555555556,40,"StaticRepo::checkParam<\/a>"],[100,2,"MedecinRepo::getById<\/a>"],[88.888888888889,3,"MedecinRepo::add<\/a>"],[100,2,"MedecinRepo::delete<\/a>"],[100,6,"MedecinRepo::search<\/a>"],[100,2,"MedecinRepo::getPatients<\/a>"],[100,1,"MedecinRepo::getAll<\/a>"],[100,1,"MedecinRepo::update<\/a>"],[100,2,"PatientRepo::getById<\/a>"],[96.774193548387,16,"PatientRepo::add<\/a>"],[96.774193548387,16,"PatientRepo::update<\/a>"],[100,2,"PatientRepo::delete<\/a>"],[100,3,"PatientRepo::updateMedecinTraitant<\/a>"],[100,6,"PatientRepo::search<\/a>"],[100,1,"PatientRepo::getAll<\/a>"],[100,2,"RDVRepo::getById<\/a>"],[100,1,"RDVRepo::getForMonth<\/a>"],[100,2,"RDVRepo::getByDate<\/a>"],[100,2,"RDVRepo::delete<\/a>"],[100,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>"],[92.592592592593,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 2f10f89..0006479 100755 --- a/coverage/index.html +++ b/coverage/index.html @@ -43,21 +43,21 @@ Total
-
- 93.36% covered (success) +
+ 93.96% covered (success)
-
93.36%
-
225 / 241
+
93.96%
+
249 / 265
-
- 70.37% covered (warning) +
+ 75.86% covered (warning)
-
70.37%
-
19 / 27
+
75.86%
+
22 / 29
0.00% covered (danger) @@ -71,21 +71,21 @@ repos
-
- 95.74% covered (success) +
+ 96.65% covered (success)
-
95.74%
-
180 / 188
+
96.65%
+
202 / 209
-
- 73.91% covered (warning) +
+ 80.00% covered (warning)
-
73.91%
-
17 / 23
+
80.00%
+
20 / 25
0.00% covered (danger) @@ -99,13 +99,13 @@ StaticRepo.php
-
- 84.91% covered (warning) +
+ 83.93% covered (warning)
-
84.91%
-
45 / 53
+
83.93%
+
47 / 56
50.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 8:04:45 UTC 2015. + Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.1 and PHPUnit 5.1.3 at Sun Jan 3 17:34:44 UTC 2016.

diff --git a/coverage/repos/MedecinRepo.php.html b/coverage/repos/MedecinRepo.php.html index 794fa2e..3ee9160 100755 --- a/coverage/repos/MedecinRepo.php.html +++ b/coverage/repos/MedecinRepo.php.html @@ -52,22 +52,22 @@
0.00%
0 / 1
-
- 83.33% covered (warning) +
+ 85.71% covered (warning)
-
83.33%
-
5 / 6
+
85.71%
+
6 / 7
CRAP
-
- 96.43% covered (success) +
+ 97.06% covered (success)
-
96.43%
-
27 / 28
+
97.06%
+
33 / 34
@@ -81,22 +81,22 @@
0.00%
0 / 1
-
- 83.33% covered (warning) +
+ 85.71% covered (warning)
-
83.33%
-
5 / 6
- 15 +
85.71%
+
6 / 7
+ 17
-
- 96.43% covered (success) +
+ 97.06% covered (success)
-
96.43%
-
27 / 28
+
97.06%
+
33 / 34
@@ -130,7 +130,7 @@
0.00%
0 / 1
- 5.03 + 3.01
88.89% covered (warning) @@ -142,7 +142,7 @@ -  delete +  delete
100.00% covered (success) @@ -159,11 +159,11 @@
100.00%
-
3 / 3
+
4 / 4
-  search +  search
100.00% covered (success) @@ -172,7 +172,7 @@
100.00%
1 / 1
- 3 + 6
100.00% covered (success) @@ -180,11 +180,11 @@
100.00%
-
5 / 5
+
8 / 8
-  getPatients +  getPatients
100.00% covered (success) @@ -205,7 +205,28 @@ -  getAll +  getAll +
+
+ 100.00% covered (success) +
+
+ +
100.00%
+
1 / 1
+ 1 +
+
+ 100.00% covered (success) +
+
+ +
100.00%
+
2 / 2
+ + + +  update
100.00% covered (success) @@ -243,69 +264,89 @@     public static function getById($id){ -         if(!StaticRepo::checkParam($id,'Integer')){return false;} +         if(!StaticRepo::checkParam($id, 'Numeric')) return false; -         $req = StaticRepo::getConnexion()->prepare('SELECT * FROM Medecin WHERE Id = :id'); -         $req->execute(['id' => $id]); -         return StaticRepo::delNumeric( $req->fetch(), true ); +         $req = StaticRepo::getConnexion()->prepare('SELECT * FROM Medecin WHERE Id = :id'); +         $req->execute(['id' => $id]); +         return StaticRepo::delNumeric( $req->fetch(), true );     }     public static function add($civilite,$prenom,$nom){ -         if(!StaticRepo::checkParam($civilite,'Civilite') && !StaticRepo::checkParam($prenom,'String45') && !StaticRepo::checkParam($nom,'String45')){return false;} +         if(!StaticRepo::checkParam($civilite,'Civilite') | !StaticRepo::checkParam($prenom,'String45') | !StaticRepo::checkParam($nom,'String45')) return false; -         $req = StaticRepo::getConnexion()->prepare('INSERT INTO Medecin VALUES (DEFAULT,:civilite,:prenom,:nom)'); -         $result = $req->execute(['civilite' => $civilite, -             'nom' => $nom, -             'prenom' => $prenom]); -         //PDO renvoie un ID sous forme de char, on transtype -         $id = StaticRepo::getConnexion()->lastInsertId(); -         settype($id,'integer'); -         if($result){return $id;} -         else{return false;} -     } +         $req = StaticRepo::getConnexion()->prepare('INSERT INTO Medecin VALUES (DEFAULT,:civilite,:prenom,:nom)'); +         $result = $req->execute(['civilite' => $civilite, +             'nom' => $nom, +             'prenom' => $prenom +         ]); + +         //PDO renvoie un ID sous forme de char, on transtype +         $id = StaticRepo::getConnexion()->lastInsertId(); +         settype($id, 'integer'); + -     public static function delete($idMedecin){ - -         if(!StaticRepo::checkParam($idMedecin,'Integer')){return false;} +         if($result) return $id; +         else        return false; +     } -         $req = StaticRepo::getConnexion()->prepare('DELETE FROM Medecin WHERE Id = :id'); -         return $req->execute(['id' => $idMedecin]); -     } +     public static function delete($idMedecin){ + +         if(!StaticRepo::checkParam($idMedecin,'Numeric')) return false; -     public static function search($nom,$prenom){ +         var_dump($idMedecin); -         if(!StaticRepo::checkParam($prenom,'String45') && !StaticRepo::checkParam($nom,'String45')){return false;} - -         $req = StaticRepo::getConnexion()->prepare('SELECT * FROM Medecin WHERE Nom LIKE :nom AND Prenom LIKE :prenom'); -         $req->execute(['nom' => $nom, -             'prenom' => $prenom]); +         $req = StaticRepo::getConnexion()->prepare('DELETE FROM Medecin WHERE Id = :id'); +         return $req->execute(['id' => $idMedecin]); +     } + +     public static function search($nom, $prenom){ -         return StaticRepo::delNumeric($req->fetchAll()); -     } - -     public static function getPatients($idMedecin){ - -         if(!StaticRepo::checkParam($idMedecin,'Integer')){return false;} - -         $req = StaticRepo::getConnexion()->prepare('SELECT Patient.* FROM Patient,Medecin -                     WHERE Medecin.Id = :id -                     AND Medecin.Id = Patient.MedecinTraitant'); - -         $req->execute(['id' => $idMedecin]); -         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() ); - -     } - - } +         if( !StaticRepo::checkParam($prenom,'String45') | !StaticRepo::checkParam($nom,'String45') ) return false; + +         // on définit les valeurs (peuvent être nulles) +         $optPrenom = ( $prenom != 'null' && StaticRepo::checkParam($prenom,'String45') ) ? '%'.$prenom.'%' : '%'; +         $optNom    = ( $nom    != 'null' && StaticRepo::checkParam($nom,   'String45') ) ? '%'.$nom.'%'    : '%'; + +         $req = StaticRepo::getConnexion()->query("SELECT Id, Civilite, Prenom, Nom +             FROM Medecin +             WHERE Nom LIKE '".$optNom."' +             AND Prenom LIKE '".$optPrenom."' +             ORDER BY Nom, Prenom ASC"); + + +         return StaticRepo::delNumeric( $req->fetchAll() ); +     } + +     public static function getPatients($idMedecin){ + +         if(!StaticRepo::checkParam($idMedecin,'Numeric')) return false; + +         $req = StaticRepo::getConnexion()->prepare('SELECT Patient.* FROM Patient,Medecin +                     WHERE Medecin.Id = :id +                     AND Medecin.Id = Patient.MedecinTraitant'); + +         $req->execute(['id' => $idMedecin]); +         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() ); + +     } + + +     public static function update($id, $nom, $prenom){ + +         $req = StaticRepo::getConnexion()->prepare("UPDATE Medecin SET Nom = :nom, Prenom = :prenom WHERE Id = :id"); +         return $req->execute([ ':nom' => strtoupper($nom), ':prenom' => $prenom, ':id' => $id ]); +     } + + } @@ -318,7 +359,7 @@ Dead Code

- 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. + Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.1 and PHPUnit 5.1.3 at Sun Jan 3 17:34:44 UTC 2016.

diff --git a/coverage/repos/PatientRepo.php.html b/coverage/repos/PatientRepo.php.html index a39d9ff..f0ff79c 100755 --- a/coverage/repos/PatientRepo.php.html +++ b/coverage/repos/PatientRepo.php.html @@ -61,13 +61,13 @@
5 / 7
CRAP
-
- 97.44% covered (success) +
+ 97.56% covered (success)
-
97.44%
-
76 / 78
+
97.56%
+
80 / 82
@@ -88,15 +88,15 @@
71.43%
5 / 7
- 44 + 46
-
- 97.44% covered (success) +
+ 97.56% covered (success)
-
97.44%
-
76 / 78
+
97.56%
+
80 / 82
@@ -130,7 +130,7 @@
0.00%
0 / 1
- 17 + 16
96.77% covered (success) @@ -184,7 +184,7 @@ -  updateMedecinTraitant +  updateMedecinTraitant
100.00% covered (success) @@ -205,7 +205,7 @@ -  search +  search
100.00% covered (success) @@ -214,7 +214,7 @@
100.00%
1 / 1
- 3 + 6
100.00% covered (success) @@ -222,11 +222,11 @@
100.00%
-
4 / 4
+
8 / 8
-  getAll +  getAll
100.00% covered (success) @@ -281,11 +281,11 @@         $correctTypes = $correctTypes && StaticRepo::checkParam($codePostal,'String');         $correctTypes = $correctTypes && StaticRepo::checkParam($dateNaissance,'Date');         $correctTypes = $correctTypes && StaticRepo::checkParam($lieuNaissance,'String50'); -         $correctTypes = $correctTypes && ( $medecinTraitant == 'null' || $medecinTraitant === null ||StaticRepo::checkParam($medecinTraitant, 'Integer') ); +         $correctTypes = $correctTypes && ( $medecinTraitant == 'null' || StaticRepo::checkParam($medecinTraitant, 'Numeric'));         if( !$correctTypes ) return false;         $dateNaissance = strtotime($dateNaissance); -         $dateNaissance = Date('o-m-d',$dateNaissance); +         $dateNaissance = Date('o-m-d', $dateNaissance);         $req = StaticRepo::getConnexion()->prepare("INSERT INTO Patient             VALUES(DEFAULT, @@ -365,41 +365,53 @@     public static function delete($idPatient){ -         if(!StaticRepo::checkParam($idPatient,'Integer')){ return false;} - -         $req = StaticRepo::getConnexion()->prepare('DELETE FROM Patient WHERE Patient.Id = :id'); -         return $req->execute(['id' => $idPatient]); +         // si format erroné, retourne FALSE +         if( !StaticRepo::checkParam($idPatient, 'Numeric') ) return false; + +         $req = StaticRepo::getConnexion()->prepare('DELETE FROM Patient WHERE Patient.Id = :id'); -     } +         return $req->execute([':id' => $idPatient]); -     public static function updateMedecinTraitant($idPatient,$idMedecin){ +     } -         if(!StaticRepo::checkParam($idPatient,'Integer') && !StaticRepo::checkParam($idMedecin,'Integer')){return false;} +     public static function updateMedecinTraitant($idPatient,$idMedecin){ -         $req = StaticRepo::getConnexion()->prepare('UPDATE Patient SET MedecinTraitant = :medecin WHERE Id = :id'); -         return $req->execute(['medecin' => $idMedecin, 'id' => $idPatient]); - -     } +         if(!StaticRepo::checkParam($idPatient,'Integer') && !StaticRepo::checkParam($idMedecin,'Integer')){return false;} + +         $req = StaticRepo::getConnexion()->prepare('UPDATE Patient SET MedecinTraitant = :medecin WHERE Id = :id'); +         return $req->execute(['medecin' => $idMedecin, 'id' => $idPatient]); -     public static function search($nom,$prenom){ +     } -         if(!StaticRepo::checkParam($prenom,'String45') && !StaticRepo::checkParam($nom,'String45')){return false;} - -         $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() ); - -     } + +     public static function search($nom, $prenom){ + +         if( !StaticRepo::checkParam($prenom,'String45') | !StaticRepo::checkParam($nom,'String45') ) return false; + +         // on définit les valeurs (peuvent être nulles) +         $optPrenom = ( $prenom != 'null' && StaticRepo::checkParam($prenom,'String45') ) ? '%'.$prenom.'%' : '%'; +         $optNom    = ( $nom    != 'null' && StaticRepo::checkParam($nom,   'String45') ) ? '%'.$nom.'%'    : '%'; + +         $req = StaticRepo::getConnexion()->query("SELECT Id, Civilite, Nom, Prenom, DATE_FORMAT(DateNaissance, '%d/%m/%Y') as DateNaissance, NumSecuriteSociale +             FROM Patient +             WHERE Nom LIKE '".$optNom."' +             AND Prenom LIKE '".$optPrenom."' +             ORDER BY Nom, Prenom ASC"); + - } +         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() ); + +     } + + } @@ -412,7 +424,7 @@ Dead Code

- 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. + Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.1 and PHPUnit 5.1.3 at Sun Jan 3 17:34:44 UTC 2016.

diff --git a/coverage/repos/RDVRepo.php.html b/coverage/repos/RDVRepo.php.html index 77df5ec..3596caf 100755 --- a/coverage/repos/RDVRepo.php.html +++ b/coverage/repos/RDVRepo.php.html @@ -52,22 +52,22 @@
0.00%
0 / 1
-
- 75.00% covered (warning) +
+ 88.89% covered (warning)
-
75.00%
-
6 / 8
+
88.89%
+
8 / 9
CRAP
-
- 94.64% covered (success) +
+ 96.77% covered (success)
-
94.64%
-
53 / 56
+
96.77%
+
60 / 62
@@ -81,22 +81,22 @@
0.00%
0 / 1
-
- 75.00% covered (warning) +
+ 88.89% covered (warning)
-
75.00%
-
6 / 8
- 24.09 +
88.89%
+
8 / 9
+ 25
-
- 94.64% covered (success) +
+ 96.77% covered (success)
-
94.64%
-
53 / 56
+
96.77%
+
60 / 62
@@ -121,7 +121,28 @@ -  getByDate +  getForMonth +
+
+ 100.00% covered (success) +
+
+ +
100.00%
+
1 / 1
+ 1 +
+
+ 100.00% covered (success) +
+
+ +
100.00%
+
4 / 4
+ + + +  getByDate
100.00% covered (success) @@ -142,7 +163,7 @@ -  delete +  delete
100.00% covered (success) @@ -163,28 +184,28 @@ -  add -
-
- 0.00% covered (danger) -
-
- -
0.00%
-
0 / 1
- 6.02 +  add
-
- 91.67% covered (success) +
+ 100.00% covered (success)
-
91.67%
-
11 / 12
+
100.00%
+
1 / 1
+ 6 +
+
+ 100.00% covered (success) +
+
+ +
100.00%
+
12 / 12
-  updateDateTime +  updateDateTime
100.00% covered (success) @@ -201,11 +222,11 @@
100.00%
-
5 / 5
+
6 / 6
-  getByPatientAndDate +  getByPatientAndDate
100.00% covered (success) @@ -226,7 +247,7 @@ -  getAll +  getAll
0.00% covered (danger) @@ -247,7 +268,7 @@ -  getByMonth +  getByMonth
100.00% covered (success) @@ -264,7 +285,7 @@
100.00%
-
6 / 6
+
7 / 7
@@ -293,98 +314,117 @@     } -     public static function getByDate($date){ - -         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()); -     } - -     public static function delete($idRDV){ +     public static function getForMonth($month, $year){ +         $req = StaticRepo::getConnexion()->prepare("SELECT RDV.Id, RDV.DateRDV, RDV.Medecin_Id, RDV.Patient_Id, RDV.Duree, Medecin.Prenom as M_Prenom, Medecin.Nom as M_Nom, Patient.Prenom as P_Prenom, Patient.Nom as P_Nom +             FROM RDV, Patient, Medecin +             WHERE Patient.Id = RDV.Patient_Id +             AND   Medecin.Id = RDV.Medecin_Id +             AND   MONTH(DateRDV) = :month +             AND   YEAR(DateRDV) = :year +             ORDER BY DateRDV ASC"); +         $req->execute(array( ':month' => $month, ':year' => $year )); +         return $req->fetchAll(); +     } -         if(!StaticRepo::checkParam($idRDV,'Integer')){return false;} +     public static function getByDate($date){ -         $req = StaticRepo::getConnexion()->prepare('DELETE FROM RDV WHERE RDV.id = :id'); -         return $req->execute(['id' => $idRDV]); -     } - -     public static function add($date,$duree,$idPatient,$idMedecin){ - -         if(!StaticRepo::checkParam($date,'Date') && !StaticRepo::checkParam($duree,'Integer') && !StaticRepo::checkParam($idPatient,'Integer') && !StaticRepo::checkParam($idMedecin,'Integer')){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 H:i:s',strtotime($date)); -         $duree = date('H:i:s',$duree*60); -         $req = StaticRepo::getConnexion()->prepare('INSERT INTO RDV VALUES (DEFAULT,:date,:duree,:patient,:medecin)'); -         $result = $req->execute(['date' => $date, -             'duree' => $duree, -             'patient' => $idPatient, -             'medecin' => $idMedecin]); +     public static function delete($idRDV){ + +         if(!StaticRepo::checkParam($idRDV,'Numeric')){return false;} + +         $req = StaticRepo::getConnexion()->prepare('DELETE FROM RDV WHERE RDV.id = :id'); +         return $req->execute(['id' => $idRDV]); +     } -         //PDO renvoie un ID sous forme de char, on transtype -         $id = StaticRepo::getConnexion()->lastInsertId(); -         settype($id,'integer'); -         if($result){return $id;} -         else{return false;} -     } - -     public static function updateDateTime($idRDV,$dateTime){ - -         if(!StaticRepo::checkParam($idRDV,'Integer')){return false;} - -         $date = date('Y-m-d H:i:s',strtotime($dateTime)); -         $req = StaticRepo::getConnexion()->prepare('UPDATE RDV SET DateRDV = :date WHERE id = :id'); -         return $req->execute(['date' => $date, -             'id' => $idRDV]); -     } - -     public static function getByPatientAndDate($idPatient,$date){ +     public static function add($date,$duree,$idPatient,$idMedecin){ + +         if(!StaticRepo::checkParam($date,'Date') && !StaticRepo::checkParam($duree,'Integer') && !StaticRepo::checkParam($idPatient,'Integer') && !StaticRepo::checkParam($idMedecin,'Integer')){return false;} + +         $date = date('Y-m-d H:i:s',strtotime($date)); +         $duree = date('H:i:s',$duree*60); +         $req = StaticRepo::getConnexion()->prepare('INSERT INTO RDV VALUES (DEFAULT,:date,:duree,:patient,:medecin)'); +         $result = $req->execute(['date' => $date, +             'duree' => $duree, +             'patient' => $idPatient, +             'medecin' => $idMedecin]); + +         //PDO renvoie un ID sous forme de char, on transtype +         $id = StaticRepo::getConnexion()->lastInsertId(); +         settype($id,'integer'); +         if($result){return $id;} +         else{return false;} +     } -         if(!StaticRepo::checkParam($idPatient,'Integer') && !StaticRepo::checkParam($date,'Date')){return false;} +     public static function updateDateTime($idRDV, $dateRdv, $duree){ -         $date = date('Y-m-d',strtotime($date)); -         $req = StaticRepo::getConnexion()->prepare('SELECT * FROM RDV WHERE Patient_Id=:patient AND DATE(DateRDV)=:date'); -         $req->execute(['patient' => $idPatient, -             'date' => $date]); -         return StaticRepo::delNumeric($req->fetchAll()); -     } - -     public static function getAll($date = 0){ - -         if(!StaticRepo::checkParam($date,'Integer')){return false;} - -         $dateTime = date('Y-m-d',time()); -         switch($date){ -             case -1: -                 $req = StaticRepo::getConnexion()->prepare('SELECT * FROM RDV WHERE DATE(DateRDV) <= :date ORDER BY DateRDV ASC'); -                 $req->execute(['date' => $dateTime]); -                 break; -             case 0: -                 $req = StaticRepo::getConnexion()->prepare('SELECT * FROM RDV ORDER BY DateRDV ASC'); -                 $req->execute(); -                 break; -             case 1: -                 $req = StaticRepo::getConnexion()->prepare('SELECT * FROM RDV WHERE DATE(DateRDV) >= :date ORDER BY DateRDV ASC'); -                 $req->execute(['date' => $dateTime]); -                 break; -         } -         return StaticRepo::delNumeric($req->fetchAll()); -     } - -     public static function getByMonth($date){ - -         if(!StaticRepo::checkParam($date,'Date')){return false;} - -         $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()); -     } - - } +         if(!StaticRepo::checkParam($idRDV, 'Numeric')) return false; + +         $req = StaticRepo::getConnexion()->prepare('UPDATE RDV SET DateRDV = :date_rdv, Duree = :duree WHERE id = :id'); +         return $req->execute([ +             ':date_rdv' => $dateRdv, +             ':duree' => $duree, +             ':id' => $idRDV +         ]); +     } + +     public static function getByPatientAndDate($idPatient,$date){ + +         if(!StaticRepo::checkParam($idPatient,'Integer') && !StaticRepo::checkParam($date,'Date')){return false;} + +         $date = date('Y-m-d',strtotime($date)); +         $req = StaticRepo::getConnexion()->prepare('SELECT * FROM RDV WHERE Patient_Id=:patient AND DATE(DateRDV)=:date'); +         $req->execute(['patient' => $idPatient, +             'date' => $date]); +         return StaticRepo::delNumeric($req->fetchAll()); +     } + +     public static function getAll($date = 0){ + +         if(!StaticRepo::checkParam($date,'Integer')){return false;} + +         $dateTime = date('Y-m-d',time()); +         switch($date){ +             case -1: +                 $req = StaticRepo::getConnexion()->prepare('SELECT * FROM RDV WHERE DATE(DateRDV) <= :date ORDER BY DateRDV ASC'); +                 $req->execute(['date' => $dateTime]); +                 break; +             case 0: +                 $req = StaticRepo::getConnexion()->prepare('SELECT * FROM RDV ORDER BY DateRDV ASC'); +                 $req->execute(); +                 break; +             case 1: +                 $req = StaticRepo::getConnexion()->prepare('SELECT * FROM RDV WHERE DATE(DateRDV) >= :date ORDER BY DateRDV ASC'); +                 $req->execute(['date' => $dateTime]); +                 break; +         } +         return StaticRepo::delNumeric($req->fetchAll()); +     } + +     public static function getByMonth($date){ + +         $strDate = date( 'Y-m-d', $date ); + +         // si erreur on retourne un tableau vide +         if( !StaticRepo::checkParam($strDate, 'Date') ) return []; + +         $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', $date ), +             'year'  => date( 'Y', $date ) +         ]); + +         return StaticRepo::delNumeric( $req->fetchAll() ); +     } + + } @@ -397,7 +437,7 @@ Dead Code

- 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. + Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.1 and PHPUnit 5.1.3 at Sun Jan 3 17:34:44 UTC 2016.

diff --git a/coverage/repos/StatsRepo.php.html b/coverage/repos/StatsRepo.php.html index a221471..66b83a2 100755 --- a/coverage/repos/StatsRepo.php.html +++ b/coverage/repos/StatsRepo.php.html @@ -61,13 +61,13 @@
1 / 2
CRAP
-
- 92.31% covered (success) +
+ 93.55% covered (success)
-
92.31%
-
24 / 26
+
93.55%
+
29 / 31
@@ -88,15 +88,15 @@
50.00%
1 / 2
- 9.04 + 9.02
-
- 92.31% covered (success) +
+ 93.55% covered (success)
-
92.31%
-
24 / 26
+
93.55%
+
29 / 31
@@ -109,19 +109,19 @@
0.00%
0 / 1
- 8.04 + 8.03
-
- 91.30% covered (success) +
+ 92.59% covered (success)
-
91.30%
-
21 / 23
+
92.59%
+
25 / 27
-  getRDVStat +  getRDVStat
100.00% covered (success) @@ -138,7 +138,7 @@
100.00%
-
3 / 3
+
4 / 4
@@ -163,44 +163,51 @@         $homme = ['25-'=>0,'25-50'=>0,'50+'=>0];         $femme = ['25-'=>0,'25-50'=>0,'50+'=>0]; -         foreach($patients as $key=>$patient){ -             $dateNaissance = strtotime($patient['DateNaissance']); -             $age = date('Y',time()-$dateNaissance); -             $patient['age'] = $age - 1970; - -             switch($patient['Civilite']){ -                 case 'M': -                     if($patient['age']<25){ -                         $homme['25-']++; -                     }elseif($patient['age']<50){ -                         $homme['25-50']++; -                     }else{ -                         $homme['50+']++; -                     } -                     break; -                 case 'F': -                     if($patient['age']<25){ -                         $femme['25-']++; -                     }elseif($patient['age']<50){ -                         $femme['25-50']++; -                     }else{ -                         $femme['50+']++; -                     } -                     break; -             } -         } - -         return ['H'=>$homme,'F'=>$femme]; -     } - -     public static function getRDVStat($medecin){ -         $req = StaticRepo::getConnexion()->prepare('SELECT count(*) NombreRDV FROM RDV WHERE Medecin_id = :medecin;'); -         $req->execute(['medecin'=>$medecin]); -         return StaticRepo::delNumeric($req->fetch(),true); -     } - - - } +         $nbrHomme=0; +         $nbrFemme=0; + +         foreach($patients as $key=>$patient){ +             $dateNaissance = strtotime($patient['DateNaissance']); +             $age = date('Y',time()-$dateNaissance); +             $patient['age'] = $age - 1970; + +             switch($patient['Civilite']){ +                 case 'M': +                     $nbrHomme++; +                     if($patient['age']<25){ +                         $homme['25-']++; +                     }elseif($patient['age']<50){ +                         $homme['25-50']++; +                     }else{ +                         $homme['50+']++; +                     } +                     break; +                 case 'F': +                     $nbrFemme++; +                     if($patient['age']<25){ +                         $femme['25-']++; +                     }elseif($patient['age']<50){ +                         $femme['25-50']++; +                     }else{ +                         $femme['50+']++; +                     } +                     break; +             } +         } + +         return ['H'=>$homme,'F'=>$femme,'NbrH'=>$nbrHomme,'NbrF'=>$nbrFemme]; +     } + +     public static function getRDVStat($medecin){ +         $req = StaticRepo::getConnexion()->prepare('SELECT count(*) NombreRDV, sum((HOUR(Duree)*60)+MINUTE(Duree)) AS DureeTotale FROM RDV WHERE Medecin_id = :medecin;'); +         $req->execute(['medecin'=>$medecin]); +         $returned = StaticRepo::delNumeric($req->fetch(),true); + +         return $returned; +     } + + + } @@ -213,7 +220,7 @@ Dead Code

- 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. + Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.1 and PHPUnit 5.1.3 at Sun Jan 3 17:34:44 UTC 2016.

diff --git a/coverage/repos/dashboard.html b/coverage/repos/dashboard.html index a8142b7..2d229e8 100755 --- a/coverage/repos/dashboard.html +++ b/coverage/repos/dashboard.html @@ -112,7 +112,7 @@ - getAll86% + getAll86% add88% @@ -130,8 +130,8 @@ - getAll5 - add5 + getAll5 + add3 @@ -141,7 +141,7 @@
@@ -180,7 +180,7 @@ $(document).ready(function() { .yAxis.tickFormat(d3.format('d')); d3.select('#methodCoverageDistribution svg') - .datum(getCoverageDistributionData([0,0,0,0,0,0,0,0,0,2,4,17], "Method Coverage")) + .datum(getCoverageDistributionData([0,0,0,0,0,0,0,0,0,2,3,20], "Method Coverage")) .transition().duration(500).call(chart); nv.utils.windowResize(chart.update); @@ -230,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>"],[94.642857142857,24,"RDVRepo<\/a>"],[92.307692307692,9,"StatsRepo<\/a>"]], 'Class Complexity')) + .datum(getComplexityData([[97.058823529412,17,"MedecinRepo<\/a>"],[97.560975609756,46,"PatientRepo<\/a>"],[96.774193548387,25,"RDVRepo<\/a>"],[93.548387096774,9,"StatsRepo<\/a>"]], 'Class Complexity')) .transition() .duration(500) .call(chart); @@ -254,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>"],[100,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,3,"MedecinRepo::add<\/a>"],[100,2,"MedecinRepo::delete<\/a>"],[100,6,"MedecinRepo::search<\/a>"],[100,2,"MedecinRepo::getPatients<\/a>"],[100,1,"MedecinRepo::getAll<\/a>"],[100,1,"MedecinRepo::update<\/a>"],[100,2,"PatientRepo::getById<\/a>"],[96.774193548387,16,"PatientRepo::add<\/a>"],[96.774193548387,16,"PatientRepo::update<\/a>"],[100,2,"PatientRepo::delete<\/a>"],[100,3,"PatientRepo::updateMedecinTraitant<\/a>"],[100,6,"PatientRepo::search<\/a>"],[100,1,"PatientRepo::getAll<\/a>"],[100,2,"RDVRepo::getById<\/a>"],[100,1,"RDVRepo::getForMonth<\/a>"],[100,2,"RDVRepo::getByDate<\/a>"],[100,2,"RDVRepo::delete<\/a>"],[100,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>"],[92.592592592593,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 d575f2a..75178d7 100755 --- a/coverage/repos/index.html +++ b/coverage/repos/index.html @@ -44,21 +44,21 @@ Total
-
- 95.74% covered (success) +
+ 96.65% covered (success)
-
95.74%
-
180 / 188
+
96.65%
+
202 / 209
-
- 73.91% covered (warning) +
+ 80.00% covered (warning)
-
73.91%
-
17 / 23
+
80.00%
+
20 / 25
0.00% covered (danger) @@ -72,21 +72,21 @@ MedecinRepo.php
-
- 96.43% covered (success) +
+ 97.06% covered (success)
-
96.43%
-
27 / 28
+
97.06%
+
33 / 34
-
- 83.33% covered (warning) +
+ 85.71% covered (warning)
-
83.33%
-
5 / 6
+
85.71%
+
6 / 7
0.00% covered (danger) @@ -100,13 +100,13 @@ PatientRepo.php
-
- 97.44% covered (success) +
+ 97.56% covered (success)
-
97.44%
-
76 / 78
+
97.56%
+
80 / 82
71.43% covered (warning) @@ -128,21 +128,21 @@ RDVRepo.php
-
- 94.64% covered (success) +
+ 96.77% covered (success)
-
94.64%
-
53 / 56
+
96.77%
+
60 / 62
-
- 75.00% covered (warning) +
+ 88.89% covered (warning)
-
75.00%
-
6 / 8
+
88.89%
+
8 / 9
0.00% covered (danger) @@ -156,13 +156,13 @@ StatsRepo.php
-
- 92.31% covered (success) +
+ 93.55% covered (success)
-
92.31%
-
24 / 26
+
93.55%
+
29 / 31
50.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 8:04:45 UTC 2015. + Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.1 and PHPUnit 5.1.3 at Sun Jan 3 17:34:44 UTC 2016.

diff --git a/css/global.css b/css/global.css index a0135c0..e305f21 100755 --- a/css/global.css +++ b/css/global.css @@ -963,4 +963,58 @@ input[type=radio]:checked + label:before{ left: calc( 100% - 3em ); top: .5em; background-image: url(../src/svg/edit.svg) !important; +} + +/* Conteneur des barres de stats du Dashboard */ +.StatContainer{ + float: left; + margin-top: 20px; + height: 240px; + width:50%; +} + +/* classe pour clear après des floats */ +.clear{ + clear: both; +} + +.bar{ + float: left; + width: 15%; + margin-right: 10%; +} + +.man{ + background-color: #F09108; +} + +.woman{ + background-color: #E04F5F; +} + +.labels{ + width: 100%; + height: 30px; +} + +.label{ + display: block; + float: left; + width: 15%; + margin-right: 10%; + text-align: center; + text-decoration: underline; +} + +.value{ + text-decoration: none; + font-size: 1.4em; +} + +.title{ + display: block; + width: 100%; + margin: 0px; + text-align: center; + font-size: 1.8em; } \ No newline at end of file diff --git a/repositories/repos/MedecinRepo.php b/repositories/repos/MedecinRepo.php index 6ef2e81..c53c489 100755 --- a/repositories/repos/MedecinRepo.php +++ b/repositories/repos/MedecinRepo.php @@ -21,7 +21,7 @@ class MedecinRepo public static function add($civilite,$prenom,$nom){ - if(!StaticRepo::checkParam($civilite,'Civilite') && !StaticRepo::checkParam($prenom,'String45') && !StaticRepo::checkParam($nom,'String45')) return false; + if(!StaticRepo::checkParam($civilite,'Civilite') | !StaticRepo::checkParam($prenom,'String45') | !StaticRepo::checkParam($nom,'String45')) return false; $req = StaticRepo::getConnexion()->prepare('INSERT INTO Medecin VALUES (DEFAULT,:civilite,:prenom,:nom)'); $result = $req->execute(['civilite' => $civilite, @@ -50,7 +50,7 @@ class MedecinRepo public static function search($nom, $prenom){ - if( !StaticRepo::checkParam($prenom,'String45') && !StaticRepo::checkParam($nom,'String45') ) return false; + if( !StaticRepo::checkParam($prenom,'String45') | !StaticRepo::checkParam($nom,'String45') ) return false; // on définit les valeurs (peuvent être nulles) $optPrenom = ( $prenom != 'null' && StaticRepo::checkParam($prenom,'String45') ) ? '%'.$prenom.'%' : '%'; diff --git a/repositories/repos/PatientRepo.php b/repositories/repos/PatientRepo.php index 247817d..3a4fe27 100755 --- a/repositories/repos/PatientRepo.php +++ b/repositories/repos/PatientRepo.php @@ -162,7 +162,7 @@ class PatientRepo public static function search($nom, $prenom){ - if( !StaticRepo::checkParam($prenom,'String45') && !StaticRepo::checkParam($nom,'String45') ) return false; + if( !StaticRepo::checkParam($prenom,'String45') | !StaticRepo::checkParam($nom,'String45') ) return false; // on définit les valeurs (peuvent être nulles) $optPrenom = ( $prenom != 'null' && StaticRepo::checkParam($prenom,'String45') ) ? '%'.$prenom.'%' : '%'; diff --git a/repositories/repos/RDVRepo.php b/repositories/repos/RDVRepo.php index 617e81d..3db4ca5 100755 --- a/repositories/repos/RDVRepo.php +++ b/repositories/repos/RDVRepo.php @@ -72,9 +72,6 @@ class RDVRepo if(!StaticRepo::checkParam($idRDV, 'Numeric')) return false; - var_dump($idRDV); - var_dump($dateRdv); - var_dump($duree); $req = StaticRepo::getConnexion()->prepare('UPDATE RDV SET DateRDV = :date_rdv, Duree = :duree WHERE id = :id'); return $req->execute([ ':date_rdv' => $dateRdv, diff --git a/repositories/repos/StatsRepo.php b/repositories/repos/StatsRepo.php index 5a5d91b..5f39354 100755 --- a/repositories/repos/StatsRepo.php +++ b/repositories/repos/StatsRepo.php @@ -15,6 +15,9 @@ class StatsRepo $homme = ['25-'=>0,'25-50'=>0,'50+'=>0]; $femme = ['25-'=>0,'25-50'=>0,'50+'=>0]; + $nbrHomme=0; + $nbrFemme=0; + foreach($patients as $key=>$patient){ $dateNaissance = strtotime($patient['DateNaissance']); $age = date('Y',time()-$dateNaissance); @@ -22,6 +25,7 @@ class StatsRepo switch($patient['Civilite']){ case 'M': + $nbrHomme++; if($patient['age']<25){ $homme['25-']++; }elseif($patient['age']<50){ @@ -31,6 +35,7 @@ class StatsRepo } break; case 'F': + $nbrFemme++; if($patient['age']<25){ $femme['25-']++; }elseif($patient['age']<50){ @@ -42,13 +47,15 @@ class StatsRepo } } - return ['H'=>$homme,'F'=>$femme]; + return ['H'=>$homme,'F'=>$femme,'NbrH'=>$nbrHomme,'NbrF'=>$nbrFemme]; } public static function getRDVStat($medecin){ - $req = StaticRepo::getConnexion()->prepare('SELECT count(*) NombreRDV FROM RDV WHERE Medecin_id = :medecin;'); + $req = StaticRepo::getConnexion()->prepare('SELECT count(*) NombreRDV, sum((HOUR(Duree)*60)+MINUTE(Duree)) AS DureeTotale FROM RDV WHERE Medecin_id = :medecin;'); $req->execute(['medecin'=>$medecin]); - return StaticRepo::delNumeric($req->fetch(),true); + $returned = StaticRepo::delNumeric($req->fetch(),true); + + return $returned; } diff --git a/test/MedecinRepoTest.php b/test/MedecinRepoTest.php index cc161aa..2df169a 100755 --- a/test/MedecinRepoTest.php +++ b/test/MedecinRepoTest.php @@ -17,10 +17,14 @@ class MedecinRepoTest extends PHPUnit_Framework_TestCase public function testConstruct(){ $this->assertTrue(new MedecinRepo() instanceof MedecinRepo); } - public function testAddAndDelete(){ + public function testAddDeleteUpdate(){ $id = $this->repo->add('M','Lucas','Mascaro'); $this->assertNotNull($id); + $this->assertTrue($this->repo->update($id,'Mascara','Loucasse')); + $this->assertEquals($this->repo->getById($id)['Nom'],'MASCARA'); $this->assertTrue($this->repo->delete($id)); + + $this->assertFalse($this->repo->add('Z','Lucas','Mascaro')); } public function testSearch(){ diff --git a/test/RDVRepoTest.php b/test/RDVRepoTest.php index aca1c52..89ea33b 100755 --- a/test/RDVRepoTest.php +++ b/test/RDVRepoTest.php @@ -24,6 +24,9 @@ class RDVRepoTest extends PHPUnit_Framework_TestCase $this->assertNotNull($id); $this->assertNotFalse($id); $this->assertTrue($this->repo->delete($id)); + + $this->assertFalse($this->repo->add(date('Y-m-d H:i:s',time()),30,2,-1)); + } public function testGetById(){ @@ -33,36 +36,40 @@ class RDVRepoTest extends PHPUnit_Framework_TestCase public function testUpdateTime(){ $date = date('Y-m-d H:i:s',time()); - $this->assertTrue($this->repo->updateDateTime(1,$date)); + $this->assertTrue($this->repo->updateDateTime(1,$date,'00:30:00')); $result = $this->repo->getById(1); $this->assertEquals($date,$result['DateRDV']); } public function testGetByDate(){ $date = date('Y-m-d H:i:s',time()); - $this->assertTrue($this->repo->updateDateTime(1,$date)); - $result = $this->repo->getByDate($date = date('Y/m/d',strtotime($date))); + $this->assertTrue($this->repo->updateDateTime(1,$date,'00:30:00')); + $result = $this->repo->getByDate(date('Y-m-d',strtotime($date))); $this->assertTrue(isset($result[0])); $this->assertEquals($result[0]['Id'],1); } public function testGetByPAtientAndDate(){ $date = '2015-12-20 13:33:00'; - $this->assertTrue($this->repo->updateDateTime(1,$date)); + $this->assertTrue($this->repo->updateDateTime(1,$date,'00:30:00')); $result = $this->repo->getByPatientAndDate(14,date('Y-m-d',strtotime($date))); $this->assertTrue(isset($result[0])); $this->assertEquals($result[0]['Id'],1); } public function testGetAll(){ - $this->assertEquals(count($this->repo->getAll(-1)),99); + $this->assertEquals(count($this->repo->getAll(-1)),100); $this->assertEquals(count($this->repo->getAll(0)),100); - $this->assertEquals(count($this->repo->getAll(1)),1); + $this->assertEquals(count($this->repo->getAll(1)),0); } public function testGetByMonth(){ $date = '2015-12-00 00:00:00'; - $this->assertEquals(count($this->repo->getByMonth(date('Y-m-d',strtotime($date)))),13); + $this->assertEquals(count($this->repo->getByMonth(strtotime($date))),13); + } + + public function testGetForMonth(){ + $this->assertEquals(count($this->repo->getForMonth('12','2015')),2); } } diff --git a/test/StatsRepoTest.php b/test/StatsRepoTest.php index 4b1a135..84d6de5 100755 --- a/test/StatsRepoTest.php +++ b/test/StatsRepoTest.php @@ -9,13 +9,14 @@ class StatsRepoTest extends PHPUnit_Framework_TestCase { public function testAgePatient(){ - $array=['H'=>['25-'=>31,'25-50'=>2,'50+'=>16],'F'=>['25-'=>36,'25-50'=>6,'50+'=>9]]; + $array=['H'=>['25-'=>31,'25-50'=>2,'50+'=>16],'F'=>['25-'=>36,'25-50'=>6,'50+'=>9],'NbrH'=>49,'NbrF'=>51]; $this->assertEquals(StatsRepo::getAgePatient(),$array); } public function testRDVStat(){ $this->assertEquals(StatsRepo::getRDVStat(2)['NombreRDV'],2); + $this->assertEquals(StatsRepo::getRDVStat(2)['DureeTotale'],120); } }