<?php
require 'xnet.inc.php';
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker:
+/***************************************************************************
+ * Copyright (C) 2003-2004 Polytechnique.org *
+ * http://opensource.polytechnique.org/ *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the Free Software *
+ * Foundation, Inc., *
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
+ ***************************************************************************/
new_group_page('xnet/groupe/evenements.tpl');
-$page->assign('logged', logged());
-$page->assign('admin', may_update());
-
-$moments = range(1, 4);
-$page->assign('moments', $moments);
-
-$page->assign('eid', Env::get('eid'));
-
-if ($eid = Env::get('eid')) {
- $res = $globals->xdb->query("SELECT asso_id, short_name FROM groupex.evenements WHERE eid = {?}", $eid);
- $infos = $res->fetchOneAssoc();
- if ($infos['asso_id'] != $globals->asso('id')) {
- unset($eid);
- unset($infos);
- }
-}
-
-if (may_update() && Post::get('intitule')) {
- $short_name = Env::get('short_name');
- //Quelques vérifications sur l'alias (caractères spéciaux)
- if ($short_name && !preg_match( "/^[a-zA-Z0-9\-.]{3,20}$/", $short_name))
- {
- $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 .");
- $short_name = $infos['short_name'];
- $page->assign('get_form', true);
- $get_form = true;
- // set the field to the previously requested field
- $page->assign('evt', $_REQUEST);
- }
- //vérifier que l'alias n'est pas déja pris
- if ($short_name && $short_name != $infos['short_name']) {
- $res = $globals->xdb->query('SELECT COUNT(*) FROM virtual WHERE alias LIKE {?}', $short_name."-%");
- if ($res->fetchOneCell() > 0) {
- $page->trig("Le raccourci demandé est déjà utilisé. Choisis en un autre.");
- $short_name = $infos['short_name'];
- $page->assign('get_form', true);
- $get_form = true;
- // set the field to the previously requested field
- $page->assign('evt', $_REQUEST);
- }
- }
- if ($short_name && $infos['short_name'] && $short_name != $infos['short_name']) {
- $globals->xdb->execute("UPDATE virtual SET alias = REPLACE(alias, {?}, {?}) WHERE type = 'evt' AND alias LIKE {?}",
- $infos['short_name'], $short_name, $infos['short_name']."-%");
- } elseif ($short_name && !$infos['short_name']) {
- $globals->xdb->execute("INSERT INTO virtual SET type = 'evt', alias = {?}", $short_name."-participants@".$globals->xnet->evts_domain);
- $res = $globals->xdb->query("SELECT LAST_INSERT_ID()");
- $globals->xdb->execute("INSERT INTO virtual_redirect (
- SELECT {?} AS vid, IF(u.nom IS NULL, m.email, CONCAT(a.alias, {?})) AS redirect
- FROM groupex.evenements_participants AS ep
- 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 = {?}
- GROUP BY ep.uid)",
- $res->fetchOneCell(), "@".$globals->mail->domain, $eid);
-
- $globals->xdb->execute("INSERT INTO virtual SET type = 'evt', alias = {?}", $short_name."-absents@".$globals->xnet->evts_domain);
- $res = $globals->xdb->query("SELECT LAST_INSERT_ID()");
- $globals->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 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)",
- $res->fetchOneCell(), "@".$globals->mail->domain, $globals->asso('id'));
- } elseif (!$short_name && $infos['short_name']) {
- $globals->xdb->execute("DELETE virtual, virtual_redirect FROM virtual LEFT JOIN virtual_redirect USING(vid) WHERE virtual.alias LIKE {?}",
- $infos['short_name']."-%");
- }
-
- $globals->xdb->execute("REPLACE INTO groupex.evenements
- SET eid={?}, asso_id={?}, organisateur_uid={?}, intitule={?},
- paiement_id = {?}, descriptif = {?},
- debut = {?}, fin = {?},
- membres_only = {?}, advertise = {?}, show_participants = {?}, short_name = {?}",
- $eid, $globals->asso('id'), Session::get('uid'), Post::get('intitule'),
- (Post::get('paiement_id')>0)?Post::get('paiement_id'):NULL, Post::get('descriptif'),
- Post::get('deb_Year')."-".Post::get('deb_Month')."-".Post::get('deb_Day')." ".Post::get('deb_Hour').":".Post::get('deb_Minute').":00",
- Post::get('fin_Year')."-".Post::get('fin_Month')."-".Post::get('fin_Day')." ".Post::get('fin_Hour').":".Post::get('fin_Minute').":00",
- Post::get('membres_only'), Post::get('advertise'), Post::get('show_participants'), $short_name, $eid);
-
- if (!$eid) {
- $res = $globals->xdb->query("SELECT LAST_INSERT_ID()");
- $eid = $res->fetchOneCell();
- }
- $nb_moments = 0;
- $money_defaut = 0;
- foreach ($moments as $i) if (Post::get('titre'.$i)) {
- $nb_moments++;
- if (!($money_defaut > 0)) $money_defaut = strtr(Post::get('montant'.$i), ',', '.');
- $globals->xdb->execute("
- REPLACE INTO groupex.evenements_items VALUES (
- {?}, {?},
- {?}, {?}, {?})",
- $eid, $i,
- Post::get('titre'.$i), Post::get('details'.$i), strtr(Post::get('montant'.$i), ',', '.'));
- } else {
- $globals->xdb->execute("DELETE FROM groupex.evenements_items WHERE eid = {?} AND item_id = {?}", $eid, $i);
- }
-
- // request for a new payment
- if (Post::get('paiement_id') == -1 && $money_defaut >= 0) {
- require_once ('validations.inc.php');
- $p = new PayReq(Session::get('uid'), Post::get('intitule')." - ".$globals->asso('nom'), Post::get('site'), $money_defaut, Post::get('confirmation'),0, 999, $globals->asso('id'), $eid);
- $p->submit();
- }
-
- // events with no sub-event
- if ($nb_moments == 0)
- $globals->xdb->execute("INSERT INTO groupex.evenements_items VALUES ({?}, {?}, '', '', 0)", $eid, 1);
+/**** manage inscriptions ****/
+// inscription to events
+if (Env::has('ins')) {
+ for ($i=1; Env::has('evt_'.$i); $i++)
+ {
+ $eid = Env::get('evt_'.$i);
+ $res = $globals->xdb->query("
+ SELECT deadline_inscription,
+ LEFT(NOW(), 10) AS now,
+ membres_only
+ FROM groupex.evenements
+ WHERE eid = {?}", $eid);
+ $e = $res->fetchOneAssoc();
+ // impossible to change inscription: either inscription closed or members only
+ if ($e['deadline_inscription'] && $e['deadline_inscription']<$e['now'])
+ {
+ $page->trig("Les inscriptions sont closes");
+ continue;
+ }
+
+ if ($e['membres_only'] && !is_member())
+ {
+ $page->trig("Les inscriptions à cet événement ne sont pas publiques");
+ continue;
+ }
+
+ // impossible to unsubscribe if you already paid sthing
+ $total_inscr = 0;
+ $inscriptions = array();
+ for ($i=1; Env::has('moment'.$eid.'_'.$i); $i++)
+ {
+ $inscriptions[$i] = Env::get('moment'.$eid.'_'.$i);
+ // retreive ohter field when more than one person
+ if ($inscriptions[$i] == 2)
+ $inscriptions[$i] = 1 + Env::get('personnes'.$eid.'_'.$i,0);
+ // avoid negative count if other field incorrect
+ if ($inscriptions[$i] < 0)
+ $inscriptions[$i] = 0;
+ // avoid floating count if other field incorrect
+ $inscriptions[$i] = floor($inscriptions[$i]);
+ $total_inscr += $inscriptions[$i];
+ }
+ $unsubscribing = ($total_inscr == 0);
+
+ // retreive the amount already paid for this event in cash
+ $res = $globals->xdb->query("
+ SELECT paid
+ FROM groupex.evenements_participants
+ WHERE eid = {?} AND uid = {?}
+ LIMIT 1",
+ $eid, Session::get("uid"));
+ $paid = $res->fetchOneCell();
+ if (!$paid) $paid = 0;
+
+ if ($unsubscribing && $paid != 0)
+ {
+ $page->trig("Impossible de te désinscrire complètement parce que tu as fait un paiement par chèque ou par liquide. Contacte un administrateur du groupe si tu es sûr de ne pas venir");
+ continue;
+ }
+
+ // update actual inscriptions
+ foreach ($inscriptions as $i=>$nb)
+ {
+ if ($nb > 0)
+ {
+ $globals->xdb->execute(
+ "REPLACE INTO groupex.evenements_participants
+ VALUES ({?}, {?}, {?}, {?}, {?})",
+ $eid, Session::get("uid"), $i, $nb, $paid);
+ }
+ else
+ {
+ $globals->xdb->execute(
+ "DELETE FROM groupex.evenements_participants
+ WHERE eid = {?} AND uid = {?} AND item_id = {?}",
+ $eid, Session::get("uid"), $i);
+ }
+ }
+ }
}
-if (may_update() && Env::has('sup') && $eid) {
- // deletes the event
- $globals->xdb->execute("DELETE FROM groupex.evenements WHERE eid = {?} AND asso_id = {?}", $eid, $globals->asso('id'));
- // deletes the event items
- $globals->xdb->execute("DELETE FROM groupex.evenements_items WHERE eid = {?}", $eid);
- // deletes the event participants
- $globals->xdb->execute("DELETE FROM groupex.evenements_participants WHERE eid = {?}", $eid);
- // deletes the event mailing aliases
- if ($infos['short_name'])
- $globals->xdb->execute("DELETE FROM virtual WHERE type = 'evt' AND alias LIKE {?}", $infos['short_name']."-%");
- // delete the requests for payments
- require_once('validations.inc.php');
- $globals->xdb->execute("DELETE FROM requests WHERE type = 'paiements' AND data LIKE {?}", PayReq::same_event($eid, $globals->asso('id')));
-}
-
-if (may_update() && (Env::has('add') || (Env::has('mod') && $eid || $get_form))) {
- $page->assign('get_form', true);
- $res = $globals->xdb->iterator
- ("SELECT id, text FROM {$globals->money->mpay_tprefix}paiements WHERE asso_id = {?}", $globals->asso('id'));
- $paiements = array();
- while ($a = $res->next()) $paiements[$a['id']] = $a['text'];
- $page->assign('paiements', $paiements);
-}
+/**** retreive all infos about all events ****/
+$page->assign('logged', logged());
+$page->assign('admin', may_update());
-if ($eid) {
- $res = $globals->xdb->query(
- "SELECT eid, intitule, descriptif, debut, fin, membres_only, advertise, show_participants, paiement_id, short_name
- FROM groupex.evenements
- WHERE eid = {?}", $eid);
- $evt = $res->fetchOneAssoc();
- require_once('validations.inc.php');
- $res = $globals->xdb->query("SELECT stamp FROM requests WHERE type = 'paiements' AND data LIKE {?}", PayReq::same_event($eid, $globals->asso('id')));
- $stamp = $res->fetchOneCell();
- if ($stamp) {
- $evt['paiement_id'] = -2;
- $evt['paiement_req'] = $stamp;
- }
- $page->assign('evt', $evt);
+$evenements = $globals->xdb->iterator(
+"SELECT e.eid, e.intitule, e.descriptif,
+ e.debut, e.fin,
+ LEFT(10,e.debut) AS debut_day,
+ LEFT(10,e.fin) AS fin_day,
+ e.paiement_id, e.membres_only,
+ e.show_participants, u.nom, u.prenom, u.promo, a.alias, MAX(ep.nb) AS inscrit,
+ e.short_name,
+ IF(e.deadline_inscription,e.deadline_inscription >= LEFT(NOW(), 10), 1) AS inscr_open, e.deadline_inscription
+ FROM groupex.evenements AS e
+INNER JOIN x4dat.auth_user_md5 AS u ON u.user_id = e.organisateur_uid
+ LEFT JOIN x4dat.aliases AS a ON (a.type = 'a_vie' AND a.id = u.user_id)
+ LEFT JOIN groupex.evenements_participants AS ep ON (ep.eid = e.eid AND ep.uid = {?})
+ WHERE asso_id = {?}
+ GROUP BY e.eid
+ ORDER BY debut",Session::get('uid'),$globals->asso('id'));
+
+$evts = array();
+while ($e = $evenements->next())
+{
+ $e['moments'] = $globals->xdb->iterator(
+ "SELECT titre, details, montant, ei.item_id, nb
+ 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 = {?})
+ WHERE ei.eid = {?}",
+ Session::get('uid'), $e['eid']);
+ $e['paid'] = 0;
+ $evts[] = $e;
}
-if (may_update() && Env::has('mod') && $eid) {
- $res = $globals->xdb->iterator(
- "SELECT item_id, titre, details, montant
- FROM groupex.evenements_items AS ei
- INNER JOIN groupex.evenements AS e ON(e.eid = ei.eid)
- WHERE e.eid = {?}
- ORDER BY item_id", $eid);
- $items = array();
- while ($item = $res->next()) $items[$item['item_id']] = $item;
- $page->assign('items', $items);
-} else {
-
- $evenements = $globals->xdb->iterator(
- "SELECT e.eid, e.intitule, e.descriptif, e.debut, e.fin, e.show_participants, u.nom, u.prenom, u.promo, a.alias, MAX(ep.nb) AS inscrit,
- e.short_name
- FROM groupex.evenements AS e
- INNER JOIN x4dat.auth_user_md5 AS u ON u.user_id = e.organisateur_uid
- LEFT JOIN x4dat.aliases AS a ON (a.type = 'a_vie' AND a.id = u.user_id)
- LEFT JOIN groupex.evenements_participants AS ep ON (ep.eid = e.eid AND ep.uid = {?})
- WHERE asso_id = {?}
- GROUP BY e.eid
- ORDER BY debut",Session::get('uid'),$globals->asso('id'));
+$page->assign('evenements', $evts);
+$page->assign('is_member', is_member());
- $page->assign('evenements', $evenements);
-
- $page->assign('nb_evt', $evenements->total());
-}
+$page->assign('nb_evt', $evenements->total());
$page->run();
+++ /dev/null
-<?php
-
-require_once 'xnet.inc.php';
-
-new_group_page('xnet/groupe/evt-detail.tpl');
-
-if (!Env::get("eid")) {
- redirect("evenements.php");
-}
-
-$may_participate = !$members_only || is_member() || may_update();
-$page->assign('may_participate', $may_participate);
-
-if (Env::get('ins')) {
- $total = 0;
- for ($i=1; Env::has('item_id'.$i); $i++)
- $total += (Env::get('item_'.Env::get('item_id'.$i)) > 0)?Env::get('item_'.Env::get('item_id'.$i)):0;
-
- $participate = $total > 0;
- $res = $globals->xdb->query("SELECT paid FROM groupex.evenements_participants WHERE eid = {?} AND uid = {?}", Env::get("eid"), Session::get("uid"));
- $paid = $res->fetchOneCell();
- if (!$paid) $paid = 0;
-
- // prevent desinscription if there is a manual paiement
- if (!$participate && $paid) {
- $page->trig("Impossible de te désinscrire complètement parce que tu as fait un paiement par chèque ou par liquide. Contacte un administrateur du groupe si tu es sûr de ne pas venir");
- $participate = true;
- $page->assign('no_ins', true);
- } else
- for ($i=1; Env::has('item_id'.$i); $i++)
- {
- $j = Env::get('item_id'.$i);
- $nb = Env::get('item_'.$j);
- if ($nb == '+') $nb = Env::get('itemnb_'.$j)+1;
- if ($nb > 0) {
- $globals->xdb->execute(
- "REPLACE INTO groupex.evenements_participants
- VALUES ({?}, {?}, {?}, {?}, {?})",
- Env::get("eid"), Session::get("uid"), $j, $nb, $paid);
- } else {
- $globals->xdb->execute(
- "DELETE FROM groupex.evenements_participants
- WHERE eid = {?} AND uid = {?} AND item_id = {?}",
- Env::get("eid"), Session::get("uid"), $j);
- }
- }
-}
-
-require_once('xnet/evenements.php');
-$evt = get_event_detail(Env::get('eid'));
-
-if (!$evt) {
- redirect("evenements.php");
-}
-
-if (Env::has('ins')) {
- subscribe_lists_event($participate, Session::get("uid"), $evt['participant_list'], $evt['absent_list']);
- redirect("evenements.php?backfrom=".Env::get('eid'));
-}
-
-$page->assign('participate', $participate);
-$page->assign('evt', $evt);
-
-$moments = $globals->xdb->iterator(
- "SELECT titre, i.item_id, details, montant, nb
- FROM groupex.evenements_items AS i
- LEFT JOIN groupex.evenements_participants AS p
- ON(i.eid = p.eid AND i.item_id = p.item_id AND uid = {?})
- WHERE i.eid = {?}",
- Session::get('uid'), Env::get('eid'));
-
-$page->assign('moments', $moments);
-
-if (!$paid) {
- $res = $globals->xdb->query("SELECT paid FROM groupex.evenements_participants WHERE eid = {?} AND uid = {?}", Env::get("eid"), Session::get("uid"));
- $paid = $res->fetchOneCell();
- $page->assign('paid_manual', $paid);
-}
-if ($evt['paiement_id']) {
- $res = $globals->xdb->query(
- "SELECT montant
- FROM {$globals->money->mpay_tprefix}transactions AS t
- WHERE ref = {?} AND uid = {?}",
- $evt['paiement_id'], Session::getInt('uid', -1));
- $montants = $res->fetchColumn();
- foreach ($montants as $m) {
- $p = strtr(substr($m, 0, strpos($m, "EUR")), ",", ".");
- $paid += trim($p);
- }
-}
-$page->assign('paid', $paid);
-
-$page->run();
-
-?>
--- /dev/null
+<?php
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker:
+/***************************************************************************
+ * Copyright (C) 2003-2004 Polytechnique.org *
+ * http://opensource.polytechnique.org/ *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the Free Software *
+ * Foundation, Inc., *
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
+ ***************************************************************************/
+
+require 'xnet.inc.php';
+
+new_group_page('xnet/groupe/evt-modif.tpl');
+
+$page->assign('logged', logged());
+$page->assign('admin', may_update());
+
+$moments = range(1, 4);
+$page->assign('moments', $moments);
+
+$page->assign('eid', Env::get('eid'));
+
+if (!may_update())
+ redirect("evenements.php");
+
+if ($eid = Env::get('eid')) {
+ $res = $globals->xdb->query("SELECT asso_id, short_name FROM groupex.evenements WHERE eid = {?}", $eid);
+ $infos = $res->fetchOneAssoc();
+ if ($infos['asso_id'] != $globals->asso('id')) {
+ unset($eid);
+ unset($infos);
+ }
+}
+
+$get_form = true;
+
+if (Post::get('intitule')) {
+ $get_form = false;
+ $short_name = Env::get('short_name');
+ //Quelques vérifications sur l'alias (caractères spéciaux)
+ if ($short_name && !preg_match( "/^[a-zA-Z0-9\-.]{3,20}$/", $short_name))
+ {
+ $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 .");
+ $short_name = $infos['short_name'];
+ $get_form = true;
+ }
+ //vérifier que l'alias n'est pas déja pris
+ if ($short_name && $short_name != $infos['short_name']) {
+ $res = $globals->xdb->query('SELECT COUNT(*) FROM virtual WHERE alias LIKE {?}', $short_name."-%");
+ if ($res->fetchOneCell() > 0) {
+ $page->trig("Le raccourci demandé est déjà utilisé. Choisis en un autre.");
+ $short_name = $infos['short_name'];
+ $get_form = true;
+ }
+ }
+
+ // if had a previous shortname change the old lists
+ if ($short_name && $infos['short_name'] && $short_name != $infos['short_name']) {
+ $globals->xdb->execute("UPDATE virtual SET alias = REPLACE(alias, {?}, {?}) WHERE type = 'evt' AND alias LIKE {?}",
+ $infos['short_name'], $short_name, $infos['short_name']."-%");
+ }
+ // if we have a first new short_name create the lists
+ elseif ($short_name && !$infos['short_name'])
+ {
+ $globals->xdb->execute("INSERT INTO virtual SET type = 'evt', alias = {?}",
+ $short_name."-participants@".$globals->xnet->evts_domain);
+
+ $res = $globals->xdb->query("SELECT LAST_INSERT_ID()");
+ $globals->xdb->execute("INSERT INTO virtual_redirect (
+ SELECT {?} AS vid, IF(u.nom IS NULL, m.email, CONCAT(a.alias, {?})) AS redirect
+ FROM groupex.evenements_participants AS ep
+ 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 = {?}
+ GROUP BY ep.uid)",
+ $res->fetchOneCell(), "@".$globals->mail->domain, $eid);
+
+ $globals->xdb->execute("INSERT INTO virtual SET type = 'evt', alias = {?}",
+ $short_name."-absents@".$globals->xnet->evts_domain);
+
+ $res = $globals->xdb->query("SELECT LAST_INSERT_ID()");
+ $globals->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 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)",
+ $res->fetchOneCell(), "@".$globals->mail->domain, $globals->asso('id'));
+ }
+ // if we delete the old short name, delete the lists
+ elseif (!$short_name && $infos['short_name']) {
+ $globals->xdb->execute("DELETE virtual, virtual_redirect FROM virtual LEFT JOIN virtual_redirect USING(vid) WHERE virtual.alias LIKE {?}",
+ $infos['short_name']."-%");
+ }
+
+ $evt = array();
+ $evt['eid'] = $eid;
+ $evt['asso_id'] = $globals->asso('id');
+ $evt['organisateur_uid'] = Session::get('uid');
+ $evt['intitule'] = Post::get('intitule');
+ $evt['paiement_id'] =(Post::get('paiement_id')>0)?Post::get('paiement_id'):null;
+ $evt['descriptif'] =Post::get('descriptif');
+ $evt['debut'] = Post::get('deb_Year')."-".Post::get('deb_Month')."-".Post::get('deb_Day')." ".Post::get('deb_Hour').":".Post::get('deb_Minute').":00";
+ $evt['fin'] = Post::get('fin_Year')."-".Post::get('fin_Month')."-".Post::get('fin_Day')." ".Post::get('fin_Hour').":".Post::get('fin_Minute').":00";
+ $evt['membres_only'] = Post::get('membres_only');
+ $evt['advertise'] = Post::get('advertise');
+ $evt['show_participants'] = Post::get('show_participants');
+ $evt['short_name'] = $short_name;
+ $evt['deadline_inscription'] = (Post::get('deadline', 'off')=='on')?null:(Post::get('inscr_Year')."-".Post::get('inscr_Month')."-".Post::get('inscr_Day'));
+
+ // Store the modifications in the database
+ $globals->xdb->execute("REPLACE INTO groupex.evenements
+ SET eid={?}, asso_id={?}, organisateur_uid={?}, intitule={?},
+ paiement_id = {?}, descriptif = {?},
+ debut = {?}, fin = {?},
+ membres_only = {?}, advertise = {?}, show_participants = {?},
+ short_name = {?}, deadline_inscription = {?}",
+ $evt['eid'], $evt['asso_id'], $evt['organisateur_uid'], $evt['intitule']
+ , $evt['paiement_id'], $evt['descriptif'],
+ $evt['debut'], $evt['fin'],
+ $evt['membres_only'], $evt['advertise'], $evt['show_participants'],
+ $evt['short_name'], $evt['deadline_inscription']);
+
+ // if new event, get its id
+ if (!$eid) {
+ $res = $globals->xdb->query("SELECT LAST_INSERT_ID()");
+ $eid = $res->fetchOneCell();
+ $evt['eid'] = $eid;
+ }
+
+ $nb_moments = 0;
+ $money_defaut = 0;
+ foreach ($moments as $i)
+ {
+ if (Post::get('titre'.$i)) {
+ $nb_moments++;
+ if (!($money_defaut > 0))
+ $money_defaut = strtr(Post::get('montant'.$i), ',', '.');
+ $globals->xdb->execute("
+ REPLACE INTO groupex.evenements_items VALUES (
+ {?}, {?},
+ {?}, {?}, {?})",
+ $eid, $i,
+ Post::get('titre'.$i), Post::get('details'.$i), strtr(Post::get('montant'.$i), ',', '.'));
+ }
+ else
+ {
+ $globals->xdb->execute("DELETE FROM groupex.evenements_items WHERE eid = {?} AND item_id = {?}", $eid, $i);
+ }
+ }
+
+ // request for a new payment
+ if (Post::get('paiement_id') == -1 && $money_defaut >= 0) {
+ require_once ('validations.inc.php');
+ $p = new PayReq(
+ Session::get('uid'),
+ Post::get('intitule')." - ".$globals->asso('nom'),
+ Post::get('site'),
+ $money_defaut,
+ Post::get('confirmation'),
+ 0,
+ 999,
+ $globals->asso('id'),
+ $eid);
+ $p->submit();
+ }
+
+ // events with no sub-event: add a sub-event with no name
+ if ($nb_moments == 0)
+ $globals->xdb->execute("INSERT INTO groupex.evenements_items VALUES ({?}, {?}, '', '', 0)", $eid, 1);
+}
+
+if (Env::has('sup') && $eid) {
+ // deletes the event
+ $globals->xdb->execute("DELETE FROM groupex.evenements WHERE eid = {?} AND asso_id = {?}", $eid, $globals->asso('id'));
+ // deletes the event items
+ $globals->xdb->execute("DELETE FROM groupex.evenements_items WHERE eid = {?}", $eid);
+ // deletes the event participants
+ $globals->xdb->execute("DELETE FROM groupex.evenements_participants WHERE eid = {?}", $eid);
+ // deletes the event mailing aliases
+ if ($infos['short_name'])
+ $globals->xdb->execute("DELETE FROM virtual WHERE type = 'evt' AND alias LIKE {?}", $infos['short_name']."-%");
+ // delete the requests for payments
+ require_once('validations.inc.php');
+ $globals->xdb->execute("DELETE FROM requests WHERE type = 'paiements' AND data LIKE {?}", PayReq::same_event($eid, $globals->asso('id')));
+}
+
+if (!$get_form)
+ redirect("Location: evenements.php");
+
+// get a list of all the payment for this asso
+$res = $globals->xdb->iterator
+ ("SELECT id, text FROM {$globals->money->mpay_tprefix}paiements WHERE asso_id = {?}", $globals->asso('id'));
+$paiements = array();
+while ($a = $res->next()) $paiements[$a['id']] = $a['text'];
+ $page->assign('paiements', $paiements);
+
+// when modifying an old event retreive the old datas
+if ($eid) {
+ $res = $globals->xdb->query(
+ "SELECT eid, intitule, descriptif, debut, fin, membres_only, advertise, show_participants, paiement_id, short_name, deadline_inscription
+ FROM groupex.evenements
+ WHERE eid = {?}", $eid);
+ $evt = $res->fetchOneAssoc();
+ // find out if there is already a request for a payment for this event
+ require_once('validations.inc.php');
+ $res = $globals->xdb->query("SELECT stamp FROM requests WHERE type = 'paiements' AND data LIKE {?}", PayReq::same_event($eid, $globals->asso('id')));
+ $stamp = $res->fetchOneCell();
+ if ($stamp) {
+ $evt['paiement_id'] = -2;
+ $evt['paiement_req'] = $stamp;
+ }
+ $page->assign('evt', $evt);
+ // get all the different moments infos
+ $res = $globals->xdb->iterator(
+ "SELECT item_id, titre, details, montant
+ FROM groupex.evenements_items AS ei
+ INNER JOIN groupex.evenements AS e ON(e.eid = ei.eid)
+ WHERE e.eid = {?}
+ ORDER BY item_id", $eid);
+ $items = array();
+ while ($item = $res->next()) $items[$item['item_id']] = $item;
+ $page->assign('items', $items);
+}
+
+$page->run();
+
+?>
"SELECT SUM(nb) AS nb_tot, e.intitule, ei.titre,
debut AS deb, fin, membres_only, descriptif, e.eid,
e.show_participants, e.paiement_id, e.short_name,
+ e.deadline_inscription, LEFT(NOW(), 10) AS now,
al.vid AS absent_list, pl.vid AS participant_list,
a.nom, a.prenom, a.promo
FROM groupex.evenements AS e
function is_member() {
global $globals;
- if (!$globals->asso('id')) { return false; }
- $res = $globals->xdb->query(
+ $asso_id = $globals->asso('id');
+ if (!$asso_id) { return false; }
+ static $is_member;
+ if (!$is_member) $is_member = array();
+ if (!isset($is_member[$asso_id]))
+ {
+ $res = $globals->xdb->query(
"SELECT COUNT(*)
FROM groupex.membres
- WHERE uid={?} AND asso_id={?}", Session::getInt('uid'), $globals->asso('id'));
- return $res->fetchOneCell() == 1;
+ WHERE uid={?} AND asso_id={?}",
+ Session::getInt('uid'), $asso_id);
+ $is_member[$asso_id] = $res->fetchOneCell() == 1;
+ }
+ return $is_member[$asso_id];
}
// }}}
{**************************************************************************}
<h1>{$asso.nom} :
-{if ($smarty.request.add || $smarty.request.mod || $get_form) && $admin}
-<a href='{$smarty.server.PHP_SELF}'>Evénements</a>
-{else}
Evénements
-{/if}
</h1>
{if !$logged}
<p class="descr">
Aucune manifestation publique n'a été saisie par ce groupe pour l'instant...
</p>
-{elseif $get_form}
- {include file='xnet/groupe/form_evenement.tpl'}
{else}
{if $admin}
<p class="center">
- [<a href="{$marty.server.PHP_SELF}?add=1">Annoncer un nouvel événement</a>]
+ [<a href="evt-modif.php?add=1">Annoncer un nouvel événement</a>]
</p>
{/if}
{else}
- {iterate from=$evenements item=e}
+ <form action="{$smarty.server.PHP_SELF}" method="post">
+ {foreach from=$evenements item=e}
<table class="tiny" cellspacing="0" cellpadding="0">
- <tr>
+ <tr {popup caption=$e.intitule text=$e.descriptif}>
<th colspan="2">
{$e.intitule}
- {if $admin || $e.show_participants}
- <a href="evt-admin.php?eid={$e.eid}"><img src="{rel}/images/loupe.gif" title="Liste des participants" alt="Liste des participants" /></a>
- {/if}
{if $admin}
- <a href="{$smarty.session.PHP_SELF}?mod=1&eid={$e.eid}"><img src="{rel}/images/profil.png" title="Edition de l'événement" alt="Edition de l'événement" /></a>
- <a href="{$smarty.session.PHP_SELF}?sup=1&eid={$e.eid}"><img src="{rel}/images/del.png" alt="Suppression de {$e.intitule}" title="Suppression de {$e.intitule}" /></a>
+ <a href="evt-modif.php?mod=1&eid={$e.eid}"><img src="{rel}/images/profil.png" title="Edition de l'événement" alt="Edition de l'événement" /></a>
+ <a href="evt-modif.php?sup=1&eid={$e.eid}"><img src="{rel}/images/del.png" alt="Suppression de {$e.intitule}" title="Suppression de {$e.intitule}" /></a>
{/if}
</th>
</tr>
- <tr>
+ <tr {popup caption=$e.intitule text=$e.descriptif}>
<td class="titre">date :</td>
<td>
- {if $e.fin}
- du {$e.debut|date_format:"%d %B %Y à %H:%M"}<br />
- au {$e.fin|date_format:"%d %B %Y à %H:%M"}
+ {if $e.fin and $e.fin neq $e.debut}
+ {if $e.debut_day eq $e.fin_day}
+ le {$e.debut|date_format:"%d %B %Y"} de {$e.debut|date_format:"%H:%M"} à {$e.fin|date_format:"%H:%M"}
+ {else}
+ du {$e.debut|date_format:"%d %B %Y à %H:%M"}<br />
+ au {$e.fin|date_format:"%d %B %Y à %H:%M"}
+ {/if}
{else}
- le {$e.debut|date_format:"%d %B %Y à %H:%M"}
+ le {$e.debut|date_format:"%d %B %Y à %H:%M"}
{/if}
</td>
</tr>
- <tr>
+ <tr {popup caption=$e.intitule text=$e.descriptif}>
<td class="titre">annonceur :</td>
<td>
<a href='https://polytechnique.org/fiche.php?user={$e.alias}' class='popup2'>{$e.prenom} {$e.nom} ({$e.promo})</a>
</td>
</tr>
- <tr>
- <td class="titre">
- <a href='evt-detail.php?eid={$e.eid}'>Détails...</a>
- </td>
- <td {if $smarty.request.backfrom eq $e.eid}class="erreur"{/if}>
- {if $e.inscrit}
- <small>tu es inscrit à cet événément.
- {if $e.inscrit > 1}(avec {$e.inscrit - 1} invité{if $e.inscrit > 2}s{/if}){/if}
- </small>
- {else}
- <small>tu n'es pas inscrit à cet événément.</small>
- {/if}
+ {if $admin || $e.show_participants}
+ <tr {popup caption=$e.intitule text=$e.descriptif}>
+ <td class="titre" colspan="2">
+ <a href="evt-admin.php?eid={$e.eid}">
+ Liste des participants
+ <img src="{rel}/images/loupe.gif" title="Liste des participants" alt="Liste des participants" />
+ </a>
</td>
</tr>
+ {/if}
+ {assign var="montant" value=0}
+ {if !$e.membres_only or $is_member or $e.inscrit}
+ {if $e.inscr_open}
+ <tr>
+ <td colspan="2">
+ Je viendrai...
+ <input type="hidden" name="evt_{counter}" value="{$e.eid}" />
+ </td>
+ </tr>
+ {/if}
+ {iterate from=$e.moments item=m}
+ {assign var="montant" value=$montant+$m.montant*$m.nb}
+ <tr {if $m.titre or $m.details or $m.montant}{popup caption="`$m.titre` (`$m.montant` €)" text=" `$m.details` "}{/if}>
+ <td>{$m.titre}</td>
+ <td>
+ {if $e.inscr_open}
+ <input type="radio" name="moment{$e.eid}_{$m.item_id}" value="0"
+ {if !$m.nb}checked="checked"{/if}/>non
+ <input type="radio" name="moment{$e.eid}_{$m.item_id}" value="1"
+ {if $m.nb eq 1}checked="checked"{/if}/>seul<br />
+ <input type="radio" name="moment{$e.eid}_{$m.item_id}" value="2"
+ {if $m.nb > 1}checked="checked"{/if}/>avec <input size="2" name="personnes{$e.eid}_{$m.item_id}" value="{if $m.nb > 1}{math equation="x - y" x=$m.nb y=1}{else}1{/if}"/> personnes
+ {else}
+ {if !$m.nb}
+ Tu ne viendras pas.
+ {elseif $m.nb eq 1}
+ Tu viendras seul.
+ {else}
+ Tu viendras avec {$m.nb} personne{if $m.nb > 2}s{/if}
+ {/if}
+ {/if}
+ </td>
+ </tr>
+ {/iterate}
+ {if $e.deadline_inscription}
+ <tr>
+ <td colspan="2" class="center">
+ {if $e.inscr_open}
+ dernières inscriptions
+ le {$e.deadline_inscription|date_format:"%d %B %Y"}
+ {else}
+ Inscriptions closes.
+ {/if}
+ </td>
+ </tr>
+ {/if}
+ {if $montant > 0 || $e.paid > 0}
+ <tr>
+ <td colspan="2" {if $montant > $e.paid}class="erreur"{/if}>
+ Tu dois payer {$montant|replace:'.':','} €{if $e.paid > 0}, et tu as déjà payé {$e.paid|replace:'.':','} €{/if}.
+ {if $e.paiement_id && $montant > $e.paid}
+ [<a href="https://www.polytechnique.org/paiement/?ref={$e.paiement_id}&montant={math equation="x - y" x=$montant y=$e.paid}">Payer en ligne</a>]
+ {/if}
+ </td>
+ </tr>
+ {/if}
+ {/if}
</table>
- <br />
- {/iterate}
+ {if (!$e.membres_only or $is_member or $e.inscrit) and $e.inscr_open}
+ <p style="text-align:center">
+ <input type="submit" value="Valider mes inscriptions" />
+ </p>
+ {/if}
+ {/foreach}
+ <div>
+ <input type="hidden" name="ins" />
+ </div>
+ </form>
{/if}
{/if}
+++ /dev/null
-{**************************************************************************}
-{* *}
-{* Copyright (C) 2003-2004 Polytechnique.org *}
-{* http://opensource.polytechnique.org/ *}
-{* *}
-{* This program is free software; you can redistribute it and/or modify *}
-{* it under the terms of the GNU General Public License as published by *}
-{* the Free Software Foundation; either version 2 of the License, or *}
-{* (at your option) any later version. *}
-{* *}
-{* This program is distributed in the hope that it will be useful, *}
-{* but WITHOUT ANY WARRANTY; without even the implied warranty of *}
-{* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *}
-{* GNU General Public License for more details. *}
-{* *}
-{* You should have received a copy of the GNU General Public License *}
-{* along with this program; if not, write to the Free Software *}
-{* Foundation, Inc., *}
-{* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *}
-{* *}
-{**************************************************************************}
-
-{if $smarty.request.ins && !$no_ins}
- {if $participate}
- Tu es maintenant inscrit à l'évenement.
- {if $evt.paiement_id} Suis le lien en bas si tu souhaites procéder à un paiement par le web.{/if}
- {else}
- Tu es maintenant désinscrit de cet évenement.
- {/if}
-{/if}
-
-<h1>{$asso.nom} : <a href="{$smarty.server.PHP_SELF}">Evénements</a></h1>
-
-<h2>{$evt.intitule}</h2>
-
-<form method='post' action='{$smarty.server.REQUEST_URI}'>
- <table class="tiny" cellspacing="0" cellpadding="0">
- <tr>
- <td class="titre">Annoncé par</td>
- <td>{$evt.prenom} {$evt.nom} (X{$evt.promo})</td>
- </tr>
- <tr>
- <td class="titre">Description</td>
- <td>{$evt.descriptif}</td>
- </tr>
- <tr>
- <td class="titre">Date</td>
- <td>
- {if $evt.fin}
- du {$evt.deb|date_format:"%d %B %Y à %H:%M"}<br />
- au {$evt.fin|date_format:"%d %B %Y à %H:%M"}
- {else}
- le {$evt.deb|date_format:"%d %B %Y à %H:%M"}
- {/if}
- </td>
- </tr>
- </table>
-
- <div><br /><br /></div>
-
- {assign var="montant" value=0}
-
- <table class="bicol" cellpadding="0" cellspacing="0">
- {iterate from=$moments item=m}
- {assign var="montant" value=$montant+$m.montant*$m.nb}
- {if $m.titre || $m.montant}
- <tr>
- <th>
- <input type="hidden" name="item_id{counter}" value="{$m.item_id}" />
- <input type="hidden" name="eid" value="{$evt.eid}" />
- <strong>{$m.titre} - {if $m.montant > 0}{$m.montant}€{else}gratuit{/if}</strong>
- </th>
- </tr>
- {/if}
- <tr>
- <td>{$m.details}</td>
- </tr>
- <tr>
- <td>
- <input name='item_{$m.item_id}' value='0' type='radio' {if $m.nb eq 0}checked="checked"{/if} /> je ne participe pas<br />
- <input name='item_{$m.item_id}' value='1' type='radio' {if $m.nb eq 1}checked="checked"{/if} /> je participe, seul<br />
- <input name='item_{$m.item_id}' value='+' type='radio' {if $m.nb > 1}checked{/if} /> je viens, et serai accompagné de
- <input type='text' name='itemnb_{$m.item_id}' value='{if $m.nb < 2}0{else}{$m.nb-1}{/if}' size="2" maxlength="2" /> personnes
- </td>
- </tr>
- {/iterate}
- </table>
-
- {if $montant > 0 || $paid > 0}
- <p {if $montant > $paid}class="erreur"{/if}>
- Pour cet événement tu dois payer {$montant|replace:'.':','} € {if $paid > 0}, et tu as déjà payé {$paid|replace:'.':','} €{/if}
- {if $evt.paiement_id && $montant > $paid} [<a href="https://www.polytechnique.org/paiement/?ref={$evt.paiement_id}&montant={math equation="x - y" x=$montant y=$paid}">Effectuer le paiement</a>]{/if}
- </p>
- {/if}
- <div class="center">
- <input type='submit' name='ins' value='valider ma participation' />
- <input type='reset' value='annuler' />
- </div>
-</form>
-
-{* vim:set et sw=2 sts=2 sws=2: *}
</td>
</tr>
<tr>
+ <td>Fin des inscriptions</td>
+ <td>pas de deadline <input type='checkbox' name='deadline' {if !$evt.deadline_inscription}checked='checked'{/if}/>
+ {html_select_date prefix='inscr_' end_year='+5' day_value_format='%02d' field_order='DMY' field_separator=' / ' month_format='%m' time=$evt.deadline_inscription}
+ </td>
+ </tr>
+ <tr>
<td colspan="2">Ouvert aux membres du groupe uniquement :
<input type="radio" name="membres_only" value="1" {if $evt.membres_only}checked="checked"{/if} /> oui
<input type="radio" name="membres_only" value="0" {if !$evt.membres_only}checked="checked"{/if} /> non
ALTER TABLE groupex.asso ADD inscriptible TINYINT NOT NULL DEFAULT 1;
+ALTER TABLE groupex.evenements ADD deadline_inscription DATE DEFAULT NULL;