Show payment summary in event admin page.
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Fri, 21 Dec 2007 21:02:46 +0000 (22:02 +0100)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Fri, 21 Dec 2007 21:02:46 +0000 (22:02 +0100)
Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
modules/xnetevents.php
modules/xnetevents/xnetevents.inc.php
templates/xnetevents/admin.tpl

index 1cc6633..4b9c4cf 100644 (file)
@@ -562,7 +562,7 @@ class XnetEventsModule extends PLModule
             $evt = get_event_detail($eid, $item_id);
         }
 
-        $page->assign('evt', $evt);
+        $page->assign_by_ref('evt', $evt);
         $page->assign('tout', is_null($item_id));
 
         if (count($evt['moments'])) {
index 9c0ad58..1fa24e5 100644 (file)
@@ -110,7 +110,7 @@ function get_event_detail($eid, $item_id = false, $asso_id = null)
 // }}}
 
 // {{{ function get_event_participants()
-function get_event_participants($evt, $item_id, $tri, $limit = '') {
+function get_event_participants(&$evt, $item_id, $tri, $limit = '') {
     global $globals;
 
     if (Env::has('initiale')) {
@@ -155,6 +155,10 @@ function get_event_participants($evt, $item_id, $tri, $limit = '') {
     $tab = array();
     $user = 0;
 
+    $evt['adminpaid'] = 0;
+    $evt['telepaid']  = 0;
+    $evt['topay']     = 0;
+    $evt['paid']      = 0;
     while ($u = $res->next()) {
         if ($u['nb'] == 0) {
             continue;
@@ -169,8 +173,8 @@ function get_event_participants($evt, $item_id, $tri, $limit = '') {
                 $pay_id, $u['uid']);
             $montants = $res_->fetchColumn();
             foreach ($montants as $m) {
-                    $p = strtr(substr($m, 0, strpos($m, "EUR")), ",", ".");
-                    $u['paid'] += trim($p);
+                $p = strtr(substr($m, 0, strpos($m, "EUR")), ",", ".");
+                $u['paid'] += trim($p);
             }
         }
         $u['telepayment'] = $u['paid'] - $u['adminpaid'];
@@ -185,6 +189,10 @@ function get_event_participants($evt, $item_id, $tri, $limit = '') {
             $u['montant'] += $i['montant']*$i['nb'];
         }
         $tab[] = $u;
+        $evt['telepaid']  += $u['telepayment'];
+        $evt['adminpaid'] += $u['adminpaid'];
+        $evt['paid']      += $u['paid'];
+        $evt['topay']     += $u['montant'];
     }
     return $tab;
 }
index f1ca9d9..975951a 100644 (file)
@@ -178,6 +178,18 @@ Ils ont payĆ© mais ont oubliĆ© de s'inscrire&nbsp;:
     {/if}
   </tr>
   {/foreach}
+  {if $is_admin && $evt.money}
+  <tr>
+    {assign var=cols value=$moments|@count}
+    <td colspan="{$cols+3}" class="right"><strong>Total</strong></td>
+    <td>{$evt.topay}&euro;</td>
+    {if $evt.paiement_id}
+    <td>{$evt.telepaid|default:0}&euro;</td>
+    <td>{$evt.adminpaid|default:0}&euro;</td>
+    {/if}
+    <td>{$evt.paid}&euro;</td>
+  </tr>
+  {/if}
 </table>
 
 <p class="descr">