xnetevents: fix user count in event administration page.
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Sun, 16 Jun 2013 19:17:37 +0000 (21:17 +0200)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Sun, 16 Jun 2013 19:17:37 +0000 (21:17 +0200)
There were several issues:
* the number of registered users was never displayed even if the phrasing
  suggested it.
* the number of lines in the 'all' view was broken because it contained
  the sum all the number of lines of all the 'moments' independently (as a
  consequence, the number of pages was always over-estimated).

Closes: #1655
Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
modules/xnetevents.php
modules/xnetevents/xnetevents.inc.php
templates/xnetevents/admin.tpl

index f5853aa..1e54dfc 100644 (file)
@@ -754,6 +754,9 @@ class XnetEventsModule extends PLModule
                                            GROUP BY  p.uid', $evt['eid']);
 
         $ofs = Env::i('offset');
+        $part = get_event_participants($evt, $item_id, UserFilter::sortByName(),
+                                       NB_PER_PAGE, $ofs * NB_PER_PAGE);
+
         $nbp = ceil($evt['user_count'] / NB_PER_PAGE);
         if ($nbp > 1) {
             $links = array();
@@ -770,9 +773,7 @@ class XnetEventsModule extends PLModule
         }
 
         $page->assign('absents', $absents);
-        $page->assign('participants',
-                      get_event_participants($evt, $item_id, UserFilter::sortByName(),
-                                             NB_PER_PAGE, $ofs * NB_PER_PAGE));
+        $page->assign('participants', $part);
     }
 }
 
index 4f7727f..4e70c06 100644 (file)
@@ -55,15 +55,13 @@ function get_event_detail($eid, $item_id = false, $asso_id = null)
         return false;
     }
 
-    // smart calculation of the total number
     if (!$item_id) {
-        $res = XDB::query('SELECT  MAX(nb)
-                             FROM  group_events              AS e
-                       INNER JOIN  group_event_items        AS ei ON (e.eid = ei.eid)
-                        LEFT JOIN  group_event_participants AS ep ON (e.eid = ep.eid AND ei.item_id = ep.item_id)
-                            WHERE  e.eid = {?}
-                         GROUP BY  ep.uid', $evt['eid']);
-        $evt['nb_tot'] = array_sum($res->fetchColumn());
+        /* Don't try to be to smart here, in case we're getting the global summary, we cannot have
+         * a general formula to estimate the total number of comers since 'moments' may (or may not be)
+         * disjuncted. As a consequence, we can only provides the number of user having fullfiled the
+         * registration procedure.
+         */
+        $evt['user_count'] = $evt['nb_tot'] = $evt['nb'];
         $evt['titre'] = '';
         $evt['item_id'] = 0;
         $evt['csv_name'] = urlencode($evt['intitule']);
@@ -157,7 +155,7 @@ function get_event_participants(&$evt, $item_id, array $tri = array(), $limit =
                             $eid, $uid);
         while ($i = $res_->next()) {
             $u[$i['item_id']] = $i['nb'];
-            $u['montant'] += $i['montant']*$i['nb'];
+            $u['montant'] += $i['montant'] * $i['nb'];
         }
         $evt['telepaid']  += $u['telepayment'];
         $evt['adminpaid'] += $u['adminpaid'];
index 0d585b5..a910390 100644 (file)
 
 <h1>{$asso->nom}&nbsp;: <a href='{$platal->ns}events'>Événements</a> </h1>
 
+{if $tout}
 <p>
   {$evt.nb_tot} personne{if $evt.nb_tot > 1}s ont réalisé leur {else} a réalisé son {/if}
   inscription à l'événement {$evt.intitule} {if $evt.titre}- {$evt.titre} {/if}
   qui aura lieu {$evt.date}.
 </p>
+{else}
+<p>
+  {$evt.nb_tot} personne{if $evt.nb_tot > 1}s participeront {else} participera {/if}
+  à {$evt.intitule} - {$evt.titre}
+</p>
+{/if}
 
 {if $evt.short_name && $participants|@count && $is_admin}
 <p class="center">