Revision e5e2493f
Von Kivitendo Admin vor mehr als 11 Jahren hinzugefügt
SL/CT.pm | ||
---|---|---|
614 | 614 |
my $where = "1 = 1"; |
615 | 615 |
my @values; |
616 | 616 |
|
617 |
my %allowed_sort_columns = |
|
618 |
map { $_, 1 } qw( |
|
619 |
id customernumber vendornumber name contact phone fax email street |
|
620 |
taxnumber business invnumber ordnumber quonumber zipcode city country salesman |
|
617 |
my %allowed_sort_columns = ( |
|
618 |
"id" => "id", |
|
619 |
"customernumber" => "customernumber", |
|
620 |
"vendornumber" => "vendornumber", |
|
621 |
"name" => "ct.name", |
|
622 |
"contact" => "contact", |
|
623 |
"phone" => "phone", |
|
624 |
"fax" => "fax", |
|
625 |
"email" => "email", |
|
626 |
"street" => "street", |
|
627 |
"taxnumber" => "taxnumber", |
|
628 |
"business" => "business", |
|
629 |
"invnumber" => "invnumber", |
|
630 |
"ordnumber" => "ordnumber", |
|
631 |
"quonumber" => "quonumber", |
|
632 |
"zipcode" => "zipcode", |
|
633 |
"city" => "city", |
|
634 |
"country" => "country", |
|
635 |
"salesman" => "e.name" |
|
621 | 636 |
); |
622 |
my $sortorder = $form->{sort} && $allowed_sort_columns{$form->{sort}} ? $form->{sort} : "name"; |
|
637 |
|
|
638 |
my $sortorder; |
|
639 |
if ( $join_records ) { |
|
640 |
# in UNION case order by hash key, e.g. salesman |
|
641 |
# the UNION created an implicit select around the result |
|
642 |
$sortorder = $form->{sort} && $allowed_sort_columns{$form->{sort}} ? $form->{sort} : "name"; |
|
643 |
} else { |
|
644 |
# in not UNION case order by hash value, e.g. e.name |
|
645 |
$sortorder = $form->{sort} && $allowed_sort_columns{$form->{sort}} ? $allowed_sort_columns{$form->{sort}} : "ct.name"; |
|
646 |
}; |
|
623 | 647 |
$form->{sort} = $sortorder; |
624 | 648 |
my $sortdir = !defined $form->{sortdir} ? 'ASC' : $form->{sortdir} ? 'ASC' : 'DESC'; |
625 | 649 |
|
... | ... | |
788 | 812 |
} |
789 | 813 |
|
790 | 814 |
$query .= qq| ORDER BY $sortorder|; |
791 |
|
|
815 |
|
|
792 | 816 |
$form->{CT} = selectall_hashref_query($form, $dbh, $query, @values); |
793 | 817 |
|
794 | 818 |
$main::lxdebug->leave_sub(); |
Auch abrufbar als: Unified diff
Korrektur für Commit 2def6461e - Kundenbericht
je nachdem ob die Abfrage mit UNION oder nicht durchgeführt wird muß die
ORDER BY Spalte angepasst werden. allowed-HASH ähnlich wie in DO
eingeführt.