2 /***************************************************************************
3 * Copyright (C) 2003-2004 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 ***************************************************************************/
42 function Payment($ref=-1)
45 $r = $ref==-1 ?
$globals->money
->mpay_def_id
: $ref;
46 $res = $globals->xdb
->query("SELECT id, text, url, flags, mail, montant_min, montant_max, montant_def
47 FROM {$globals->money->mpay_tprefix}paiements WHERE id={?}", $r);
48 list($this->id
, $this->text
, $this->url
, $flags, $this->mail
,
49 $this->montant_min
, $this->montant_max
, $this->montant_def
) = $res->fetchOneRow();
51 $this->montant_min
= (float)$this->montant_min
;
52 $this->montant_max
= (float)$this->montant_max
;
53 $this->flags
= new Flagset($flags);
57 // {{{ function check()
59 function check($value)
61 $v = (float)strtr($value, ',', '.');
62 if ($this->montant_min
> $v) {
63 return "Montant inférieur au minimum autorisé ({$this->montant_min}).";
64 } elseif ($v > $this->montant_max
) {
65 return "Montant supérieur au maximum autorisé ({$this->montant_max}).";
72 // {{{ function init()
74 function init($val, &$meth)
76 require_once('money/'.$meth->inc
);
77 $this->api
= new $api($val);
81 // {{{ function prepareform()
83 function prepareform()
85 return $this->api
->prepareform($this);
90 // {{{ class PayMethod
103 function PayMethod($id=-1)
106 $i = $id==-1 ?
$globals->money
->mpay_def_meth
: $id;
107 $res = $globals->xdb
->query("SELECT id,text,include FROM {$globals->money->mpay_tprefix}methodes WHERE id={?}", $i);
108 list($this->id
, $this->text
, $this->inc
) = $res->fetchOneRow();
116 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker: