[Bps-public-commit] r10976 - RT-Extension-Reports/html/Reports/Types

sunnavy at bestpractical.com sunnavy at bestpractical.com
Mon Mar 3 03:51:28 EST 2008


Author: sunnavy
Date: Mon Mar  3 03:51:28 2008
New Revision: 10976

Modified:
   RT-Extension-Reports/html/Reports/Types/Created

Log:
updated Created page

Modified: RT-Extension-Reports/html/Reports/Types/Created
==============================================================================
--- RT-Extension-Reports/html/Reports/Types/Created	(original)
+++ RT-Extension-Reports/html/Reports/Types/Created	Mon Mar  3 03:51:28 2008
@@ -52,6 +52,13 @@
 <form>
 <table align="center">
 <tr>
+<td />
+<td>
+<input type="radio" name="Type" value="simple">Simple</input>
+<input type="radio" name="Type" value="verbose">Verbose</input>
+</td>
+</tr>
+<tr>
 <td><&|/l&>Start Date</&></td>
 <td><& /Elements/SelectDate, Name => 'StartDate', current => 0, Default =>
 $StartDate &>
@@ -75,29 +82,19 @@
 <table>
 </form>
 
-<table border="0" cellspacing="0" cellpadding="1" width="100%">
-<tr class="collection-as-table">
-% for my $column ( @columns ) {
-<th class="collection-as-table"><% $column %></th>
-% }
-</tr>
-% my $odd = 1;
-% for my $row ( @output ) {
-<tr class=<% $odd++ % 2 ? "oddline" : "evenline"%>>
-% for my $item ( @$row ) {
-<td class="collection-as-table"><%$item%></td>
-% }
-</tr>
-% }
-</table>
+<& /Reports/Elements/ShowResults, Headers => \@headers, Results => \@results &>
+
 
 <%INIT>
 
-my ( @columns, $num, @output );
+my ( @headers, $num, @results, %data );
 
 
 if ( $Run ) {
-    @columns = qw/Date Created/;
+    @headers = qw/Date Queue Created/;
+    if ( $Type eq 'verbose' ) {
+        push @headers, 'Open', 'Resolved';
+    }
 
     my ( $start_date, $end_date );
     $start_date = RT::Date->new( $session{CurrentUser} );
@@ -109,15 +106,16 @@
     $end_date->AddDay; # we want the date ranage to be inclusive
     my $tickets = RT::Tickets->new( $session{CurrentUser} );
 
+    $tickets->FromSQL( q{ Created >= '} . $start_date->ISO . q{ ' AND
+Created < '} . $end_date->ISO . q{'} );
+
     my $tmp_date = RT::Date->new( $session{CurrentUser} );
     $tmp_date->Set( Value => $start_date->Unix );
     while ( $tmp_date->Unix < $end_date->Unix ) {
-        push @output, [ $tmp_date->Date, 0 ];
+        $data{$tmp_date->Date} = {};
         $tmp_date->AddDay;
     }
 
-    $tickets->FromSQL( q{ Created >= '} . $start_date->ISO . q{ ' AND
-Created < '} . $end_date->ISO . q{'} );
 
     TICKET:
     while ( my $ticket = $tickets->Next ) {
@@ -133,32 +131,32 @@
                     => $ticket, Value => $value, Operator => $op, Field =>
                     $field );
         }
-        $output[int( ($ticket->CreatedObj->Unix - $start_date->Unix)/(3600*24)
-)]->[1]++;
-    }
-    if ( $ARGS{csv} ) {
-        $r->content_type( 'text/csv' );
-        $m->out( "Date,Created\n" );
-        for ( @output ) {
-            $m->out( join ',', @$_ );
-            $m->out( "\n" );
+        $data{$ticket->CreatedObj->Date}{$ticket->QueueObj->Name}[0]++; # Created
+        if ( $Type eq 'verbose' ) {
+            require RT::Extension::Reports::Util;
+            if ( RT::Extension::Reports::Util::is_open($ticket) ) {
+                $data{$ticket->CreatedObj->Date}{$ticket->QueueObj->Name}[1]++; # Resolved
+            }
+            else {
+                $data{$ticket->CreatedObj->Date}{$ticket->QueueObj->Name}[2]++; # Open
+            }
         }
-        $m->abort;
     }
-    elsif ( $ARGS{chart} ) {
-        $r->content_type( 'image/png' );
-        require GD::Graph::bars;
-        my $graph = GD::Graph::bars->new( 800, 600 );
-        my @data;
-        for ( my $i = 0; $i < @output; $i++ ) {
-            for ( my $j = 0; $j < @{$output[$i]}; $j++ ) {
-                $data[$j][$i] = $output[$i][$j];
+
+    for ( sort keys %data ) {
+        if ( keys %{$data{$_}} == 0 ) {
+            push @results, [$_];
+        }
+        else {
+            for my $queue ( sort keys %{$data{$_}} ) {
+                push @results, [ $_, $queue, @{$data{$_}{$queue}} ];
             }
         }
-        
-        my $gd = $graph->plot(\@data) or die $graph->error;
-        $m->out( $gd->png );
-        $m->abort;
+    }
+
+    if ( $ARGS{csv} || $ARGS{chart} ) {
+        $m->comp( '/Reports/Elements/ShowResults', Headers => \@headers,
+Results => \@results, Type => $ARGS{csv} ? 'csv' : 'chart' );
     }
 }
 else {
@@ -177,5 +175,6 @@
 $EndDate => undef
 $Run => undef
 $Filter => undef
+$Type => 'simple'
 </%ARGS>
 



More information about the Bps-public-commit mailing list