"transaction_description" => "dord.transaction_description"
);
- my $sortoder = "dord.id";
+ my $sortdir = $form->{sortdir} ? 'ASC' : 'DESC';
+ my $sortorder = "dord.id";
if ($form->{sort} && grep($form->{sort}, keys(%allowed_sort_columns))) {
$sortorder = $allowed_sort_columns{$form->{sort}};
}
- $query .= qq| ORDER by | . $sortorder;
+ $query .= qq| ORDER by | . $sortorder . " $sortdir";
$form->{DO} = selectall_hashref_query($form, $dbh, $query, @values);
($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;
DO->transactions();
);
foreach my $name (qw(id transdate donumber ordnumber name employee 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";
}
$form->{"l_type"} = "Y";
$report->set_export_options('orders', @hidden_variables);
- $report->set_sort_indicator($form->{sort}, 1);
+ $report->set_sort_indicator($form->{sort}, $form->{sortdir});
my @options;
if ($form->{customer}) {