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

sunnavy at bestpractical.com sunnavy at bestpractical.com
Fri Feb 29 06:57:20 EST 2008


Author: sunnavy
Date: Fri Feb 29 06:57:18 2008
New Revision: 10963

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

Log:
sample csv and chart support

Modified: RT-Extension-Reports/html/Reports/Types/TicketsNumber
==============================================================================
--- RT-Extension-Reports/html/Reports/Types/TicketsNumber	(original)
+++ RT-Extension-Reports/html/Reports/Types/TicketsNumber	Fri Feb 29 06:57:18 2008
@@ -67,7 +67,9 @@
 </tr>
 <tr><td /><td>
 <input type="hidden" name="Run" value=1>
-<input type="submit" value="submit" />
+<input type="submit" name="screen" value="Submit" />
+<input type="submit" name="csv" value="CSV File" />
+<input type="submit" name="chart" value="Chart" />
 </td>
 </tr>
 <table>
@@ -120,6 +122,30 @@
         $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" );
+        }
+        $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];
+            }
+        }
+        
+        my $gd = $graph->plot(\@data) or die $graph->error;
+        $m->out( $gd->png );
+        $m->abort;
+    }
 }
 else {
     my $today = RT::Date->new($session{CurrentUser});



More information about the Bps-public-commit mailing list