From ece225ccbcec367d3b128ad9dd4e13145901aa6a Mon Sep 17 00:00:00 2001 From: Udo Spallek Date: Thu, 5 Jan 2006 23:17:36 +0000 Subject: [PATCH] BUG 125 solved. (Dank an Hartmut Goebel) --- SL/GL.pm | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/SL/GL.pm b/SL/GL.pm index a080b85fc..11cbe3646 100644 --- a/SL/GL.pm +++ b/SL/GL.pm @@ -342,6 +342,17 @@ sub all_transactions { my $false = ($myconfig->{dbdriver} eq 'Pg') ? FALSE: q|'0'|; + my $sortorder = join ', ', $form->sort_columns(qw(transdate reference source description accno)); + my %ordinal = ( transdate => 6, + reference => 4, + source => 7, + description => 5 ); + map { $sortorder =~ s/$_/$ordinal{$_}/ } keys %ordinal; + + if ($form->{sort}) { + $sortorder = $form->{sort} . ',' . $sortorder; + } + my $query = qq|SELECT g.id, 'gl' AS type, $false AS invoice, g.reference, ac.taxkey, t.taxkey AS sorttax, g.description, ac.transdate, ac.source, ac.trans_id, @@ -371,7 +382,7 @@ sub all_transactions { AND ac.chart_id = c.id AND a.vendor_id = ct.id AND a.id = ac.trans_id - ORDER BY transdate, trans_id, taxkey DESC, sorttax DESC, oid|; + ORDER BY $sortorder, oid|; my $sth = $dbh->prepare($query); $sth->execute || $form->dberror($query); my $trans_id = ""; -- 2.20.1