<table width="100%" border="0" cellpadding="2" cellspacing="0">
<tr><td valign="top" width="50%">

<& LookupSummary, %ARGS, Queue => 'Incidents', Query => $query &>

</td><td valign="top" width="50%">

<& LookupSummary, %ARGS, Queue => 'Investigations', Query => $query &>

</td></tr><tr><td valign="top" width="50%">

<& LookupSummary, %ARGS, Queue => 'Incident Reports', Query => $query &>

</td><td width="50%" valign="top">

% unless ( RT->Config->Get('RTIR_DisableBlocksQueue') ) {
<& LookupSummary, %ARGS, Queue => 'Blocks', Query => $query &>
% }

</td></tr>

</table>
<%args>
$LookupType => undef
$q => undef
</%args>
<%init>

return unless defined $q && length $q;

my $query;
if ( $LookupType && RT::IR->CustomFields( Field => $LookupType ) ) {
    $query = "'CF.{$LookupType}' = '$q'"
} else {
    $query = join ' OR ', map "ContentType = '$_'",
        qw(text/plain text/html text);
    $query = "( $query ) AND Content LIKE '$q'";

    # apply transaction date search only if it's FTS as otherwise
    # it can ruin performance of mysql optimizer rather than help
    my $age = RT::Date->new( $session{'CurrentUser'} );
    $age->SetToNow;
    $age->AddDays( 0 - (RT->Config->Get('RTIR_OldestRelatedTickets') || 60) );

    $query = "$query AND TransactionDate > '". $age->ISO ."'"
}
</%init>
