[rt-users] number tickets returned by a search?

Phil Homewood pdh at snapgear.com
Sun Oct 6 21:45:57 EDT 2002


Grant Miller wrote:
> > I'm trying to put a little text into Search/Listing.html to tell the user
> > how many tickets were returned in the search they just ran.
> > 
> I figured it out, had to get the count right after 
> $session{'tickets'}->RedoSearch();
> 
> Then I put in
> 
<snip>
> 
> To have it only show those links if there's more than a page of tickets
> returned.

Building on (and including) Grant's work, the attached patch
should also prevent the "Previous page" link on the first page,
and the "Next page" link on the last. Whee.
-- 
Phil Homewood, Systems Janitor, www.SnapGear.com
pdh at snapgear.com Ph: +61 7 3435 2810 Fx: +61 7 3891 3630
SnapGear - Custom Embedded Solutions and Security Appliances
-------------- next part --------------
Index: webrt/Search/Listing.html
===================================================================
RCS file: /cvs/local/rt/webrt/Search/Listing.html,v
retrieving revision 1.4
diff -u -r1.4 Listing.html
--- webrt/Search/Listing.html	15 Jul 2002 01:30:27 -0000	1.4
+++ webrt/Search/Listing.html	7 Oct 2002 01:41:53 -0000
@@ -39,8 +39,10 @@
 <%PERL>
 
 my $i;
+my $ticketcount;
       
 $session{'tickets'}->RedoSearch();
+$ticketcount=$session{'tickets'}->Count();
 while (my $Ticket = $session{'tickets'}->Next) {
  $i++;
  if ($i % 2) {
@@ -63,19 +65,32 @@
 </TABLE>
 
 <div align=center>
+%if ($ticketcount > $session{'tickets_rows_per_page'}) {
 <font size=2>
 <a href="Listing.html?GotoPage=1">First page</a>
   
+%  if ( $session{'tickets'}->FirstRow >= $session{'tickets_rows_per_page'}-1 ) {
 <a href="Listing.html?GotoPage=Prev"><Previous page</a>
   
+%  }
+%  if ( $session{'tickets'}->FirstRow + $session{'tickets_rows_per_page'} < $ticketcount ) {
 <a href="Listing.html?GotoPage=Next">Next page></a>
+%  }
 %#  <form method=get action="Listing.html">Goto page <input name=GotoPage size=2></form>
 </font>
+%}
 </div>
 % if ($session{'tickets'}->Count()) { 
-<div align=right>
+<table width="100%" border=0 cellpadding=3 CELLSPACING=1>
+<tr>
+<td align=left>
+<% $ticketcount %> result(s) found
+</td>
+<td align=right>
 <a href="Bulk.html">Update all these tickets at once</a>
-</div>
+</td>
+</tr>
+</table>
 % }
 <HR>
 


More information about the rt-users mailing list