0337d704 |
1 | <?php |
2 | /*************************************************************************** |
3 | * Copyright (C) 2003-2004 Polytechnique.org * |
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 PayReq |
23 | |
24 | class PayReq extends Validate |
25 | { |
26 | // {{{ properties |
27 | |
28 | var $titre; |
29 | var $site; |
30 | |
31 | var $montant; |
32 | var $montant_min; |
33 | var $montant_max; |
34 | |
35 | var $msg_reponse; |
36 | var $asso_id; |
37 | var $asso; |
38 | var $evt; |
39 | var $evt_intitule; |
40 | |
41 | var $rules = "Laisser la validation à un trésorier"; |
42 | // }}} |
43 | // {{{ constructor |
44 | |
45 | function PayReq($_uid, $_intitule, $_site, $_montant, $_msg, $_montantmin=0, $_montantmax=999, $_asso_id = 0, $_evt = 0, $_stamp=0) |
46 | { |
47 | global $globals; |
48 | $this->Validate($_uid, false, 'paiements', $_stamp); |
49 | |
50 | $this->titre = $_intitule; |
51 | $this->site = $_site; |
52 | $this->msg_reponse = $_msg; |
53 | $this->asso_id = $_asso_id; |
54 | $this->evt = $_evt; |
55 | $this->montant = $_montant; |
56 | $this->montant_min = $_montantmin; |
57 | $this->montant_max = $_montantmax; |
58 | |
59 | if ($_asso_id) { |
60 | $res = $globals->xdb->query("SELECT nom FROM groupex.asso WHERE id = {?}", $_asso_id); |
61 | $this->asso = $res->fetchOneCell(); |
62 | } |
63 | if ($_asso_id && $_evt) { |
64 | $res = $globals->xdb->query("SELECT intitule FROM groupex.evenements WHERE asso_id = {?} AND eid = {?}", $_asso_id, $_evt); |
65 | $this->evt_intitule = $res->fetchOneCell(); |
66 | } |
67 | } |
68 | |
69 | // }}} |
029e6327 |
70 | // {{{ function submit() |
71 | // supprime les demandes de paiments pour le meme evenement |
72 | function submit() |
73 | { |
74 | global $globals; |
75 | $evt = 's:3:"evt";s:'.strlen($this->evt+"").':"'.$this->evt.'"'; |
76 | $assoid = 's:7:"asso_id";s:'.strlen($this->asso_id + "").':"'.$this->asso_id.'"'; |
77 | if ($this->evt) |
78 | { |
79 | $globals->xdb->execute('DELETE FROM requests WHERE type={?} AND data LIKE {?}', 'paiements', "%".$assoid."%".$evt."%"); |
80 | } |
81 | Validate::submit(); |
82 | } |
83 | // }}} |
84 | // {{{ function formu() |
0337d704 |
85 | |
86 | function formu() |
87 | { return 'include/form.valid.paiements.tpl'; } |
88 | |
89 | // }}} |
90 | // {{{ function _mail_subj |
91 | |
92 | function _mail_subj() |
93 | { |
94 | return "[Polytechnique.org/Paiments] Demande de création de paiement {$this->titre}"; |
95 | } |
96 | |
97 | // }}} |
98 | // {{{ function _mail_body |
99 | |
100 | function _mail_body($isok) |
101 | { |
102 | if ($isok) { |
103 | return " Le paiement que tu avais demandé pour {$this->titre} vient d'être créé.".($this->evt?" Il a bien été associé à la gestion de l'événement du groupe":""); |
104 | } else { |
105 | return " La demande que tu avais faite pour le paiement de {$this->intitule} a été refusée."; |
106 | } |
107 | } |
108 | |
109 | // }}} |
110 | // {{{ function commit() |
111 | |
112 | function commit() |
113 | { |
114 | global $globals; |
115 | $res = $globals->xdb->query("SELECT MAX(id) FROM paiement.paiements"); |
116 | $id = $res->fetchOneCell()+1; |
117 | $ret = $globals->xdb->execute("INSERT INTO paiement.paiements VALUES |
118 | ( {?}, {?}, {?}, '', |
119 | {?}, {?}, {?}, |
120 | {?}, {?}, {?} ) |
121 | ", |
122 | $id, $this->titre, $this->site, |
123 | $this->montant, $this->montant_min, $this->montant_max, |
124 | $this->bestalias."@".$globals->mail->domain, $this->msg_reponse, $this->asso_id); |
125 | if ($this->asso_id && $this->evt) |
126 | $ret = $globals->xdb->execute("UPDATE groupex.evenements SET paiement_id = {?} WHERE asso_id = {?} AND eid = {?}", $id, $this->asso_id, $this->evt); |
127 | |
128 | return $ret; |
129 | } |
130 | |
131 | // }}} |
132 | } |
133 | |
134 | // }}} |
135 | |
136 | // vim:set et sw=4 sts=4 sws=4 foldmethod=marker: |
137 | ?> |