From a2aca2e1d8136681d2a95fefd240d509581c8bc8 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Mon, 7 Jul 2008 10:09:16 +0000 Subject: [PATCH] =?utf8?q?Sortierung=20in=20Berichten=20=C3=BCber=20Kunden?= =?utf8?q?=20und=20Lieferanten=20auch=20auf-=20und=20absteigbar=20sortierb?= =?utf8?q?ar=20gemacht.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/CT.pm | 11 ++++++----- bin/mozilla/ct.pl | 11 ++++++++--- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/SL/CT.pm b/SL/CT.pm index 0468c379d..31ba176ee 100644 --- a/SL/CT.pm +++ b/SL/CT.pm @@ -682,15 +682,16 @@ sub search { my %allowed_sort_columns = map({ $_, 1 } qw(id customernumber vendornumber name address contact phone fax email taxnumber sic_code business invnumber ordnumber quonumber)); - $sortorder = - $form->{sort} && $allowed_sort_columns{$form->{sort}} ? - $form->{sort} : "name"; + $sortorder = $form->{sort} && $allowed_sort_columns{$form->{sort}} ? $form->{sort} : "name"; $form->{sort} = $sortorder; + my $sortdir = !defined $form->{sortdir} ? 'ASC' : $form->{sortdir} ? 'ASC' : 'DESC'; if ($sortorder eq "address") { - $sortorder = "lower(country), lower(city), lower(street)"; + $sortorder = "lower(country) ${sortdir}, lower(city) ${sortdir}, lower(street) ${sortdir}"; } elsif ($sortorder ne 'id') { - $sortorder = "lower($sortorder)"; + $sortorder = "lower($sortorder) ${sortdir}"; + } else { + $sortorder .= " ${sortdir}"; } if ($form->{"${cv}number"}) { diff --git a/bin/mozilla/ct.pl b/bin/mozilla/ct.pl index 29603c94d..086565d7d 100644 --- a/bin/mozilla/ct.pl +++ b/bin/mozilla/ct.pl @@ -108,6 +108,8 @@ sub list_names { $form->{IS_CUSTOMER} = $form->{db} eq 'customer'; + report_generator_set_default_sort('name', 1); + CT->search(\%myconfig, \%$form); my $cvar_configs = CVar->get_configs('module' => 'CT'); @@ -159,9 +161,12 @@ sub list_names { my @hidden_variables = (qw(db status obsolete), map { "l_$_" } @columns); my @hidden_nondefault = grep({ $form->{$_} } @hidden_variables); my $callback = build_std_url('action=list_names', grep { $form->{$_} } @hidden_variables); - $form->{callback} = "$callback&sort=" . E($form->{sort}); + $form->{callback} = "$callback&sort=" . E($form->{sort}) . "&sortdir=" . E($form->{sortdir}); - map { $column_defs{$_}->{link} = "${callback}&sort=${_}" } @columns; + foreach (@columns) { + my $sortdir = $form->{sort} eq $_ ? 1 - $form->{sortdir} : $form->{sortdir}; + $column_defs{$_}->{link} = "${callback}&sort=${_}&sortdir=${sortdir}"; + } my ($ordertype, $quotationtype, $attachment_basename); if ($form->{IS_CUSTOMER}) { @@ -192,7 +197,7 @@ sub list_names { $report->set_export_options('list_names', @hidden_variables); - $report->set_sort_indicator($form->{sort}, 1); + $report->set_sort_indicator($form->{sort}, $form->{sortdir}); CVar->add_custom_variables_to_report('module' => 'CT', 'trans_id_field' => 'id', -- 2.20.1