2 /***************************************************************************
3 * Copyright (C) 2003-2010 Polytechnique.org *
4 * http://opensource.polytechnique.org/ *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the Free Software *
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
20 ***************************************************************************/
41 function Payment($ref=-1)
44 $r = $ref==-1 ?
$globals->money
->mpay_def_id
: $ref;
45 $res = XDB
::query("SELECT id, text, url, flags, mail, amount_min, amount_max, amount_def, asso_id
46 FROM payments WHERE id={?}", $r);
47 list($this->id
, $this->text
, $this->url
, $flags, $this->mail
,
48 $this->amount_min
, $this->amount_max
, $this->amount_def
, $this->asso_id
) = $res->fetchOneRow();
50 $this->amount_min
= (float)$this->amount_min
;
51 $this->amount_max
= (float)$this->amount_max
;
52 $this->flags
= new PlFlagSet($flags);
56 // {{{ function check()
58 function check($value)
60 $v = (float)strtr($value, ',', '.');
61 if ($this->amount_min
> $v) {
62 return "Montant inférieur au minimum autorisé ({$this->amount_min}).";
63 } elseif ($v > $this->amount_max
) {
64 return "Montant supérieur au maximum autorisé ({$this->amount_max}).";
71 // {{{ function init()
73 function init($val, &$meth)
75 require_once dirname(__FILE__
).'/money/'.$meth->inc
;
76 $this->api
= new $api($val);
80 // {{{ function prepareform()
82 function prepareform()
84 return $this->api
->prepareform($this);
90 $res = XDB
::query("SELECT e.eid, a.diminutif
91 FROM group_events AS e
92 INNER JOIN groups AS a ON (e.asso_id = a.id)
93 LEFT JOIN group_event_participants AS p ON (p.eid = e.eid AND p.uid = {?})
94 WHERE e.paiement_id = {?} AND p.uid IS NULL", S
::i('uid'), $this->id
);
95 if ($res->numRows()) {
96 return $res->fetchOneAssoc();
104 // {{{ class PayMethod
117 function PayMethod($id=-1)
120 $i = $id==-1 ?
$globals->money
->mpay_def_meth
: $id;
121 $res = XDB
::query("SELECT id,text,include FROM payment_methods WHERE id={?}", $i);
122 list($this->id
, $this->text
, $this->inc
) = $res->fetchOneRow();
130 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: