X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fxnetevents%2Fxnetevents.inc.php;h=d179a709f12f935829d8393c7e2c7293bd3418d8;hb=d7610c358d074c78e1e8dc25fe0cf0e5e7e1c55e;hp=455641fca336621720693e3ad4a38034b059dce6;hpb=f56e5e531ccb47ceca2e26ffc01d6a107fb140f6;p=platal.git diff --git a/modules/xnetevents/xnetevents.inc.php b/modules/xnetevents/xnetevents.inc.php index 455641f..d179a70 100644 --- a/modules/xnetevents/xnetevents.inc.php +++ b/modules/xnetevents/xnetevents.inc.php @@ -1,6 +1,6 @@ asso('id'); + } $res = XDB::query( - "SELECT SUM(nb) AS nb_tot, e.*, + "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 debut_day, LEFT(10, e.fin) AS fin_day, @@ -33,22 +36,22 @@ function get_event_detail($eid, $item_id = false) 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 + 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) + 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 = {?} OR e.short_name = {?}) AND ei.item_id = {?} AND e.asso_id = {?} + 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, - $eid, $eid, $item_id ? $item_id : 1, $globals->asso('id')); + $eid, $eid, $item_id ? $item_id : 1, $asso_id); $evt = $res->fetchOneAssoc(); - if (!$evt || ($evt['accept_nonmembre'] == 0 && !is_member() && !may_update())) { + if (!$evt || ($GLOBALS['IS_XNET_SITE'] && $evt['accept_nonmembre'] == 0 && !is_member() && !may_update())) { return null; } @@ -68,7 +71,7 @@ function get_event_detail($eid, $item_id = false) } $res = XDB::query( - "SELECT titre, details, montant, ei.item_id, nb, ep.paid + "SELECT titre, details, montant, ei.item_id, nb, ep.paid, FIND_IN_SET('notify_payment', ep.flags) AS notify_payment FROM groupex.evenements_items AS ei LEFT JOIN groupex.evenements_participants AS ep ON (ep.eid = ei.eid AND ep.item_id = ei.item_id AND uid = {?}) @@ -78,12 +81,14 @@ function get_event_detail($eid, $item_id = false) $evt['topay'] = 0; $evt['paid'] = 0; + $evt['notify_payment'] = false; foreach ($evt['moments'] as $m) { $evt['topay'] += $m['nb'] * $m['montant']; if ($m['montant']) { $evt['money'] = true; } $evt['paid'] = $m['paid']; + $evt['notify_payment'] = $evt['notify_payment'] || $m['notify_payment']; } $req = XDB::query( @@ -92,9 +97,11 @@ function get_event_detail($eid, $item_id = false) WHERE ref = {?} AND uid = {?}", $evt['paiement_id'], S::v('uid')); $montants = $req->fetchColumn(); + $evt['telepaid'] = 0; foreach ($montants as $m) { $p = strtr(substr($m, 0, strpos($m, 'EUR')), ',', '.'); $evt['paid'] += trim($p); + $evt['telepaid'] += trim($p); } return $evt; @@ -103,7 +110,7 @@ function get_event_detail($eid, $item_id = false) // }}} // {{{ function get_event_participants() -function get_event_participants($evt, $item_id, $tri, $limit = '') { +function get_event_participants(&$evt, $item_id, $tri, $limit = '') { global $globals; if (Env::has('initiale')) { @@ -115,21 +122,22 @@ function get_event_participants($evt, $item_id, $tri, $limit = '') { } $eid = $evt['eid']; - $money = $evt['money'] && may_update(); + $money = $evt['money'] && (function_exists('may_update')) && may_update(); $pay_id = $evt['paiement_id']; $query = "SELECT IF(m.origine != 'X',m.nom,IF(u.nom_usage<>'', u.nom_usage, u.nom)) AS nom, IF(m.origine != 'X',m.prenom,u.prenom) AS prenom, - IF(m.origine != 'X','extérieur',u.promo) AS promo, + IF(m.origine != 'X','extérieur',u.promo) AS promo, IF(m.origine != 'X' OR u.perms = 'pending',m.email,a.alias) AS email, IF(m.origine != 'X',m.sexe,FIND_IN_SET('femme', u.flags)) AS femme, m.perms='admin' AS admin, - (m.origine = 'X') AS x, - ep.uid, ep.paid, SUM(nb) AS nb + (m.origine = 'X' OR m.origine IS NULL) AS x, + ep.uid, SUM(ep.paid) AS paid, SUM(ep.nb) AS nb, + FIND_IN_SET('notify_payment', ep.flags) AS notify_payment FROM groupex.evenements_participants AS ep INNER JOIN groupex.evenements AS e ON (ep.eid = e.eid) - LEFT JOIN groupex.membres AS m ON ( ep.uid = m.uid AND e.asso_id = m.asso_id) + LEFT JOIN groupex.membres AS m ON ( ep.uid = m.uid AND e.asso_id = m.asso_id) LEFT JOIN auth_user_md5 AS u ON ( u.user_id = ep.uid ) LEFT JOIN aliases AS a ON ( a.id = ep.uid AND a.type='a_vie' ) WHERE ep.eid = {?} @@ -147,9 +155,17 @@ function get_event_participants($evt, $item_id, $tri, $limit = '') { $tab = array(); $user = 0; + $evt['adminpaid'] = 0; + $evt['telepaid'] = 0; + $evt['topay'] = 0; + $evt['paid'] = 0; while ($u = $res->next()) { + if ($u['nb'] == 0) { + continue; + } + $u['adminpaid'] = $u['paid']; $u['montant'] = 0; - if ($money && $pay_id) { + if ($money && $pay_id) { $res_ = XDB::query( "SELECT montant FROM {$globals->money->mpay_tprefix}transactions AS t @@ -157,21 +173,26 @@ function get_event_participants($evt, $item_id, $tri, $limit = '') { $pay_id, $u['uid']); $montants = $res_->fetchColumn(); foreach ($montants as $m) { - $p = strtr(substr($m, 0, strpos($m, "EUR")), ",", "."); - $u['paid'] += trim($p); + $p = strtr(substr($m, 0, strpos($m, "EUR")), ",", "."); + $u['paid'] += trim($p); } - } + } + $u['telepayment'] = $u['paid'] - $u['adminpaid']; $res_ = XDB::iterator( - "SELECT ep.nb, ep.item_id, ei.montant - FROM groupex.evenements_participants AS ep - INNER JOIN groupex.evenements_items AS ei ON (ei.eid = ep.eid AND ei.item_id = ep.item_id) - WHERE ep.eid = {?} AND ep.uid = {?}", + "SELECT ep.nb, ep.item_id, ei.montant + FROM groupex.evenements_participants AS ep + INNER JOIN groupex.evenements_items AS ei ON (ei.eid = ep.eid AND ei.item_id = ep.item_id) + WHERE ep.eid = {?} AND ep.uid = {?}", $eid, $u['uid']); while ($i = $res_->next()) { $u[$i['item_id']] = $i['nb']; $u['montant'] += $i['montant']*$i['nb']; } - $tab[] = $u; + $tab[] = $u; + $evt['telepaid'] += $u['telepayment']; + $evt['adminpaid'] += $u['adminpaid']; + $evt['paid'] += $u['paid']; + $evt['topay'] += $u['montant']; } return $tab; } @@ -181,12 +202,13 @@ function get_event_participants($evt, $item_id, $tri, $limit = '') { function subscribe_lists_event($participate, $uid, $evt) { require_once('user.func.inc.php'); - global $globals,$page; + global $globals; + $page =& Platal::page(); $participant_list = $evt['participant_list']; $absent_list = $evt['absent_list']; - $email = get_user_forlife($uid); + $email = get_user_forlife($uid, '_silent_user_callback'); if ($email) { $email .= '@'.$globals->mail->domain; @@ -229,30 +251,30 @@ function subscribe_lists_event($participate, $uid, $evt) } // }}} -function event_change_shortname(&$page, $old, $new) +function event_change_shortname(&$page, $eid, $old, $new) { global $globals; if (is_null($old)) { $old = ''; } - // Quelques vérifications sur l'alias (caractères spéciaux) + // Quelques vérifications sur l'alias (caractères spéciaux) if ($new && !preg_match( "/^[a-zA-Z0-9\-.]{3,20}$/", $new)) { - $page->trig("Le raccourci demandé n'est pas valide. - Vérifie qu'il comporte entre 3 et 20 caractères - et qu'il ne contient que des lettres non accentuées, - des chiffres ou les caractères - et ."); + $page->trigError("Le raccourci demandé n'est pas valide. + Vérifie qu'il comporte entre 3 et 20 caractères + et qu'il ne contient que des lettres non accentuées, + des chiffres ou les caractères - et ."); return $old; } - //vérifier que l'alias n'est pas déja pris + //vérifier que l'alias n'est pas déja pris if ($new && $old != $new) { $res = XDB::query('SELECT COUNT(*) FROM groupex.evenements WHERE short_name = {?}', $new); if ($res->fetchOneCell() > 0) { - $page->trig("Le raccourci demandé est déjà utilisé. Choisis en un autre."); + $page->trigError("Le raccourci demandé est déjà utilisé. Choisis en un autre."); return $old; } } @@ -286,7 +308,7 @@ function event_change_shortname(&$page, $old, $new) LEFT JOIN groupex.membres AS m ON (ep.uid = m.uid) LEFT JOIN auth_user_md5 AS u ON (u.user_id = ep.uid) LEFT JOIN aliases AS a ON (a.id = ep.uid AND a.type = 'a_vie') - WHERE ep.eid = {?} + WHERE ep.eid = {?} AND ep.nb > 0 GROUP BY ep.uid)", $lastid, '@'.$globals->mail->domain, $eid); @@ -297,12 +319,12 @@ function event_change_shortname(&$page, $old, $new) XDB::execute("INSERT INTO virtual_redirect ( SELECT {?} AS vid, IF(u.nom IS NULL, m.email, CONCAT(a.alias, {?})) AS redirect FROM groupex.membres AS m - LEFT JOIN groupex.evenements_participants AS ep ON (ep.uid = m.uid) + LEFT JOIN groupex.evenements_participants AS ep ON (ep.uid = m.uid AND ep.eid = {?}) LEFT JOIN auth_user_md5 AS u ON (u.user_id = m.uid) LEFT JOIN aliases AS a ON (a.id = m.uid AND a.type = 'a_vie') WHERE m.asso_id = {?} AND ep.uid IS NULL GROUP BY m.uid)", - $lastid, "@".$globals->mail->domain, $globals->asso('id')); + $lastid, "@".$globals->mail->domain, $eid, $globals->asso('id')); return $new; } @@ -323,5 +345,5 @@ function event_change_shortname(&$page, $old, $new) return $old; } -// vim:set et sw=4 sts=4 sws=4 foldmethod=marker: +// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: ?>