Table editor fills the new entry form with the default values of the fields
[platal.git] / modules / xnetevents / xnetevents.inc.php
index 1cc15cc..ed5794c 100644 (file)
@@ -68,7 +68,7 @@ function get_event_detail($eid, $item_id = false)
     }
 
     $res = XDB::query(
-        "SELECT titre, details, montant, ei.item_id, nb
+        "SELECT titre, details, montant, ei.item_id, nb, ep.paid
            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 = {?})
@@ -77,10 +77,13 @@ function get_event_detail($eid, $item_id = false)
     $evt['moments'] = $res->fetchAllAssoc();
 
     $evt['topay'] = 0;
+    $evt['paid'] = 0;
     foreach ($evt['moments'] as $m) {
         $evt['topay'] += $m['nb'] * $m['montant'];
-        if ($m['montant'])
+        if ($m['montant']) {
             $evt['money'] = true;
+        }
+        $evt['paid']  = $m['paid'];
     }
 
     $req = XDB::query(
@@ -89,7 +92,6 @@ function get_event_detail($eid, $item_id = false)
          WHERE ref = {?} AND uid = {?}", $evt['paiement_id'], S::v('uid'));
     $montants = $req->fetchColumn();
 
-    $evt['paid'] = 0;
     foreach ($montants as $m) {
         $p = strtr(substr($m, 0, strpos($m, 'EUR')), ',', '.');
         $evt['paid'] += trim($p);
@@ -273,7 +275,7 @@ function event_change_shortname(&$page, $old, $new)
         XDB::execute("INSERT INTO virtual SET type = 'evt', alias = {?}",
                 $new.'-participants@'.$globals->xnet->evts_domain);
 
-        $lastid = mysql_insert_id();
+        $lastid = XDB::insertId();
         XDB::execute(
           "INSERT INTO virtual_redirect (
                 SELECT {?} AS vid, IF(u.nom IS NULL, m.email, CONCAT(a.alias, {?})) AS redirect
@@ -288,7 +290,7 @@ function event_change_shortname(&$page, $old, $new)
         XDB::execute("INSERT INTO virtual SET type = 'evt', alias = {?}",
                 $new.'-absents@'.$globals->xnet->evts_domain);
 
-        $lastid = mysql_insert_id();
+        $lastid = XDB::insertId();
         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