X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/9b3455eaa0e7ae850c48c17bcf53735e5d5416da..1cd7aea87cff5ab5a4b51a539e2dc24935f4d8c4:/SL/CT.pm?ds=inline diff --git a/SL/CT.pm b/SL/CT.pm index b61a07a63..3252fe8a0 100644 --- a/SL/CT.pm +++ b/SL/CT.pm @@ -155,8 +155,9 @@ sub populate_drop_down_boxes { # get shipto address $query = - qq|SELECT shipto_id, shiptoname, shiptodepartment_1 | . - qq|FROM shipto WHERE (trans_id = ?) AND (module = 'CT')|; + qq|SELECT shipto_id, shiptoname, shiptodepartment_1, shiptostreet, shiptocity + FROM shipto + WHERE (trans_id = ?) AND (module = 'CT')|; $form->{SHIPTO} = selectall_hashref_query($form, $dbh, $query, $form->{id}); # get contacts @@ -682,11 +683,17 @@ sub search { my %allowed_sort_columns = map({ $_, 1 } qw(id customernumber vendornumber name address contact phone fax email taxnumber sic_code business invnumber ordnumber quonumber)); - $sortorder = - $form->{sort} && $allowed_sort_columns{$form->{sort}} ? - $form->{sort} : "name"; + $sortorder = $form->{sort} && $allowed_sort_columns{$form->{sort}} ? $form->{sort} : "name"; $form->{sort} = $sortorder; - $sortorder = "country,city,street" if ($sortorder eq "address"); + my $sortdir = !defined $form->{sortdir} ? 'ASC' : $form->{sortdir} ? 'ASC' : 'DESC'; + + if ($sortorder eq "address") { + $sortorder = "lower(country) ${sortdir}, lower(city) ${sortdir}, lower(street) ${sortdir}"; + } elsif ($sortorder ne 'id') { + $sortorder = "lower($sortorder) ${sortdir}"; + } else { + $sortorder .= " ${sortdir}"; + } if ($form->{"${cv}number"}) { $where .= " AND ct.${cv}number ILIKE ?";