Add reference to rib in payments table and in admin pages.
authorAnne Limoges <anne.limoges_git@polytechnique.org>
Wed, 7 Nov 2012 06:11:22 +0000 (07:11 +0100)
committerAnne Limoges <anne.limoges_git@polytechnique.org>
Fri, 9 Nov 2012 14:41:06 +0000 (15:41 +0100)
modules/payment.php
templates/admin/index.tpl
templates/payment/reconcile.tpl
upgrade/1.1.6/02_payments.sql [new file with mode: 0644]

index 1291ef0..e3788e5 100644 (file)
@@ -587,10 +587,13 @@ class PaymentModule extends PLModule
         $table_editor->describe('amount_max', 'montant maximum', false, true);
         $table_editor->describe('mail', 'email contact', true);
         $table_editor->describe('confirmation', 'message confirmation', false, true);
-
+        $table_editor->describe('rib_id', 'RIB', false, true);
         // adds a column with the start date of the linked event if there is one
         $table_editor->add_option_table('group_events', 'group_events.paiement_id = t.id');
         $table_editor->add_option_field('group_events.archive', 'related_event', 'évènement archivé ?', 'tinyint');
+        // adds a column with the linked rib if there is one
+        $table_editor->add_option_table('payment_bankaccounts', 'payment_bankaccounts.id = t.rib_id');
+        $table_editor->add_option_field('payment_bankaccounts.owner', 'linked_rib_owner', 'rib associé', 'varchar');
 
         $table_editor->apply($page, $action, $id);
     }
@@ -693,8 +696,9 @@ class PaymentModule extends PLModule
                                   $recongp['id']);
                 $recongp['recons'] = $res->fetchAllAssoc();
 
-                $res = XDB::query('SELECT  id, payment_id, amount, account_id, message, date
-                                     FROM  payment_transfers
+                $res = XDB::query('SELECT  t.id, t.payment_id, t.amount, b.owner, t.message, t.date
+                                     FROM  payment_transfers    AS t
+                                LEFT JOIN  payment_bankaccounts AS b ON (t.account_id=b.id)
                                     WHERE  recongroup_id = {?}',
                                   $recongp['id']);
                 $recongp['transfers'] = $res->fetchAllAssoc();
@@ -897,7 +901,7 @@ class PaymentModule extends PLModule
 
             // create transfers
             XDB::execute('INSERT INTO  payment_transfers
-                               SELECT  NULL, {?}, t.ref, SUM(t.amount+t.commission), NULL, p.text, NULL
+                               SELECT  NULL, {?}, t.ref, SUM(t.amount+t.commission), p.rib_id, p.text, NULL
                                  FROM  payment_transactions AS t
                             LEFT JOIN  payments             AS p ON (t.ref = p.id)
                             LEFT JOIN  groups               AS g ON (p.asso_id = g.id)
index d20e113..d7cf838 100644 (file)
     <td>
       <a href="admin/payments">Paiements</a>
       &nbsp;&nbsp;|&nbsp;&nbsp;
-      <a href="admin/payments/methods">Méthodes de paiement</a>
-      &nbsp;&nbsp;|&nbsp;&nbsp;
       <a href="admin/reconcile">Virements</a>
       &nbsp;&nbsp;|&nbsp;&nbsp;
       <a href="admin/reconcile/bankaccounts">RIBs</a>
+      &nbsp;&nbsp;|&nbsp;&nbsp;
+      <a href="admin/payments/methods">Méthodes de paiement</a>
     </td>
   </tr>
   <tr class="pair">
index 8770588..d517c10 100644 (file)
@@ -94,7 +94,7 @@
                                                <td>{$transfer.id}</td>
                                                <td>{if $transfer.date}{$transfer.date}{else}à virer{/if}</td>
                                                <td><small>{$transfer.message}</small></td>
-                                               <td>{$transfer.account}</td>
+                                               <td>{$transfer.owner}</td>
                                                <td class="right">{$transfer.amount}</td>
                                                <td class="right">
                                                  {if !$transfer.date}<a href="admin/reconcile/transfers/confirm/{$transfer.id}?token={xsrf_token}">{icon name=tick title='Confirmer la réalisation'}</a>{/if}
diff --git a/upgrade/1.1.6/02_payments.sql b/upgrade/1.1.6/02_payments.sql
new file mode 100644 (file)
index 0000000..5813f3d
--- /dev/null
@@ -0,0 +1,4 @@
+ALTER TABLE payments ADD COLUMN rib_id INT(11) NULL DEFAULT NULL ;
+ALTER TABLE payments ADD CONSTRAINT fk_rib_id FOREIGN KEY (rib_id) REFERENCES payment_bankaccounts(id);
+
+-- vim=set syntax=mysql: