X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/6ce732c8e61b47d9bf59ca49715dec96706d64c0..aae5bae7d37a440abdfab7cf5c36d4fe77ff68f3:/SL/GL.pm diff --git a/SL/GL.pm b/SL/GL.pm index a080b85fc..3b0e74e82 100644 --- a/SL/GL.pm +++ b/SL/GL.pm @@ -38,6 +38,8 @@ package GL; +use Data::Dumper; + sub delete_transaction { my ($self, $myconfig, $form) = @_; $main::lxdebug->enter_sub(); @@ -342,6 +344,19 @@ 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} . ","; + } else { + $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 +386,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 transdate, trans_id, taxkey DESC, sorttax DESC,oid|; my $sth = $dbh->prepare($query); $sth->execute || $form->dberror($query); my $trans_id = ""; @@ -505,6 +520,7 @@ sub all_transactions { ($form->{gifi_account_description}) = $sth->fetchrow_array; $sth->finish; } + print(STDERR Dumper($form->{GL})); $main::lxdebug->leave_sub(); $dbh->disconnect;