diff --git a/CHANGELOG b/CHANGELOG
index 5c48bd5..651b2f4 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -631,6 +631,10 @@ Ne pas autoriser la commande via url si le bouton order est désactivé dans la
======= CHANGES =======
-------
+25/11/2021 v5.3.9-3.7.9
+ - (b) Bugfix page statistique sur les matériels (conditions limites, division par zéro quand année précédente nulle)
+
+-------
24/11/2021 v5.3.8-3.7.9
- (e) Nouvelle Amélioration (bugfix) de la présentation de la page de configuration des champs obligatoires
- (e) Amélioration de toutes les pages de config : pliées par défaut
diff --git a/README.md b/README.md
index 9ef8073..30a8bc2 100644
--- a/README.md
+++ b/README.md
@@ -52,8 +52,8 @@ Logiciel testé et validé sur les configurations suivantes :
--------------------------------------------------------------------------------------------
-Date: 24/11/2021
-Version: v5.3.8-3.7.9
+Date: 25/11/2021
+Version: v5.3.9-3.7.9
HISTORIQUE DES CHANGEMENTS DE VERSION : voir le fichier CHANGES.txt (ou la page web /pages/changes)
diff --git a/src/Template/Pages/stats.ctp b/src/Template/Pages/stats.ctp
index 5cdc492..a86d243 100644
--- a/src/Template/Pages/stats.ctp
+++ b/src/Template/Pages/stats.ctp
@@ -76,55 +76,78 @@ function displayEmptyLine() {
";
}
-
+// 100 * (current - prev) / prev
+function computeEvolutionFromPrevToCurrent($prev,$current) {
+ $evol_from_year_prev = round ( 100 * ($current-$prev) / $prev );
+ if ($evol_from_year_prev >= 0) $evol_from_year_prev = '+'.$evol_from_year_prev;
+ return $evol_from_year_prev.'%';
+}
//function displayStatsLine($title, $line, $suivis, $prets, $bold=false, $year_prev=null, $avg=null) {
-function displayStatsLine($title, $line, $is_bold=false, $year_prev=null, $avg=null) {
+function displayStatsLine($title, $line, $is_bold=false, $year_prev_tot=-1, $avg=-1) {
//debug($line);
?>
=$title?> |
-
-
+
+
+
+
=0) $evol_from_year_prev = '+'.$evol_from_year_prev;
- $evol_from_year_prev .= '%';
+ //$evol_from_year_prev = '/';
+ $evol_from_year_prev = $year_prev_tot>0 ? computeEvolutionFromPrevToCurrent($year_prev_tot, $year_curr_tot) : '/';
+ /* inutile, on fait pas des maths ici
+ // - Si prev = 0 => éviter division par zéro, résultat = +/- INFINI
+ if ($year_prev_tot==0) {
+ if ($year_curr_tot==0) $evol_from_year_prev = '+0';
+ else $evol_from_year_prev = $year_curr_tot>0 ? '+INF' : '-INF';
}
+ // - Si prev <> 0 => Cas nominal
+ else {
+ $evol_from_year_prev = round ( 100 * ($year_curr_tot-$year_prev_tot) / $year_prev_tot );
+ if ($evol_from_year_prev >= 0) $evol_from_year_prev = '+'.$evol_from_year_prev;
+ $evol_from_year_prev .= '%';
+ */
+ ?>
+ =$evol_from_year_prev?> |
+
+
+ 0 ? computeEvolutionFromPrevToCurrent($avg, $year_curr_tot) : '/';
+ /*
if ($avg) {
- $evol_from_avg = round (($total-$avg['CREATED'])/$avg['CREATED'] * 100);
+ $evol_from_avg = round (($year_curr_tot-$avg['CREATED'])/$avg['CREATED'] * 100);
if ($evol_from_avg>=0) $evol_from_avg = '+'.$evol_from_avg;
$evol_from_avg .= '%';
}
+ */
?>
- =$evol_from_year_prev?> |
=$evol_from_avg?> |
- =echoAsPctAndBold($total, null, $is_bold)?> |
+ =echoAsPctAndBold($year_curr_tot, null, $is_bold)?> |
- =echoAsPctAndBold($line['VALIDATED'], $total, $is_bold)?> |
+ =echoAsPctAndBold($line['VALIDATED'], $year_curr_tot, $is_bold)?> |
- =echoAsPctAndBold($line['TOBEARCHIVED'], $total, $is_bold)?> |
+ =echoAsPctAndBold($line['TOBEARCHIVED'], $year_curr_tot, $is_bold)?> |
- =echoAsPctAndBold($line['ARCHIVED'], $total, $is_bold)?> |
+ =echoAsPctAndBold($line['ARCHIVED'], $year_curr_tot, $is_bold)?> |
- =echoAsPctAndBold($line['suivis'], $total, $is_bold)?> |
+ =echoAsPctAndBold($line['suivis'], $year_curr_tot, $is_bold)?> |
- =echoAsPctAndBold($line['prets'], $total, $is_bold)?> |
+ =echoAsPctAndBold($line['prets'], $year_curr_tot, $is_bold)?> |
Form->end();
$val = $years[$y];
$year_title = $y;
if ($y==$current_year) $year_title = "Année en cours ($y)";
- $year_prev = $y==$year_min ? null : $years[$y-1];
- displayStatsLine($year_title, $val, false, $year_prev, $avg);
+ $year_prev_tot = $y==$year_min ? -1 : $years[$y-1]['CREATED'];
+ displayStatsLine($year_title, $val, false, $year_prev_tot, $avg['CREATED']);
}
?>
--
libgit2 0.21.2