we don't need diogenes session anymore
[platal.git] / include / money.inc.php
CommitLineData
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
22// {{{ class Payment
23
24class 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;
3b3e9d15 47 $res = $globals->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 {
93 global $globals;
94 if ($this->asso_id)
95 {
96 $res = $globals->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);
97 return $res->fetchOneAssoc();
98 }
99 return null;
100 }
0337d704 101}
102
103// }}}
104// {{{ class PayMethod
105
106class 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;
121 $res = $globals->xdb->query("SELECT id,text,include FROM {$globals->money->mpay_tprefix}methodes WHERE id={?}", $i);
122 list($this->id, $this->text, $this->inc) = $res->fetchOneRow();
123 }
124
125 // }}}
126}
127
128// }}}
129
130// vim:set et sw=4 sts=4 sws=4 foldmethod=marker:
131?>