The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
<&| Elements/Wrapper, %ARGS, title => loc("Activity reports") &>
<& /Elements/ListActions, actions => \@actions &>

% if ($ReportType) {
%   if ($mode eq 'screen') {
      <& /Widgets/SavedSearch:show, %ARGS, Action => 'index.html', self => $saved_search, Title => 'Saved Activity reports' &>
%   }
<& /Search/Elements/ActivityReport, %ARGS &>
% }

</&>

<%args>
$ReportType => ''
$mode  => 'screen'
</%args>
<%init>
$ReportType = $ARGS{ReportType} ||= $ARGS{type} ||= '';
$ARGS{Start}      ||= $ARGS{start};
$ARGS{End}        ||= $ARGS{end};
$ARGS{Query}      ||= $ARGS{query};
delete $ARGS{$_} for qw(type start end query);

unless ($ARGS{Start}) {
    my $then = RT::Date->new($session{'CurrentUser'});
    $then->Set(Format => 'Unix', Value => time - (86400*7));
    $ARGS{Start} = substr($then->ISO,0,10);
}

unless ($ARGS{End}) {
    my $now = RT::Date->new($session{'CurrentUser'});
    $now->SetToNow();
    $ARGS{End} = substr($now->ISO,0,10);
}

$ARGS{show_print_link} = 0 unless $ReportType;

$m->callback( CallbackName => 'FlipInvoiced', %ARGS );

my $saved_search = $m->comp( '/Widgets/SavedSearch:new',
    SearchType   => 'ActivityReport',
    SearchFields => [qw(Query ReportType Start End Actor)] );

my @actions = $m->comp( '/Widgets/SavedSearch:process', args => \%ARGS, self => $saved_search );

</%init>