ajout de la gestion du telepaiement avec les evenements
authorPascal Corpet <pascal.corpet@m4x.org>
Fri, 10 Jun 2005 13:23:12 +0000 (13:23 +0000)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Thu, 26 Jun 2008 21:29:11 +0000 (23:29 +0200)
git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-693

htdocs.net/groupe/evenements.php
include/validations/paiements.inc.php [new file with mode: 0644]
templates/include/form.valid.paiements.tpl [new file with mode: 0644]
templates/xnet/groupe/form_evenement.tpl
templates/xnet/groupe/telepaiement.tpl

index 06e4f59..37a53b1 100644 (file)
@@ -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 (file)
index 0000000..09c7d0c
--- /dev/null
@@ -0,0 +1,123 @@
+<?php
+/***************************************************************************
+ *  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                *
+ ***************************************************************************/
+
+// {{{ class PayReq
+
+class PayReq extends Validate
+{
+    // {{{ properties
+    
+    var $titre;
+    var $site;
+
+    var $montant;
+    var $montant_min;
+    var $montant_max;
+
+    var $msg_reponse;
+    var $asso_id;
+    var $asso;
+    var $evt;
+    var $evt_intitule;
+
+    var $rules = "Laisser la validation à un trésorier";
+    // }}}
+    // {{{ constructor
+    
+    function PayReq($_uid, $_intitule, $_site, $_montant, $_msg, $_montantmin=0, $_montantmax=999, $_asso_id = 0, $_evt = 0, $_stamp=0)
+    {
+        global $globals;
+        $this->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 (file)
index 0000000..b2fe4a6
--- /dev/null
@@ -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               *}
+{*                                                                        *}
+{**************************************************************************}
+
+
+<tr class="pair">
+  <td class="titre">Paiement&nbsp;:</td>
+  <td>{$valid->titre}</td>
+</tr>
+<tr class="pair">
+  <td class="titre">Site web&nbsp;:</td>
+  <td>
+    <a href="{$valid->site}">{$valid->site}</a>
+  </td>
+</tr>
+<tr class="pair">
+  <td class="titre">Montant&nbsp;:</td>
+  <td>
+    {$valid->montant} ({$valid->montant_min} &lt; x &lt; {$valid->montant_max})
+  </td>
+</tr>
+<tr class="pair">
+  <td class="titre">Contact&nbsp;:</td>
+  <td>
+    {$valid->bestalias}@polytechnique.org
+  </td>
+</tr>
+<tr class="pair">
+  <td class="titre">Message de confirmation&nbsp;:</td>
+  <td><pre wrap>{$valid->msg_reponse}</pre></td>
+</tr>
+{if $valid->asso_id}
+<tr class="pair">
+  <td class="titre">Lié à l'asso&nbsp;:</td>
+  <td>{$valid->asso}</td>
+</tr>
+{if $valid->evt}
+<tr class="pair">
+  <td class="titre">événement&nbsp;:</td>
+  <td>{$valid->evt_intitule}</td>
+</tr>
+{/if}
+{/if}
+{* vim:set et sw=2 sts=2 sws=2: *}
index 6d1cd7a..54077fa 100644 (file)
       <td>Référence de paiement :
       </td>
       <td>
-      <select name="paiement">
-       <option value=''>Pas de paiement déclaré</option>
+      <select name="paiement" onchange="document.getElementById('new_pay').style.display=(value < 0)?'block':'none'">
+       <option value=''>Pas de paiement</option>
+       <option value='-1'>- Nouveau paiement -</option>
        {html_options options=$paiements selected=$evt.paiement_id}
       </select>
       </td>
     </tr>
   </table>
+    <div id="new_pay" style="display:none">
+       Nouveau paiement, message de confirmation&nbsp;:<br />
+       <textarea name="confirmation" rows="12" cols="65"><salutation> <prenom> <nom>,
+        
+Ton inscription à %%%%% a bien été enregistrée et ton paiement de <montant> a bien été reçu. 
+Nous t'attendons donc le %%%%% à %%%%%. 
+Si tu as des questions eventuelles, tu peux contacter %%%%%
+  
+A très bientot,
+  
+%%%%%</textarea><br />
+       Page internet de l'événement&nbsp;:<br />
+       <input size="40" name="site" value="{$asso.site}" />
+    </div>
   {foreach from=$moments item=i}
   {assign var='moment' value=$items[$i]}
   <hr />
index 44df9c0..a3c7606 100644 (file)
@@ -27,11 +27,12 @@ Voici la liste des paiements en ligne possible pour le groupe {$asso.nom}
 </p>
 
 {foreach from=$titres item=p}
+<hr />
 <a href="https://www.polytechnique.org/paiement/?ref={$p.id}">{$p.text}</a>
 {if $trans[$p.id]}
 <table>
   <tr>
-    <th colspan="3">{$p.text} : détails pour les administrateur</th>
+    <th colspan="3">{$p.text} : détails pour les administrateurs</th>
   </tr>
   <tr>
     {foreach from=$trans[$p.id] item=p}