-%
-%
% # options example...
% # (everything not commented required is optional)
% #
%
% my $type = '';
% my $limit = '';
-% my($maxrecords, $total, $offset, $count_arrayref);
+% my($confmax, $maxrecords, $total, $offset, $count_arrayref);
%
% if ( $cgi->param('_type') =~ /^(csv|\w*\.xls)$/ ) {
%
%
% unless (exists($opt{'count_query'}) && length($opt{'count_query'})) {
% ( $opt{'count_query'} = $opt{'query'} ) =~
-% s/^\s*SELECT\s*(.*?)\s+FROM\s/SELECT COUNT(*) FROM /i;
+% s/^\s*SELECT\s*(.*?)\s+FROM\s/SELECT COUNT(*) FROM /i; #silly vim:/
% }
%
% my $conf = new FS::Conf;
-% $maxrecords = $conf->config('maxsearchrecordsperpage');
+% $confmax = $conf->config('maxsearchrecordsperpage');
+% if ( $cgi->param('maxrecords') =~ /^(\d+)$/ ) {
+% $maxrecords = $1;
+% } else {
+% $maxrecords ||= $confmax;
+% }
%
% $limit = $maxrecords ? "LIMIT $maxrecords" : '';
%
)
: ''
%>
-% my $pager = include ( '/elements/pager.html',
-% 'offset' => $offset,
-% 'num_rows' => scalar(@$rows),
-% 'total' => $total,
-% 'maxrecords' => $maxrecords,
-% );
%
% unless ( $total ) {
% unless ( $opt{'disable_nonefound'} ) {
% }
% } else {
-
<TABLE>
<TR>
+
<TD VALIGN="bottom">
+
+ <FORM>
+
<% $total %> total <% $opt{'name'} %>
+
+% if ( $confmax && $total > $confmax ) {
+% $cgi->delete('maxrecords');
+% $cgi->param('_dummy', 1);
+
+%# ( show <SELECT NAME="maxrecords" onChange="this.form.submit();">
+ ( show <SELECT NAME="maxrecords" onChange="window.location = '<% $cgi->self_url %>;maxrecords=' + this.options[this.selectedIndex].value;">
+
+% foreach my $max ( map { $_ * $confmax } qw( 1 5 10 25 ) ) {
+ <OPTION VALUE="<% $max %>" <% ( $maxrecords == $max ) ? 'SELECTED' : '' %>><% $max %></OPTION>
+% }
+
+ </SELECT> per page )
+
+% $cgi->param('maxrecords', $maxrecords);
+% }
+
+
<% defined($opt{'html_posttotal'})
? ( ref($opt{'html_posttotal'})
? &{$opt{'html_posttotal'}}()
: ''
%>
<BR>
+
% if ( $opt{'count_addl'} ) {
-% my $n=0; foreach my $count ( @{$opt{'count_addl'}} ) {
+% my $n=0; foreach my $count ( @{$opt{'count_addl'}} ) {
- <% sprintf( $count, $count_arrayref->[++$n] ) %><BR>
-% }
+ <% sprintf( $count, $count_arrayref->[++$n] ) %><BR>
+
+% }
% }
+ </FORM>
</TD>
+
% unless ( $opt{'disable_download'} ) {
<TD ALIGN="right">
as <A HREF="<% $cgi->self_url %>">CSV file</A>
</TD>
+% $cgi->param('_type', "html" );
% }
</TR>
<TR>
<TD COLSPAN=2>
- <% $pager %>
+
+ <% my $pager = include ( '/elements/pager.html',
+ 'offset' => $offset,
+ 'num_rows' => scalar(@$rows),
+ 'total' => $total,
+ 'maxrecords' => $maxrecords,
+ ) %>
<% include('/elements/table-grid.html') %>
<% include( '/elements/footer.html' ) %>
% }
% }
-