git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-690
define('NB_PER_PAGE', 25);
-// check this event is from this asso
-if (Env::get('eid')) {
- $res = $globals->xdb->query("SELECT eid FROM groupex.evenements WHERE eid = {?} AND asso_id = {?}", Env::get('eid'), $globals->asso('id'));
- $eid = $res->fetchOneCell();
-}
+require_once('xnet/evenements.php');
+
+$evt = get_event_detail(Env::get('eid'), Env::get('item_id'));
+
+// the event doesn't exist or doesn't belong to this assoif (!$evt)
+if (!$evt)
+ header("Location: evenements.php");
+
+if ($evt['show_participants'])
+ new_group_page('xnet/groupe/evt-admin.tpl');
+else
+ new_groupadmin_page('xnet/groupe/evt-admin.tpl');
-$res = $globals->xdb->iterator(
- "SELECT eid, item_id, titre, montant
- FROM groupex.evenements_items
- WHERE eid = {?}",
- $eid);
-$moments = array();
-while ($m = $res->next()) $moments[$m['item_id']] = $m;
+$admin = may_update();
-if (may_update() && Env::get('adm') && Env::get('mail') && $eid) {
+// select a member from his mail
+if ($admin && Env::get('adm') && Env::get('mail')) {
if (strpos(Env::get('mail'), '@') === false)
$res = $globals->xdb->query(
"SELECT m.uid
WHERE m.email = {?} AND m.asso_id = {?}",
Env::get('mail'), $globals->asso('id'));
$member = $res->fetchOneCell();
+ if (!$member) $page->trig("Membre introuvable");
}
-if (may_update() && Env::get('adm') == 'prix' && $member && $eid) {
+// change the price paid by a participant
+if ($admin && Env::get('adm') == 'prix' && $member) {
$globals->xdb->execute("UPDATE groupex.evenements_participants SET paid = IF(paid + {?} > 0, paid + {?}, 0) WHERE uid = {?} AND eid = {?}",
strtr(Env::get('montant'), ',', '.'),
strtr(Env::get('montant'), ',', '.'),
- $member, $eid);
+ $member, Env::get('eid'));
}
-if (may_update() && Env::get('adm') == 'nbs' && $member && $eid) {
- $res = $globals->xdb->query("SELECT paid FROM groupex.evenements_participants WHERE uid = {?} AND eid = {?}", $member, $eid);
+// change the number of personns coming with a participant
+if ($admin && Env::get('adm') == 'nbs' && $member) {
+ $res = $globals->xdb->query("SELECT paid FROM groupex.evenements_participants WHERE uid = {?} AND eid = {?}", $member, Env::get('eid'));
$paid = $res->fetchOneCell();
- foreach ($moments as $m) if (Env::has('nb'.$m['item_id'])) {
+ foreach ($evt['moments'] as $m) if (Env::has('nb'.$m['item_id'])) {
$nb = Env::getInt('nb'.$m['item_id'], 0);
if ($nb < 0) $nb = 0;
if ($nb) {
if (!$paid) $paid = 0;
$globals->xdb->execute("REPLACE INTO groupex.evenements_participants VALUES ({?}, {?}, {?}, {?}, {?})",
- $eid, $member, $m['item_id'], $nb, $paid);
+ Env::get('eid'), $member, $m['item_id'], $nb, $paid);
}
else
- $globals->xdb->execute("DELETE FROM groupex.evenements_participants WHERE uid = {?} AND eid = {?} AND item_id = {?}", $member, $eid, $m['item_id']);
+ $globals->xdb->execute("DELETE FROM groupex.evenements_participants WHERE uid = {?} AND eid = {?} AND item_id = {?}", $member, Env::get('eid'), $m['item_id']);
}
}
-$res = $globals->xdb->query(
- "SELECT SUM(nb) AS nb_tot, e.intitule, ei.titre, e.show_participants, e.paiement_id
- FROM groupex.evenements AS e
- INNER JOIN groupex.evenements_items AS ei ON (e.eid = ei.eid)
- LEFT JOIN groupex.evenements_participants AS ep ON(e.eid = ep.eid AND ei.item_id = ep.item_id)
- WHERE e.eid = {?} AND ei.item_id = {?}
- GROUP BY ei.item_id",
- $eid, Env::getInt('item_id', 1));
-
-$evt = $res->fetchOneAssoc();
-
-if (!Env::has('item_id')) {
- $res = $globals->xdb->query("SELECT MAX(nb)
- FROM groupex.evenements AS e
- INNER JOIN groupex.evenements_items AS ei ON (e.eid = ei.eid)
- LEFT JOIN groupex.evenements_participants AS ep ON(e.eid = ep.eid AND ei.item_id = ep.item_id)
- WHERE e.eid = {?}
- GROUP BY ep.uid",
- $eid);
- $evt['nb_tot'] = array_sum($res->fetchColumn());
- $evt['titre'] = '';
- $evt['item_id'] = 0;
-}
-
-if (!$evt['intitule'])
- header("Location: evenements.php");
-
-if ($evt['show_participants'])
- new_group_page('xnet/groupe/evt-admin.tpl');
-else
- new_groupadmin_page('xnet/groupe/evt-admin.tpl');
-
-$page->assign('admin', may_update());
+$page->assign('admin', $admin);
$page->assign('evt', $evt);
-$page->assign('url_page', Env::get('PHP_SELF')."?eid=".$eid.(Env::has('item_id')?("&item_id=".Env::getInt('item_id')):''));
+$page->assign('url_page', Env::get('PHP_SELF')."?eid=".Env::get('eid').(Env::has('item_id')?("&item_id=".Env::getInt('item_id')):''));
$page->assign('tout', !Env::has('item_id'));
-if (count($moments) > 1) $page->assign('moments', $moments);
-foreach ($moments as $m) if ($m['montant'] > 0) $money = true;
-if ($money) $page->assign('money', true);
+if (count($evt['moments']) > 1) $page->assign('moments', $evt['moments']);
+$page->assign('money', $evt['money']);
$tri = (Env::get('order') == 'alpha' ? 'promo, nom, prenom' : 'nom, prenom, promo');
$whereitemid = Env::has('item_id')?('AND ep.item_id = '.Env::getInt('item_id', 1)):'';
LEFT JOIN groupex.membres AS m ON ( ep.uid = m.uid AND e.asso_id = m.asso_id)
LEFT JOIN auth_user_md5 AS u ON ( u.user_id = ep.uid )
WHERE ep.eid = {?} '.$whereitemid.'
- GROUP BY UPPER(SUBSTRING(IF(u.nom IS NULL,m.nom,u.nom), 1, 1))', $eid);
+ GROUP BY UPPER(SUBSTRING(IF(u.nom IS NULL,m.nom,u.nom), 1, 1))', Env::get('eid'));
$alphabet = array();
$nb_tot = 0;
}
$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')).'%"' : '';
-$ann = $globals->xdb->iterator(
- "SELECT IF(u.nom IS NULL,m.nom,IF(u.nom_usage<>'', u.nom_usage, u.nom)) AS nom,
- IF(u.nom IS NULL,m.prenom,u.prenom) AS prenom,
- IF(u.nom IS NULL,'extérieur',u.promo) AS promo,
- IF(u.nom IS NULL,m.email,a.alias) AS email,
- IF(u.nom IS NULL,0,FIND_IN_SET('femme', u.flags)) AS femme,
- m.perms='admin' AS admin,
- NOT(u.nom IS NULL) AS x,
- ep.uid, ep.paid, SUM(nb) AS nb
- FROM groupex.evenements_participants AS ep
- INNER JOIN groupex.evenements AS e ON (ep.eid = e.eid)
- LEFT JOIN groupex.membres AS m ON ( ep.uid = m.uid AND e.asso_id = m.asso_id)
- 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 = {?} $whereitemid $ini
- GROUP BY ep.uid
- ORDER BY $tri
- LIMIT {?}, {?}",
- $eid,
- $ofs*NB_PER_PAGE, NB_PER_PAGE);
-$globals->xdb->execute("SELECT 1");
-$tab = array();
-$user = 0;
-while ($u = $ann->next()) {
- $u['montant'] = 0;
- if ($money && $evt['paiement_id'] && may_update() && !Env::has('item_id')) {
- $res = $globals->xdb->query(
- "SELECT montant
- FROM {$globals->money->mpay_tprefix}transactions AS t
- WHERE ref = {?} AND uid = {?}",
- $evt['paiement_id'], $u['uid']);
- $montants = $res->fetchColumn();
- foreach ($montants as $m) {
- $p = strtr(substr($m, 0, strpos($m, "EUR")), ",", ".");
- $u['paid'] += trim($p);
- }
- }
- if (!Env::has('item_id')) {
- $res = $globals->xdb->iterator(
- "SELECT nb, item_id
- FROM groupex.evenements_participants AS ep
- WHERE eid = {?} $whereitemid AND uid = {?}",
- Env::get('eid'), $u['uid']);
- while ($i = $res->next()) {
- $u[$i['item_id']] = $i['nb'];
- $u['montant'] += $moments[$i['item_id']]['montant']*$i['nb'];
- }
- }
- $tab[] = $u;
-}
-$page->assign('ann', $tab);
+$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']);
+
+$page->assign('participants', $participants);
$page->run();
--- /dev/null
+<?php
+/***************************************************************************
+ * 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';
+
+require_once('xnet/evenements.php');
+
+$evt = get_event_detail(Env::get('eid'), Env::get('item_id'));
+
+header("Content-type: text/x-csv");
+header("Pragma: ");
+header("Cache-Control: ");
+new_nonhtml_page('xnet/groupe/evt-csv.tpl');
+
+if ($evt) {
+
+ $admin = may_update();
+
+ $tri = (Env::get('order') == 'alpha' ? 'promo, nom, prenom' : 'nom, prenom, promo');
+
+ $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')).'%"' : '';
+
+ $participants = get_event_participants(Env::get('eid'), Env::get('item_id'), $ini, $tri, "", $evt['money'] && $admin, $evt['paiement_id']);
+
+ $page->assign('participants', $participants);
+ $page->assign('admin', $admin);
+ $page->assign('moments', $evt['moments']);
+ $page->assign('money', $evt['money']);
+ $page->assign('tout', !Env::get('item_id', false));
+}
+
+$page->run();
+
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker:
+?>
}
// }}}
+// {{{ function new_nonhtml_page()
+
+function new_nonhtml_page($tpl_name)
+{
+ global $page, $globals;
+ require_once("xnet/page.inc.php");
+ $page = new XnetGroupPage($tpl_name, NO_SKIN);
+ $page->assign('xorg_tpl', $tpl_name);
+}
+
+// }}}
// vim:set et sw=4 sts=4 sws=4 foldmethod=marker:
?>
--- /dev/null
+<?php
+/***************************************************************************
+ * 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 *
+ ***************************************************************************/
+
+// {{{ function get_event_detail()
+function get_event_detail($eid, $item_id = false) {
+ global $globals;
+ $res = $globals->xdb->query(
+ "SELECT SUM(nb) AS nb_tot, e.intitule, ei.titre, e.show_participants, e.paiement_id
+ FROM groupex.evenements AS e
+ INNER JOIN groupex.evenements_items AS ei ON (e.eid = ei.eid)
+ LEFT JOIN groupex.evenements_participants AS ep ON(e.eid = ep.eid AND ei.item_id = ep.item_id)
+ WHERE e.eid = {?} AND ei.item_id = {?} AND e.asso_id = {?}
+ GROUP BY ei.item_id",
+ $eid, $item_id?$item_id:1, $globals->asso('id'));
+ $evt = $res->fetchOneAssoc();
+ if (!$evt) return false;
+
+ // smart calculation of the total number
+ if (!$item_id) {
+ $res = $globals->xdb->query(
+ "SELECT MAX(nb)
+ FROM groupex.evenements AS e
+ INNER JOIN groupex.evenements_items AS ei ON (e.eid = ei.eid)
+ LEFT JOIN groupex.evenements_participants AS ep ON(e.eid = ep.eid AND ei.item_id = ep.item_id)
+ WHERE e.eid = {?}
+ GROUP BY ep.uid", $eid);
+ $evt['nb_tot'] = array_sum($res->fetchColumn());
+ $evt['titre'] = '';
+ $evt['item_id'] = 0;
+ }
+
+ $res = $globals->xdb->iterator(
+ "SELECT eid, item_id, titre, montant
+ FROM groupex.evenements_items
+ WHERE eid = {?}",
+ $eid);
+ $moments = array(); $evt['money'] = false;
+ while ($m = $res->next()) {
+ $moments[$m['item_id']] = $m;
+ if ($m['montant'] > 0) $evt['money'] = true;
+ }
+ $evt['moments'] = $moments;
+ return $evt;
+}
+// }}}
+
+// {{{ function get_event_participants()
+function get_event_participants($eid, $item_id, $where, $tri, $limit, $money, $pay_id) {
+ global $globals;
+ $query =
+ "SELECT IF(u.nom IS NULL,m.nom,IF(u.nom_usage<>'', u.nom_usage, u.nom)) AS nom,
+ IF(u.nom IS NULL,m.prenom,u.prenom) AS prenom,
+ IF(u.nom IS NULL,'extérieur',u.promo) AS promo,
+ IF(u.nom IS NULL,m.email,a.alias) AS email,
+ IF(u.nom IS NULL,0,FIND_IN_SET('femme', u.flags)) AS femme,
+ m.perms='admin' AS admin,
+ NOT(u.nom IS NULL) AS x,
+ ep.uid, ep.paid, SUM(nb) AS nb
+ FROM groupex.evenements_participants AS ep
+ INNER JOIN groupex.evenements AS e ON (ep.eid = e.eid)
+ LEFT JOIN groupex.membres AS m ON ( ep.uid = m.uid AND e.asso_id = m.asso_id)
+ 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 = {?}
+ ".(($item_id)?" AND item_id = $item_id":"")."
+ $where
+ GROUP BY ep.uid
+ ORDER BY $tri
+ $limit";
+ if ($item_id) {
+ $res = $globals->xdb->query($query, $eid);
+ return $res->fetchAllAssoc();
+ }
+ $res = $globals->xdb->iterator($query, $eid);
+ $tab = array();
+ $user = 0;
+ while ($u = $res->next()) {
+ $u['montant'] = 0;
+ if ($money && $pay_id) {
+ $res_ = $globals->xdb->query(
+ "SELECT montant
+ FROM {$globals->money->mpay_tprefix}transactions AS t
+ WHERE ref = {?} AND uid = {?}",
+ $pay_id, $u['uid']);
+ $montants = $res_->fetchColumn();
+ foreach ($montants as $m) {
+ $p = strtr(substr($m, 0, strpos($m, "EUR")), ",", ".");
+ $u['paid'] += trim($p);
+ }
+ }
+ $res_ = $globals->xdb->iterator(
+ "SELECT ep.nb, ep.item_id, ei.montant
+ FROM groupex.evenements_participants AS ep
+ INNER JOIN groupex.evenements_items AS ei ON (ei.eid = ep.eid AND ei.item_id = ep.item_id)
+ WHERE ep.eid = {?} AND ep.uid = {?}",
+ $eid, $u['uid']);
+ while ($i = $res_->next()) {
+ $u[$i['item_id']] = $i['nb'];
+ $u['montant'] += $i['montant']*$i['nb'];
+ }
+ $tab[] = $u;
+ }
+ return $tab;
+}
+// }}}
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker:
+?>
static $aid = null;
if ($aid === null) {
$gp = basename(dirname($_SERVER['PHP_SELF']));
+ // for url like /groupex/event.php/file.csv
+ if (substr($gp, -4) == ".php")
+ $gp = basename(dirname(dirname($_SERVER['PHP_SELF'])));
$res = $this->xdb->query('SELECT a.*, d.nom AS domnom
FROM groupex.asso AS a
LEFT JOIN groupex.dom AS d ON d.id = a.dom
<th>Nombre</th>
{/if}
</tr>
- {foreach from=$ann item=m}
+ {foreach from=$participants item=m}
<tr style="background:#d0c198;">
<td>{if $m.femme}•{/if}{$m.prenom} {$m.nom}</td>
<td>{$m.promo}</td>
</p>
{if $admin}
+<p class="descr">
+[<a href="evt-csv.php/{$evt.intitule}{if $evt.titre}.{$evt.titre}{/if}.csv?eid={$smarty.request.eid}&item_id={$smarty.request.item_id}">Télécharger le fichier Excel</a>]
+</p>
<hr />
-<p class="decr">
+<p class="descr">
En tant qu'administrateur, tu peux fixer la venue (accompagnée ou pas) d'un des membres du groupe. Donne ici son mail (complet pour les extérieurs, sans @polytechnique.org pour les X), ainsi que le nombre de participants.<br />
<form action="{$smarty.server.PHP_SELF}" method="post">
<input type="hidden" name="eid" value="{$smarty.request.eid}" />
--- /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 *}
+{* *}
+{**************************************************************************}
+Nom;Prénom;Promotion{if $tout}{foreach from=$moments item=m};{$m.titre}{/foreach}{if $admin && $money};A payer;Payé{/if}{else};Nombre{/if}
+
+{if $participants}
+{foreach from=$participants item=m}
+
+;
+{$m.nom};{$m.prenom};{$m.promo}{if $tout}{foreach from=$moments item=i};{$m[$i.item_id]}{/foreach}{if $admin && $money};{$m.montant};{$m.paid}{/if}{else};{$m.nb}{/if}
+
+{/foreach}
+;
+{/if}