QuicksearchSummary

From Request Tracker Wiki
Jump to navigation Jump to search

A small patch to show a summary line at the bottom of the Quicksearch.

Example:
Queue		New	Open
Support	5	10
IT		3	5
ALL		8	15
 *** ../../share/html/Elements/Quicksearch      2005-02-01 15:20:40.000000000 +0100
 --- Elements/Quicksearch       2005-05-03 12:57:37.000000000 +0200
 ***************
 *** 54,59 ****
 --- 54,60 ----
 
   <%PERL>
   my $i;
 + my ($total_open,$total_new);
   while (my $queue = $Queues->Next) {
          next unless ($queue->CurrentUserHasRight('ShowTicket'));
 
 ***************
 *** 63,82 ****
 
       $Tickets->FromSQL($open_q);
        my $open = $Tickets->Count();
 
           $Tickets->FromSQL($new_q);
        my $new = $Tickets->Count();
 
 
 
   </%PERL>
   % $i++;
 ! <TR class="<% $i%2 ? 'oddline' : 'evenline'%>" >
   <td><A HREF="<% $RT::WebPath%>/Search/Results.html?Query=<%$all_q%>&Rows=50" TITLE="<% $queue->Description %>"><%$queue->Name%></a></TD>
   <td align="right"><A HREF="<% $RT::WebPath%>/Search/Results.html?Query=<%$new_q%>&Rows=50"><%$new%></a></TD>
   <td align="right"><A HREF="<% $RT::WebPath%>/Search/Results.html?Query=<%$open_q%>&Rows=50"><%$open%></a></TD>
   </TR>
   % }
   </TABLE>
   <& /Elements/TitleBoxEnd &>
 
 --- 64,92 ----
 
       $Tickets->FromSQL($open_q);
        my $open = $Tickets->Count();
 +      $total_open += $open;
 
           $Tickets->FromSQL($new_q);
        my $new = $Tickets->Count();
 +      $total_new += $new;
 
 
 
   </%PERL>
   % $i++;
 ! <TR class="<% $i%2 ? 'oddline' : 'evenline'%>" >
   <td><A HREF="<% $RT::WebPath%>/Search/Results.html?Query=<%$all_q%>&Rows=50" TITLE="<% $queue->Description %>"><%$queue->Name%></a></TD>
   <td align="right"><A HREF="<% $RT::WebPath%>/Search/Results.html?Query=<%$new_q%>&Rows=50"><%$new%></a></TD>
   <td align="right"><A HREF="<% $RT::WebPath%>/Search/Results.html?Query=<%$open_q%>&Rows=50"><%$open%></a></TD>
   </TR>
   % }
 + % $i++;
 +  <tr><td colspan="3"><hr style="color:black; background-color:black; height:1px;"></td></tr>
 +  <TR class="<% $i%2 ? 'oddline' : 'evenline'%>" >
 +  <td><A HREF="<% $RT::WebPath%>/Search/Results.html?Query=Status%20=%20'open'%20OR%20Status%20=%20'new'&Rows=50" TITLE="Alle neuen und offenen Tickets">Summe</a></TD>
 +  <td align="right"><A HREF="<% $RT::WebPath%>/Search/Results.html?Query=Status%20=%20'new'&Rows=50"><%$total_new%></a></TD>
 +  <td align="right"><A HREF="<% $RT::WebPath%>/Search/Results.html?Query=Status%20=%20'open'&Rows=50"><%$total_open%></a></TD>
 +  </TR>
   </TABLE>
   <& /Elements/TitleBoxEnd &>
 
 

--

Update for RT 3.4.4 with additional Information. Tested under RT 3.4.4 / Torsten Brumm

The Patch File can be downloaded under: <> http://www.torsten-brumm.de/wordpress/?page_id=241>; some more informations are also at the Site.

--- /opt/rt3/share/html/Elements/Quicksearch	2005-08-17 19:41:38.000000000 +0200
+++ /opt/rt3/local/html/Elements/Quicksearch	2005-12-01 10:30:03.000000000 +0100
@@ -49,11 +49,14 @@
<tr>
       <th class="collection-as-table" align=left><&|/l&>Queue</&></th>
       <th class="collection-as-table" align=right><&|/l&>New</&></th>
-       <th class="collection-as-table" align=right><&|/l&>Open</&></th>
+       <th class="collection-as-table" align=right><&|/l&>Open</&></th>
+       <th class="collection-as-table" align=right><&|/l&>Stalled</&></th>
+       <th class="collection-as-table" align=right><&|/l&>Resolved</&></th>
 </tr>

<%PERL>
my $i;
+my ($total_open,$total_new,$total_stalled,$total_resolved);
while (my $queue = $Queues->Next) {
  next unless ($queue->CurrentUserHasRight('ShowTicket'));

@@ -62,22 +65,46 @@

  my $new_q = "Queue = '$name' AND Status = 'new'";
  my $open_q = "Queue = '$name' AND Status = 'open'";
+  my $stalled_q = "Queue = '$name' AND Status = 'stalled'";
+  my $resolved_q = "Queue = '$name' AND Status = 'resolved'";
  my $all_q = "Queue = '$name' AND (Status = 'open' OR Status = 'new')";

  $Tickets->FromSQL($open_q);
  my $open = $Tickets->Count();
+  $total_open += $open;

  $Tickets->FromSQL($new_q);
  my $new = $Tickets->Count();
+  $total_new += $new;
+
+  $Tickets->FromSQL($stalled_q);
+  my $stalled = $Tickets->Count();
+  $total_stalled += $stalled;
+
+  $Tickets->FromSQL($resolved_q);
+  my $resolved = $Tickets->Count();
+  $total_resolved += $resolved;

  $i++;
-</%PERL>
-<TR class="<% $i%2 ? 'oddline' : 'evenline'%>" >
-<td><A HREF="<% $RT::WebPath%>/Search/Results.html?Query=<%$all_q |nu%>&Rows=50" TITLE="<% $queue->Description %>"><%$queue->Name%></a></TD>
-<td align="right"><A HREF="<% $RT::WebPath%>/Search/Results.html?Query=<%$new_q |nu%>&Rows=50"><%$new%></a></TD>
-<td align="right"><A HREF="<% $RT::WebPath%>/Search/Results.html?Query=<%$open_q |nu%>&Rows=50"><%$open%></a></TD>
+
+  </%PERL>
+<TR class="<% $i%2 ? 'oddline' : 'evenline'%>" >
+<td><A HREF="<% $RT::WebPath%>/Search/Results.html?Query=<%$all_q%>&Rows=50" TITLE="<% $queue->Description %>"><%$queue->Name%></a></TD>
+<td align="right"><A HREF="<% $RT::WebPath%>/Search/Results.html?Query=<%$new_q%>&Rows=50"><%$new%></a></TD>
+<td align="right"><A HREF="<% $RT::WebPath%>/Search/Results.html?Query=<%$open_q%>&Rows=50"><%$open%></a></TD>
+<td align="right"><A HREF="<% $RT::WebPath%>/Search/Results.html?Query=<%$stalled_q%>&Rows=50"><%$stalled%></a></TD>
+<td align="right"><A HREF="<% $RT::WebPath%>/Search/Results.html?Query=<%$resolved_q%>&Rows=50"><%$resolved%></a></TD>
</TR>
% }
+% $i++;
+<tr><td colspan="3"></td></tr>
+<TR class="<% $i%2 ? 'oddline' : 'evenline'%>" >
+<td><A HREF="<%  $RT::WebPath%>/Search/Results.html?Query=Status%20=%20'open'%20OR%20Status%20=%20'new'%20OR%20Status%20=%20'stalled'%20OR%20Status%20=%20'resolved'&Rows=50" TITLE="Sum of all new, open, stalled and resolved Tickets">Sum of:</a></TD>
+<td align="right"><A HREF="<% $RT::WebPath%>/Search/Results.html?Query=Status%20=%20'new'&Rows=50"><%$total_new%></a></TD>
+<td align="right"><A HREF="<% $RT::WebPath%>/Search/Results.html?Query=Status%20=%20'open'&Rows=50"><%$total_open%></a></TD>
+<td align="right"><A HREF="<% $RT::WebPath%>/Search/Results.html?Query=Status%20=%20'stalled'&Rows=50"><%$total_stalled%></a></TD>
 +<td align="right"><A HREF="<% $RT::WebPath%>/Search/Results.html?Query=Status%20=%20'resolved'&Rows=50"><%$total_resolved%></a></TD>
+</TR>
</TABLE>
<& /Elements/TitleBoxEnd &>

@@ -86,3 +113,4 @@
$Queues->UnLimit();
my $Tickets = RT::Tickets->new($session{'CurrentUser'});
</%INIT>
+