From: Stéphane Jacob Date: Fri, 22 Apr 2011 08:51:47 +0000 (+0200) Subject: Separates different cycles in statistic array. X-Git-Tag: xorg/1.1.1~75 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=750727e8adcabeb1185eae1108744944426e62b5;p=platal.git Separates different cycles in statistic array. Signed-off-by: Stéphane Jacob --- diff --git a/modules/stats.php b/modules/stats.php index df2212a..aa830a3 100644 --- a/modules/stats.php +++ b/modules/stats.php @@ -241,6 +241,7 @@ EOF2; function handler_promos($page, $required_promo = null) { $page->changeTpl('stats/nb_by_promo.tpl'); + $cycles = array('X' => 'Polytechniciens', 'M' => 'Masters', 'D' => 'Docteurs'); $res = XDB::iterRow('SELECT pd.promo, COUNT(*) FROM accounts AS a @@ -255,10 +256,10 @@ EOF2; while (list($promo, $count) = $res->next()) { $prefix = substr($promo, 0, 4) . '-'; $unit = substr($promo, -1); - if(!isset($nbpromo[$prefix])) { - $nbpromo[$prefix] = array('', '', '', '', '', '', '', '', '', ''); // Empty array containing 10 cells. + if(!isset($nbpromo[$cycles[$promo{0}]][$prefix])) { + $nbpromo[$cycles[$promo{0}]][$prefix] = array('', '', '', '', '', '', '', '', '', ''); // Empty array containing 10 cells. } - $nbpromo[$prefix][$unit] = array('promo' => $promo, 'nb' => $count); + $nbpromo[$cycles[$promo{0}]][$prefix][$unit] = array('promo' => $promo, 'nb' => $count); } $count = XDB::fetchOneCell('SELECT COUNT(*) @@ -267,7 +268,7 @@ EOF2; INNER JOIN profiles AS p ON (p.pid = ap.pid) INNER JOIN profile_display AS pd ON (pd.pid = ap.pid) WHERE a.state = \'active\' AND p.deathdate IS NULL AND pd.promo = \'D (en cours)\''); - $nbpromo['D (en cours)'][0] = array('promo' => 'D (en cours)', 'nb' => $count); + $nbpromo[$cycles['D']]['D (en cours)'][0] = array('promo' => 'D (en cours)', 'nb' => $count); $page->assign_by_ref('nbs', $nbpromo); $page->assign('promo', $required_promo); diff --git a/templates/stats/nb_by_promo.tpl b/templates/stats/nb_by_promo.tpl index 9471995..80a55fb 100644 --- a/templates/stats/nb_by_promo.tpl +++ b/templates/stats/nb_by_promo.tpl @@ -27,12 +27,13 @@ Voici le nombre d'inscrits par promotion :

+ {foreach from=$nbs key=cycle item=nb_cycle} - + - {foreach item=nb10 key=lustre from=$nbs} + {foreach item=nb10 key=lustre from=$nb_cycle} {foreach item=nb from=$nb10} @@ -48,6 +49,7 @@ Voici le nombre d'inscrits par promotion : {/foreach} {/foreach} + {/foreach}
{$cycle} 01234 56789
{$lustre}
{if $promo}