X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fxnetevents.php;h=9db873e1f430cff5af1ec5f0f74cca700664d53c;hb=a81ee98706ff11231e6d708270e2fb1c97775650;hp=43fa0a5d831fba25e7544aa46ce2960d65b3dd76;hpb=34465ab035104f739a54ec62660f04f874448627;p=platal.git diff --git a/modules/xnetevents.php b/modules/xnetevents.php index 43fa0a5..9db873e 100644 --- a/modules/xnetevents.php +++ b/modules/xnetevents.php @@ -154,8 +154,8 @@ class XnetEventsModule extends PLModule } $query = XDB::query( - "SELECT montant - FROM {$globals->money->mpay_tprefix}transactions AS t + "SELECT amount + FROM payment_transactions AS t WHERE ref = {?} AND uid = {?}", $e['paiement_id'], S::v('uid')); $montants = $query->fetchColumn(); @@ -269,7 +269,7 @@ class XnetEventsModule extends PLModule } if ($updated !== false) { $page->trigSuccess('Ton inscription à l\'événement a été mise à jour avec succès.'); - subscribe_lists_event($total, S::i('uid'), $evt, $paid); + subscribe_lists_event(S::i('uid'), $evt, ($total > 0 ? 1 : 0), 0); } $page->assign('event', get_event_detail($eid)); } @@ -394,12 +394,12 @@ class XnetEventsModule extends PLModule ); $trivial = array('intitule', 'descriptif', 'noinvite', - 'show_participants', 'accept_nonmembre', 'organisateur_uid'); + 'show_participants', 'accept_nonmembre', 'uid'); foreach ($trivial as $k) { $evt[$k] = Post::v($k); } if (!$eid) { - $evt['organisateur_uid'] = S::v('uid'); + $evt['uid'] = S::v('uid'); } if (Post::v('deadline')) { @@ -411,17 +411,17 @@ class XnetEventsModule extends PLModule } // Store the modifications in the database - XDB::execute('REPLACE INTO group_events - SET eid={?}, asso_id={?}, organisateur_uid={?}, intitule={?}, - paiement_id = {?}, descriptif = {?}, debut = {?}, - fin = {?}, show_participants = {?}, short_name = {?}, - deadline_inscription = {?}, noinvite = {?}, - accept_nonmembre = {?}', - $evt['eid'], $evt['asso_id'], $evt['organisateur_uid'], - $evt['intitule'], $evt['paiement_id'], $evt['descriptif'], - $evt['debut'], $evt['fin'], $evt['show_participants'], - $evt['short_name'], $evt['deadline_inscription'], - $evt['noinvite'], $evt['accept_nonmembre']); + XDB::execute('REPLACE INTO group_events + SET eid = {?}, asso_id = {?}, uid = {?}, intitule = {?}, + paiement_id = {?}, descriptif = {?}, debut = {?}, + fin = {?}, show_participants = {?}, short_name = {?}, + deadline_inscription = {?}, noinvite = {?}, + accept_nonmembre = {?}', + $evt['eid'], $evt['asso_id'], $evt['uid'], + $evt['intitule'], $evt['paiement_id'], $evt['descriptif'], + $evt['debut'], $evt['fin'], $evt['show_participants'], + $evt['short_name'], $evt['deadline_inscription'], + $evt['noinvite'], $evt['accept_nonmembre']); // if new event, get its id if (!$eid) { @@ -477,7 +477,7 @@ class XnetEventsModule extends PLModule // get a list of all the payment for this asso $res = XDB::iterator("SELECT id, text - FROM {$globals->money->mpay_tprefix}paiements + FROM payments WHERE asso_id = {?}", $globals->asso('id')); $paiements = array(); while ($a = $res->next()) $paiements[$a['id']] = $a['text']; { @@ -487,7 +487,7 @@ class XnetEventsModule extends PLModule // when modifying an old event retreive the old datas if ($eid) { $res = XDB::query( - "SELECT eid, intitule, descriptif, debut, fin, organisateur_uid, + "SELECT eid, intitule, descriptif, debut, fin, uid, show_participants, paiement_id, short_name, deadline_inscription, noinvite, accept_nonmembre FROM group_events @@ -540,18 +540,19 @@ class XnetEventsModule extends PLModule if (may_update() && Post::v('adm')) { S::assert_xsrf_token(); - $member = get_infos(Post::v('mail')); + $member = User::getSilent(Post::v('mail')); if (!$member) { $page->trigError("Membre introuvable"); } // change the price paid by a participant if (Env::v('adm') == 'prix' && $member) { + $amount = strtr(Env::v('montant'), ',', '.'); XDB::execute("UPDATE group_event_participants SET paid = paid + {?} WHERE uid = {?} AND eid = {?} AND item_id = 1", - strtr(Env::v('montant'), ',', '.'), - $member['uid'], $evt['eid']); + $amount, $member->uid, $evt['eid']); + subscribe_lists_event($member->uid, $evt, 1, $amount); } // change the number of personns coming with a participant @@ -559,26 +560,35 @@ class XnetEventsModule extends PLModule $res = XDB::query("SELECT paid FROM group_event_participants WHERE uid = {?} AND eid = {?}", - $member['uid'], $evt['eid']); + $member->uid, $evt['eid']); $paid = intval($res->fetchOneCell()); $nbs = Post::v('nb', array()); foreach ($nbs as $id => $nb) { $nb = max(intval($nb), 0); - XDB::execute("REPLACE INTO group_event_participants - VALUES ({?}, {?}, {?}, {?}, {?}, {?})", - $evt['eid'], $member['uid'], $id, $nb, '', $id == 1 ? $paid : 0); + XDB::execute('REPLACE INTO group_event_participants + VALUES ({?}, {?}, {?}, {?}, {?}, {?})', + $evt['eid'], $member->uid, $id, $nb, '', $id == 1 ? $paid : 0); } - $res = XDB::query("SELECT COUNT(uid) AS cnt, SUM(nb) AS nb - FROM group_event_participants - WHERE uid = {?} AND eid = {?} - GROUP BY uid", - $member['uid'], $evt['eid']); + $res = XDB::query('SELECT COUNT(uid) AS cnt, SUM(nb) AS nb + FROM group_event_participants + WHERE uid = {?} AND eid = {?} + GROUP BY uid', + $member->uid, $evt['eid']); $u = $res->fetchOneAssoc(); - $u = $u['cnt'] ? $u['nb'] : null; - subscribe_lists_event($u, $member['uid'], $evt, $paid); + if ($u['cnt'] == 1 && $paid == 0 && Post::v('cancel')) { + XDB::execute("DELETE FROM group_event_participants + WHERE uid = {?} AND eid = {?}", + $member->uid, $evt['eid']); + $u = 0; + subscribe_lists_event($member->uid, $evt, -1, $paid); + } else { + var_dump($u); + $u = $u['cnt'] ? $u['nb'] : null; + subscribe_lists_event($member->uid, $evt, ($u > 0 ? 1 : 0), $paid); + } } $evt = get_event_detail($eid, $item_id); @@ -593,8 +603,8 @@ class XnetEventsModule extends PLModule if ($evt['paiement_id']) { $infos = User::getBulkUsersWithUIDs( - XDB::fetchAllAssoc('SELECT t.uid, t.montant - FROM ' . $globals->money->mpay_tprefix . 'transactions AS t + XDB::fetchAllAssoc('SELECT t.uid, t.amount + FROM payment_transactions AS t LEFT JOIN group_event_participants AS ep ON(ep.uid = t.uid AND ep.eid = {?}) WHERE t.ref = {?} AND ep.uid IS NULL', $evt['eid'], $evt['paiement_id']), @@ -611,9 +621,9 @@ class XnetEventsModule extends PLModule WHERE p.eid = {?} AND p2.eid IS NULL GROUP BY p.uid', $evt['eid']); - $ofs = Env::i('offset'); - $tot = (Env::v('initiale') ? $tot : $nb_tot); - $nbp = ceil($tot / NB_PER_PAGE); + $ofs = Env::i('offset'); + $tot = (is_null($evt['nb_tot']) ? $evt['nb'] : $evt['nb_tot']); + $nbp = ceil($tot / NB_PER_PAGE); if ($nbp > 1) { $links = array(); if ($ofs) { @@ -622,7 +632,7 @@ class XnetEventsModule extends PLModule for ($i = 1 ; $i <= $nbp; $i++) { $links[(string)$i] = $i - 1; } - if ($ofs < $nbp) { + if ($ofs < $nbp - 1) { $links['suivant'] = $ofs+1; } $page->assign('links', $links);