2 /***************************************************************************
3 * Copyright (C) 2003-2006 Polytechnique.org *
4 * http://opensource.polytechnique.org/ *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the Free Software *
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
20 ***************************************************************************/
22 // {{{ function get_event_detail()
23 function get_event_detail($eid, $item_id = false
) {
25 $res = $globals->xdb
->query(
26 "SELECT SUM(nb) AS nb_tot, e.intitule, ei.titre,
27 debut AS deb, fin, membres_only, descriptif, e.eid,
28 e.show_participants, e.paiement_id, e.short_name,
29 e.deadline_inscription, LEFT(NOW(), 10) AS now,
30 al.vid AS absent_list, pl.vid AS participant_list,
31 a.nom, a.prenom, a.promo
32 FROM groupex.evenements AS e
33 INNER JOIN groupex.evenements_items AS ei ON (e.eid = ei.eid)
34 LEFT JOIN groupex.evenements_participants AS ep ON(e.eid = ep.eid AND ei.item_id = ep.item_id)
35 LEFT JOIN virtual AS al ON(al.type = 'evt' AND al.alias = CONCAT(short_name, {?}))
36 LEFT JOIN virtual AS pl ON(pl.type = 'evt' AND pl.alias = CONCAT(short_name, {?}))
37 LEFT JOIN auth_user_md5 AS a ON (a.user_id = e.organisateur_uid)
38 WHERE e.eid = {?} AND ei.item_id = {?} AND e.asso_id = {?}
40 '-absents@'.$globals->xnet
->evts_domain
,
41 '-participants@'.$globals->xnet
->evts_domain
,
42 $eid, $item_id?
$item_id:1, $globals->asso('id'));
43 $evt = $res->fetchOneAssoc();
44 if (!$evt) return false
;
46 // smart calculation of the total number
48 $res = $globals->xdb
->query(
50 FROM groupex.evenements AS e
51 INNER JOIN groupex.evenements_items AS ei ON (e.eid = ei.eid)
52 LEFT JOIN groupex.evenements_participants AS ep ON(e.eid = ep.eid AND ei.item_id = ep.item_id)
54 GROUP BY ep.uid", $eid);
55 $evt['nb_tot'] = array_sum($res->fetchColumn());
60 $res = $globals->xdb
->iterator(
61 "SELECT eid, item_id, titre, montant
62 FROM groupex.evenements_items
65 $moments = array(); $evt['money'] = false
;
66 while ($m = $res->next()) {
67 $moments[$m['item_id']] = $m;
68 if ($m['montant'] > 0) $evt['money'] = true
;
70 $evt['moments'] = $moments;
75 // {{{ function get_event_participants()
76 function get_event_participants($eid, $item_id, $where, $tri, $limit, $money, $pay_id) {
79 "SELECT IF(u.nom IS NULL,m.nom,IF(u.nom_usage<>'', u.nom_usage, u.nom)) AS nom,
80 IF(u.nom IS NULL,m.prenom,u.prenom) AS prenom,
81 IF(u.nom IS NULL,'extérieur',u.promo) AS promo,
82 IF(u.nom IS NULL,m.email,a.alias) AS email,
83 IF(u.nom IS NULL,0,FIND_IN_SET('femme', u.flags)) AS femme,
84 m.perms='admin' AS admin,
85 NOT(u.nom IS NULL) AS x,
86 ep.uid, ep.paid, SUM(nb) AS nb
87 FROM groupex.evenements_participants AS ep
88 INNER JOIN groupex.evenements AS e ON (ep.eid = e.eid)
89 LEFT JOIN groupex.membres AS m ON ( ep.uid = m.uid AND e.asso_id = m.asso_id)
90 LEFT JOIN auth_user_md5 AS u ON ( u.user_id = ep.uid )
91 LEFT JOIN aliases AS a ON ( a.id = ep.uid AND a.type='a_vie' )
93 ".(($item_id)?
" AND item_id = $item_id":"")."
99 $res = $globals->xdb
->query($query, $eid);
100 return $res->fetchAllAssoc();
102 $res = $globals->xdb
->iterator($query, $eid);
105 while ($u = $res->next()) {
107 if ($money && $pay_id) {
108 $res_ = $globals->xdb
->query(
110 FROM {$globals->money->mpay_tprefix}transactions AS t
111 WHERE ref = {?} AND uid = {?}",
113 $montants = $res_->fetchColumn();
114 foreach ($montants as $m) {
115 $p = strtr(substr($m, 0, strpos($m, "EUR")), ",", ".");
116 $u['paid'] +
= trim($p);
119 $res_ = $globals->xdb
->iterator(
120 "SELECT ep.nb, ep.item_id, ei.montant
121 FROM groupex.evenements_participants AS ep
122 INNER JOIN groupex.evenements_items AS ei ON (ei.eid = ep.eid AND ei.item_id = ep.item_id)
123 WHERE ep.eid = {?} AND ep.uid = {?}",
125 while ($i = $res_->next()) {
126 $u[$i['item_id']] = $i['nb'];
127 $u['montant'] +
= $i['montant']*$i['nb'];
135 // {{{ function subscribe_lists_event()
136 function subscribe_lists_event($participate, $uid, $participant_list, $absent_list) {
137 global $globals,$page;
139 $email = Session
::get('forlife');
142 $email .= '@'.$globals->mail
->domain
;
144 $res = $globals->xdb
->query("SELECT email FROM groupex.membres WHERE uid = {?} AND asso_id = {?}", Session
::get('uid'), $globals->asso('id'));
145 $email = $res->fetchOneCell();
148 $subscribe = $participate?
$participant_list:(is_member()?
$absent_list:0);
149 $unsubscri = $participate?
$absent_list:$participant_list;
152 $globals->xdb
->execute(
153 "REPLACE INTO virtual_redirect VALUES({?},{?})",
158 $globals->xdb
->execute(
159 "DELETE FROM virtual_redirect WHERE vid = {?} AND redirect = {?}",
166 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker: