&|Elements/Wrapper, %ARGS, title => loc("Activity detail"),
path => "Reports/Activity/ActivityDetail.html",
&>
<& Elements/MiniPlot, data => \%counts &>
Queue | Activity | Date | Time | Ticket # | User | Short description |
% for my $item (@items) {
<% $item->{queue} %> |
<% $item->{status} %> |
<% $item->{date} %> |
<% $item->{time} %> |
<% $item->{id} %> |
<% $item->{actor} %> |
<% $item->{notes} %> |
% }
&>
<%args>
$query => 'id > 0'
$start => "2005/01/01"
$end => "2006/01/01"
%args>
<%init>
my $summary_tickets = RT::Tickets->new($session{'CurrentUser'});
$summary_tickets->FromSQL($query . " AND ( Updated >= '$start' AND Updated <= '$end')");
my %counts;
while (my $ticket = $summary_tickets->Next) {
my $txns = $ticket->Transactions;
$txns->Limit(FIELD => 'Created', OPERATOR => '>=', VALUE => $start);
$txns->Limit(FIELD => 'Created', OPERATOR => '<=', VALUE => $end);
# I think they really don't just want status changes
$txns->Limit(FIELD => 'Type', VALUE => 'Status', ENTRYAGGREGATOR => 'OR');
$txns->Limit(FIELD => 'Type', VALUE => 'Create');
while (my $txn = $txns->Next){
my $date = substr($txn->Created, 0, 10);
# we don't have data on the status of a new ticket, default to 'new'
$counts{$date}{$txn->NewValue || 'new'}++;
}
}
my $tickets = RT::Tickets->new($session{'CurrentUser'});
$tickets->FromSQL($query);
my @items;
while (my $ticket = $tickets->Next) {
my $txns = $ticket->Transactions;
$txns->Limit(FIELD => 'Created', OPERATOR => '>=', VALUE => $start);
$txns->Limit(FIELD => 'Created', OPERATOR => '<=', VALUE => $end);
# I think they really don't just want status changes
$txns->Limit(FIELD => 'Type', VALUE => 'Status', ENTRYAGGREGATOR => 'OR');
$txns->Limit(FIELD => 'Type', VALUE => 'Create');
while (my $txn = $txns->Next) {
push @items, { queue => $txn->TicketObj->QueueObj->Name,
id => $txn->TicketObj->id,
date => (split ' ', $txn->CreatedObj->ISO)[0],
time => (split ' ', $txn->CreatedObj->ISO)[1],
status => $txn->NewValue || 'new',
actor => $txn->CreatorObj->Name,
notes => ($txn->Content ne 'This transaction appears to have no content' ? substr($txn->Content, 0, 60) : $txn->BriefDescription)
};
}
}
@items = sort {
$a->{queue} cmp $b->{'queue'}
|| $a->{'status'} cmp $b->{'status'}
|| $a->{'id'} <=> $b->{'id'}
|| $a->{'actor'} cmp $b->{'actor'}
|| $a->{'notes'} <=> $b->{'notes'}
} @items;
%init>