Commit 5f149ade6fe7e2c0f068af36ff255109c61ab844
1 parent
9849f8a7
Exists in
master
and in
1 other branch
Bugfix page statistique sur les matériels (conditions limites, division
par zéro quand année précédente nulle) v5.3.9-3.7.9
Showing
3 changed files
with
50 additions
and
23 deletions
Show diff stats
CHANGELOG
... | ... | @@ -631,6 +631,10 @@ Ne pas autoriser la commande via url si le bouton order est désactivé dans la |
631 | 631 | ======= CHANGES ======= |
632 | 632 | |
633 | 633 | ------- |
634 | +25/11/2021 v5.3.9-3.7.9 | |
635 | + - (b) Bugfix page statistique sur les matériels (conditions limites, division par zéro quand année précédente nulle) | |
636 | + | |
637 | +------- | |
634 | 638 | 24/11/2021 v5.3.8-3.7.9 |
635 | 639 | - (e) Nouvelle Amélioration (bugfix) de la présentation de la page de configuration des champs obligatoires |
636 | 640 | - (e) Amélioration de toutes les pages de config : pliées par défaut | ... | ... |
README.md
... | ... | @@ -52,8 +52,8 @@ Logiciel testé et validé sur les configurations suivantes : |
52 | 52 | |
53 | 53 | -------------------------------------------------------------------------------------------- |
54 | 54 | |
55 | -Date: 24/11/2021 | |
56 | -Version: v5.3.8-3.7.9 | |
55 | +Date: 25/11/2021 | |
56 | +Version: v5.3.9-3.7.9 | |
57 | 57 | |
58 | 58 | |
59 | 59 | HISTORIQUE DES CHANGEMENTS DE VERSION : voir le fichier CHANGES.txt (ou la page web /pages/changes) | ... | ... |
src/Template/Pages/stats.ctp
... | ... | @@ -76,55 +76,78 @@ function displayEmptyLine() { |
76 | 76 | </tr>"; |
77 | 77 | } |
78 | 78 | |
79 | - | |
79 | +// 100 * (current - prev) / prev | |
80 | +function computeEvolutionFromPrevToCurrent($prev,$current) { | |
81 | + $evol_from_year_prev = round ( 100 * ($current-$prev) / $prev ); | |
82 | + if ($evol_from_year_prev >= 0) $evol_from_year_prev = '+'.$evol_from_year_prev; | |
83 | + return $evol_from_year_prev.'%'; | |
84 | +} | |
80 | 85 | //function displayStatsLine($title, $line, $suivis, $prets, $bold=false, $year_prev=null, $avg=null) { |
81 | -function displayStatsLine($title, $line, $is_bold=false, $year_prev=null, $avg=null) { | |
86 | +function displayStatsLine($title, $line, $is_bold=false, $year_prev_tot=-1, $avg=-1) { | |
82 | 87 | //debug($line); |
83 | 88 | ?> |
84 | 89 | <tr> |
85 | 90 | |
86 | 91 | <!-- Titre --> |
87 | 92 | <td><b><?=$title?></b></td> |
88 | - | |
89 | - <!-- Evolution \N-1 et \avg --> | |
93 | + | |
94 | + <?php | |
95 | + $year_curr_tot = $line['CREATED']; | |
96 | + ?> | |
97 | + | |
98 | + <!-- Evolution \ N-1 --> | |
90 | 99 | <?php |
91 | - $total = $line['CREATED']; | |
92 | - $evol_from_year_prev = '/'; | |
93 | - $evol_from_avg = '/'; | |
94 | - if ($year_prev) { | |
95 | - $evol_from_year_prev = round (($total-$year_prev['CREATED'])/$year_prev['CREATED'] * 100); | |
96 | - if ($evol_from_year_prev>=0) $evol_from_year_prev = '+'.$evol_from_year_prev; | |
97 | - $evol_from_year_prev .= '%'; | |
100 | + //$evol_from_year_prev = '/'; | |
101 | + $evol_from_year_prev = $year_prev_tot>0 ? computeEvolutionFromPrevToCurrent($year_prev_tot, $year_curr_tot) : '/'; | |
102 | + /* inutile, on fait pas des maths ici | |
103 | + // - Si prev = 0 => éviter division par zéro, résultat = +/- INFINI | |
104 | + if ($year_prev_tot==0) { | |
105 | + if ($year_curr_tot==0) $evol_from_year_prev = '+0'; | |
106 | + else $evol_from_year_prev = $year_curr_tot>0 ? '+INF' : '-INF'; | |
98 | 107 | } |
108 | + // - Si prev <> 0 => Cas nominal | |
109 | + else { | |
110 | + $evol_from_year_prev = round ( 100 * ($year_curr_tot-$year_prev_tot) / $year_prev_tot ); | |
111 | + if ($evol_from_year_prev >= 0) $evol_from_year_prev = '+'.$evol_from_year_prev; | |
112 | + $evol_from_year_prev .= '%'; | |
113 | + */ | |
114 | + ?> | |
115 | + <td><?=$evol_from_year_prev?></td> | |
116 | + | |
117 | + <!-- Evolution \ moyenne --> | |
118 | + <?php | |
119 | + //$evol_from_avg = '/'; | |
120 | + $evol_from_avg = $avg>0 ? computeEvolutionFromPrevToCurrent($avg, $year_curr_tot) : '/'; | |
121 | + /* | |
99 | 122 | if ($avg) { |
100 | - $evol_from_avg = round (($total-$avg['CREATED'])/$avg['CREATED'] * 100); | |
123 | + $evol_from_avg = round (($year_curr_tot-$avg['CREATED'])/$avg['CREATED'] * 100); | |
101 | 124 | if ($evol_from_avg>=0) $evol_from_avg = '+'.$evol_from_avg; |
102 | 125 | $evol_from_avg .= '%'; |
103 | 126 | } |
127 | + */ | |
104 | 128 | ?> |
105 | - <td><?=$evol_from_year_prev?></td> | |
106 | 129 | <td><?=$evol_from_avg?></td> |
107 | 130 | |
108 | 131 | <!-- TOTAL --> |
109 | - <td><?=echoAsPctAndBold($total, null, $is_bold)?></td> | |
132 | + <td><?=echoAsPctAndBold($year_curr_tot, null, $is_bold)?></td> | |
110 | 133 | |
111 | 134 | <!-- VALIDATED --> |
112 | - <td><?=echoAsPctAndBold($line['VALIDATED'], $total, $is_bold)?></td> | |
135 | + <td><?=echoAsPctAndBold($line['VALIDATED'], $year_curr_tot, $is_bold)?></td> | |
113 | 136 | |
114 | 137 | <!-- TBA --> |
115 | 138 | <!-- |
116 | 139 | <td><echoAsPctAndBold($line['TOBEARCHIVED'], null, $is_bold)></td> |
117 | 140 | --> |
118 | - <td><?=echoAsPctAndBold($line['TOBEARCHIVED'], $total, $is_bold)?></td> | |
141 | + <td><?=echoAsPctAndBold($line['TOBEARCHIVED'], $year_curr_tot, $is_bold)?></td> | |
119 | 142 | |
120 | 143 | <!-- ARCHIVED --> |
121 | - <td><?=echoAsPctAndBold($line['ARCHIVED'], $total, $is_bold)?></td> | |
144 | + <td><?=echoAsPctAndBold($line['ARCHIVED'], $year_curr_tot, $is_bold)?></td> | |
122 | 145 | |
123 | 146 | <!-- SUIVIS --> |
124 | - <td><?=echoAsPctAndBold($line['suivis'], $total, $is_bold)?></td> | |
147 | + <td><?=echoAsPctAndBold($line['suivis'], $year_curr_tot, $is_bold)?></td> | |
125 | 148 | |
126 | 149 | <!-- EMPRUNTS --> |
127 | - <td><?=echoAsPctAndBold($line['prets'], $total, $is_bold)?></td> | |
150 | + <td><?=echoAsPctAndBold($line['prets'], $year_curr_tot, $is_bold)?></td> | |
128 | 151 | |
129 | 152 | </tr> |
130 | 153 | <?php |
... | ... | @@ -279,8 +302,8 @@ echo $this->Form->end(); |
279 | 302 | $val = $years[$y]; |
280 | 303 | $year_title = $y; |
281 | 304 | if ($y==$current_year) $year_title = "Année en cours ($y)"; |
282 | - $year_prev = $y==$year_min ? null : $years[$y-1]; | |
283 | - displayStatsLine($year_title, $val, false, $year_prev, $avg); | |
305 | + $year_prev_tot = $y==$year_min ? -1 : $years[$y-1]['CREATED']; | |
306 | + displayStatsLine($year_title, $val, false, $year_prev_tot, $avg['CREATED']); | |
284 | 307 | } |
285 | 308 | |
286 | 309 | ?> | ... | ... |