Commit | Line | Data |
---|---|---|
0337d704 | 1 | <?php |
2 | /*************************************************************************** | |
5ddeb07c | 3 | * Copyright (C) 2003-2007 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 | ||
0337d704 | 22 | class Payment |
23 | { | |
24 | // {{{ properties | |
25 | ||
26 | var $id; | |
27 | var $text; | |
28 | var $url; | |
29 | var $flags; | |
30 | var $mail; | |
31 | var $montant_min; | |
32 | var $montant_max; | |
33 | var $montant_def; | |
3b3e9d15 | 34 | var $asso_id; |
0337d704 | 35 | |
36 | var $api = null; | |
37 | ||
38 | // }}} | |
39 | // {{{ constructor | |
eaf30d86 | 40 | |
0337d704 | 41 | function Payment($ref=-1) |
42 | { | |
43 | global $globals; | |
44 | $r = $ref==-1 ? $globals->money->mpay_def_id : $ref; | |
08cce2ff | 45 | $res = XDB::query("SELECT id, text, url, flags, mail, montant_min, montant_max, montant_def, asso_id |
f057316b | 46 | FROM {$globals->money->mpay_tprefix}paiements WHERE id={?}", $r); |
0337d704 | 47 | list($this->id, $this->text, $this->url, $flags, $this->mail, |
f057316b | 48 | $this->montant_min, $this->montant_max, $this->montant_def, $this->asso_id) = $res->fetchOneRow(); |
eaf30d86 | 49 | |
0337d704 | 50 | $this->montant_min = (float)$this->montant_min; |
51 | $this->montant_max = (float)$this->montant_max; | |
52 | $this->flags = new Flagset($flags); | |
53 | } | |
54 | ||
55 | // }}} | |
56 | // {{{ function check() | |
eaf30d86 | 57 | |
0337d704 | 58 | function check($value) |
59 | { | |
60 | $v = (float)strtr($value, ',', '.'); | |
61 | if ($this->montant_min > $v) { | |
a7de4ef7 | 62 | return "Montant inférieur au minimum autorisé ({$this->montant_min})."; |
0337d704 | 63 | } elseif ($v > $this->montant_max) { |
a7de4ef7 | 64 | return "Montant supérieur au maximum autorisé ({$this->montant_max})."; |
0337d704 | 65 | } else { |
66 | return true; | |
67 | } | |
68 | } | |
69 | ||
70 | // }}} | |
71 | // {{{ function init() | |
72 | ||
73 | function init($val, &$meth) | |
74 | { | |
50bda57a | 75 | require_once dirname(__FILE__).'/money/'.$meth->inc; |
0337d704 | 76 | $this->api = new $api($val); |
77 | } | |
78 | ||
79 | // }}} | |
80 | // {{{ function prepareform() | |
81 | ||
82 | function prepareform() | |
83 | { | |
84 | return $this->api->prepareform($this); | |
85 | } | |
3b3e9d15 | 86 | |
87 | function event() | |
88 | { | |
a3a049fc | 89 | if ($this->asso_id) { |
614199d8 FB |
90 | $res = XDB::query("SELECT e.eid, a.diminutif |
91 | FROM groupex.evenements AS e | |
92 | INNER JOIN groupex.asso AS a ON (e.asso_id = a.id) | |
93 | LEFT JOIN groupex.evenements_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(); | |
97 | } | |
3b3e9d15 | 98 | } |
99 | return null; | |
100 | } | |
089a5801 | 101 | // }}} |
0337d704 | 102 | } |
103 | ||
0337d704 | 104 | // {{{ class PayMethod |
105 | ||
106 | class PayMethod | |
107 | { | |
108 | // {{{ properties | |
109 | ||
110 | var $id; | |
111 | var $text; | |
112 | var $inc; | |
113 | ||
114 | // }}} | |
115 | // {{{ constructor | |
116 | ||
117 | function PayMethod($id=-1) | |
118 | { | |
119 | global $globals; | |
120 | $i = $id==-1 ? $globals->money->mpay_def_meth : $id; | |
08cce2ff | 121 | $res = XDB::query("SELECT id,text,include FROM {$globals->money->mpay_tprefix}methodes WHERE id={?}", $i); |
0337d704 | 122 | list($this->id, $this->text, $this->inc) = $res->fetchOneRow(); |
eaf30d86 | 123 | } |
0337d704 | 124 | |
125 | // }}} | |
126 | } | |
127 | ||
128 | // }}} | |
129 | ||
a7de4ef7 | 130 | // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: |
0337d704 | 131 | ?> |