rework XOrgDB -> XDB (shorter, easier to use).
[platal.git] / include / money.inc.php
index 78979ba..400019c 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2004 Polytechnique.org                              *
+ *  Copyright (C) 2003-2006 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -33,6 +33,7 @@ class Payment
     var $montant_min;
     var $montant_max;
     var $montant_def;
+    var $asso_id;
 
     var $api = null;
 
@@ -43,14 +44,16 @@ class Payment
     {
         global $globals;
         $r   = $ref==-1 ? $globals->money->mpay_def_id : $ref;
-        $res = $globals->xdb->query("SELECT  id, text, url, flags, mail, montant_min, montant_max, montant_def
+        $res = XDB::query("SELECT  id, text, url, flags, mail, montant_min, montant_max, montant_def, asso_id
                                        FROM  {$globals->money->mpay_tprefix}paiements WHERE id={?}", $r);
         list($this->id, $this->text, $this->url, $flags, $this->mail,
-                $this->montant_min, $this->montant_max, $this->montant_def) = $res->fetchOneRow();
+                $this->montant_min, $this->montant_max, $this->montant_def, $this->asso_id) = $res->fetchOneRow();
         
         $this->montant_min = (float)$this->montant_min;
         $this->montant_max = (float)$this->montant_max;
         $this->flags       = new Flagset($flags);
+
+        return $link;
     }
 
     // }}}
@@ -84,6 +87,17 @@ class Payment
     {
         return $this->api->prepareform($this);
     }
+
+    function event()
+    {
+        global $globals;
+        if ($this->asso_id)
+        {
+            $res = XDB::query("SELECT eid, a.diminutif FROM groupex.evenements AS e, groupex.asso AS a WHERE e.asso_id = {?} AND a.id = {?}", $this->asso_id, $this->asso_id);
+            return $res->fetchOneAssoc();
+        }
+        return null;
+    }
 }
 
 // }}}
@@ -104,7 +118,7 @@ class PayMethod
     {
         global $globals;
         $i   = $id==-1 ? $globals->money->mpay_def_meth : $id;
-        $res = $globals->xdb->query("SELECT id,text,include FROM {$globals->money->mpay_tprefix}methodes WHERE id={?}", $i);
+        $res = XDB::query("SELECT id,text,include FROM {$globals->money->mpay_tprefix}methodes WHERE id={?}", $i);
         list($this->id, $this->text, $this->inc) = $res->fetchOneRow();
     }