From 033709735189caa804476fc17e9946809516fcf7 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 11 Nov 2010 01:44:43 +0000 Subject: [PATCH] sort by clicking on headers, RT#6465 --- httemplate/browse/access_group.html | 2 +- httemplate/browse/access_user.html | 2 +- httemplate/browse/agent_type.cgi | 2 +- httemplate/browse/cust_attachment.html | 2 +- httemplate/browse/cust_category.html | 2 +- httemplate/browse/cust_class.html | 2 +- httemplate/browse/discount.html | 9 ++++---- httemplate/browse/part_pkg_report_option.html | 2 +- httemplate/browse/pkg_category.html | 2 +- httemplate/browse/pkg_class.html | 2 +- httemplate/browse/rate.cgi | 2 +- httemplate/browse/svc_acct_pop.cgi | 2 +- httemplate/browse/usage_class.html | 2 +- httemplate/search/cust_bill.html | 7 ++++++ httemplate/search/cust_bill_event.cgi | 3 ++- httemplate/search/cust_bill_pay.html | 10 +++++++++ httemplate/search/cust_bill_pkg.cgi | 11 +++++++++ httemplate/search/cust_bill_pkg_discount.html | 8 +++++++ httemplate/search/cust_credit.html | 6 ++++- httemplate/search/cust_credit_bill.html | 7 ++++++ httemplate/search/cust_credit_refund.html | 5 +++++ httemplate/search/cust_event.html | 3 ++- httemplate/search/cust_pkg_svc.html | 3 ++- httemplate/search/cust_svc.html | 3 ++- httemplate/search/elements/cust_pay_or_refund.html | 9 +++++++- httemplate/search/elements/search-html.html | 15 +++++++++++++ httemplate/search/elements/search.html | 26 +++++++++++++++++++++- httemplate/search/pay_batch.cgi | 3 ++- httemplate/search/queue.html | 2 +- httemplate/search/svc_domain.cgi | 3 ++- httemplate/search/svc_external.cgi | 3 ++- httemplate/search/svc_forward.cgi | 3 ++- httemplate/search/svc_phone.cgi | 3 ++- httemplate/search/svc_www.cgi | 3 ++- 34 files changed, 138 insertions(+), 31 deletions(-) diff --git a/httemplate/browse/access_group.html b/httemplate/browse/access_group.html index aa9097f36..2df0ba053 100644 --- a/httemplate/browse/access_group.html +++ b/httemplate/browse/access_group.html @@ -5,7 +5,7 @@ 'name' => 'employee groups', 'query' => { 'table' => 'access_group', 'hashref' => {}, - 'extra_sql' => 'ORDER BY groupname', #?? + 'order_by' => 'ORDER BY groupname', #?? }, 'count_query' => $count_query, 'header' => [ '#', diff --git a/httemplate/browse/access_user.html b/httemplate/browse/access_user.html index 3162e3a6c..6a1fea1ce 100644 --- a/httemplate/browse/access_user.html +++ b/httemplate/browse/access_user.html @@ -7,7 +7,7 @@ 'disabled_statuspos' => 2, 'query' => { 'table' => 'access_user', 'hashref' => {}, - 'extra_sql' => 'ORDER BY last, first' + 'order_by' => 'ORDER BY last, first' }, 'count_query' => $count_query, 'header' => \@header, diff --git a/httemplate/browse/agent_type.cgi b/httemplate/browse/agent_type.cgi index f07a6515b..1959302d2 100755 --- a/httemplate/browse/agent_type.cgi +++ b/httemplate/browse/agent_type.cgi @@ -5,7 +5,7 @@ 'name' => 'agent types', 'query' => { 'table' => 'agent_type', 'hashref' => {}, - 'extra_sql' => 'ORDER BY typenum', # 'ORDER BY atype', + 'order_by' => 'ORDER BY typenum', # 'ORDER BY atype', }, 'count_query' => $count_query, 'header' => [ '#', diff --git a/httemplate/browse/cust_attachment.html b/httemplate/browse/cust_attachment.html index e19259d05..9d62e5609 100755 --- a/httemplate/browse/cust_attachment.html +++ b/httemplate/browse/cust_attachment.html @@ -13,7 +13,7 @@ , 'query' => { 'table' => 'cust_attachment', 'hashref' => $hashref, - 'extra_sql' => 'ORDER BY '.$orderby, + 'order_by' => 'ORDER BY '.$orderby, }, 'count_query' => $count_query, 'header' => [ selflink('#',orderby => 'attachnum'), diff --git a/httemplate/browse/cust_category.html b/httemplate/browse/cust_category.html index 4468d2f09..09168bac4 100644 --- a/httemplate/browse/cust_category.html +++ b/httemplate/browse/cust_category.html @@ -6,7 +6,7 @@ 'disabled_statuspos' => 2, 'query' => { 'table' => 'cust_category', 'hashref' => {}, - 'extra_sql' => 'ORDER BY categorynum', + 'order_by' => 'ORDER BY categorynum', }, 'count_query' => $count_query, 'header' => [ '#', 'Category' ], diff --git a/httemplate/browse/cust_class.html b/httemplate/browse/cust_class.html index da303cf72..d7c622837 100644 --- a/httemplate/browse/cust_class.html +++ b/httemplate/browse/cust_class.html @@ -6,7 +6,7 @@ 'disabled_statuspos' => 2, 'query' => { 'table' => 'cust_class', 'hashref' => {}, - 'extra_sql' => 'ORDER BY classnum', + 'order_by' => 'ORDER BY classnum', }, 'count_query' => $count_query, 'header' => $header, diff --git a/httemplate/browse/discount.html b/httemplate/browse/discount.html index f7ef0b30f..13dc1e6f9 100644 --- a/httemplate/browse/discount.html +++ b/httemplate/browse/discount.html @@ -7,14 +7,13 @@ 'query' => { 'table' => 'discount', }, 'count_query' => 'SELECT COUNT(*) FROM discount', 'disableable' => 1, - 'disabled_statuspos' => 2, - 'header' => [ '#', 'Name', 'Discount', ], - 'fields' => [ 'discountnum', - 'name', + 'disabled_statuspos' => 1, + 'header' => [ 'Name', 'Discount', ], + 'fields' => [ 'name', 'description', ], 'links' => [ $link, - $link, + '', ], ) %> diff --git a/httemplate/browse/part_pkg_report_option.html b/httemplate/browse/part_pkg_report_option.html index 9745b13d2..00f2e8388 100644 --- a/httemplate/browse/part_pkg_report_option.html +++ b/httemplate/browse/part_pkg_report_option.html @@ -6,7 +6,7 @@ 'disabled_statuspos' => 2, 'query' => { 'table' => 'part_pkg_report_option', 'hashref' => {}, - 'extra_sql' => 'ORDER BY name', + 'order_by' => 'ORDER BY name', }, 'count_query' => 'SELECT COUNT(*) FROM part_pkg_report_option', 'header' => [ '#', 'Class' ], diff --git a/httemplate/browse/pkg_category.html b/httemplate/browse/pkg_category.html index 16da23066..2c181a3db 100644 --- a/httemplate/browse/pkg_category.html +++ b/httemplate/browse/pkg_category.html @@ -6,7 +6,7 @@ 'disabled_statuspos' => 3, 'query' => { 'table' => 'pkg_category', 'hashref' => {}, - 'extra_sql' => 'ORDER BY categorynum', + 'order_by' => 'ORDER BY categorynum', }, 'count_query' => $count_query, 'header' => [ '#', 'Category', 'Weight', 'Condense' ], diff --git a/httemplate/browse/pkg_class.html b/httemplate/browse/pkg_class.html index 7097c8617..97b0621ae 100644 --- a/httemplate/browse/pkg_class.html +++ b/httemplate/browse/pkg_class.html @@ -6,7 +6,7 @@ 'disabled_statuspos' => 2, 'query' => { 'table' => 'pkg_class', 'hashref' => {}, - 'extra_sql' => 'ORDER BY classnum', + 'order_by' => 'ORDER BY classnum', }, 'count_query' => $count_query, 'header' => $header, diff --git a/httemplate/browse/rate.cgi b/httemplate/browse/rate.cgi index 428158a6d..c6cfec074 100644 --- a/httemplate/browse/rate.cgi +++ b/httemplate/browse/rate.cgi @@ -9,7 +9,7 @@ 'name' => 'rate plans', 'query' => { 'table' => 'rate', 'hashref' => {}, - 'extra_sql' => 'ORDER BY ratenum', + 'order_by' => 'ORDER BY ratenum', }, 'count_query' => $count_query, 'header' => [ '#', 'Rate plan', 'Rates' ], diff --git a/httemplate/browse/svc_acct_pop.cgi b/httemplate/browse/svc_acct_pop.cgi index 501d3625a..e71a8a732 100755 --- a/httemplate/browse/svc_acct_pop.cgi +++ b/httemplate/browse/svc_acct_pop.cgi @@ -46,7 +46,7 @@ my $query = { 'select' => '*, ', 'table' => 'svc_acct_pop', #'hashref' => { 'disabled' => '' }, - 'extra_sql' => 'ORDER BY state, city, ac, exch, loc', + 'order_by' => 'ORDER BY state, city, ac, exch, loc', }; my $count_query = "SELECT COUNT(*) FROM svc_acct_pop"; # WHERE DISABLED IS NULL OR DISABLED = ''"; diff --git a/httemplate/browse/usage_class.html b/httemplate/browse/usage_class.html index 75223e025..7e55dba2a 100644 --- a/httemplate/browse/usage_class.html +++ b/httemplate/browse/usage_class.html @@ -6,7 +6,7 @@ 'disabled_statuspos' => 2, 'query' => { 'table' => 'usage_class', 'hashref' => {}, - 'extra_sql' => 'ORDER BY classnum', + 'order_by' => 'ORDER BY classnum', }, 'count_query' => 'SELECT COUNT(*) FROM usage_class', 'header' => [ '#', diff --git a/httemplate/search/cust_bill.html b/httemplate/search/cust_bill.html index cf6ce4999..4e40fb06d 100755 --- a/httemplate/search/cust_bill.html +++ b/httemplate/search/cust_bill.html @@ -22,6 +22,13 @@ sub { time2str('%b %d %Y', shift->_date ) }, \&FS::UI::Web::cust_fields, ], + 'sort_fields' => [ + 'COALESCE( agent_invid, invnum )', + FS::cust_bill->owed_sql, + FS::cust_bill->net_sql, + 'charged', + '_date', + ], 'align' => 'rrrrl'.FS::UI::Web::cust_aligns(), 'links' => [ $link, diff --git a/httemplate/search/cust_bill_event.cgi b/httemplate/search/cust_bill_event.cgi index 16c9acdc7..90c89139c 100644 --- a/httemplate/search/cust_bill_event.cgi +++ b/httemplate/search/cust_bill_event.cgi @@ -113,7 +113,8 @@ my $sql_query = { FS::UI::Web::cust_sql_fields(), ), 'hashref' => {}, - 'extra_sql' => "$where ORDER BY _date ASC", + 'extra_sql' => $where, + 'order_by' => 'ORDER BY _date ASC', 'addl_from' => $join, }; diff --git a/httemplate/search/cust_bill_pay.html b/httemplate/search/cust_bill_pay.html index 4272d8669..1fc8ffd78 100644 --- a/httemplate/search/cust_bill_pay.html +++ b/httemplate/search/cust_bill_pay.html @@ -25,6 +25,16 @@ sub { shift->cust_pay_otaker }, \&FS::UI::Web::cust_fields, ], + 'sort_fields' => [ + 'amount', + 'invnum', + 'cust_bill_charged', + 'cust_bill_date', + '', + 'cust_pay_paid', + 'cust_pay_date', + '', + ], 'align' => 'rrrrlrrl'.FS::UI::Web::cust_aligns(), 'links' => [ '', diff --git a/httemplate/search/cust_bill_pkg.cgi b/httemplate/search/cust_bill_pkg.cgi index f2a5ccd4f..8b6b0cebd 100644 --- a/httemplate/search/cust_bill_pkg.cgi +++ b/httemplate/search/cust_bill_pkg.cgi @@ -74,6 +74,17 @@ sub { time2str('%b %d %Y', shift->_date ) }, \&FS::UI::Web::cust_fields, ], + 'sort_fields' => [ + 'setup', #broken in $unearned case i guess + ( $unearned ? ('', '') : () ), + ( $use_usage eq 'recurring' ? 'recur - usage' : + $use_usage eq 'usage' ? 'usage' + : 'recur' + ), + ( $undearned ? ('sdate', 'edate') : () ), + 'invnum', + '_date', + ], 'links' => [ #'', '', diff --git a/httemplate/search/cust_bill_pkg_discount.html b/httemplate/search/cust_bill_pkg_discount.html index b472366be..bb8038a44 100644 --- a/httemplate/search/cust_bill_pkg_discount.html +++ b/httemplate/search/cust_bill_pkg_discount.html @@ -26,6 +26,14 @@ sub { time2str('%b %d %Y', shift->_date ) }, \&FS::UI::Web::cust_fields, ], + 'sort_fields' => [ + '', + 'amount', + 'months', + 'pkg', + 'invnum', + '_date', + ], 'links' => [ #'', '', #link to customer discount??? diff --git a/httemplate/search/cust_credit.html b/httemplate/search/cust_credit.html index a3b22b113..43f112f8b 100755 --- a/httemplate/search/cust_credit.html +++ b/httemplate/search/cust_credit.html @@ -7,6 +7,7 @@ #'redirect' => $link, 'header' => \@header, 'fields' => \@fields, + 'sort_fields' => \@sort_fields, 'align' => $align, 'links' => \@links, 'color' => \@color, @@ -32,12 +33,13 @@ my $clink = sub { : ''; }; -my (@header, @fields, $align, @links, @color, @style); +my (@header, @fields, @sort_fields, $align, @links, @color, @style); $align = ''; #amount push @header, 'Amount'; push @fields, sub { $money_char .sprintf('%.2f', shift->amount) }; +push @sort_fields, 'amount'; $align .= 'r'; push @links, ''; push @color, ''; @@ -47,6 +49,7 @@ push @style, ''; if ($unapplied) { push @header, 'Unapplied'; push @fields, sub { $money_char .sprintf('%.2f', shift->unapplied_amount) }; + push @sort_fields, ''; $align .= 'r'; push @links, ''; push @color, ''; @@ -63,6 +66,7 @@ push @fields, sub { time2str('%b %d %Y', shift->_date ) }, 'reason', \&FS::UI::Web::cust_fields, ; +push @sort_fields, '_date', 'otaker', 'reason'; $align .= 'rll'.FS::UI::Web::cust_aligns(), push @links, '', '', diff --git a/httemplate/search/cust_credit_bill.html b/httemplate/search/cust_credit_bill.html index 818e603a1..7f9eb7887 100644 --- a/httemplate/search/cust_credit_bill.html +++ b/httemplate/search/cust_credit_bill.html @@ -30,6 +30,13 @@ sub { shift->cust_credit->reason }, \&FS::UI::Web::cust_fields, ], + 'sort_fields' => [ + 'amount', + 'invnum', + 'cust_credit_amount', #? + '', #'otaker' #this is usernum now + '', + ], 'align' => 'rrrll'.FS::UI::Web::cust_aligns(), 'links' => [ '', diff --git a/httemplate/search/cust_credit_refund.html b/httemplate/search/cust_credit_refund.html index d9abe2e00..fd87aa575 100644 --- a/httemplate/search/cust_credit_refund.html +++ b/httemplate/search/cust_credit_refund.html @@ -28,6 +28,11 @@ sub { shift->cust_refund->otaker }, \&FS::UI::Web::cust_fields, ], + 'sort_fields' => [ + 'amount', + '', #cust_credit_amount? cust_credit_date? prolly split field + '', #_date? cust_refund_refund? also split + ], 'align' => 'rrrl'.FS::UI::Web::cust_aligns(), 'links' => [ '', diff --git a/httemplate/search/cust_event.html b/httemplate/search/cust_event.html index a0429e44f..503f252bd 100644 --- a/httemplate/search/cust_event.html +++ b/httemplate/search/cust_event.html @@ -188,7 +188,8 @@ my $sql_query = { FS::UI::Web::cust_sql_fields(), ), 'hashref' => {}, - 'extra_sql' => "$where ORDER BY _date ASC", + 'extra_sql' => $where, + 'order_by' => 'ORDER BY _date ASC', 'addl_from' => $join, }; diff --git a/httemplate/search/cust_pkg_svc.html b/httemplate/search/cust_pkg_svc.html index 4f27d6617..9c5b32fc7 100644 --- a/httemplate/search/cust_pkg_svc.html +++ b/httemplate/search/cust_pkg_svc.html @@ -78,7 +78,8 @@ my $sql_query = { 'table' => 'cust_svc', 'addl_from' => $addl_from, 'hashref' => {}, - 'extra_sql' => "$extra_sql $orderby", + 'extra_sql' => $extra_sql, + 'order_by' => $orderby, }; #warn Dumper($sql_query)."\n"; diff --git a/httemplate/search/cust_svc.html b/httemplate/search/cust_svc.html index 2c17561f2..a2cdc8a2d 100644 --- a/httemplate/search/cust_svc.html +++ b/httemplate/search/cust_svc.html @@ -110,7 +110,8 @@ my $sql_query = { 'table' => 'cust_svc', 'addl_from' => $addl_from, 'hashref' => {}, - 'extra_sql' => "$extra_sql $orderby", + 'extra_sql' => $extra_sql, + 'order_by' => $orderby, }; my $count_query = "SELECT COUNT(*) FROM cust_svc $addl_from $extra_sql"; diff --git a/httemplate/search/elements/cust_pay_or_refund.html b/httemplate/search/elements/cust_pay_or_refund.html index 6f4aaf848..fccb9eef7 100755 --- a/httemplate/search/elements/cust_pay_or_refund.html +++ b/httemplate/search/elements/cust_pay_or_refund.html @@ -48,6 +48,7 @@ Examples: 'redirect_empty' => $opt{'redirect_empty'}, 'header' => \@header, 'fields' => \@fields, + 'sort_fields' => \@sort_fields, 'align' => $align, 'links' => \@links, 'color' => \@color, @@ -135,6 +136,7 @@ if ( $cgi->param('tax_names') ) { my @header = (); my @fields = (); +my @sort_fields = (); my $align = ''; my @links = (); if ( $opt{'pre_header'} ) { @@ -142,6 +144,7 @@ if ( $opt{'pre_header'} ) { $align .= 'c' x scalar(@{ $opt{'pre_header'} }); push @links, map '', @{ $opt{'pre_header'} }; push @fields, @{ $opt{'pre_fields'} }; + push @sort_fields, @{ $opt{'pre_fields'} }; } push @header, "\u$name_singular", @@ -152,18 +155,21 @@ push @links, '', ''; push @fields, 'payby_payinfo_pretty', sub { sprintf('$%.2f', shift->$amount_field() ) }, ; +push @sort_fields, '', $amount_field; if ( $unapplied ) { push @header, 'Unapplied'; $align .= 'r'; push @links, ''; push @fields, sub { sprintf('$%.2f', shift->unapplied_amount) }; + push @sort_fields, ''; } push @header, 'Date'; $align .= 'r'; push @links, ''; push @fields, sub { time2str('%b %d %Y', shift->_date ) }; +push @sort_fields, '_date'; unless ( $opt{'disable_by'} ) { push @header, 'By'; @@ -414,7 +420,8 @@ if ( $cgi->param('magic') ) { 'table' => $table, 'select' => join(', ', @select), 'hashref' => {}, - 'extra_sql' => "$search $group_by ORDER BY $orderby", + 'extra_sql' => "$search $group_by", + 'order_by' => "ORDER BY $orderby", 'addl_from' => $addl_from, }; diff --git a/httemplate/search/elements/search-html.html b/httemplate/search/elements/search-html.html index 98f9c4476..d6cc62691 100644 --- a/httemplate/search/elements/search-html.html +++ b/httemplate/search/elements/search-html.html @@ -190,11 +190,26 @@ % my $h2 = 0; % my $colspan = 0; +% my @fields = @{ $opt{'sort_fields'} || $opt{'fields'}}; +% my $order_by = $cgi->param('order_by'); % foreach my $header ( @{ $opt{header} } ) { +% +% my $field = shift @fields; +% % $colspan-- if $colspan > 0; % next if $colspan; % % my $label = ref($header) ? $header->{label} : $header; +% unless ( ref($field) || !$field ) { +% if ( $order_by eq $field ) { +% $cgi->param('order_by', "$field DESC"); +% } else { +% $cgi->param('order_by', $field); +% } +% $label = qq($label); +% } +% % $colspan = ref($header) ? $header->{colspan} : 0; % my $rowspan = 1; % my $style = ''; diff --git a/httemplate/search/elements/search.html b/httemplate/search/elements/search.html index 218816938..a8e9f086a 100644 --- a/httemplate/search/elements/search.html +++ b/httemplate/search/elements/search.html @@ -132,7 +132,10 @@ Example: # qsearch hashref and header & fields need to # be defined) - # link & display properties for fields + # sort, link & display properties for fields + + 'sort_fields' => [], #optional list of field names or SQL expressions for + # sorts #listref - each item is the empty string, # or a listref of link and method name to append, @@ -369,6 +372,13 @@ unless ( $type =~ /^(csv|\w*.xls)$/) { } +#order by override +my $order_by = ''; +#if ( $cgi->param('order_by') =~ /^([\w\, ]+)$/ ) { +# $order_by = $1; +#} +$order_by = $cgi->param('order_by') if $cgi->param('order_by'); + # run the query my $header = [ map { ref($_) ? $_->{'label'} : $_ } @{$opt{header}} ]; @@ -378,6 +388,20 @@ if ( ref($opt{query}) ) { my @query; if (ref($opt{query}) eq 'HASH') { @query = ( $opt{query} ); + + if ( $order_by ) { + if ( $opt{query}->{'order_by'} ) { + if ( $opt{query}->{'order_by'} =~ /^(\s*ORDER\s+BY\s+)?(\S.*)$/is ) { + $opt{query}->{'order_by'} = "ORDER BY $order_by, $2"; + } else { + warn "unparsable query order_by: ". $opt{query}->{'order_by'}; + die "unparsable query order_by: ". $opt{query}->{'order_by'}; + } + } else { + $opt{query}->{'order_by'} = "ORDER BY $order_by"; + } + } + } elsif (ref($opt{query}) eq 'ARRAY') { @query = @{ $opt{query} }; } else { diff --git a/httemplate/search/pay_batch.cgi b/httemplate/search/pay_batch.cgi index ebd323e13..6d571b42f 100755 --- a/httemplate/search/pay_batch.cgi +++ b/httemplate/search/pay_batch.cgi @@ -3,7 +3,8 @@ 'name_singular' => 'batch', 'query' => { 'table' => 'pay_batch', 'hashref' => $hashref, - 'extra_sql' => "$extra_sql ORDER BY batchnum DESC", + 'extra_sql' => $extra_sql, + 'order_by' => 'ORDER BY batchnum DESC', }, 'count_query' => "$count_query $extra_sql", 'header' => [ 'Batch', diff --git a/httemplate/search/queue.html b/httemplate/search/queue.html index e5f7aed6a..1c124706c 100644 --- a/httemplate/search/queue.html +++ b/httemplate/search/queue.html @@ -4,7 +4,7 @@ 'html_form' => qq!
!, 'query' => { 'table' => 'queue', 'hashref' => $hashref, - 'extra_sql' => 'ORDER BY jobnum', + 'order_by' => 'ORDER BY jobnum', }, 'count_query' => $count_query, 'header' => [ '#', diff --git a/httemplate/search/svc_domain.cgi b/httemplate/search/svc_domain.cgi index 08ffdba5e..9827b8d38 100755 --- a/httemplate/search/svc_domain.cgi +++ b/httemplate/search/svc_domain.cgi @@ -97,7 +97,8 @@ my $sql_query = { 'cust_main.custnum', FS::UI::Web::cust_sql_fields(), ), - 'extra_sql' => "$extra_sql $orderby", + 'extra_sql' => $extra_sql, + 'order_by' => $orderby, 'addl_from' => $addl_from, }; diff --git a/httemplate/search/svc_external.cgi b/httemplate/search/svc_external.cgi index f0617542a..cb51d44fd 100755 --- a/httemplate/search/svc_external.cgi +++ b/httemplate/search/svc_external.cgi @@ -121,7 +121,8 @@ my $sql_query = { 'cust_main.custnum', FS::UI::Web::cust_sql_fields(), ), - 'extra_sql' => "$extra_sql $orderby", + 'extra_sql' => $extra_sql, + 'order_by' => $orderby, 'addl_from' => $addl_from, }; diff --git a/httemplate/search/svc_forward.cgi b/httemplate/search/svc_forward.cgi index 2bcd0c8c8..f17f131ab 100755 --- a/httemplate/search/svc_forward.cgi +++ b/httemplate/search/svc_forward.cgi @@ -89,7 +89,8 @@ my $sql_query = { 'cust_main.custnum', FS::UI::Web::cust_sql_fields(), ), - 'extra_sql' => "$extra_sql $orderby", + 'extra_sql' => $extra_sql, + 'order_by' => $orderby, 'addl_from' => $addl_from, }; diff --git a/httemplate/search/svc_phone.cgi b/httemplate/search/svc_phone.cgi index 0ad458b72..29434083f 100644 --- a/httemplate/search/svc_phone.cgi +++ b/httemplate/search/svc_phone.cgi @@ -161,7 +161,8 @@ my $sql_query = { 'cust_main.custnum', FS::UI::Web::cust_sql_fields(), ), - 'extra_sql' => "$extra_sql $orderby", + 'extra_sql' => $extra_sql, + 'order_by' => $orderby, 'addl_from' => $addl_from, }; diff --git a/httemplate/search/svc_www.cgi b/httemplate/search/svc_www.cgi index 2e3c4615b..adc31c88a 100755 --- a/httemplate/search/svc_www.cgi +++ b/httemplate/search/svc_www.cgi @@ -96,7 +96,8 @@ my $sql_query = { 'cust_main.custnum', FS::UI::Web::cust_sql_fields(), ), - 'extra_sql' => "$extra_sql $orderby", + 'extra_sql' => $extra_sql, + 'order_by' => $orderby, 'addl_from' => $addl_from, }; -- 2.11.0