X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fxnetevents.php;h=0523d5e54dd922fc87e52d41de2137cbc49fbdc1;hb=0554f70a322c69cf35b622bcf76f2c25013c43c1;hp=43fa0a5d831fba25e7544aa46ce2960d65b3dd76;hpb=257ae4081d1b5da12c4458f0642b9d2b7843abee;p=platal.git diff --git a/modules/xnetevents.php b/modules/xnetevents.php index 43fa0a5..0523d5e 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(); @@ -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']; { @@ -540,7 +540,7 @@ 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"); } @@ -551,7 +551,7 @@ class XnetEventsModule extends PLModule SET paid = paid + {?} WHERE uid = {?} AND eid = {?} AND item_id = 1", strtr(Env::v('montant'), ',', '.'), - $member['uid'], $evt['eid']); + $member->uid, $evt['eid']); } // change the number of personns coming with a participant @@ -559,7 +559,7 @@ 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()); @@ -568,17 +568,24 @@ class XnetEventsModule extends PLModule $nb = max(intval($nb), 0); XDB::execute("REPLACE INTO group_event_participants VALUES ({?}, {?}, {?}, {?}, {?}, {?})", - $evt['eid'], $member['uid'], $id, $nb, '', $id == 1 ? $paid : 0); + $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']); + $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; + } else { + $u = $u['cnt'] ? $u['nb'] : null; + } + subscribe_lists_event($u, $member->uid, $evt, $paid); } $evt = get_event_detail($eid, $item_id); @@ -593,8 +600,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']), @@ -631,7 +638,7 @@ class XnetEventsModule extends PLModule $page->assign('absents', $absents); $page->assign('participants', get_event_participants($evt, $item_id, UserFilter::sortByName(), - NB_PER_PAGE, $ofs * NB_PER_PAGE)); + new PLLimit(NB_PER_PAGE), $ofs * NB_PER_PAGE)); } }