From 262108d0f0d61ce6e4d3e436e9042c1002ec41f7 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Mon, 7 Jul 2008 09:44:29 +0000 Subject: [PATCH] =?utf8?q?Sortierung=20in=20Berichten=20=C3=BCber=20Eingan?= =?utf8?q?gsrechnungen/Kreditorenbuchungen=20auch=20auf-=20und=20absteigba?= =?utf8?q?r=20sortierbar=20gemacht.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/AP.pm | 7 ++++--- bin/mozilla/ap.pl | 10 +++++----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/SL/AP.pm b/SL/AP.pm index 7629381b0..e9e1a7ecd 100644 --- a/SL/AP.pm +++ b/SL/AP.pm @@ -464,15 +464,16 @@ sub ap_transactions { my @a = (transdate, invnumber, name); push @a, "employee" if $self->{l_employee}; - my $sortorder = join(', ', @a); + my $sortdir = $form->{sortdir} ? 'ASC' : 'DESC'; + my $sortorder = join(', ', map { "$_ $sortdir" } @a); if (grep({ $_ eq $form->{sort} } qw(transdate id invnumber ordnumber name netamount tax amount paid datepaid due duedate notes employee))) { - $sortorder = $form->{sort}; + $sortorder = $form->{sort} . " $sortdir"; } - $query .= " ORDER by $sortorder"; + $query .= " ORDER BY $sortorder"; my $sth = $dbh->prepare($query); $sth->execute(@values) || diff --git a/bin/mozilla/ap.pl b/bin/mozilla/ap.pl index a252f0ec8..b729cf0f6 100644 --- a/bin/mozilla/ap.pl +++ b/bin/mozilla/ap.pl @@ -1376,7 +1376,7 @@ sub ap_transactions { ($form->{vendor}, $form->{vendor_id}) = split(/--/, $form->{vendor}); - $form->{sort} ||= 'transdate'; + report_generator_set_default_sort('transdate', 1); AP->ap_transactions(\%myconfig, \%$form); @@ -1413,9 +1413,9 @@ sub ap_transactions { 'globalprojectnumber' => { 'text' => $locale->text('Project Number'), }, ); - foreach my $name (qw(id transdate duedate invnumber ordnumber name datepaid - employee shippingpoint shipvia)) { - $column_defs{$name}->{link} = $href . "&sort=$name"; + foreach my $name (qw(id transdate duedate invnumber ordnumber name datepaid employee shippingpoint shipvia)) { + my $sortdir = $form->{sort} eq $name ? 1 - $form->{sortdir} : $form->{sortdir}; + $column_defs{$name}->{link} = $href . "&sort=$name&sortdir=$sortdir"; } my %column_alignment = map { $_ => 'right' } qw(netamount tax amount paid due); @@ -1428,7 +1428,7 @@ sub ap_transactions { $report->set_export_options('ap_transactions', @hidden_variables); - $report->set_sort_indicator($form->{sort}, 1); + $report->set_sort_indicator($form->{sort}, $form->{sortdir}); my @options; if ($form->{vendor}) { -- 2.20.1