$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 acquis Répartition par statut Suivis et Emprunts
Evol. \ N-1 Evol. \ moyenne Total Validés A archiver Archivés Matériels suivis Matériels prêtés