add a dynpostkv function:
[platal.git] / modules / xnetevents.php
CommitLineData
4f10a058 1<?php
2/***************************************************************************
3 * Copyright (C) 2003-2006 Polytechnique.org *
4 * http://opensource.polytechnique.org/ *
5 * *
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. *
10 * *
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. *
15 * *
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 *
18 * Foundation, Inc., *
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
20 ***************************************************************************/
21
22class XnetEventsModule extends PLModule
23{
24 function handlers()
25 {
26 return array(
bd46a8e4 27 'grp/events' => $this->make_hook('events', AUTH_MDP),
d6d580ec 28 'grp/events/sub' => $this->make_hook('sub', AUTH_MDP),
bd46a8e4 29 'grp/events/csv' => $this->make_hook('csv', AUTH_MDP),
30 'grp/events/edit' => $this->make_hook('edit', AUTH_MDP),
31 'grp/events/admin' => $this->make_hook('admin', AUTH_MDP),
4f10a058 32 );
33 }
34
35 function handler_events(&$page)
36 {
37 global $globals;
38
d6d580ec 39 new_group_page('xnetevents/index.tpl');
4f10a058 40
4f10a058 41 $page->assign('admin', may_update());
42
43 $evenements = $globals->xdb->iterator(
d6d580ec 44 "SELECT e.*, LEFT(10, e.debut) AS debut_day, LEFT(10, e.fin) AS fin_day,
bd46a8e4 45 IF(e.deadline_inscription, e.deadline_inscription >= LEFT(NOW(), 10),
d6d580ec 46 1) AS inscr_open, e.deadline_inscription,
47 u.nom, u.prenom, u.promo, a.alias,
48 MAX(ep.nb) AS inscrit, MAX(ep.paid) AS paid
49 FROM groupex.evenements AS e
4f10a058 50 INNER JOIN x4dat.auth_user_md5 AS u ON u.user_id = e.organisateur_uid
d6d580ec 51 INNER JOIN x4dat.aliases AS a ON (a.type = 'a_vie' AND a.id = u.user_id)
4f10a058 52 LEFT JOIN groupex.evenements_participants AS ep ON (ep.eid = e.eid AND ep.uid = {?})
53 WHERE asso_id = {?}
54 GROUP BY e.eid
bd46a8e4 55 ORDER BY debut", Session::get('uid'), $globals->asso('id'));
4f10a058 56
57 $evts = array();
d6d580ec 58
4f10a058 59 while ($e = $evenements->next()) {
d6d580ec 60 $res = $globals->xdb->query(
4f10a058 61 "SELECT titre, details, montant, ei.item_id, nb
62 FROM groupex.evenements_items AS ei
63 LEFT JOIN groupex.evenements_participants AS ep
64 ON (ep.eid = ei.eid AND ep.item_id = ei.item_id AND uid = {?})
65 WHERE ei.eid = {?}",
66 Session::get('uid'), $e['eid']);
d6d580ec 67 $e['moments'] = $res->fetchAllAssoc();
68
69 $e['topay'] = 0;
70 foreach ($e['moments'] as $m) {
71 $e['topay'] += $m['nb'] * $m['montant'];
72 }
73
4f10a058 74 $query = $globals->xdb->query(
75 "SELECT montant
76 FROM {$globals->money->mpay_tprefix}transactions AS t
77 WHERE ref = {?} AND uid = {?}", $e['paiement_id'], Session::get('uid'));
78 $montants = $query->fetchColumn();
d6d580ec 79
4f10a058 80 foreach ($montants as $m) {
d6d580ec 81 $p = strtr(substr($m, 0, strpos($m, 'EUR')), ',', '.');
4f10a058 82 $e['paid'] += trim($p);
83 }
d6d580ec 84
4f10a058 85 $evts[] = $e;
86 }
87
88 $page->assign('evenements', $evts);
89 $page->assign('is_member', is_member());
90 }
91
d6d580ec 92 function handler_sub(&$page, $eid = null)
93 {
94 global $globals;
95
96 require_once('xnet/evenements.php');
97
98 new_group_page('xnetevents/subscribe.tpl');
99
100 $evt = get_event_detail($eid);
101 if (!$evt) {
102 return PL_NOT_FOUND;
103 }
104
105 if (!$evt['inscr_open']) {
106 $page->kill('Les inscriptions pour cet événement sont closes');
107 }
108
109 $page->assign('event', $evt);
110
111 if (!Post::has('submit')) {
112 return;
113 }
114
115 $moments = Post::getMixed('moment', array());
116 $pers = Post::getMixed('personnes', array());
117 $subs = array();
118
119 foreach ($moments as $j => $v) {
120 $subs[$j] = intval($v);
121
122 // retreive ohter field when more than one person
123 if ($subs[$j] == 2) {
124 if (!isset($pers[$j]) || !is_numeric($pers[$j])
125 || $pers[$j] < 0)
126 {
127 $page->trig('Tu dois choisir un nombre d\'invités correct !');
128 return;
129 }
130 $subs[$j] = 1 + $pers[$j];
131 }
132 }
133
134 // impossible to unsubscribe if you already paid sthing
135 if (array_sum($subs) && $evt['paid'] != 0) {
136 $page->trig("Impossible de te désinscrire complètement ".
137 "parce que tu as fait un paiement par ".
138 "chèque ou par liquide. Contacte un ".
139 "administrateur du groupe si tu es sûr de ".
140 "ne pas venir");
141 return;
142 }
143
144 // update actual inscriptions
145 foreach ($subs as $j => $nb) {
146 if ($nb > 0) {
147 $globals->xdb->execute(
148 "REPLACE INTO groupex.evenements_participants
149 VALUES ({?}, {?}, {?}, {?}, {?})",
150 $eid, Session::getInt('uid'), $j, $nb, $evt['paid']);
151 } else {
152 $globals->xdb->execute(
153 "DELETE FROM groupex.evenements_participants
154 WHERE eid = {?} AND uid = {?} AND item_id = {?}",
155 $eid, Session::getInt("uid"), $j);
156 }
157 }
158
159 $page->assign('event', get_event_detail($eid));
160 }
161
4f10a058 162 function handler_csv(&$page, $eid = null, $item_id = null)
163 {
164 require_once('xnet/evenements.php');
165
bd46a8e4 166 if (!is_numeric($item_id)) {
167 $item_id = null;
168 }
169
4f10a058 170 $evt = get_event_detail($eid, $item_id);
171 if (!$evt) {
172 return PL_NOT_FOUND;
173 }
174
175 header('Content-type: text/x-csv');
176 header('Pragma: ');
177 header('Cache-Control: ');
178
179 new_nonhtml_page('xnet/groupe/evt-csv.tpl');
180
181 $admin = may_update();
182
183 $tri = (Env::get('order') == 'alpha' ? 'promo, nom, prenom' : 'nom, prenom, promo');
184
185 if (Env::has('initiale')) {
186 $ini = 'AND IF(u.nom IS NULL, m.nom,
187 IF(u.nom_usage<>"", u.nom_usage, u.nom))
188 LIKE "'.addslashes(Env::get('initiale')).'%"';
189 } else {
190 $ini = '';
191 }
192
193 $participants = get_event_participants($eid, $item_id, $ini, $tri, "",
194 $evt['money'] && $admin,
195 $evt['paiement_id']);
196
197 $page->assign('participants', $participants);
198 $page->assign('admin', $admin);
199 $page->assign('moments', $evt['moments']);
200 $page->assign('money', $evt['money']);
201 $page->assign('tout', !Env::get('item_id', false));
202 }
bd46a8e4 203
204 function handler_edit(&$page, $eid = null)
205 {
206 global $globals;
207
208 new_groupadmin_page('xnet/groupe/evt-modif.tpl');
209
210 $page->assign('logged', logged());
211 $page->assign('admin', may_update());
212
213 $moments = range(1, 4);
214 $page->assign('moments', $moments);
215
216 if (!is_null($eid)) {
217 $res = $globals->xdb->query("SELECT short_name, asso_id
218 FROM groupex.evenements
219 WHERE eid = {?}", $eid);
220 $infos = $res->fetchOneAssoc();
221 if ($infos['asso_id'] != $globals->asso('id')) {
222 return PL_NOT_ALLOWED;
223 }
224 }
225
226 $get_form = true;
227
228 if (Post::get('intitule')) {
229 $get_form = false;
230 $short_name = Env::get('short_name');
231
232 // Quelques vérifications sur l'alias (caractères spéciaux)
233 if ($short_name && !preg_match( "/^[a-zA-Z0-9\-.]{3,20}$/", $short_name)) {
234 $page->trig("Le raccourci demandé n'est pas valide.
235 Vérifie qu'il comporte entre 3 et 20 caractères
236 et qu'il ne contient que des lettres non accentuées,
237 des chiffres ou les caractères - et .");
238 $short_name = $infos['short_name'];
239 $get_form = true;
240 }
241
242 //vérifier que l'alias n'est pas déja pris
243 if ($short_name && $short_name != $infos['short_name']) {
244 $res = $globals->xdb->query('SELECT COUNT(*) FROM virtual WHERE alias LIKE {?}', $short_name."-%");
245 if ($res->fetchOneCell() > 0) {
246 $page->trig("Le raccourci demandé est déjà utilisé. Choisis en un autre.");
247 $short_name = $infos['short_name'];
248 $get_form = true;
249 }
250 }
251
252 // if had a previous shortname change the old lists
253 if ($short_name && $infos['short_name'] && $short_name != $infos['short_name']) {
254 $globals->xdb->execute("UPDATE virtual
255 SET alias = REPLACE(alias, {?}, {?})
256 WHERE type = 'evt' AND alias LIKE {?}",
257 $infos['short_name'], $short_name,
258 $infos['short_name']."-%");
259 }
260 elseif ($short_name && !$infos['short_name']) {
261 // if we have a first new short_name create the lists
262 //
263 $globals->xdb->execute("INSERT INTO virtual SET type = 'evt', alias = {?}",
264 $short_name."-participants@".$globals->xnet->evts_domain);
265
266 $res = $globals->xdb->query("SELECT LAST_INSERT_ID()");
267 $globals->xdb->execute("INSERT INTO virtual_redirect (
268 SELECT {?} AS vid, IF(u.nom IS NULL, m.email, CONCAT(a.alias, {?})) AS redirect
269 FROM groupex.evenements_participants AS ep
270 LEFT JOIN groupex.membres AS m ON (ep.uid = m.uid)
271 LEFT JOIN auth_user_md5 AS u ON (u.user_id = ep.uid)
272 LEFT JOIN aliases AS a ON (a.id = ep.uid AND a.type = 'a_vie')
273 WHERE ep.eid = {?}
274 GROUP BY ep.uid)",
275 $res->fetchOneCell(), "@".$globals->mail->domain, $eid);
276
277 $globals->xdb->execute("INSERT INTO virtual SET type = 'evt', alias = {?}",
278 $short_name."-absents@".$globals->xnet->evts_domain);
279
280 $res = $globals->xdb->query("SELECT LAST_INSERT_ID()");
281 $globals->xdb->execute("INSERT INTO virtual_redirect (
282 SELECT {?} AS vid, IF(u.nom IS NULL, m.email, CONCAT(a.alias, {?})) AS redirect
283 FROM groupex.membres AS m
284 LEFT JOIN groupex.evenements_participants AS ep ON (ep.uid = m.uid)
285 LEFT JOIN auth_user_md5 AS u ON (u.user_id = m.uid)
286 LEFT JOIN aliases AS a ON (a.id = m.uid AND a.type = 'a_vie')
287 WHERE m.asso_id = {?} AND ep.uid IS NULL
288 GROUP BY m.uid)",
289 $res->fetchOneCell(), "@".$globals->mail->domain, $globals->asso('id'));
290 }
291 elseif (!$short_name && $infos['short_name']) {
292 // if we delete the old short name, delete the lists
293 $globals->xdb->execute("DELETE virtual, virtual_redirect FROM virtual
294 LEFT JOIN virtual_redirect USING(vid)
295 WHERE virtual.alias LIKE {?}",
296 $infos['short_name']."-%");
297 }
298
299 $evt = array();
300 $evt['eid'] = $eid;
301 $evt['asso_id'] = $globals->asso('id');
302 $evt['organisateur_uid'] = Session::get('uid');
303 $evt['intitule'] = Post::get('intitule');
304 $evt['paiement_id'] = (Post::get('paiement_id')>0) ? Post::get('paiement_id') : null;
305 $evt['descriptif'] = Post::get('descriptif');
306 $evt['debut'] = Post::get('deb_Year')."-".Post::get('deb_Month')
307 . "-".Post::get('deb_Day')." ".Post::get('deb_Hour')
308 . ":".Post::get('deb_Minute').":00";
309 $evt['fin'] = Post::get('fin_Year')."-".Post::get('fin_Month')
310 . "-".Post::get('fin_Day')." ".Post::get('fin_Hour')
311 . ":".Post::get('fin_Minute').":00";
312 $evt['membres_only'] = Post::get('membres_only');
313 $evt['advertise'] = Post::get('advertise');
314 $evt['show_participants'] = Post::get('show_participants');
315 $evt['noinvite'] = Post::get('noinvite');
316 if (!$short_name) {
317 $short_name = '';
318 }
319 $evt['short_name'] = $short_name;
320 $evt['deadline_inscription'] = Post::get('deadline', 'off') == 'on' ? null
321 : (Post::get('inscr_Year')."-".Post::get('inscr_Month')
322 ."-".Post::get('inscr_Day'));
323
324 // Store the modifications in the database
325 $globals->xdb->execute("REPLACE INTO groupex.evenements
326 SET eid={?}, asso_id={?}, organisateur_uid={?}, intitule={?},
327 paiement_id = {?}, descriptif = {?},
328 debut = {?}, fin = {?},
329 membres_only = {?}, advertise = {?}, show_participants = {?},
330 short_name = {?}, deadline_inscription = {?}, noinvite = {?}",
331 $evt['eid'], $evt['asso_id'], $evt['organisateur_uid'], $evt['intitule']
332 , $evt['paiement_id'], $evt['descriptif'],
333 $evt['debut'], $evt['fin'],
334 $evt['membres_only'], $evt['advertise'], $evt['show_participants'],
335 $evt['short_name'], $evt['deadline_inscription'], $evt['noinvite']);
336
337 // if new event, get its id
338 if (!$eid) {
339 $res = $globals->xdb->query("SELECT LAST_INSERT_ID()");
340 $eid = $res->fetchOneCell();
341 $evt['eid'] = $eid;
342 }
343
344 $nb_moments = 0;
345 $money_defaut = 0;
346
347 foreach ($moments as $i) {
348 if (Post::get('titre'.$i)) {
349 $nb_moments++;
350 if (!($money_defaut > 0))
351 $money_defaut = strtr(Post::get('montant'.$i), ',', '.');
352 $globals->xdb->execute("
353 REPLACE INTO groupex.evenements_items
354 VALUES ({?}, {?}, {?}, {?}, {?})",
355 $eid, $i, Post::get('titre'.$i),
356 Post::get('details'.$i),
357 strtr(Post::get('montant'.$i), ',', '.'));
358 } else {
359 $globals->xdb->execute("DELETE FROM groupex.evenements_items
360 WHERE eid = {?} AND item_id = {?}", $eid, $i);
361 }
362 }
363
364 // request for a new payment
365 if (Post::get('paiement_id') == -1 && $money_defaut >= 0) {
366 require_once 'validations.inc.php';
367 $p = new PayReq(Session::get('uid'),
368 Post::get('intitule')." - ".$globals->asso('nom'),
369 Post::get('site'), $money_defaut,
370 Post::get('confirmation'), 0, 999,
371 $globals->asso('id'), $eid);
372 $p->submit();
373 }
374
375 // events with no sub-event: add a sub-event with no name
376 if ($nb_moments == 0) {
377 $globals->xdb->execute("INSERT INTO groupex.evenements_items
378 VALUES ({?}, {?}, '', '', 0)", $eid, 1);
379 }
380 }
381
382 if (Env::has('sup') && $eid) {
383 // deletes the event
384 $globals->xdb->execute("DELETE FROM groupex.evenements
385 WHERE eid = {?} AND asso_id = {?}",
386 $eid, $globals->asso('id'));
387
388 // deletes the event items
389 $globals->xdb->execute("DELETE FROM groupex.evenements_items WHERE eid = {?}", $eid);
390
391 // deletes the event participants
392 $globals->xdb->execute("DELETE FROM groupex.evenements_participants
393 WHERE eid = {?}", $eid);
394
395 // deletes the event mailing aliases
396 if ($infos['short_name']) {
397 $globals->xdb->execute("DELETE FROM virtual
398 WHERE type = 'evt' AND alias LIKE {?}",
399 $infos['short_name']."-%");
400 }
401
402 // delete the requests for payments
403 require_once 'validations.inc.php';
404 $globals->xdb->execute("DELETE FROM requests
405 WHERE type = 'paiements' AND data LIKE {?}",
406 PayReq::same_event($eid, $globals->asso('id')));
407 redirect("evenements.php");
408 }
409
410 if (!$get_form) {
411 redirect("evenements.php");
412 }
413
414 // get a list of all the payment for this asso
415 $res = $globals->xdb->iterator("SELECT id, text
416 FROM {$globals->money->mpay_tprefix}paiements
417 WHERE asso_id = {?}", $globals->asso('id'));
418 $paiements = array();
419 while ($a = $res->next()) $paiements[$a['id']] = $a['text']; {
420 $page->assign('paiements', $paiements);
421 }
422
423 // when modifying an old event retreive the old datas
424 if ($eid) {
425 $res = $globals->xdb->query(
426 "SELECT eid, intitule, descriptif, debut, fin,
427 membres_only, advertise, show_participants,
428 paiement_id, short_name, deadline_inscription,
429 noinvite
430 FROM groupex.evenements
431 WHERE eid = {?}", $eid);
432 $evt = $res->fetchOneAssoc();
433 // find out if there is already a request for a payment for this event
434 require_once 'validations.inc.php';
435 $res = $globals->xdb->query("SELECT stamp FROM requests
436 WHERE type = 'paiements' AND data LIKE {?}",
437 PayReq::same_event($eid, $globals->asso('id')));
438 $stamp = $res->fetchOneCell();
439 if ($stamp) {
440 $evt['paiement_id'] = -2;
441 $evt['paiement_req'] = $stamp;
442 }
443 $page->assign('evt', $evt);
444 // get all the different moments infos
445 $res = $globals->xdb->iterator(
446 "SELECT item_id, titre, details, montant
447 FROM groupex.evenements_items AS ei
448 INNER JOIN groupex.evenements AS e ON(e.eid = ei.eid)
449 WHERE e.eid = {?}
450 ORDER BY item_id", $eid);
451 $items = array();
452 while ($item = $res->next()) {
453 $items[$item['item_id']] = $item;
454 }
455 $page->assign('items', $items);
456 }
457 }
458
459 function handler_admin(&$page, $eid = null, $item_id = null)
460 {
461 global $globals;
462
463 define('NB_PER_PAGE', 25);
464
465 require_once('xnet/evenements.php');
466
467 $evt = get_event_detail($eid, $item_id);
468
469 // the event doesn't exist or doesn't belong to this assoif (!$evt)
470 if (!$evt) {
471 return PL_NOT_FOUND;
472 }
473
474 if ($evt['show_participants']) {
475 new_group_page('xnet/groupe/evt-admin.tpl');
476 } else {
477 new_groupadmin_page('xnet/groupe/evt-admin.tpl');
478 }
479
480 $admin = may_update();
481
482 // select a member from his mail
483 if ($admin && Env::get('adm') && Env::get('mail')) {
484 if (strpos(Env::get('mail'), '@') === false) {
485 $res = $globals->xdb->query(
486 "SELECT m.uid
487 FROM groupex.membres AS m
488 INNER JOIN aliases AS a ON (a.id = m.uid)
489 WHERE a.alias = {?} AND m.asso_id = {?}",
490 Env::get('mail'), $globals->asso('id'));
491 } else {
492 $res = $globals->xdb->query(
493 "SELECT m.uid
494 FROM groupex.membres AS m
495 WHERE m.email = {?} AND m.asso_id = {?}",
496 Env::get('mail'), $globals->asso('id'));
497 }
498 $member = $res->fetchOneCell();
499 if (!$member) $page->trig("Membre introuvable");
500 }
501
502 // change the price paid by a participant
503 if ($admin && Env::get('adm') == 'prix' && $member) {
504 $globals->xdb->execute("UPDATE groupex.evenements_participants SET paid = IF(paid + {?} > 0, paid + {?}, 0) WHERE uid = {?} AND eid = {?}",
505 strtr(Env::get('montant'), ',', '.'),
506 strtr(Env::get('montant'), ',', '.'),
507 $member, Env::get('eid'));
508 }
509
510 // change the number of personns coming with a participant
511 if ($admin && Env::get('adm') == 'nbs' && $member) {
512 $res = $globals->xdb->query("SELECT paid FROM groupex.evenements_participants WHERE uid = {?} AND eid = {?}", $member, Env::get('eid'));
513 $paid = $res->fetchOneCell();
514 $participate = false;
515 foreach ($evt['moments'] as $m) if (Env::has('nb'.$m['item_id'])) {
516 $nb = Env::getInt('nb'.$m['item_id'], 0);
517 if ($nb < 0) $nb = 0;
518 if ($nb) {
519 $participate = true;
520 if (!$paid) $paid = 0;
521 $globals->xdb->execute("REPLACE INTO groupex.evenements_participants VALUES ({?}, {?}, {?}, {?}, {?})",
522 Env::get('eid'), $member, $m['item_id'], $nb, $paid);
523 } else {
524 $globals->xdb->execute("DELETE FROM groupex.evenements_participants WHERE uid = {?} AND eid = {?} AND item_id = {?}", $member, Env::get('eid'), $m['item_id']);
525 }
526 }
527 if ($participate) {
528 subscribe_lists_event(true, $member, $evt['participant_list'], $evt['absent_list']);
529 } else {
530 $res = $globals->xdb->query(
531 "SELECT uid FROM groupex.evenements_participants
532 WHERE uid = {?} AND eid = {?}", $member, $eid);
533 $u = $res->fetchOneCell();
534 subscribe_lists_event($u, $member, $evt['participant_list'], $evt['absent_list']);
535 }
536 $evt = get_event_detail($eid, $item_id);
537 }
538
539 $page->assign('admin', $admin);
540 $page->assign('evt', $evt);
541 $page->assign('url_page', Env::get('PHP_SELF')."?eid=".Env::get('eid').(Env::has('item_id')?("&item_id=".Env::getInt('item_id')):''));
542 $page->assign('tout', !Env::has('item_id'));
543
544 if (count($evt['moments'])) $page->assign('moments', $evt['moments']);
545 $page->assign('money', $evt['money']);
546
547 $tri = (Env::get('order') == 'alpha' ? 'promo, nom, prenom' : 'nom, prenom, promo');
548 $whereitemid = Env::has('item_id')?('AND ep.item_id = '.Env::getInt('item_id', 1)):'';
549 $res = $globals->xdb->iterRow(
550 'SELECT UPPER(SUBSTRING(IF(u.nom IS NULL,m.nom,IF(u.nom_usage<>"", u.nom_usage, u.nom)), 1, 1)), COUNT(DISTINCT ep.uid)
551 FROM groupex.evenements_participants AS ep
552 INNER JOIN groupex.evenements AS e ON (ep.eid = e.eid)
553 LEFT JOIN groupex.membres AS m ON ( ep.uid = m.uid AND e.asso_id = m.asso_id)
554 LEFT JOIN auth_user_md5 AS u ON ( u.user_id = ep.uid )
555 WHERE ep.eid = {?} '.$whereitemid.'
556 GROUP BY UPPER(SUBSTRING(IF(u.nom IS NULL,m.nom,u.nom), 1, 1))', Env::get('eid'));
557
558 $alphabet = array();
559 $nb_tot = 0;
560 while (list($char, $nb) = $res->next()) {
561 $alphabet[ord($char)] = $char;
562 $nb_tot += $nb;
563 if (Env::has('initiale') && $char == strtoupper(Env::get('initiale'))) {
564 $tot = $nb;
565 }
566 }
567 ksort($alphabet);
568 $page->assign('alphabet', $alphabet);
569
570 $ofs = Env::getInt('offset');
571 $tot = Env::get('initiale') ? $tot : $nb_tot;
572 $nbp = intval(($tot-1)/NB_PER_PAGE);
573 $links = array();
574 if ($ofs) {
575 $links['précédent'] = $ofs-1;
576 }
577 for ($i = 0; $i <= $nbp; $i++) {
578 $links[(string)($i+1)] = $i;
579 }
580 if ($ofs < $nbp) {
581 $links['suivant'] = $ofs+1;
582 }
583 if (count($links)>1) {
584 $page->assign('links', $links);
585 }
586
587 $ini = Env::has('initiale') ? 'AND IF(u.nom IS NULL,m.nom,IF(u.nom_usage<>"", u.nom_usage, u.nom)) LIKE "'.addslashes(Env::get('initiale')).'%"' : '';
588
589 $participants = get_event_participants(Env::get('eid'), Env::get('item_id'), $ini, $tri, "LIMIT ".($ofs*NB_PER_PAGE).", ".NB_PER_PAGE, $evt['money'] && $admin, $evt['paiement_id']);
590
591 if ($evt['paiement_id']) {
592 $res = $globals->xdb->iterator(
593 "SELECT IF(u.nom_usage<>'', u.nom_usage, u.nom) AS nom, u.prenom,
594 u.promo, a.alias AS email, t.montant
595 FROM {$globals->money->mpay_tprefix}transactions AS t
596 INNER JOIN auth_user_md5 AS u ON(t.uid = u.user_id)
597 INNER JOIN aliases AS a ON (a.id = t.uid AND a.type='a_vie' )
598 LEFT JOIN groupex.evenements_participants AS ep ON(ep.uid = t.uid AND ep.eid = {?})
599 WHERE t.ref = {?} AND ep.uid IS NULL",
600 $evt['eid'], $evt['paiement_id']);
601 $page->assign('oublis', $res->total());
602 $page->assign('oubliinscription', $res);
603 }
604
605 $page->assign('participants', $participants);
606 }
4f10a058 607}
608
609?>