From aec8fd6774a979dffa968c9dc7a5aa3b02c36402 Mon Sep 17 00:00:00 2001 From: Pascal Corpet Date: Fri, 10 Jun 2005 13:23:12 +0000 Subject: [PATCH] ajout de la gestion du telepaiement avec les evenements git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-693 --- htdocs.net/groupe/evenements.php | 12 ++- include/validations/paiements.inc.php | 123 +++++++++++++++++++++++++++++ templates/include/form.valid.paiements.tpl | 62 +++++++++++++++ templates/xnet/groupe/form_evenement.tpl | 19 ++++- templates/xnet/groupe/telepaiement.tpl | 3 +- 5 files changed, 214 insertions(+), 5 deletions(-) create mode 100644 include/validations/paiements.inc.php create mode 100644 templates/include/form.valid.paiements.tpl diff --git a/htdocs.net/groupe/evenements.php b/htdocs.net/groupe/evenements.php index 06e4f59..37a53b1 100644 --- a/htdocs.net/groupe/evenements.php +++ b/htdocs.net/groupe/evenements.php @@ -22,7 +22,7 @@ if (may_update() && Post::get('intitule')) { {?}, {?}, {?}, {?})", $eid, $globals->asso('id'), Session::get('uid'), Post::get('intitule'), - Post::get('paiement')?Post::get('paiement'):NULL, Post::get('descriptif'), + (Post::get('paiement')>0)?Post::get('paiement'):NULL, Post::get('descriptif'), Post::get('deb_Year')."-".Post::get('deb_Month')."-".Post::get('deb_Day')." ".Post::get('deb_Hour').":".Post::get('deb_Minute').":00", Post::get('fin_Year')."-".Post::get('fin_Month')."-".Post::get('fin_Day')." ".Post::get('fin_Hour').":".Post::get('fin_Minute').":00", Post::get('membres_only'), Post::get('advertise'), Post::get('show_participants')); @@ -31,10 +31,11 @@ if (may_update() && Post::get('intitule')) { $res = $globals->xdb->query("SELECT LAST_INSERT_ID()"); $eid = $res->fetchOneCell(); } - $nb_moments = 0; + $money_defaut = 0; foreach ($moments as $i) if (Post::get('titre'.$i)) { $nb_moments++; + if (!($money_defaut > 0)) $money_defaut = strtr(Post::get('montant'.$i), ',', '.'); $globals->xdb->execute(" REPLACE INTO groupex.evenements_items VALUES ( {?}, {?}, @@ -44,6 +45,13 @@ if (may_update() && Post::get('intitule')) { } else { $globals->xdb->execute("DELETE FROM groupex.evenements_items WHERE eid = {?} AND item_id = {?}", $eid, $i); } + + // request for a new payment + if (Post::get('paiement') == -1 && $money_defaut >= 0) { + require_once ('validations.inc.php'); + $p = new PayReq(Session::get('uid'), Post::get('intitule')." - ".$globals->asso('nom'), Post::get('site'), $money_defaut, Post::get('confirmation'),0, 999, $globals->asso('id'), $eid); + $p->submit(); + } // events with no sub-event if ($nb_moments == 0) diff --git a/include/validations/paiements.inc.php b/include/validations/paiements.inc.php new file mode 100644 index 0000000..09c7d0c --- /dev/null +++ b/include/validations/paiements.inc.php @@ -0,0 +1,123 @@ +Validate($_uid, false, 'paiements', $_stamp); + + $this->titre = $_intitule; + $this->site = $_site; + $this->msg_reponse = $_msg; + $this->asso_id = $_asso_id; + $this->evt = $_evt; + $this->montant = $_montant; + $this->montant_min = $_montantmin; + $this->montant_max = $_montantmax; + + if ($_asso_id) { + $res = $globals->xdb->query("SELECT nom FROM groupex.asso WHERE id = {?}", $_asso_id); + $this->asso = $res->fetchOneCell(); + } + if ($_asso_id && $_evt) { + $res = $globals->xdb->query("SELECT intitule FROM groupex.evenements WHERE asso_id = {?} AND eid = {?}", $_asso_id, $_evt); + $this->evt_intitule = $res->fetchOneCell(); + } + } + + // }}} + // {{{ function formu() + + function formu() + { return 'include/form.valid.paiements.tpl'; } + + // }}} + // {{{ function _mail_subj + + function _mail_subj() + { + return "[Polytechnique.org/Paiments] Demande de création de paiement {$this->titre}"; + } + + // }}} + // {{{ function _mail_body + + function _mail_body($isok) + { + if ($isok) { + 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":""); + } else { + return " La demande que tu avais faite pour le paiement de {$this->intitule} a été refusée."; + } + } + + // }}} + // {{{ function commit() + + function commit() + { + global $globals; + $res = $globals->xdb->query("SELECT MAX(id) FROM paiement.paiements"); + $id = $res->fetchOneCell()+1; + $ret = $globals->xdb->execute("INSERT INTO paiement.paiements VALUES + ( {?}, {?}, {?}, '', + {?}, {?}, {?}, + {?}, {?}, {?} ) + ", + $id, $this->titre, $this->site, + $this->montant, $this->montant_min, $this->montant_max, + $this->bestalias."@".$globals->mail->domain, $this->msg_reponse, $this->asso_id); + if ($this->asso_id && $this->evt) + $ret = $globals->xdb->execute("UPDATE groupex.evenements SET paiement_id = {?} WHERE asso_id = {?} AND eid = {?}", $id, $this->asso_id, $this->evt); + + return $ret; + } + + // }}} +} + +// }}} + +// vim:set et sw=4 sts=4 sws=4 foldmethod=marker: +?> diff --git a/templates/include/form.valid.paiements.tpl b/templates/include/form.valid.paiements.tpl new file mode 100644 index 0000000..b2fe4a6 --- /dev/null +++ b/templates/include/form.valid.paiements.tpl @@ -0,0 +1,62 @@ +{**************************************************************************} +{* *} +{* Copyright (C) 2003-2004 Polytechnique.org *} +{* http://opensource.polytechnique.org/ *} +{* *} +{* This program is free software; you can redistribute it and/or modify *} +{* it under the terms of the GNU General Public License as published by *} +{* the Free Software Foundation; either version 2 of the License, or *} +{* (at your option) any later version. *} +{* *} +{* This program is distributed in the hope that it will be useful, *} +{* but WITHOUT ANY WARRANTY; without even the implied warranty of *} +{* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *} +{* GNU General Public License for more details. *} +{* *} +{* You should have received a copy of the GNU General Public License *} +{* along with this program; if not, write to the Free Software *} +{* Foundation, Inc., *} +{* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *} +{* *} +{**************************************************************************} + + + + Paiement : + {$valid->titre} + + + Site web : + + {$valid->site} + + + + Montant : + + {$valid->montant} ({$valid->montant_min} < x < {$valid->montant_max}) + + + + Contact : + + {$valid->bestalias}@polytechnique.org + + + + Message de confirmation : +
{$valid->msg_reponse}
+ +{if $valid->asso_id} + + Lié à l'asso : + {$valid->asso} + +{if $valid->evt} + + événement : + {$valid->evt_intitule} + +{/if} +{/if} +{* vim:set et sw=2 sts=2 sws=2: *} diff --git a/templates/xnet/groupe/form_evenement.tpl b/templates/xnet/groupe/form_evenement.tpl index 6d1cd7a..54077fa 100644 --- a/templates/xnet/groupe/form_evenement.tpl +++ b/templates/xnet/groupe/form_evenement.tpl @@ -87,13 +87,28 @@ Référence de paiement : - + + {html_options options=$paiements selected=$evt.paiement_id} + {foreach from=$moments item=i} {assign var='moment' value=$items[$i]}
diff --git a/templates/xnet/groupe/telepaiement.tpl b/templates/xnet/groupe/telepaiement.tpl index 44df9c0..a3c7606 100644 --- a/templates/xnet/groupe/telepaiement.tpl +++ b/templates/xnet/groupe/telepaiement.tpl @@ -27,11 +27,12 @@ Voici la liste des paiements en ligne possible pour le groupe {$asso.nom}

{foreach from=$titres item=p} +
{$p.text} {if $trans[$p.id]} - + {foreach from=$trans[$p.id] item=p} -- 2.1.4
{$p.text} : détails pour les administrateur{$p.text} : détails pour les administrateurs