X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fpayment%2Fmoney.inc.php;h=ecd49f507e8bb43fc8df334b49e299295b992456;hb=a037f0a822d44e1fd79e5fe488092b0ab8dbc1ab;hp=862232ad2c1c17bfe3fe5f093d122a73339373bf;hpb=e0210288e07b472b2341c6f2b5d5d5046d8cd4e9;p=platal.git diff --git a/modules/payment/money.inc.php b/modules/payment/money.inc.php index 862232a..ecd49f5 100644 --- a/modules/payment/money.inc.php +++ b/modules/payment/money.inc.php @@ -1,6 +1,6 @@ money->mpay_def_id : $ref; - $res = XDB::query("SELECT id, text, url, flags, mail, montant_min, montant_max, montant_def, asso_id - FROM {$globals->money->mpay_tprefix}paiements WHERE id={?}", $r); + + $r = ($ref == -1) ? $globals->money->mpay_def_id : $ref; + $res = XDB::query('SELECT id, text, url, flags, mail, amount_min, amount_max, amount_def, asso_id + FROM payments + WHERE id = {?}', $r); list($this->id, $this->text, $this->url, $flags, $this->mail, - $this->montant_min, $this->montant_max, $this->montant_def, $this->asso_id) = $res->fetchOneRow(); - - $this->montant_min = (float)$this->montant_min; - $this->montant_max = (float)$this->montant_max; - $this->flags = new Flagset($flags); + $this->amount_min, $this->amount_max, $this->amount_def, $this->asso_id) = $res->fetchOneRow(); - return $link; + $this->amount_min = (float)$this->amount_min; + $this->amount_max = (float)$this->amount_max; + $this->flags = new PlFlagSet($flags); } - // }}} - // {{{ function check() - function check($value) { $v = (float)strtr($value, ',', '.'); - if ($this->montant_min > $v) { - return "Montant inférieur au minimum autorisé ({$this->montant_min})."; - } elseif ($v > $this->montant_max) { - return "Montant supérieur au maximum autorisé ({$this->montant_max})."; + if ($this->amount_min > $v) { + return "Montant inférieur au minimum autorisé ({$this->amount_min})."; + } elseif ($v > $this->amount_max) { + return "Montant supérieur au maximum autorisé ({$this->amount_max})."; } else { return true; } } - // }}} - // {{{ function init() - - function init($val, &$meth) + function init($val, $meth) { - require_once dirname(__FILE__).'/money/'.$meth->inc; + require_once dirname(__FILE__) . '/money/' . $meth->inc; $this->api = new $api($val); } - // }}} - // {{{ function prepareform() - - function prepareform() + function prepareform(User $user) { - return $this->api->prepareform($this); + return $this->api->prepareform($this, $user); } function event() { if ($this->asso_id) { - $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); - return $res->fetchOneAssoc(); + $res = XDB::query("SELECT e.eid, a.diminutif + FROM group_events AS e + INNER JOIN groups AS a ON (e.asso_id = a.id) + LEFT JOIN group_event_participants AS p ON (p.eid = e.eid AND p.uid = {?}) + WHERE e.paiement_id = {?} AND p.uid IS NULL", S::i('uid'), $this->id); + if ($res->numRows()) { + return $res->fetchOneAssoc(); + } } return null; } - // }}} } -// {{{ class PayMethod - class PayMethod { - // {{{ properties - - var $id; - var $text; - var $inc; + public $id; + public $text; + public $inc; - // }}} - // {{{ constructor - - function PayMethod($id=-1) + function PayMethod($id = -1) { global $globals; - $i = $id==-1 ? $globals->money->mpay_def_meth : $id; - $res = XDB::query("SELECT id,text,include FROM {$globals->money->mpay_tprefix}methodes WHERE id={?}", $i); - list($this->id, $this->text, $this->inc) = $res->fetchOneRow(); - } - // }}} + $i = ($id == -1) ? $globals->money->mpay_def_meth : $id; + $res = XDB::query('SELECT id, text, include + FROM payment_methods + WHERE id = {?}', $i); + list($this->id, $this->text, $this->inc) = $res->fetchOneRow(); + } } -// }}} - -// vim:set et sw=4 sts=4 sws=4 foldmethod=marker: +// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: ?>