Fix listing of xnetevent participants.
[platal.git] / modules / xnetevents / xnetevents.inc.php
index be5eeac..237e3f7 100644 (file)
@@ -33,12 +33,15 @@ function get_event_detail($eid, $item_id = false, $asso_id = null)
                                      1) AS inscr_open,
                                LEFT(10, e.debut) AS start_day, LEFT(10, e.fin) AS last_day,
                                LEFT(NOW(), 10) AS now,
-                               ei.titre, al.vid AS absent_list, pl.vid AS participant_list
+                               ei.titre, al.vid AS absent_list, pl.vid AS participant_list,
+                               pyl.vid AS payed_list, bl.vid AS booked_unpayed_list
                          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)
                     LEFT JOIN  virtual AS al ON(al.type = \'evt\' AND al.alias = CONCAT(short_name, {?}))
                     LEFT JOIN  virtual AS pl ON(pl.type = \'evt\' AND pl.alias = CONCAT(short_name, {?}))
+                    LEFT JOIN  virtual AS pyl ON(pyl.type = \'evt\' AND pyl.alias = CONCAT(short_name, {?}))
+                    LEFT JOIN  virtual AS bl ON(bl.type = \'evt\' AND bl.alias = CONCAT(short_name, {?}))
                         WHERE  (e.eid = {?} OR e.short_name = {?}) AND ei.item_id = {?} AND e.asso_id = {?}
                      GROUP BY  ei.item_id',
                    '-absents@'.$globals->xnet->evts_domain,
@@ -87,8 +90,8 @@ function get_event_detail($eid, $item_id = false, $asso_id = null)
         $evt['notify_payment'] = $evt['notify_payment'] || $m['notify_payment'];
     }
 
-    $montants = XDB::fetchColumn('SELECT  montant
-                                    FROM  ' . $globals->money->mpay_tprefix . 'transactions AS t
+    $montants = XDB::fetchColumn('SELECT  amount
+                                    FROM  payment_transactions AS t
                                    WHERE  ref = {?} AND uid = {?}',
                                    $evt['paiement_id'], S::v('uid'));
     $evt['telepaid'] = 0;
@@ -106,7 +109,7 @@ function get_event_detail($eid, $item_id = false, $asso_id = null)
 // }}}
 
 // {{{ function get_event_participants()
-function get_event_participants(&$evt, $item_id, array $tri = array(), $count = null, $offset = null)
+function get_event_participants(&$evt, $item_id, array $tri = array(), $limit = null)
 {
     global $globals;
 
@@ -114,14 +117,14 @@ function get_event_participants(&$evt, $item_id, array $tri = array(), $count =
     $money  = $evt['money'] && (function_exists('may_update')) && may_update();
     $pay_id = $evt['paiement_id'];
 
-    $append = $item_id ? XDB::foramt(' AND ep.item_id = {?}', $item_id) : '';
+    $append = $item_id ? XDB::format(' AND ep.item_id = {?}', $item_id) : '';
     $query = XDB::fetchAllAssoc('uid', 'SELECT  ep.uid, SUM(ep.paid) AS paid, SUM(ep.nb) AS nb,
                                                 FIND_IN_SET(\'notify_payment\', ep.flags) AS notify_payment
                                           FROM  group_event_participants AS ep
                                          WHERE  ep.eid = {?} AND nb > 0 ' . $append . '
                                       GROUP BY  ep.uid', $eid);
     $uf = new UserFilter(new PFC_True(), $tri);
-    $users = User::getBulkUsersWithUIDs($uf->filter(array_keys($query), $count, $offset));
+    $users = User::getBulkUsersWithUIDs($uf->filter(array_keys($query), $limit));
     $tab = array();
     foreach ($users as $user) {
         $uid = $user->id();
@@ -141,8 +144,8 @@ function get_event_participants(&$evt, $item_id, array $tri = array(), $count =
         $u['adminpaid'] = $u['paid'];
         $u['montant'] = 0;
         if ($money && $pay_id) {
-            $montants = XDB::fetchColumn('SELECT  montant
-                                            FROM  ' . $globals->money->mpay_tprefix . 'transactions AS t
+            $montants = XDB::fetchColumn('SELECT  amount
+                                            FROM  payment_transactions AS t
                                            WHERE  ref = {?} AND uid = {?}',
                                          $pay_id, $uid);
             foreach ($montants as $m) {
@@ -181,15 +184,7 @@ function subscribe_lists_event($participate, $uid, $evt, $paid, $payment = null)
     $payed_list        = $evt['payed_list'];
 
     $user = User::getSilent($uid);
-    if ($user) {
-        $email = $user->forlifeEmail();
-    } else {
-        $res = XDB::query("SELECT  email
-                             FROM  group_members
-                            WHERE  uid = {?} AND asso_id = {?}",
-                          $uid, $globals->asso('id'));
-        $email = $res->fetchOneCell();
-    }
+    $email = $user->forlifeEmail();
 
     function subscribe($list, $email)
     {
@@ -248,7 +243,7 @@ function event_change_shortname(&$page, $eid, $old, $new)
                     et qu'il ne contient que des lettres non accentuées,
                     des chiffres ou les caractères - et .");
         return $old;
-    } elseif ($new && ctype_digit($new)) {
+    } elseif ($new && (is_int($new) || ctype_digit($new))) {
         $page->trigError("Le raccourci demandé ne peut être accepté car il
                          ne contient que des chiffres. Rajoute-lui par exemple
                          une lettre.");