Commit d7f8c94fc8c076eda95be36c64af39a14e99b62e
1 parent
e4729831
Exists in
master
and in
1 other branch
Stats avec pourcentages (en plus des valeurs absolues)
Showing
2 changed files
with
32 additions
and
33 deletions
Show diff stats
src/Controller/PagesController.php
... | ... | @@ -298,8 +298,6 @@ class PagesController extends AppController |
298 | 298 | // - Page des STATISTIQUES |
299 | 299 | if ($this->page=='stats') { |
300 | 300 | |
301 | - // TODO: créer le champ 'date_status_changed' dans materiels mis à jour à chaque changement d'état du matos | |
302 | - | |
303 | 301 | // - Année en cours |
304 | 302 | $now = new \DateTime('now'); |
305 | 303 | //debug($now); |
... | ... | @@ -373,9 +371,7 @@ class PagesController extends AppController |
373 | 371 | }); |
374 | 372 | //$year_min = 2009; |
375 | 373 | $year_min = (int) $matos_year_min->date_acquisition->format('Y'); |
376 | - // TODO: | |
377 | - // Ajouter progression d'année en année (2020 = 2019 +/- 10%) | |
378 | - // Ajouter % validé, archivé | |
374 | + // TODO: Ajouter progression d'année en année (2020 = 2019 +/- 10%) | |
379 | 375 | for ($y=$year ; $y>$year_min ; $y--) { |
380 | 376 | //debug($y); |
381 | 377 | try { | ... | ... |
src/Template/Pages/stats.ctp
... | ... | @@ -26,6 +26,29 @@ $years = $years; |
26 | 26 | $avg = $avg; |
27 | 27 | $tot = $tot; |
28 | 28 | |
29 | + | |
30 | + | |
31 | +function displayStatsLine($title, $line) { | |
32 | + ?> | |
33 | + <tr> | |
34 | + <td><b><?=$title?></b></td> | |
35 | + <?php | |
36 | + $total = $line['CREATED']; | |
37 | + ?> | |
38 | + <td><?=$total?></td> | |
39 | + <?php | |
40 | + $pct_validated = round( ($line['VALIDATED'] / $total) * 100 ); | |
41 | + ?> | |
42 | + <td><?=$line['VALIDATED']." ($pct_validated%)"?></td> | |
43 | + <td><?=$line['TOBEARCHIVED']?></td> | |
44 | + <?php | |
45 | + $pct_archived = round( ($line['ARCHIVED'] / $total) * 100 ); | |
46 | + ?> | |
47 | + <td><?=$line['ARCHIVED']." ($pct_archived%)"?></td> | |
48 | + </tr> | |
49 | + <?php | |
50 | +} | |
51 | + | |
29 | 52 | ?> |
30 | 53 | |
31 | 54 | |
... | ... | @@ -60,23 +83,12 @@ $tot = $tot; |
60 | 83 | |
61 | 84 | <!-- LIGNES DATA --> |
62 | 85 | |
63 | - <tr> | |
64 | - <td><b>Moyenne par an</b></td> | |
65 | - <td><?=$avg['CREATED']?></td> | |
66 | - <td><?=$avg['VALIDATED']?></td> | |
67 | - <td><?=$avg['TOBEARCHIVED']?></td> | |
68 | - <td><?=$avg['ARCHIVED']?></td> | |
69 | - </tr> | |
86 | + <?php | |
87 | + displayStatsLine('Total Général', $tot); | |
88 | + displayStatsLine('Moyenne par an', $avg); | |
89 | + ?> | |
70 | 90 | |
71 | 91 | <tr> |
72 | - <td><b>Total Général</b></td> | |
73 | - <td><?=$tot['CREATED']?></td> | |
74 | - <td><?=$tot['VALIDATED']?></td> | |
75 | - <td><?=$tot['TOBEARCHIVED']?></td> | |
76 | - <td><?=$tot['ARCHIVED']?></td> | |
77 | - </tr> | |
78 | - | |
79 | - <tr> | |
80 | 92 | <td><b></b></td> |
81 | 93 | <td></td> |
82 | 94 | <td></td> |
... | ... | @@ -84,21 +96,12 @@ $tot = $tot; |
84 | 96 | </tr> |
85 | 97 | |
86 | 98 | <!-- ANNÉE PAR ANNÉE (1 ligne par année) --> |
99 | + | |
87 | 100 | <?php |
88 | 101 | foreach ($years as $y=>$val) { |
89 | - ?> | |
90 | - <tr> | |
91 | - <?php | |
92 | - $year_title = $y; | |
93 | - if ($y==$year) $year_title = "Année en cours ($y)"; | |
94 | - ?> | |
95 | - <td><b><?=$year_title?></b></td> | |
96 | - <td><?=$val['CREATED']?></td> | |
97 | - <td><?=$val['VALIDATED']?></td> | |
98 | - <td><?=$val['TOBEARCHIVED']?></td> | |
99 | - <td><?=$val['ARCHIVED']?></td> | |
100 | - </tr> | |
101 | - <?php | |
102 | + $year_title = $y; | |
103 | + if ($y==$year) $year_title = "Année en cours ($y)"; | |
104 | + displayStatsLine($year_title, $val); | |
102 | 105 | } |
103 | 106 | ?> |
104 | 107 | ... | ... |