#478: correctly sort payments
authorx2003bruneau <x2003bruneau@839d8a87-29fc-0310-9880-83ba4fa771e5>
Wed, 27 Sep 2006 19:56:45 +0000 (19:56 +0000)
committerx2003bruneau <x2003bruneau@839d8a87-29fc-0310-9880-83ba4fa771e5>
Wed, 27 Sep 2006 19:56:45 +0000 (19:56 +0000)
git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@924 839d8a87-29fc-0310-9880-83ba4fa771e5

ChangeLog
classes/PLTableEditor.php
modules/payment.php

index c5c3546..422fcb5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,10 +1,16 @@
 ================================================================================
 VERSION 0.9.12                                                        ?? ?? 2006
 
+New:
+
+    * Admin:
+        - Can add sorting key in Table Editor                              -FRU
+
 Bug/Wish:
 
     * Admin:
         - #468: Can edit requests before validation                        -FRU
+        - #478: Sort payments by flag                                      -FRU
 
     * Core:
         - #473: Use 'événement' instead of 'évènement'                     -FRU
index ac41b39..7d435a5 100644 (file)
@@ -26,6 +26,8 @@ class PLTableEditor {
     var $table;
     // joint tables to delete when deleting an entry
     var $jtables = array();
+    // sorting field
+    var $sort = array();
     // the id field
     var $idfield;
     // possibility to edit the field
@@ -111,6 +113,13 @@ class PLTableEditor {
         if ($joindel)
             $this->jtables[$name] = array("joinid" => $joinid,"joinextra" => $joinextra?(" AND ".$joinextra):"");
     }
+
+    // add a sort key
+    function add_sort_field($key, $desc = false)
+    {
+        $this->sort[] = $key . ($desc ? ' DESC' : '');
+    }
+
     // call when done
     function apply(&$page, $action, $id = false) {
         $page->changeTpl('table-editor.tpl');
@@ -176,7 +185,10 @@ class PLTableEditor {
                 $page->trig("Impossible de mette à jour.");
         }
         if ($list) {
-            $it = XDB::iterator("SELECT * FROM {$this->table}");
+            if (count($this->sort) > 0) {
+                $sort = 'ORDER BY ' . join($this->sort, ',');
+            }
+            $it = XDB::iterator("SELECT * FROM {$this->table} $sort");
             $this->nbfields = 0;
             foreach ($this->vars as $field => $descr)
                 if ($descr['display']) $this->nbfields++;
index 4b7f037..dae084c 100644 (file)
@@ -321,6 +321,7 @@ class PaymentModule extends PLModule
         $page->assign('title', 'Gestion des télépaiements');
         $table_editor = new PLTableEditor('admin/payments','paiement.paiements','id');
         $table_editor->add_join_table('paiement.transactions','ref',true);
+        $table_editor->add_sort_field('flags');
         $table_editor->describe('text','intitulé',true);
         $table_editor->describe('url','site web',false);
         $table_editor->describe('montant_def','montant par défaut',false);