From 258b971059bfaac7000ffed6e3f4793e203c071a Mon Sep 17 00:00:00 2001 From: x2001corpet Date: Sat, 31 Dec 2005 08:26:28 +0000 Subject: [PATCH] corrections interface evenements bugs 374 et 388 git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@180 839d8a87-29fc-0310-9880-83ba4fa771e5 --- htdocs.net/groupe/evenements.php | 312 +++++++++------------ htdocs.net/groupe/evt-detail.php | 95 ------- htdocs.net/groupe/evt-modif.php | 246 ++++++++++++++++ include/xnet/evenements.php | 1 + include/xnet/session.inc.php | 16 +- templates/xnet/groupe/evenements.tpl | 125 ++++++--- templates/xnet/groupe/evt-detail.tpl | 101 ------- .../groupe/{form_evenement.tpl => evt-modif.tpl} | 6 + upgrade/0.9.9/00_xnet.sql | 1 + 9 files changed, 490 insertions(+), 413 deletions(-) delete mode 100644 htdocs.net/groupe/evt-detail.php create mode 100644 htdocs.net/groupe/evt-modif.php delete mode 100644 templates/xnet/groupe/evt-detail.tpl rename templates/xnet/groupe/{form_evenement.tpl => evt-modif.tpl} (95%) diff --git a/htdocs.net/groupe/evenements.php b/htdocs.net/groupe/evenements.php index bcd71ac..cbf1ad3 100644 --- a/htdocs.net/groupe/evenements.php +++ b/htdocs.net/groupe/evenements.php @@ -1,193 +1,147 @@ 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(); diff --git a/htdocs.net/groupe/evt-detail.php b/htdocs.net/groupe/evt-detail.php deleted file mode 100644 index f36c702..0000000 --- a/htdocs.net/groupe/evt-detail.php +++ /dev/null @@ -1,95 +0,0 @@ -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(); - -?> diff --git a/htdocs.net/groupe/evt-modif.php b/htdocs.net/groupe/evt-modif.php new file mode 100644 index 0000000..1b1ba55 --- /dev/null +++ b/htdocs.net/groupe/evt-modif.php @@ -0,0 +1,246 @@ +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(); + +?> diff --git a/include/xnet/evenements.php b/include/xnet/evenements.php index d0502e0..03a5415 100644 --- a/include/xnet/evenements.php +++ b/include/xnet/evenements.php @@ -26,6 +26,7 @@ function get_event_detail($eid, $item_id = false) { "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 diff --git a/include/xnet/session.inc.php b/include/xnet/session.inc.php index 00f513f..b905c44 100644 --- a/include/xnet/session.inc.php +++ b/include/xnet/session.inc.php @@ -163,12 +163,20 @@ function may_update() { 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]; } // }}} diff --git a/templates/xnet/groupe/evenements.tpl b/templates/xnet/groupe/evenements.tpl index 2d8b228..8f3bc6c 100644 --- a/templates/xnet/groupe/evenements.tpl +++ b/templates/xnet/groupe/evenements.tpl @@ -21,24 +21,18 @@ {**************************************************************************}

{$asso.nom} : -{if ($smarty.request.add || $smarty.request.mod || $get_form) && $admin} -Evénements -{else} Evénements -{/if}

{if !$logged}

Aucune manifestation publique n'a été saisie par ce groupe pour l'instant...

-{elseif $get_form} - {include file='xnet/groupe/form_evenement.tpl'} {else} {if $admin}

- [Annoncer un nouvel événement] + [Annoncer un nouvel événement]

{/if} @@ -50,55 +44,118 @@ Ev {else} - {iterate from=$evenements item=e} +
+ {foreach from=$evenements item=e} - + - + - + - - - + + {/if} + {assign var="montant" value=0} + {if !$e.membres_only or $is_member or $e.inscrit} + {if $e.inscr_open} + + + + {/if} + {iterate from=$e.moments item=m} + {assign var="montant" value=$montant+$m.montant*$m.nb} + + + + + {/iterate} + {if $e.deadline_inscription} + + + + {/if} + {if $montant > 0 || $e.paid > 0} + + + + {/if} + {/if}
{$e.intitule} - {if $admin || $e.show_participants} - Liste des participants - {/if} {if $admin} - Edition de l'événement - Suppression de {$e.intitule} + Edition de l'événement + Suppression de {$e.intitule} {/if}
date : - {if $e.fin} - du {$e.debut|date_format:"%d %B %Y à %H:%M"}
- 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"}
+ 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}
annonceur : {$e.prenom} {$e.nom} ({$e.promo})
- Détails... - - {if $e.inscrit} - tu es inscrit à cet événément. - {if $e.inscrit > 1}(avec {$e.inscrit - 1} invité{if $e.inscrit > 2}s{/if}){/if} - - {else} - tu n'es pas inscrit à cet événément. - {/if} + {if $admin || $e.show_participants} +
+ + Liste des participants + Liste des participants +
+ Je viendrai... + +
{$m.titre} + {if $e.inscr_open} + non + seul
+ 1}checked="checked"{/if}/>avec 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} +
+ {if $e.inscr_open} + dernières inscriptions + le {$e.deadline_inscription|date_format:"%d %B %Y"} + {else} + Inscriptions closes. + {/if} +
$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} + [Payer en ligne] + {/if} +
-
- {/iterate} + {if (!$e.membres_only or $is_member or $e.inscrit) and $e.inscr_open} +

+ +

+ {/if} + {/foreach} +
+ +
+
{/if} {/if} diff --git a/templates/xnet/groupe/evt-detail.tpl b/templates/xnet/groupe/evt-detail.tpl deleted file mode 100644 index 7a195e7..0000000 --- a/templates/xnet/groupe/evt-detail.tpl +++ /dev/null @@ -1,101 +0,0 @@ -{**************************************************************************} -{* *} -{* 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} - -

{$asso.nom} : Evénements

- -

{$evt.intitule}

- -
- - - - - - - - - - - - - -
Annoncé par{$evt.prenom} {$evt.nom} (X{$evt.promo})
Description{$evt.descriptif}
Date - {if $evt.fin} - du {$evt.deb|date_format:"%d %B %Y à %H:%M"}
- au {$evt.fin|date_format:"%d %B %Y à %H:%M"} - {else} - le {$evt.deb|date_format:"%d %B %Y à %H:%M"} - {/if} -
- -


- - {assign var="montant" value=0} - - - {iterate from=$moments item=m} - {assign var="montant" value=$montant+$m.montant*$m.nb} - {if $m.titre || $m.montant} - - - - {/if} - - - - - - - {/iterate} -
- - - {$m.titre} - {if $m.montant > 0}{$m.montant}€{else}gratuit{/if} -
{$m.details}
- je ne participe pas
- je participe, seul
- 1}checked{/if} /> je viens, et serai accompagné de - personnes -
- - {if $montant > 0 || $paid > 0} -

$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} [Effectuer le paiement]{/if} -

- {/if} -
- - -
-
- -{* vim:set et sw=2 sts=2 sws=2: *} diff --git a/templates/xnet/groupe/form_evenement.tpl b/templates/xnet/groupe/evt-modif.tpl similarity index 95% rename from templates/xnet/groupe/form_evenement.tpl rename to templates/xnet/groupe/evt-modif.tpl index 72eb71d..78929c7 100644 --- a/templates/xnet/groupe/form_evenement.tpl +++ b/templates/xnet/groupe/evt-modif.tpl @@ -72,6 +72,12 @@ + Fin des inscriptions + pas de deadline + {html_select_date prefix='inscr_' end_year='+5' day_value_format='%02d' field_order='DMY' field_separator=' / ' month_format='%m' time=$evt.deadline_inscription} + + + Ouvert aux membres du groupe uniquement : oui non diff --git a/upgrade/0.9.9/00_xnet.sql b/upgrade/0.9.9/00_xnet.sql index 494b33d..1f248a1 100644 --- a/upgrade/0.9.9/00_xnet.sql +++ b/upgrade/0.9.9/00_xnet.sql @@ -1,2 +1,3 @@ ALTER TABLE groupex.asso ADD inscriptible TINYINT NOT NULL DEFAULT 1; +ALTER TABLE groupex.evenements ADD deadline_inscription DATE DEFAULT NULL; -- 2.1.4