ergonomie des tables de paiement xnet bug 383
authorx2001corpet <x2001corpet@839d8a87-29fc-0310-9880-83ba4fa771e5>
Mon, 5 Jun 2006 08:05:15 +0000 (08:05 +0000)
committerx2001corpet <x2001corpet@839d8a87-29fc-0310-9880-83ba4fa771e5>
Mon, 5 Jun 2006 08:05:15 +0000 (08:05 +0000)
git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@295 839d8a87-29fc-0310-9880-83ba4fa771e5

ChangeLog
htdocs.net/groupe/telepaiement.php
templates/xnet/groupe/telepaiement.tpl

index 63580d4..bc75823 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -34,6 +34,9 @@ Bug/Wish :
     * Wiki :
         - #403: Cache is cleared when editing a page.                       -Car
 
+    * Xnet :
+        - #383: Paiements table relook.                                     -Car
+
 From 0.9.8 Branch :
 
     * Xnet :
index 94204cb..75a73f2 100644 (file)
@@ -8,18 +8,37 @@ $res = $globals->xdb->query("SELECT id, text FROM {$globals->money->mpay_tprefix
 $tit = $res->fetchAllAssoc();
 $page->assign('titres', $tit);
 
+$order = Env::get('order', 'timestamp');
+$orders = array('timestamp', 'nom', 'promo', 'montant');
+if (!in_array($order, $orders)) $order = 'timestamp';
+$inv_order = Env::get('order_inv', 0);
+$page->assign('order', $order);
+$page->assign('order_inv', !$inv_order);
+if ($order == 'timestamp') $inv_order = !$inv_order;
+
+if ($inv_order) $inv_order = ' DESC'; else $inv_order = '';
+if ($order == 'montant') $order = 'LENGTH(montant) '.$inv_order.', montant';
+
+$orderby = 'ORDER BY '.$order.$inv_order;
+if ($order != 'nom') { $orderby .= ', nom'; $inv_order = ''; }
+$orderby .= ', prenom'.$inv_order;
+if ($order != 'timestamp') $orderby .= ', timestamp DESC';
+
 if (may_update()) {
     $trans = array();
     foreach($tit as $foo) {
         $pid = $foo['id'];
         $res = $globals->xdb->query(
-                "SELECT  IF(u.nom_usage<>'', u.nom_usage, u.nom) as nom, u.prenom, u.promo, a.alias, timestamp, montant
+                "SELECT  IF(u.nom_usage<>'', u.nom_usage, u.nom) as nom, u.prenom, u.promo, a.alias, timestamp AS `date`, montant 
                    FROM  {$globals->money->mpay_tprefix}transactions AS t
              INNER JOIN  auth_user_md5                               AS u ON ( t.uid = u.user_id )
              INNER JOIN  aliases                                     AS a ON ( t.uid = a.id AND a.type='a_vie' )
-                  WHERE  ref = {?}
-               ORDER BY  timestamp DESC", $pid);
+                  WHERE  ref = {?} ".$orderby, $pid);
         $trans[$pid] = $res->fetchAllAssoc();
+        $sum = 0;
+        foreach ($trans[$pid] as $i => $t)
+            $sum += strtr(substr($t['montant'], 0, strpos($t['montant'], "EUR")), ",", ".");
+        $trans[$pid][] = array("nom" => "somme totale", "montant" => strtr($sum, ".", ",")." EUR");
     }
     $page->assign('trans', $trans);
 }
index de2de09..6a8069d 100644 (file)
@@ -36,16 +36,30 @@ Voici la liste des paiements en ligne possible pour le groupe {$asso.nom}
 {if $trans[$p.id]}
 <table cellpadding="0" cellspacing="0" class='bicol'>
   <tr>
-    <th colspan="3">{$p.text} : détails pour les administrateurs</th>
+    <th colspan="4">{$p.text} : détails pour les administrateurs</th>
   </tr>
+  <tr>
+    <td class="center">[{if $order eq 'timestamp'}<strong><a href='?order={$order}&order_inv={$order_inv}'>{else}<a href='?order=timestamp'>{/if}Date</a>{if $order eq 'timestamp'}</strong>{/if}]</td>
+    <td class="center">[{if $order eq 'nom'}<strong><a href='?order={$order}&order_inv={$order_inv}'>{else}<a href='?order=nom'>{/if}Prénom NOM</a>{if $order eq 'nom'}</strong>{/if}]</td>
+    <td class="center">[{if $order eq 'promo'}<strong><a href='?order={$order}&order_inv={$order_inv}'>{else}<a href='?order=promo'>{/if}Promo</a>{if $order eq 'promo'}</strong>{/if}]</td>
+    <td class="center">[{if $order eq 'montant'}<strong><a href='?order={$order}&order_inv={$order_inv}'>{else}<a href='?order=montant'>{/if}Montant</a>{if $order eq 'montant'}</strong>{/if}]</td>
+  </tr>
+  {assign var="somme" value=0}
   {foreach from=$trans[$p.id] item=p}
   <tr>
-    <td>{$p.date|date_format}</td>
-    <td>
-      <a href="https://www.polytechnique.org/fiche.php?user={$p.alias}">{$p.nom} {$p.prenom} (X{$promo})</a>
-      (<a href="mailto:{$p.alias}@polytechnique.org">mail</a>)
-    </td>
-    <td>{$p.montant}</td>
+    {if $p.nom neq "somme totale"}
+        <td class="center">{$p.date|date_format:"%d/%m/%y"}</td>
+        <td>
+          {$p.prenom} {$p.nom}
+          <a href="https://www.polytechnique.org/fiche.php?user={$p.alias}"><img alt="[fiche]" title="Voir sa fiche" src="{rel}/images/loupe.gif"/></a>
+          <a href="mailto:{$p.alias}@polytechnique.org"><img alt="[mail]" title="Lui envoyer un mail" src="{rel}/images/mail.png"/></a>
+        </td>
+        <td class="center">X {$p.promo}</td>
+        <td class="right">{$p.montant}</td>
+    {else}
+        <td class="right" colspan="3"><strong>Total </strong></td>
+        <th class="right">{$p.montant}</th>
+    {/if}        
   </tr>
   {/foreach}
 </table>