From 2e7b5921d0c012deb619842276fcefa3515ae044 Mon Sep 17 00:00:00 2001 From: x2003bruneau Date: Wed, 27 Sep 2006 19:56:45 +0000 Subject: [PATCH] #478: correctly sort payments git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@924 839d8a87-29fc-0310-9880-83ba4fa771e5 --- ChangeLog | 6 ++++++ classes/PLTableEditor.php | 14 +++++++++++++- modules/payment.php | 1 + 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index c5c3546..422fcb5 100644 --- 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 diff --git a/classes/PLTableEditor.php b/classes/PLTableEditor.php index ac41b39..7d435a5 100644 --- a/classes/PLTableEditor.php +++ b/classes/PLTableEditor.php @@ -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++; diff --git a/modules/payment.php b/modules/payment.php index 4b7f037..dae084c 100644 --- a/modules/payment.php +++ b/modules/payment.php @@ -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); -- 2.1.4