From: Moritz Bunkus Date: Mon, 7 Jul 2008 10:36:04 +0000 (+0000) Subject: Bericht über Mahnungen sortierbar gemacht. X-Git-Tag: release-2.6.0beta1~81 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=dde9d68d7704edcaa4334356cec15ef7ce4f380f;p=kivitendo-erp.git Bericht über Mahnungen sortierbar gemacht. --- diff --git a/SL/DN.pm b/SL/DN.pm index 291c99ced..67a7d9ec5 100644 --- a/SL/DN.pm +++ b/SL/DN.pm @@ -598,7 +598,21 @@ sub get_dunning { push(@values, $form->{dunningto}); } - $query = + my %sort_columns = ( + 'dunning_description' => [ qw(dn.dunning_description customername invnumber) ], + 'customername' => [ qw(customername invnumber) ], + 'invnumber' => [ qw(a.invnumber) ], + 'transdate' => [ qw(a.transdate a.invnumber) ], + 'duedate' => [ qw(a.duedate a.invnumber) ], + 'dunning_date' => [ qw(dunning_date a.invnumber) ], + 'dunning_duedate' => [ qw(dunning_duedate a.invnumber) ], + ); + + my $sortdir = !defined $form->{sortdir} ? 'ASC' : $form->{sortdir} ? 'ASC' : 'DESC'; + my $sortkey = $sort_columns{$form->{sort}} ? $form->{sort} : 'customername'; + my $sortorder = join ', ', map { "$_ $sortdir" } @{ $sort_columns{$sortkey} }; + + my $query = qq|SELECT a.id, a.ordnumber, a.invoice, a.transdate, a.invnumber, a.amount, ct.name AS customername, ct.id AS customer_id, a.duedate, da.fee, da.interest, dn.dunning_description, da.transdate AS dunning_date, @@ -607,7 +621,7 @@ sub get_dunning { JOIN customer ct ON (a.customer_id = ct.id), dunning da LEFT JOIN dunning_config dn ON (da.dunning_config_id = dn.id) $where - ORDER BY name, a.id|; + ORDER BY $sortorder|; $form->{DUNNINGS} = selectall_hashref_query($form, $dbh, $query, @values); diff --git a/bin/mozilla/dn.pl b/bin/mozilla/dn.pl index 338d86a23..07830aabc 100644 --- a/bin/mozilla/dn.pl +++ b/bin/mozilla/dn.pl @@ -287,6 +287,8 @@ sub show_dunning { my @filter_field_list = qw(customer_id customer dunning_level department_id invnumber ordnumber transdatefrom transdateto dunningfrom dunningto notes showold); + report_generator_set_default_sort('customername', 1); + DN->get_dunning(\%myconfig, \%$form); if (!$form->{callback}) { @@ -310,7 +312,7 @@ sub show_dunning { 'title' => $form->{title}); $report->set_export_options('show_dunning', @filter_field_list); - $report->set_columns( + my %column_defs = ( 'checkbox' => { 'text' => '', 'visible' => 'HTML' }, 'dunning_description' => { 'text' => $locale->text('Dunning Level') }, 'customername' => { 'text' => $locale->text('Customername') }, @@ -324,11 +326,19 @@ sub show_dunning { 'interest' => { 'text' => $locale->text('Interest') }, ); + $report->set_columns(%column_defs); $report->set_column_order(qw(checkbox dunning_description customername invnumber transdate duedate amount dunning_date dunning_duedate fee interest)); + $report->set_sort_indicator($form->{sort}, $form->{sortdir}); my $edit_url = build_std_url('script=is.pl', 'action=edit', 'callback') . '&id='; my $print_url = build_std_url('action=print_dunning', 'format=pdf', 'media=screen') . '&dunning_id='; + my $sort_url = build_std_url('action=show_dunning', grep { $form->{$_} } @filter_field_list); + + foreach my $name (qw(dunning_description customername invnumber transdate duedate dunning_date dunning_duedate)) { + my $sortdir = $form->{sort} eq $name ? 1 - $form->{sortdir} : $form->{sortdir}; + $column_defs{$name}->{link} = $sort_url . "&sort=$name&sortdir=$sortdir"; + } my %alignment = map { $_ => 'right' } qw(transdate duedate amount dunning_date dunning_duedate fee interest);