From: G. Richardson Date: Mon, 25 Feb 2013 15:06:57 +0000 (+0100) Subject: Korrektur für Commit 2def6461e - Kundenbericht X-Git-Tag: release-3.1.0beta1~606 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=e5e2493f45a28623c056023159f4166c2dac63a0;p=kivitendo-erp.git 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. --- diff --git a/SL/CT.pm b/SL/CT.pm index 63b252d9e..dd9d627b8 100644 --- a/SL/CT.pm +++ b/SL/CT.pm @@ -614,12 +614,36 @@ sub search { my $where = "1 = 1"; my @values; - my %allowed_sort_columns = - map { $_, 1 } qw( - id customernumber vendornumber name contact phone fax email street - taxnumber business invnumber ordnumber quonumber zipcode city country salesman + my %allowed_sort_columns = ( + "id" => "id", + "customernumber" => "customernumber", + "vendornumber" => "vendornumber", + "name" => "ct.name", + "contact" => "contact", + "phone" => "phone", + "fax" => "fax", + "email" => "email", + "street" => "street", + "taxnumber" => "taxnumber", + "business" => "business", + "invnumber" => "invnumber", + "ordnumber" => "ordnumber", + "quonumber" => "quonumber", + "zipcode" => "zipcode", + "city" => "city", + "country" => "country", + "salesman" => "e.name" ); - my $sortorder = $form->{sort} && $allowed_sort_columns{$form->{sort}} ? $form->{sort} : "name"; + + my $sortorder; + if ( $join_records ) { + # in UNION case order by hash key, e.g. salesman + # the UNION created an implicit select around the result + $sortorder = $form->{sort} && $allowed_sort_columns{$form->{sort}} ? $form->{sort} : "name"; + } else { + # in not UNION case order by hash value, e.g. e.name + $sortorder = $form->{sort} && $allowed_sort_columns{$form->{sort}} ? $allowed_sort_columns{$form->{sort}} : "ct.name"; + }; $form->{sort} = $sortorder; my $sortdir = !defined $form->{sortdir} ? 'ASC' : $form->{sortdir} ? 'ASC' : 'DESC'; @@ -788,7 +812,7 @@ sub search { } $query .= qq| ORDER BY $sortorder|; - + $form->{CT} = selectall_hashref_query($form, $dbh, $query, @values); $main::lxdebug->leave_sub();