[Rt-commit] r3088 - in rt/branches/QUEBEC-EXPERIMENTAL: . lib/RT/Report

jesse at bestpractical.com jesse at bestpractical.com
Wed Jun 8 16:57:16 EDT 2005


Author: jesse
Date: Wed Jun  8 16:57:16 2005
New Revision: 3088

Modified:
   rt/branches/QUEBEC-EXPERIMENTAL/   (props changed)
   rt/branches/QUEBEC-EXPERIMENTAL/lib/RT/Report/Tickets.pm
Log:
 r19629 at hualien:  jesse | 2005-06-08 16:50:45 -0400
 * Now ticket reports grouped by Status will show all statuses
   even if some values are 0


Modified: rt/branches/QUEBEC-EXPERIMENTAL/lib/RT/Report/Tickets.pm
==============================================================================
--- rt/branches/QUEBEC-EXPERIMENTAL/lib/RT/Report/Tickets.pm	(original)
+++ rt/branches/QUEBEC-EXPERIMENTAL/lib/RT/Report/Tickets.pm	Wed Jun  8 16:57:16 2005
@@ -32,6 +32,9 @@
 sub GroupBy {
     my $self = shift;
     my $field = shift;
+
+    $self->{'_group_by_field'} = $field; 
+
     my $function;
     (undef, $function) = $self->_FieldToFunction($field);
     $self->GroupByCols({ FIELD => $field, FUNCTION => $function});
@@ -48,6 +51,22 @@
     return $self->SUPER::Column(%args);
 }
 
+=head2 _DoSearch
+
+Subclass _DoSearch from our parent so we can go through and add in empty 
+columns if it makes sense 
+
+=cut
+
+sub _DoSearch {
+    my $self = shift;
+    $self->SUPER::_DoSearch(@_);
+    $self->AddEmptyRows();
+
+}
+
+
+
 =head2 _FieldToFunction FIELD
 
 Returns a tuple of the field or a database function to allow grouping on that 
@@ -108,7 +127,28 @@
 }
 
 
+=head2 AddEmptyRows
 
+If we're grouping on a criterion we know how to add zero-value rows
+for, do that.
 
+=cut
 
+sub AddEmptyRows {
+    my $self = shift;
+     if ( $self->{'_group_by_field'} eq 'Status' ) {
+            foreach my $status (RT::Queue->new($self->CurrentUser)->StatusArray ) {
+            unless ( grep { $_->__Value('Status') eq $status } @{ $self->ItemsArrayRef } )  {
+                my $record =     $self->NewItem;
+                $record->LoadFromHash(
+                        {
+                            id     => 0,
+                            status => $status
+                        }
+                    );
+                $self->AddRecord($record);
+            } 
+    }
+}
+}
 1;


More information about the Rt-commit mailing list