push(@values, '%' . $form->{transaction_description} . '%');
}
- my $sortorder = join(', ', ("o.id", $form->sort_columns("transdate", $ordnumber, "name")));
+ my $sortdir = $form->{sortdir} ? 'ASC' : 'DESC';
+ my $sortorder = join(', ', map { "${_} ${sortdir} " } ("o.id", $form->sort_columns("transdate", $ordnumber, "name")));
my %allowed_sort_columns = (
"transdate" => "o.transdate",
"reqdate" => "o.reqdate",
"transaction_description" => "o.transaction_description"
);
if ($form->{sort} && grep($form->{sort}, keys(%allowed_sort_columns))) {
- $sortorder = $allowed_sort_columns{$form->{sort}};
+ $sortorder = $allowed_sort_columns{$form->{sort}} . " ${sortdir}";
}
$query .= qq| ORDER by | . $sortorder;
($form->{ $form->{vc} }, $form->{"${form->{vc}}_id"}) = split(/--/, $form->{ $form->{vc} });
- $form->{sort} ||= 'transdate';
+ $form->{sort} ||= 'transdate';
+ $form->{sortdir} = 1 unless (defined $form->{sortdir});
+ $form->{sortdir} = $form->{sortdir} ? 1 : 0;
OE->transactions(\%myconfig, \%$form);
);
foreach my $name (qw(id transdate reqdate quonumber ordnumber name employee salesman shipvia)) {
- $column_defs{$name}->{link} = $href . "&sort=$name";
+ 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 curr);
$report->set_columns(%column_defs);
$report->set_column_order(@columns);
$report->set_export_options('orders', @hidden_variables);
- $report->set_sort_indicator($form->{sort}, 1);
+ $report->set_sort_indicator($form->{sort}, $form->{sortdir});
my @options;
my ($department) = split m/--/, $form->{department};