}
$page->assign('archive', $archive);
- $evenements = XDB::iterator('SELECT e.*, LEFT(10, e.debut) AS first_day, LEFT(10, e.fin) AS last_day,
+ $evenements = XDB::iterator('SELECT e.*, LEFT(e.debut, 10) AS first_day, LEFT(e.fin, 10) AS last_day,
IF(e.deadline_inscription,
e.deadline_inscription >= LEFT(NOW(), 10),
1) AS inscr_open,
}
// update actual inscriptions
- $updated = false;
- $total = 0;
- $paid = $evt['paid'] ? $evt['paid'] : 0;
- $telepaid= $evt['telepaid'] ? $evt['telepaid'] : 0;
+ $updated = false;
+ $total = 0;
+ $paid = $evt['paid'] ? $evt['paid'] : 0;
+ $telepaid = $evt['telepaid'] ? $evt['telepaid'] : 0;
+ $paid_inserted = false;
foreach ($subs as $j => $nb) {
if ($nb >= 0) {
XDB::execute('INSERT INTO group_event_participants (eid, uid, item_id, nb, flags, paid)
VALUES ({?}, {?}, {?}, {?}, {?}, {?})
ON DUPLICATE KEY UPDATE nb = VALUES(nb), flags = VALUES(flags), paid = VALUES(paid)',
$eid, S::v('uid'), $j, $nb, (Env::has('notify_payment') ? 'notify_payment' : ''),
- ($j == 1 ? $paid - $telepaid : 0));
+ ((!$paid_inserted) ? $paid - $telepaid : 0));
$updated = $eid;
+ $paid_inserted = true;
} else {
XDB::execute(
"DELETE FROM group_event_participants
return PL_NOT_FOUND;
}
- pl_cached_content_headers('text/x-csv', 1);
+ pl_cached_content_headers('text/x-csv', 'iso-8859-1', 1);
$page->changeTpl('xnetevents/csv.tpl', NO_SKIN);
$admin = may_update();
-
$tri = (Env::v('order') == 'alpha' ? UserFilter::sortByPromo() : UserFilter::sortByName());
+ $all = !Env::v('item_id', false);
- $page->assign('participants',
- get_event_participants($evt, $item_id, $tri));
+ $participants = get_event_participants($evt, $item_id, $tri);
+ $title = 'Nom;Prénom;Promotion';
+ if ($all) {
+ foreach ($evt['moments'] as $moment) {
+ $title .= ';' . $moment['titre'];
+ }
+ }
+ if ($admin && $evt['money']) {
+ $title .= ';À payer;';
+ if ($evt['paiement_id']) {
+ $title .= 'Télépaiement;Liquide/Chèque;';
+ }
+ $title .= 'Payé';
+ } else {
+ $title .= ';Nombre';
+ }
+ echo utf8_decode($title) . "\n";
+
+ if ($participants) {
+ foreach ($participants as $participant) {
+ $user = $participant['user'];
+ $line = $user->lastName() . ';' . $user->firstName() . ';' . $user->promo();
+ if ($all) {
+ foreach ($evt['moments'] as $moment) {
+ $line .= ';' . $participant[$moment['item_id']];
+ }
+ }
+ if ($admin && $evt['money']) {
+ $line .= ';' . $participant['montant'] . ';';
+ if ($evt['paiement_id']) {
+ $line .= $participant['telepayment'] . ';' . $participant['adminpaid'] . ';';
+ }
+ $line .= $participant['paid'];
+ } else {
+ $line .= ';' . $participant['nb'];
+ }
- $page->assign('admin', $admin);
- $page->assign('moments', $evt['moments']);
- $page->assign('money', $evt['money']);
- $page->assign('telepayment', $evt['paiement_id']);
- $page->assign('tout', !Env::v('item_id', false));
+ echo utf8_decode($line) . "\n";
+ }
+ }
+ exit();
}
function handler_ical($page, $eid = null)
if ($p->accept()) {
$p->submit();
} else {
- $page->assign('paiement_message', Post::v('confirmation'));
- $page->assign('paiement_site', Post::v('site'));
+ $page->assign('payment_message', Post::v('confirmation'));
+ $page->assign('payment_site', Post::v('site'));
+ $page->assign('payment_public', Post::v('payment_public') == 'yes');
+ $page->assign('error', true);
$error = true;
}
}
$res = XDB::query("SELECT stamp
FROM requests
WHERE type = 'paiements' AND data LIKE {?}",
- PayReq::same_event($eid, $globals->asso('id')));
+ PayReq::same_event($eid, $globals->asso('id')));
$stamp = $res->fetchOneCell();
if ($stamp) {
$evt['paiement_id'] = -2;
$amount = strtr(Env::v('montant'), ',', '.');
XDB::execute("UPDATE group_event_participants
SET paid = paid + {?}
- WHERE uid = {?} AND eid = {?} AND item_id = 1",
+ WHERE uid = {?} AND eid = {?} AND nb > 0
+ ORDER BY item_id ASC
+ LIMIT 1",
$amount, $member->uid, $evt['eid']);
subscribe_lists_event($member->uid, $evt['short_name'], 1, $amount);
}
// change the number of personns coming with a participant
if (Env::v('adm') == 'nbs' && $member) {
- $res = XDB::query("SELECT paid
+ $res = XDB::query("SELECT SUM(paid)
FROM group_event_participants
WHERE uid = {?} AND eid = {?}",
$member->uid, $evt['eid']);
- $paid = intval($res->fetchOneCell());
+ $paid = $res->fetchOneCell();
$nbs = Post::v('nb', array());
+ $paid_inserted = false;
foreach ($nbs as $id => $nb) {
$nb = max(intval($nb), 0);
+ if (!$paid_inserted && $nb > 0) {
+ $item_paid = $paid;
+ $paid_inserted = true;
+ } else {
+ $item_paid = 0;
+ }
XDB::execute('INSERT INTO group_event_participants (eid, uid, item_id, nb, flags, paid)
VALUES ({?}, {?}, {?}, {?}, {?}, {?})
ON DUPLICATE KEY UPDATE nb = VALUES(nb), flags = VALUES(flags), paid = VALUES(paid)',
- $evt['eid'], $member->uid, $id, $nb, '', ($id == 1 ? $paid : 0));
+ $evt['eid'], $member->uid, $id, $nb, '', $item_paid);
}
$res = XDB::query('SELECT COUNT(uid) AS cnt, SUM(nb) AS nb
GROUP BY uid',
$member->uid, $evt['eid']);
$u = $res->fetchOneAssoc();
- if ($u['cnt'] == 1 && $paid == 0 && Post::v('cancel')) {
+ if ($paid == 0 && Post::v('cancel')) {
XDB::execute("DELETE FROM group_event_participants
WHERE uid = {?} AND eid = {?}",
$member->uid, $evt['eid']);