Separates different cycles in statistic array.
authorStéphane Jacob <sj@m4x.org>
Fri, 22 Apr 2011 08:51:47 +0000 (10:51 +0200)
committerStéphane Jacob <sj@m4x.org>
Fri, 22 Apr 2011 09:09:54 +0000 (11:09 +0200)
Signed-off-by: Stéphane Jacob <sj@m4x.org>
modules/stats.php
templates/stats/nb_by_promo.tpl

index df2212a..aa830a3 100644 (file)
@@ -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);
index 9471995..80a55fb 100644 (file)
@@ -27,12 +27,13 @@ Voici le nombre d'inscrits par promotion&nbsp;:
 </p>
 
 <table class="bicol" cellpadding="3" cellspacing="0" summary="Statistiques">
+  {foreach from=$nbs key=cycle item=nb_cycle}
   <tr>
-    <th></th>
+    <th>{$cycle}</th>
     <th>0</th><th>1</th><th>2</th><th>3</th><th>4</th>
     <th>5</th><th>6</th><th>7</th><th>8</th><th>9</th>
   </tr>
-  {foreach item=nb10 key=lustre from=$nbs}
+  {foreach item=nb10 key=lustre from=$nb_cycle}
   <tr>
     <th>{$lustre}</th>
     {foreach item=nb from=$nb10}
@@ -48,6 +49,7 @@ Voici le nombre d'inscrits par promotion&nbsp;:
     {/foreach}
   </tr>
   {/foreach}
+  {/foreach}
 </table>
 
 {if $promo}