Adds bankaccount edition in payment validation.
authorAnne Limoges <anne.limoges_git@polytechnique.org>
Tue, 15 Jan 2013 09:27:17 +0000 (10:27 +0100)
committerAnne Limoges <anne.limoges_git@polytechnique.org>
Tue, 15 Jan 2013 09:27:17 +0000 (10:27 +0100)
classes/phone.php
include/validations/paiements.inc.php
templates/include/form.valid.edit-paiements.tpl
templates/include/form.valid.paiements.tpl

index 870f551..21be6a6 100644 (file)
@@ -329,15 +329,17 @@ class Phone
     static private function formArrayWalk(array $data, $function, &$success = true, $requiresEmptyPhone = false, $maxPublicity = null)
     {
         $phones = array();
-        foreach ($data as $item) {
-            $phone = new Phone($item);
-            $success = (!$phone->error && ($phone->format() || $phone->isEmpty()) && $success);
-            if (!$phone->isEmpty()) {
-                // Restrict phone visibility to $maxPublicity
-                if (!is_null($maxPublicity) && Visibility::isLessRestrictive($maxPublicity, $phone->pub)) {
-                    $phone->pub = $maxPublicity;
+        if (!is_null($data)) {
+            foreach ($data as $item) {
+                $phone = new Phone($item);
+                $success = (!$phone->error && ($phone->format() || $phone->isEmpty()) && $success);
+                if (!$phone->isEmpty()) {
+                    // Restrict phone visibility to $maxPublicity
+                    if (!is_null($maxPublicity) && Visibility::isLessRestrictive($maxPublicity, $phone->pub)) {
+                        $phone->pub = $maxPublicity;
+                    }
+                    $phones[] = call_user_func(array($phone, $function));
                 }
-                $phones[] = call_user_func(array($phone, $function));
             }
         }
         if (count($phones) == 0 && $requiresEmptyPhone) {
index 88e9c23..9bd54f6 100644 (file)
@@ -38,6 +38,8 @@ class PayReq extends Validate
     public $evt;
     public $evt_intitule;
     public $public;
+    public $rib_id;
+    public $rib_nom;
 
     public $rules = "Vérifier que les balises &lt;salutation&gt;, &lt;prenom&gt;, &lt;nom&gt;,  &lt;montant&gt; et &lt;comment&gt; n'ont pas été modifiées.
 Vérifier que le demandeur n'a pas laissé les crochets [].
@@ -69,6 +71,11 @@ Si le télépaiement n'est pas lié à un groupe ou supérieur à 51 euros, lais
             $res = XDB::query("SELECT intitule FROM group_events WHERE asso_id = {?} AND eid = {?}", $_asso_id, $_evt);
             $this->evt_intitule = $res->fetchOneCell();
         }
+        // for future use, when anims can choose there bankaccounts
+        if ($this->rib_id) {
+            $res = XDB::query("SELECT owner FROM payment_bankaccounts WHERE id = {?}", $this->rib_id);
+            $this->rib_nom = $res->fetchOneCell();
+        }
     }
 
     // }}}
@@ -140,6 +147,13 @@ Si le télépaiement n'est pas lié à un groupe ou supérieur à 51 euros, lais
         $this->montant_max = Env::i('pay_montant_max');
         $this->msg_reponse = Env::v('pay_msg_reponse');
         $this->public      = (Env::v('pay_public') == 'yes');
+        $this->rib_id      = Env::v('pay_rib_id');
+        if ($this->rib_id) {
+            $res = XDB::query("SELECT owner FROM payment_bankaccounts WHERE id = {?}", $this->rib_id);
+            $this->rib_nom = $res->fetchOneCell();
+        } else {
+            $this->rib_nom = null;
+        }
         return true;
     }
 
@@ -170,11 +184,11 @@ Si le télépaiement n'est pas lié à un groupe ou supérieur à 51 euros, lais
     {
         $res = XDB::query("SELECT MAX(id) FROM payments");
         $id = $res->fetchOneCell()+1;
-        $ret = XDB::execute('INSERT INTO  payments (id, text, url, amount_def, amount_min, amount_max, mail, confirmation, asso_id, flags)
-                                  VALUES  ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})',
+        $ret = XDB::execute('INSERT INTO  payments (id, text, url, amount_def, amount_min, amount_max, mail, confirmation, asso_id, flags, rib_id)
+                                  VALUES  ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})',
                             $id, $this->titre, $this->site, $this->montant, $this->montant_min,
                             $this->montant_max, $this->user->bestEmail(), $this->msg_reponse, $this->asso_id,
-                            ($this->public ? 'public' : ''));
+                            ($this->public ? 'public' : ''), $this->rib_id);
         if ($this->asso_id && $this->evt) {
             XDB::execute("UPDATE  group_events
                              SET  paiement_id = {?}
index 26e53a1..cdb94c5 100644 (file)
@@ -36,5 +36,5 @@
 <label><input type="radio" name="pay_public" value="no" {if !t($valid->public)}checked="checked"{/if} />Non</label>
 &nbsp;-&nbsp;
 <label>Oui<input type="radio" name="pay_public" value="yes" {if t($valid->public)}checked="checked"{/if} /></label><br />
-
+<strong>Rib_id&nbsp;:</strong> <input type="text" name="pay_rib_id" size="5" value="{$valid->rib_id}" /> <br />
 {* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
index e714fe7..10de1d5 100644 (file)
@@ -63,5 +63,9 @@
   <td class="titre">Public&nbsp;:</td>
   <td>{if $valid->public}Oui{else}Non{/if}</td>
 </tr>
+<tr class="pair">
+  <td class="titre">RIB&nbsp;:</td>
+  <td>{if $valid->rib_id}{$valid->rib_nom}{else}NULL{/if}</td>
+</tr>
 
 {* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}