fix SQL query, RT#11127
[freeside.git] / httemplate / search / elements / search-html.html
index d8cc2fc..32f26e8 100644 (file)
 %                 $cgi->delete('maxrecords');
 %                 $cgi->param('_dummy', 1);
 
-                  ( show <SELECT NAME="maxrecords" onChange="window.location = '<% $self_url %>;maxrecords=' + this.options[this.selectedIndex].value;">
+                  ( show <SELECT NAME="maxrecords" onChange="window.location = '<% "$self_url?". $cgi->query_string %>;maxrecords=' + this.options[this.selectedIndex].value;">
 
 %                   foreach my $max ( map { $_ * $confmax } qw( 1 5 10 25 ) ) {
                   <OPTION VALUE="<% $max %>" <% ( $maxrecords == $max ) ? 'SELECTED' : '' %>><% $max %></OPTION>
                 Download full results<BR>
 
 %               $cgi->param('_type', "$xlsname.xls" ); 
-                as <A HREF="<% $cgi->self_url %>">Excel spreadsheet</A><BR>
+                as <A HREF="<% "$self_url?". $cgi->query_string %>">Excel spreadsheet</A><BR>
 
 %               $cgi->param('_type', 'csv'); 
-                as <A HREF="<% $cgi->self_url %>">CSV file</A><BR>
+                as <A HREF="<% "$self_url?". $cgi->query_string %>">CSV file</A><BR>
 
 %             if ( defined($opt{xml_elements}) ) {
 %               $cgi->param('_type', 'xml'); 
-                as <A HREF="<% $cgi->self_url %>">XML file</A><BR>
+                as <A HREF="<% "$self_url?". $cgi->query_string %>">XML file</A><BR>
 %             }
 
 %               $cgi->param('_type', 'html-print'); 
-                as <A HREF="<% $cgi->self_url %>">printable copy</A>
+                as <A HREF="<% "$self_url?". $cgi->query_string %>">printable copy</A>
 
               </TD>
 %             $cgi->param('_type', "html" ); 
                 <TR>
 %                 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(<A HREF="$self_url?). $cgi->query_string.
+%                              qq(">$label</A>);
+%                   }
+%
 %                   $colspan = ref($header) ? $header->{colspan} : 0;
 %                   my $rowspan = 1;
 %                   my $style = '';
@@ -464,7 +479,7 @@ my $confmax        = $args{'confmax'};
 my $maxrecords     = $args{'maxrecords'};
 my $offset         = $args{'offset'};
 my %opt            = %{ $args{'opt'} };
-my $self_url       = $opt{'url'} || $cgi->self_url;
+my $self_url       = $opt{'url'} || $cgi->url('-path_info' => 1, '-full' =>1);
 
 my $count_sth = dbh->prepare($opt{'count_query'})
   or die "Error preparing $opt{'count_query'}: ". dbh->errstr;