rework events main page, so that we can have more simple code.
authorx2000habouzit <x2000habouzit@839d8a87-29fc-0310-9880-83ba4fa771e5>
Sat, 15 Jul 2006 21:47:49 +0000 (21:47 +0000)
committerx2000habouzit <x2000habouzit@839d8a87-29fc-0310-9880-83ba4fa771e5>
Sat, 15 Jul 2006 21:47:49 +0000 (21:47 +0000)
put subscription in a separate page *again* because it's in fact horrible in the UI like it was done.

also amend get_event_detail to return more coherent datas, and use it in the new events/sub page.

git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@507 839d8a87-29fc-0310-9880-83ba4fa771e5

htdocs.net/css/xnet.css
include/xnet/evenements.php
modules/xnetevents.php
templates/xnet/groupe/evenements.tpl [deleted file]
templates/xnetevents/index.tpl [new file with mode: 0644]
templates/xnetevents/subscribe.tpl [new file with mode: 0644]

index 2316e67..894dd7f 100644 (file)
@@ -177,7 +177,7 @@ table.large, table.bicol     { width: 96%; margin-left:  2%; border: 2px solid g
 
 table.tiny td, table.tinybicol td, table.large td, table.bicol td {
     border: 1px solid gray;
-    padding: 2px;
+    padding: 2px 4px;
 }
 table.tiny th, table.tinybicol th, table.large th, table.bicol th {
     border: 1px solid gray;
index 51180e6..732f21c 100644 (file)
  ***************************************************************************/
 
 // {{{ function get_event_detail()
-function get_event_detail($eid, $item_id = false) {
+
+function get_event_detail($eid, $item_id = false)
+{
     global $globals;
     $res = $globals->xdb->query(
-        "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,
+        "SELECT        SUM(nb) AS nb_tot, e.*,
+                IF(e.deadline_inscription, e.deadline_inscription >= LEFT(NOW(), 10),
+                   1) AS inscr_open,
+                LEFT(10, e.debut) AS debut_day, LEFT(10, e.fin) AS fin_day,
+                LEFT(NOW(), 10) AS now,
+                ei.titre,
                 al.vid AS absent_list, pl.vid AS participant_list,
-                a.nom, a.prenom, a.promo
-           FROM        groupex.evenements AS e
-     INNER JOIN        groupex.evenements_items AS ei ON (e.eid = ei.eid)
+                a.nom, a.prenom, a.promo, aa.alias
+           FROM        groupex.evenements              AS e
+     INNER JOIN x4dat.auth_user_md5             AS a  ON a.user_id = e.organisateur_uid
+     INNER JOIN x4dat.aliases                   AS aa ON (aa.type = 'a_vie' AND aa.id = a.user_id)
+     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)
       LEFT JOIN virtual AS al ON(al.type = 'evt' AND al.alias = CONCAT(short_name, {?}))
       LEFT JOIN virtual AS pl ON(pl.type = 'evt' AND pl.alias = CONCAT(short_name, {?}))
-      LEFT JOIN auth_user_md5 AS a ON (a.user_id = e.organisateur_uid)
           WHERE        e.eid = {?} AND ei.item_id = {?} AND e.asso_id = {?} 
        GROUP BY ei.item_id",
        '-absents@'.$globals->xnet->evts_domain,
        '-participants@'.$globals->xnet->evts_domain,
-       $eid, $item_id?$item_id:1, $globals->asso('id'));
+       $eid, $item_id ? $item_id : 1, $globals->asso('id'));
+
     $evt = $res->fetchOneAssoc();
-    if (!$evt) return false;
+
+    if (!$evt) {
+        return null;
+    }
 
     // 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)
+                  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;
+
+    $res = $globals->xdb->query(
+        "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'), $evt['eid']);
+    $evt['moments'] = $res->fetchAllAssoc();
+
+    $evt['topay'] = 0;
+    foreach ($evt['moments'] as $m) {
+        $evt['topay'] += $m['nb'] * $m['montant'];
+    }
+
+    $req = $globals->xdb->query(
+        "SELECT montant
+           FROM {$globals->money->mpay_tprefix}transactions AS t
+         WHERE ref = {?} AND uid = {?}", $evt['paiement_id'], Session::get('uid'));
+    $montants = $req->fetchColumn();
+
+    $evt['paid'] = 0;
+    foreach ($montants as $m) {
+        $p = strtr(substr($m, 0, strpos($m, 'EUR')), ',', '.');
+        $evt['paid'] += trim($p);
     }
-    $evt['moments'] = $moments;
+
     return $evt;
 }
+
 // }}}
 
 // {{{ function get_event_participants()
index 957153e..ddf7ed1 100644 (file)
@@ -25,6 +25,7 @@ class XnetEventsModule extends PLModule
     {
         return array(
             'grp/events'       => $this->make_hook('events',  AUTH_MDP),
+            'grp/events/sub'   => $this->make_hook('sub',     AUTH_MDP),
             'grp/events/csv'   => $this->make_hook('csv',     AUTH_MDP),
             'grp/events/edit'  => $this->make_hook('edit',    AUTH_MDP),
             'grp/events/admin' => $this->make_hook('admin',   AUTH_MDP),
@@ -35,131 +36,52 @@ class XnetEventsModule extends PLModule
     {
         global $globals;
 
-        new_group_page('xnet/groupe/evenements.tpl');
-
-        /**** 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,
-                            noinvite,
-                            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 ($j=1; Env::has('moment'.$eid.'_'.$j); $j++)
-                {
-                    $inscriptions[$j] = Env::get('moment'.$eid.'_'.$j);
-                    // retreive ohter field when more than one person
-                    if ($inscriptions[$j] == 2)
-                        $inscriptions[$j] = 1 + Env::get('personnes'.$eid.'_'.$j,0);
-                    // avoid negative count if other field incorrect
-                    if ($inscriptions[$j] < 0)
-                        $inscriptions[$j] = 0;
-                    // avoid floating count if other field incorrect
-                    $inscriptions[$j] = floor($inscriptions[$j]);
-                    // avoid invite if no invite allowed
-                    if ($inscriptions[$j] > 1 && $e['noinvite'])
-                        $inscriptions[$j] = 1;
-                    $total_inscr += $inscriptions[$j];
-                }
-                $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 $j=>$nb) {
-                    if ($nb > 0) {
-                        $globals->xdb->execute(
-                            "REPLACE INTO  groupex.evenements_participants
-                                   VALUES  ({?}, {?}, {?}, {?}, {?})",
-                            $eid, Session::get("uid"), $j, $nb, $paid);
-                    } else {
-                        $globals->xdb->execute(
-                            "DELETE FROM  groupex.evenements_participants
-                                   WHERE  eid = {?} AND uid = {?} AND item_id = {?}",
-                            $eid, Session::get("uid"), $j);            
-                    }
-                }
-            }
-        }
+        new_group_page('xnetevents/index.tpl');
 
-        /**** retreive all infos about all events ****/
-        $page->assign('logged', logged());
         $page->assign('admin', may_update());
 
         $evenements = $globals->xdb->iterator(
-                "SELECT  e.eid, IF(e.intitule = '', ' ', e.intitule) AS intitule,
-                         IF(e.descriptif = '', ' ', e.descriptif) AS 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.noinvite, e.show_participants, u.nom, u.prenom,
-                         u.promo, a.alias, MAX(ep.nb) AS inscrit,
-                         MAX(ep.paid) AS paid, e.short_name,
+                "SELECT  e.*, LEFT(10, e.debut) AS debut_day, LEFT(10, e.fin) AS fin_day,
                          IF(e.deadline_inscription, e.deadline_inscription >= LEFT(NOW(), 10),
-                            1) AS inscr_open, e.deadline_inscription
-                  FROM  groupex.evenements AS e
+                            1) AS inscr_open, e.deadline_inscription,
+                         u.nom, u.prenom, u.promo, a.alias,
+                         MAX(ep.nb) AS inscrit, MAX(ep.paid) AS paid
+                  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)
+            INNER 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(
+            $res = $globals->xdb->query(
                 "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['moments'] = $res->fetchAllAssoc();
+
+            $e['topay'] = 0;
+            foreach ($e['moments'] as $m) {
+                $e['topay'] += $m['nb'] * $m['montant'];
+            }
+
             $query = $globals->xdb->query(
                 "SELECT montant
                    FROM {$globals->money->mpay_tprefix}transactions AS t
                  WHERE ref = {?} AND uid = {?}", $e['paiement_id'], Session::get('uid'));
             $montants = $query->fetchColumn();
+
             foreach ($montants as $m) {
-                $p = strtr(substr($m, 0, strpos($m, "EUR")), ",", ".");
+                $p = strtr(substr($m, 0, strpos($m, 'EUR')), ',', '.');
                 $e['paid'] += trim($p);
             }
+
             $evts[] = $e;
         }
 
@@ -167,6 +89,76 @@ class XnetEventsModule extends PLModule
         $page->assign('is_member', is_member());
     }
 
+    function handler_sub(&$page, $eid = null)
+    {
+        global $globals;
+
+        require_once('xnet/evenements.php');
+
+        new_group_page('xnetevents/subscribe.tpl');
+
+        $evt = get_event_detail($eid);
+        if (!$evt) {
+            return PL_NOT_FOUND;
+        }
+
+        if (!$evt['inscr_open']) {
+            $page->kill('Les inscriptions pour cet événement sont closes');
+        }
+
+        $page->assign('event', $evt);
+
+        if (!Post::has('submit')) {
+            return;
+        }
+
+        $moments = Post::getMixed('moment',    array());
+        $pers    = Post::getMixed('personnes', array());
+        $subs    = array();
+
+        foreach ($moments as $j => $v) {
+            $subs[$j] = intval($v);
+
+            // retreive ohter field when more than one person
+            if ($subs[$j] == 2) {
+                if (!isset($pers[$j]) || !is_numeric($pers[$j])
+                ||  $pers[$j] < 0)
+                {
+                    $page->trig('Tu dois choisir un nombre d\'invités correct !');
+                    return;
+                }
+                $subs[$j] = 1 + $pers[$j];
+            }
+        }
+
+        // impossible to unsubscribe if you already paid sthing
+        if (array_sum($subs) && $evt['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");
+            return;
+        }
+
+        // update actual inscriptions
+        foreach ($subs as $j => $nb) {
+            if ($nb > 0) {
+                $globals->xdb->execute(
+                    "REPLACE INTO  groupex.evenements_participants
+                           VALUES  ({?}, {?}, {?}, {?}, {?})",
+                    $eid, Session::getInt('uid'), $j, $nb, $evt['paid']);
+            } else {
+                $globals->xdb->execute(
+                    "DELETE FROM  groupex.evenements_participants
+                           WHERE  eid = {?} AND uid = {?} AND item_id = {?}",
+                    $eid, Session::getInt("uid"), $j);         
+            }
+        }
+
+        $page->assign('event', get_event_detail($eid));
+    }
+
     function handler_csv(&$page, $eid = null, $item_id = null)
     {
         require_once('xnet/evenements.php');
diff --git a/templates/xnet/groupe/evenements.tpl b/templates/xnet/groupe/evenements.tpl
deleted file mode 100644 (file)
index 4339b79..0000000
+++ /dev/null
@@ -1,170 +0,0 @@
-{**************************************************************************}
-{*                                                                        *}
-{*  Copyright (C) 2003-2006 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               *}
-{*                                                                        *}
-{**************************************************************************}
-
-<h1>{$asso.nom} :
-Evénements
-</h1>
-
-{if !$logged}
-  <p class="descr">
-     Aucune manifestation publique n'a été saisie par ce groupe pour l'instant...
-  </p>
-{else}
-
-{if $admin}
-<p class="center">
-[<a href="{rel}/{$platal->ns}events/edit">Annoncer un nouvel événement</a>]
-</p>
-{/if}
-
-{if !$evenements}
-
-<p class="descr">
-  Aucun événement n'a été référencé par les animateurs du groupe.
-</p>
-
-{else}
-
-<form action="{rel}/{$platal->ns}events" method="post">
-  {foreach from=$evenements item=e}
-  <table class="bicol" cellspacing="0" cellpadding="0">
-    <tr {popup caption=$e.intitule" text=$e.descriptif}>
-      <th colspan="2">
-        {$e.intitule}
-        {if $admin}
-        <a href="{rel}/{$platal->ns}events/edit/{$e.eid}?mod=1"><img src="{rel}/images/profil.png" title="Edition de l'événement" alt="Edition de l'événement" /></a>
-        <a href="{rel}/{$platal->ns}events/edit/{$e.eid}?sup=1" onclick="return confirm('Supprimer l\'événement effacera la liste des inscrits et des paiements.\n Es-tu sûr de vouloir supprimer l\'événement ?')"><img src="{rel}/images/del.png" alt="Suppression de {$e.intitule}" title="Suppression de {$e.intitule}" /></a>
-        {/if}
-      </th>
-    </tr>
-    <tr {popup caption=$e.intitule text=$e.descriptif}>
-      <td class="titre">date :</td>
-      <td>
-        {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"}
-        {/if}
-      </td>
-    </tr>
-    <tr {popup caption=$e.intitule text=$e.descriptif}>
-      <td class="titre">annonceur :</td>
-      <td>
-        <a href='https://polytechnique.org/profile/{$e.alias}' class='popup2'>{$e.prenom} {$e.nom} ({$e.promo})</a>
-      </td>
-    </tr>
-    {if $admin || $e.show_participants}
-    <tr {popup caption=$e.intitule text=$e.descriptif}>
-      <td class="titre" colspan="2">
-        <a href="{rel}/{$platal->ns}events/admin/{$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` &#x20AC;)"  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
-              {if $e.noinvite}
-                  <input type="radio" name="moment{$e.eid}_{$m.item_id}" value="1"
-                  {if $m.nb eq 1}checked="checked"{/if}/>oui
-              {else}
-                  <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
-              {/if}
-            {else}
-              {if !$m.nb}
-                Je ne viendrai pas.
-              {elseif $m.nb eq 1}
-                Je viendrai{if !$e.noinvite} seul{/if}.
-              {else}
-                Je viendrai 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:'.':','}&nbsp;&euro;{if $e.paid > 0}, et tu as déjà payé {$e.paid|replace:'.':','}&nbsp;&euro;{/if}.
-          {if $e.paiement_id && $montant > $e.paid}
-            [<a href="https://www.polytechnique.org/payment/{$e.paiement_id}?montant={math equation="x - y" x=$montant y=$e.paid}">Payer en ligne</a>]
-          {/if}
-        </td>
-      </tr>
-      {/if}
-    {/if}
-  </table>
-  {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>
-  {else}
-    <p>&nbsp;</p>
-  {/if}
-  {/foreach}
-
-  <div>
-    <input type="hidden" name="ins" />
-  </div>
-</form>
-{/if}
-
-{/if}
-
-{* vim:set et sw=2 sts=2 sws=2: *}
diff --git a/templates/xnetevents/index.tpl b/templates/xnetevents/index.tpl
new file mode 100644 (file)
index 0000000..507efa9
--- /dev/null
@@ -0,0 +1,160 @@
+{**************************************************************************}
+{*                                                                        *}
+{*  Copyright (C) 2003-2006 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               *}
+{*                                                                        *}
+{**************************************************************************}
+
+<h1>{$asso.nom} : Evénements</h1>
+
+{if $admin}
+<p class="center">
+  [<a href="{rel}/{$platal->ns}events/edit">Annoncer un nouvel événement</a>]
+</p>
+{/if}
+
+{foreach from=$evenements item=e}
+
+<table class="bicol" cellspacing="0" cellpadding="0" {popup caption=$e.intitule text=$e.descriptif}>
+  <colgroup>
+    <col width='25%' />
+  </colgroup>
+  <tr>
+    <th colspan="2">
+      {$e.intitule}
+      {if $admin}
+      <br />
+      [<a href="{rel}/{$platal->ns}events/edit/{$e.eid}?mod=1">
+        modifier
+        <img src="{rel}/images/profil.png" title="Edition de l'événement" alt="Edition" />
+      </a>]
+      &nbsp;&nbsp;&nbsp;&nbsp;
+      [<a href="{rel}/{$platal->ns}events/edit/{$e.eid}?sup=1"
+        onclick="return confirm('Supprimer l\'événement effacera la liste des inscrits et des paiements.\n Es-tu sûr de vouloir supprimer l\'événement ?')">
+        supprimer
+        <img src="{rel}/images/del.png" alt="Suppression de {$e.intitule}" title="Suppression" />
+      </a>]
+      {/if}
+    </th>
+  </tr>
+
+  <tr>
+    <td class="titre">date :</td>
+    <td>
+      {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"}
+      {/if}
+    </td>
+  </tr>
+
+  <tr>
+    <td class="titre">annonceur :</td>
+    <td>
+      <a href='https://polytechnique.org/profile/{$e.alias}' class='popup2'>{$e.prenom} {$e.nom} ({$e.promo})</a>
+    </td>
+  </tr>
+
+  <tr>
+    <td class="titre">Informations :</td>
+    <td class='actions'>
+      {if $admin || $e.show_participants}
+      <a href="{rel}/{$platal->ns}events/admin/{$e.eid}">
+        consulter la liste des participants
+        <img src="{rel}/images/loupe.gif" title="Liste des participants" alt="" />
+      </a><br />
+      {/if}
+      {if $e.deadline_inscription}
+        {if $e.inscr_open}
+          dernières inscriptions
+          le {$e.deadline_inscription|date_format:"%d %B %Y"}
+        {else}
+          <span class='error'>Inscriptions closes.</span><br />
+        {/if}
+      {/if}
+    </td>
+  </tr>
+
+  <tr>
+    <td class="titre">
+      État inscription
+      {if $e.inscr_open}
+        <input type="hidden" name="evt_{counter}" value="{$e.eid}" />
+      {/if}
+    </td>
+    <td>
+      {if !$e.inscrit}
+      <span class='error'>Non inscrit</span><br />
+      {else}
+        {foreach from=$e.moments item=m}
+        {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} à <em>{$m.titre}</em><br />
+        {/foreach}
+      {/if}
+
+      {if $e.topay}
+      <span class="error">
+      Tu dois payer {$e.topay|replace:'.':','}&nbsp;&euro;
+      {if $e.paid > 0}
+      (tu as déjà payé {$e.paid|replace:'.':','}&nbsp;&euro;)
+      {/if}
+      {if $e.paiement_id}
+        [<a href="https://www.polytechnique.org/payment/{$e.paiement_id}?montant={$e.topay}}">
+        Payer en ligne</a>]
+      {/if}
+      </span>
+      {/if}
+    </td>
+  </tr>
+
+  {if (!$e.membres_only or $is_member or $e.inscrit) and $e.inscr_open}
+  <tr>
+    <td colspan='2' class='center'>
+      <strong>
+      <a href='{rel}/{$platal->ns}events/sub/{$e.eid}'>
+        gérer mon inscription
+      </a>
+      </strong>
+    </td>
+  </tr>
+  {/if}
+
+</table>
+
+<br />
+
+{foreachelse}
+
+<p class="descr">
+  Aucun événement n'a été référencé par les animateurs du groupe.
+</p>
+
+{/foreach}
+
+{* vim:set et sw=2 sts=2 sws=2: *}
diff --git a/templates/xnetevents/subscribe.tpl b/templates/xnetevents/subscribe.tpl
new file mode 100644 (file)
index 0000000..4d12aed
--- /dev/null
@@ -0,0 +1,133 @@
+{**************************************************************************}
+{*                                                                        *}
+{*  Copyright (C) 2003-2006 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               *}
+{*                                                                        *}
+{**************************************************************************}
+
+<h1>{$asso.nom} : Evénement {$event.intitule}</h1>
+
+<p>
+  [<a href="{rel}/{$platal->ns}events">Revenir à la liste des événements</a>]
+</p>
+
+<p class='descr'>
+  Cet événement a lieu 
+  <strong>
+  {if $event.fin and $event.fin neq $event.debut}
+    {if $event.debut_day eq $event.fin_day}
+      le {$event.debut|date_format:"%d %B %Y"} de {$event.debut|date_format:"%H:%M"} à {$event.fin|date_format:"%H:%M"}
+    {else}
+      du {$event.debut|date_format:"%d %B %Y à %H:%M"}<br />
+      au {$event.fin|date_format:"%d %B %Y à %H:%M"}
+    {/if}
+  {else}
+    le {$event.debut|date_format:"%d %B %Y à %H:%M"}
+  {/if}
+  </strong>
+  et a été proposé par
+  <a href='https://www.polytechnique.org/profile/{$event.alias}' class='popup2'>
+    {$event.prenom} {$event.nom} ({$event.promo})
+  </a>
+</p>
+
+<p class='descr'>
+  {$event.descriptif|nl2br}
+</p>
+
+{if $admin || $event.show_participants}
+<p class='descr'>
+  Tu peux 
+  <a href="{rel}/{$platal->ns}events/admin/{$event.eid}">
+    consulster liste des participants
+    <img src="{rel}/images/loupe.gif" title="Liste des participants" alt="Liste des participants" />
+  </a>
+  déjà inscrits.
+</p>
+{/if}
+
+<form action="{rel}/{$platal->ns}events/sub/{$event.eid}" method="post">
+  <table class="tiny" cellspacing="0" cellpadding="0">
+    {foreach from=$event.moments item=m}
+    <tr><th>{$m.titre} ({$m.montant} &euro;)</th></tr>
+    {if $m.details}
+    <tr>
+      <td>
+      {$m.details|nl2br}
+      </td>
+    </tr>
+    {/if}
+    <tr>
+      <td>
+        {if $event.inscr_open}
+          <input type="radio" name="moment[{$m.item_id}]" value="0"
+          {if !$m.nb}checked="checked"{/if}/>non
+          {if $event.noinvite}
+              <input type="radio" name="moment[{$m.item_id}]" value="1"
+              {if $m.nb eq 1}checked="checked"{/if}/>oui
+          {else}
+              <input type="radio" name="moment[{$m.item_id}]" value="1"
+              {if $m.nb eq 1}checked="checked"{/if}/>seul<br />
+              <input type="radio" name="moment[{$m.item_id}]" value="2"
+              {if $m.nb > 1}checked="checked"{/if}/>avec
+                <input size="2" name="personnes[{$m.item_id}]"
+                  value="{if $m.nb > 1}{math equation='x - 1' x=$m.nb}{else}1{/if}"/> personnes
+          {/if}
+        {else}
+          {if !$m.nb}
+            Je ne viendrai pas.
+          {elseif $m.nb eq 1}
+            Je viendrai{if !$event.noinvite} seul{/if}.
+          {else}
+            Je viendrai avec {$m.nb} personne{if $m.nb > 2}s{/if}
+          {/if}
+        {/if}
+      </td>
+    </tr>
+    {/foreach}
+
+    <tr><th>À payer</th></tr>
+    <tr>
+      <td>
+        {if $event.topay}
+        <span class="error">
+        Tu dois payer {$event.topay|replace:'.':','}&nbsp;&euro;
+        {if $event.paid > 0}
+        (tu as déjà payé {$event.paid|replace:'.':','}&nbsp;&euro;)
+        {/if}.
+        {if $event.paiement_id}
+          [<a href="https://www.polytechnique.org/payment/{$event.paiement_id}?montant={$event.topay}}">
+          Payer en ligne</a>]
+        {/if}
+        </span>
+        {else}
+        Rien à payer
+        {if $event.paid > 0}
+        (tu as déjà payé {$event.paid|replace:'.':','}&nbsp;&euro;)
+        {/if}.
+        {/if}
+      </td>
+    </tr>
+  </table>
+
+  <p style="text-align:center">
+    <input type="submit" name='submit' value="Valider mes inscriptions" />
+  </p>
+</form>
+
+{* vim:set et sw=2 sts=2 sws=2: *}