invoice_sections_with_taxes per-agent, RT#79636
[freeside.git] / httemplate / elements / pager.html
1 % if ( $opt{'total'} != $opt{'num_rows'} && $opt{'maxrecords'} ) {
2 %
3 %   unless ( $opt{'offset'} == 0 ) {
4 %     $cgi->param('offset', $opt{'offset'} - $opt{'maxrecords'});
5       <A HREF="<% $cgi->self_url %>"><B><FONT SIZE="+1">Previous</FONT></B></A>
6 %   }
7 %
8 %   my $page = 0;
9 %   my $prevpage = 0;
10 %   my $over = 0;
11 %   my $step = $opt{total} / 10; # 10 evenly spaced
12 %   for ( my $poff = 0; $poff < $opt{total}; $poff += $opt{maxrecords} ) {
13 %     $page++;
14 %       
15 %     next unless
16 %          $page <= 4                                          #first four
17 %       || $page >= ( $opt{total} / $opt{maxrecords} ) - 3     #last four
18 %       || abs( ($opt{offset}-$poff) / $opt{maxrecords} ) <= 3 #w/i 3 of current
19 %       || $poff > $over                                       # evenly spaced
20 %     ;           
21 %
22 %     $over += $step if $poff > $over;
23 %
24 %     if ( $opt{'offset'} == $poff ) {
25
26         <FONT SIZE="+2"><% $page %></FONT>
27
28 %     } else {
29 %       $cgi->param('offset', $poff);
30 %
31 %       if ( $page > $prevpage+1 ) {
32           ...
33 %       }
34
35         <A HREF="<% $cgi->self_url %>"><% $page %></A>
36
37 %     }
38 %
39 %     $prevpage = $page;
40 %
41 %   }
42 %
43 %   unless ( $opt{'offset'} + $opt{'maxrecords'} > $opt{'total'} ) {
44 %     $cgi->param('offset', $opt{'offset'} + $opt{'maxrecords'});
45       <A HREF="<% $cgi->self_url %>"><B><FONT SIZE="+1">Next</FONT></B></A>
46 %   }
47 %
48 %   $cgi->param('offset', $orig_offset); #so future $self_url invocations don't advance a page
49 %
50 % }
51 <%init>
52
53 my %opt = @_;
54
55 my $orig_offset = $opt{'offset'};
56
57 </%init>
58