0337d704 |
1 | <?php |
2 | /*************************************************************************** |
50a40a33 |
3 | * Copyright (C) 2003-2006 Polytechnique.org * |
0337d704 |
4 | * http://opensource.polytechnique.org/ * |
5 | * * |
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. * |
10 | * * |
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. * |
15 | * * |
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 * |
18 | * Foundation, Inc., * |
19 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * |
20 | ***************************************************************************/ |
21 | |
089a5801 |
22 | require_once 'diogenes/diogenes.flagset.inc.php'; |
0337d704 |
23 | |
24 | class Payment |
25 | { |
26 | // {{{ properties |
27 | |
28 | var $id; |
29 | var $text; |
30 | var $url; |
31 | var $flags; |
32 | var $mail; |
33 | var $montant_min; |
34 | var $montant_max; |
35 | var $montant_def; |
3b3e9d15 |
36 | var $asso_id; |
0337d704 |
37 | |
38 | var $api = null; |
39 | |
40 | // }}} |
41 | // {{{ constructor |
42 | |
43 | function Payment($ref=-1) |
44 | { |
45 | global $globals; |
46 | $r = $ref==-1 ? $globals->money->mpay_def_id : $ref; |
08cce2ff |
47 | $res = XDB::query("SELECT id, text, url, flags, mail, montant_min, montant_max, montant_def, asso_id |
0337d704 |
48 | FROM {$globals->money->mpay_tprefix}paiements WHERE id={?}", $r); |
49 | list($this->id, $this->text, $this->url, $flags, $this->mail, |
3b3e9d15 |
50 | $this->montant_min, $this->montant_max, $this->montant_def, $this->asso_id) = $res->fetchOneRow(); |
0337d704 |
51 | |
52 | $this->montant_min = (float)$this->montant_min; |
53 | $this->montant_max = (float)$this->montant_max; |
54 | $this->flags = new Flagset($flags); |
3b3e9d15 |
55 | |
56 | return $link; |
0337d704 |
57 | } |
58 | |
59 | // }}} |
60 | // {{{ function check() |
61 | |
62 | function check($value) |
63 | { |
64 | $v = (float)strtr($value, ',', '.'); |
65 | if ($this->montant_min > $v) { |
66 | return "Montant inférieur au minimum autorisé ({$this->montant_min})."; |
67 | } elseif ($v > $this->montant_max) { |
68 | return "Montant supérieur au maximum autorisé ({$this->montant_max})."; |
69 | } else { |
70 | return true; |
71 | } |
72 | } |
73 | |
74 | // }}} |
75 | // {{{ function init() |
76 | |
77 | function init($val, &$meth) |
78 | { |
79 | require_once('money/'.$meth->inc); |
80 | $this->api = new $api($val); |
81 | } |
82 | |
83 | // }}} |
84 | // {{{ function prepareform() |
85 | |
86 | function prepareform() |
87 | { |
88 | return $this->api->prepareform($this); |
89 | } |
3b3e9d15 |
90 | |
91 | function event() |
92 | { |
a3a049fc |
93 | if ($this->asso_id) { |
08cce2ff |
94 | $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); |
3b3e9d15 |
95 | return $res->fetchOneAssoc(); |
96 | } |
97 | return null; |
98 | } |
089a5801 |
99 | // }}} |
0337d704 |
100 | } |
101 | |
0337d704 |
102 | // {{{ class PayMethod |
103 | |
104 | class PayMethod |
105 | { |
106 | // {{{ properties |
107 | |
108 | var $id; |
109 | var $text; |
110 | var $inc; |
111 | |
112 | // }}} |
113 | // {{{ constructor |
114 | |
115 | function PayMethod($id=-1) |
116 | { |
117 | global $globals; |
118 | $i = $id==-1 ? $globals->money->mpay_def_meth : $id; |
08cce2ff |
119 | $res = XDB::query("SELECT id,text,include FROM {$globals->money->mpay_tprefix}methodes WHERE id={?}", $i); |
0337d704 |
120 | list($this->id, $this->text, $this->inc) = $res->fetchOneRow(); |
121 | } |
122 | |
123 | // }}} |
124 | } |
125 | |
126 | // }}} |
127 | |
128 | // vim:set et sw=4 sts=4 sws=4 foldmethod=marker: |
129 | ?> |