From 23f8b2d4ba300bfef740184e68aa5acc63882805 Mon Sep 17 00:00:00 2001 From: Etienne Pallier Date: Tue, 30 Nov 2021 10:42:56 +0100 Subject: [PATCH] Bugfix mysql sur filtrage materiels pour partitionnement par site --- CHANGELOG | 6 +++++- README.md | 4 ++-- src/Template/Materiels/stats.ctp | 325 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/Template/Pages/stats.ctp | 324 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ 4 files changed, 332 insertions(+), 327 deletions(-) create mode 100644 src/Template/Materiels/stats.ctp delete mode 100644 src/Template/Pages/stats.ctp diff --git a/CHANGELOG b/CHANGELOG index 3231453..37cb0b3 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -613,9 +613,13 @@ Gestion multi-sites : ======= CHANGES ======= ------- +30/11/2021 v5.4.2-3.7.9 + - (b) bugfix mysql sur filtrage materiels pour partitionnement par site (ça passait sur mysql récent mais pas sur vieux mysql) + => requete sql plus propre + +------- 29/11/2021 v5.4.1-3.7.9 - (i) /pages/stats migré dans /materiels/stats et transformé en simple alias - - (b) bugfix pour IRAP seulement (vieux mysql pourri et vieux php5 pourri !!!) ------- 29/11/2021 v5.4.0-3.7.9 diff --git a/README.md b/README.md index 3d3077a..0ccfd5d 100644 --- a/README.md +++ b/README.md @@ -52,8 +52,8 @@ Logiciel testé et validé sur les configurations suivantes : -------------------------------------------------------------------------------------------- -Date: 29/11/2021 -Version: v5.4.1-3.7.9 +Date: 30/11/2021 +Version: v5.4.2-3.7.9 HISTORIQUE DES CHANGEMENTS DE VERSION : voir le fichier CHANGES.txt (ou la page web /pages/changes) diff --git a/src/Template/Materiels/stats.ctp b/src/Template/Materiels/stats.ctp new file mode 100644 index 0000000..148e89e --- /dev/null +++ b/src/Template/Materiels/stats.ctp @@ -0,0 +1,325 @@ +$year-5 ; $y--) { + $years[$y]['created'] = 8; + $years[$y]['validated'] = 8; + $years[$y]['archived'] = 8; +} + +$suivis = []; +$prets = []; +$suivis['tot'] = 100; +$suivis['avg'] = 10; +for ($y=$current_year ; $y>=$year_min ; $y--) $suivis[$y] = 8; +$prets = $suivis; +*/ + + + +// Parameters passed by controller +$current_year = $current_year; +$year_min = $year_min; +$nbyears = $nbyears; +$avg = $avg; +$tot = $tot; +//$tot2 = $tot2; +$years = $years; +//debug($years); +//debug($tot); + + + + + +function echoAsPctAndBold($nbelem, $total=null, $is_bold=false) { + if ($is_bold) echo ''; + //if ($total !== null && $total>0) { + if ($total !== null) { + // Eviter division par zero + if ($nbelem==0) $total=1; + $pct = round( ($nbelem / $total) * 100 , 1 ); + $nbelem = "$pct% ($nbelem)"; + //$nbelem = "$nbelem ($pct%)"; + //$nbelem = "$pct%"; + } echo $nbelem; + if ($is_bold) echo ''; +} + + +// LIGNE VIDE DE SÉPARATION +function displayEmptyLine() { + echo " + + + + + + + + + + + "; +} + +// 100 * (current - prev) / prev +function computeEvolutionFromPrevToCurrent($prev,$current) { + // On ne fait pas le calcul si l'un des 2 paramètres est nul (ou n'existe pas), car inutile de comparer qqch à un nul (ou inexistant) + //if ($year_curr_tot==0 || $year_prev_tot==0) return '/'; + //if ($prev<=0 || $current<=0) return '/'; + if ($prev<=0 || $current<=0) return '\\'; + $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_tot=-1, $avg=-1) { + //debug($line); + ?> + + + + + + + + + 0 && $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 .= '%'; + */ + ?> + + + + =0) $evol_from_avg = '+'.$evol_from_avg; + $evol_from_avg .= '%'; + } + */ + ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+ +
STATISTIQUES SUR LES MATÉRIELS
+

+ +

+ + + + + + +
Prendre en compte les +Form->create('Statistiques', [ + 'type' => 'get', +]); + //echo ''; + echo $this->Form->control('nbyears', [ + 'id' => 'nby', + //'class' => 'search-input', + 'label' => '', + //'type' => 'text', + 'default' => $nbyears + ]); + /* + echo $this->Form->submit('Chercher', [ + 'name' => 'MaterielSAll', + 'id' => 'MaterielSAll', + 'style' => 'margin: 0px;' + ]); + */ +echo $this->Form->end(); +?> + +dernières années ()
+

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $val) { + $year_title = $y; + if ($y==$year) $year_title = "Année en cours ($y)"; + displayStatsLine($year_title, $val); + } + */ + if ($nbyears>0) + for ($y=$current_year ; $y>=$year_min ; $y--) { + $val = $years[$y]; + $year_title = $y; + if ($y==$current_year) $year_title = "Année en cours ($y)"; + $year_prev_tot = $y==$year_min ? -1 : $years[$y-1]['CREATED']; + displayStatsLine($year_title, $val, false, $year_prev_tot, $avg['CREATED']); + } + + ?> + + + +
Matériels acquisRépartition par statutSuivis et Emprunts
Evol. \ N-1Evol. \ moyenneTotalValidésA archiverArchivésMatériels suivisMatériels prêtés
+ + diff --git a/src/Template/Pages/stats.ctp b/src/Template/Pages/stats.ctp deleted file mode 100644 index 8c775b9..0000000 --- a/src/Template/Pages/stats.ctp +++ /dev/null @@ -1,324 +0,0 @@ -$year-5 ; $y--) { - $years[$y]['created'] = 8; - $years[$y]['validated'] = 8; - $years[$y]['archived'] = 8; -} - -$suivis = []; -$prets = []; -$suivis['tot'] = 100; -$suivis['avg'] = 10; -for ($y=$current_year ; $y>=$year_min ; $y--) $suivis[$y] = 8; -$prets = $suivis; -*/ - - - -// Parameters passed by controller -$current_year = $current_year; -$year_min = $year_min; -$nbyears = $nbyears; -$avg = $avg; -$tot = $tot; -//$tot2 = $tot2; -$years = $years; -//debug($years); -//debug($tot); - - - - - -function echoAsPctAndBold($nbelem, $total=null, $is_bold=false) { - if ($is_bold) echo ''; - //if ($total !== null && $total>0) { - if ($total !== null) { - // Eviter division par zero - if ($nbelem==0) $total=1; - $pct = round( ($nbelem / $total) * 100 , 1 ); - $nbelem = "$pct% ($nbelem)"; - //$nbelem = "$nbelem ($pct%)"; - //$nbelem = "$pct%"; - } echo $nbelem; - if ($is_bold) echo ''; -} - - -// LIGNE VIDE DE SÉPARATION -function displayEmptyLine() { - echo " - - - - - - - - - - - "; -} - -// 100 * (current - prev) / prev -function computeEvolutionFromPrevToCurrent($prev,$current) { - // On ne fait pas le calcul si l'un des 2 paramètres est nul (ou n'existe pas), car inutile de comparer qqch à un nul (ou inexistant) - //if ($year_curr_tot==0 || $year_prev_tot==0) return '/'; - if ($prev<=0 || $current<=0) return '/'; - $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_tot=-1, $avg=-1) { - //debug($line); - ?> - - - - - - - - - 0 && $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 .= '%'; - */ - ?> - - - - =0) $evol_from_avg = '+'.$evol_from_avg; - $evol_from_avg .= '%'; - } - */ - ?> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

- -
STATISTIQUES SUR LES MATÉRIELS
-

- -

- - - - - - -
Prendre en compte les -Form->create('Statistiques', [ - 'type' => 'get', -]); - //echo ''; - echo $this->Form->control('nbyears', [ - 'id' => 'nby', - //'class' => 'search-input', - 'label' => '', - //'type' => 'text', - 'default' => $nbyears - ]); - /* - echo $this->Form->submit('Chercher', [ - 'name' => 'MaterielSAll', - 'id' => 'MaterielSAll', - 'style' => 'margin: 0px;' - ]); - */ -echo $this->Form->end(); -?> - -dernières années ()
-

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - $val) { - $year_title = $y; - if ($y==$year) $year_title = "Année en cours ($y)"; - displayStatsLine($year_title, $val); - } - */ - if ($nbyears>0) - for ($y=$current_year ; $y>=$year_min ; $y--) { - $val = $years[$y]; - $year_title = $y; - if ($y==$current_year) $year_title = "Année en cours ($y)"; - $year_prev_tot = $y==$year_min ? -1 : $years[$y-1]['CREATED']; - displayStatsLine($year_title, $val, false, $year_prev_tot, $avg['CREATED']); - } - - ?> - - - -
Matériels acquisRépartition par statutSuivis et Emprunts
Evol. \ N-1Evol. \ moyenneTotalValidésA archiverArchivésMatériels suivisMatériels prêtés
- - -- libgit2 0.21.2