- $res = XDB::query(
- "SELECT SUM(nb) AS nb_tot, e.*,
- IF(e.deadline_inscription, e.deadline_inscription >= LEFT(NOW(), 10),
- 1) AS inscr_open,
- LEFT(10, e.debut) AS debut_day, LEFT(10, e.fin) AS fin_day,
- LEFT(NOW(), 10) AS now,
- ei.titre,
- al.vid AS absent_list, pl.vid AS participant_list,
- a.nom, a.prenom, a.promo, aa.alias
- FROM groupex.evenements AS e
- INNER JOIN x4dat.auth_user_md5 AS a ON a.user_id = e.organisateur_uid
- INNER JOIN x4dat.aliases AS aa ON (aa.type = 'a_vie' AND aa.id = a.user_id)
- INNER JOIN groupex.evenements_items AS ei ON (e.eid = ei.eid)
- LEFT JOIN groupex.evenements_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, {?}))
- WHERE e.eid = {?} AND ei.item_id = {?} AND e.asso_id = {?}
- GROUP BY ei.item_id",
- '-absents@'.$globals->xnet->evts_domain,
- '-participants@'.$globals->xnet->evts_domain,
- $eid, $item_id ? $item_id : 1, $globals->asso('id'));
-
+ if (is_null($asso_id)) {
+ $asso_id = $globals->asso('id');
+ }
+ $res = XDB::query('SELECT SUM(nb) AS nb_tot, COUNT(DISTINCT ep.uid) AS nb, e.*,
+ IF(e.deadline_inscription,
+ e.deadline_inscription >= LEFT(NOW(), 10),
+ 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,
+ 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,
+ '-participants@'.$globals->xnet->evts_domain,
+ '-paye@' . $globals->xnet->evts_domain,
+ '-participants-non-paye@' . $globals->xnet->evts_domain,
+ $eid, $eid, $item_id ? $item_id : 1, $asso_id);