[Bps-public-commit] r10961 - in RT-Extension-Reports: html/Reports/Types
sunnavy at bestpractical.com
sunnavy at bestpractical.com
Fri Feb 29 03:27:33 EST 2008
Author: sunnavy
Date: Fri Feb 29 03:27:32 2008
New Revision: 10961
Modified:
RT-Extension-Reports/html/Reports/Types/TicketsNumber
RT-Extension-Reports/lib/RT/Extension/Reports.pm
Log:
created tickets numver sample
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 03:27:32 2008
@@ -46,12 +46,90 @@
%#
%# END BPS TAGGED BLOCK }}}
+<& /Elements/Header, Title => $Title &>
+<& /Elements/Tabs, Title => $Title, current_toptab => 'Reports' &>
+
+<form action="/Reports/Types/TicketsNumber">
+<table align="center">
+<tr>
+<td><&|/l&>Start Date</&></td>
+<td><& /Elements/SelectDate, Name => 'StartDate', current => 0, Default =>
+$StartDate &>
+</tr>
+<tr>
+<td><&|/l&>End Date</&></td>
+<td><& /Elements/SelectDate, Name => 'EndDate', current => 0, Default =>
+$EndDate &>
+</tr>
+<tr><td /><td>
+<input type="hidden" name="Run" value=1>
+<input type="submit" value="submit" />
+</td>
+<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>
+
<%INIT>
-my $tickets = RT::Tickets->new( $RT::SystemUser );
+
+my ( @columns, $num, @output );
+
+
+if ( $Run ) {
+ @columns = qw/Date Created/;
+
+ my ( $start_date, $end_date );
+ $start_date = RT::Date->new( $session{CurrentUser} );
+ $end_date = RT::Date->new( $session{CurrentUser} );
+ $start_date->Set( Format => 'iso', Value => $StartDate . ' 00:00:00' );
+ $end_date->Set( Format => 'iso', Value => $EndDate . ' 00:00:00' );
+
+
+ $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 ];
+ $tmp_date->AddDay;
+ }
+
+ while ( my $ticket = $tickets->Next ) {
+ $output[int( ($ticket->CreatedObj->Unix - $start_date->Unix)/(3600*24)
+)]->[1]++;
+ }
+}
+else {
+ my $today = RT::Date->new($session{CurrentUser});
+ $today->SetToNow;
+ $EndDate ||= $today->Date;
+ $today->AddDays( -7 );
+ $StartDate ||= $today->Date;
+}
</%INIT>
<%ARGS>
$Title => 'Number of Tickets'
+$StartDate => undef
+$EndDate => undef
+$Run => undef
</%ARGS>
Modified: RT-Extension-Reports/lib/RT/Extension/Reports.pm
==============================================================================
--- RT-Extension-Reports/lib/RT/Extension/Reports.pm (original)
+++ RT-Extension-Reports/lib/RT/Extension/Reports.pm Fri Feb 29 03:27:32 2008
@@ -9,7 +9,7 @@
=head1 NAME
-RT::Extension::Reports - [One line description of module's purpose here]
+RT::Extension::Reports - RT Reports
=head1 SYNOPSIS
More information about the Bps-public-commit
mailing list