From 750727e8adcabeb1185eae1108744944426e62b5 Mon Sep 17 00:00:00 2001
From: =?utf8?q?St=C3=A9phane=20Jacob?=
Date: Fri, 22 Apr 2011 10:51:47 +0200
Subject: [PATCH] Separates different cycles in statistic array.
MIME-Version: 1.0
Content-Type: text/plain; charset=utf8
Content-Transfer-Encoding: 8bit
Signed-off-by: Stéphane Jacob
---
modules/stats.php | 9 +++++----
templates/stats/nb_by_promo.tpl | 6 ++++--
2 files changed, 9 insertions(+), 6 deletions(-)
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}
- |
+ {$cycle} |
0 | 1 | 2 | 3 | 4 |
5 | 6 | 7 | 8 | 9 |
- {foreach item=nb10 key=lustre from=$nbs}
+ {foreach item=nb10 key=lustre from=$nb_cycle}
{$lustre} |
{foreach item=nb from=$nb10}
@@ -48,6 +49,7 @@ Voici le nombre d'inscrits par promotion :
{/foreach}
{/foreach}
+ {/foreach}
{if $promo}
--
2.1.4