<& /Elements/Header,
    Title => loc("Assets at a glance"),
    Refresh => $session{'home_refresh_interval'} &>
<& /Elements/Tabs &>

<TABLE BORDER=0 WIDTH=100%>
<TR>
<TD class="boxcontainer">
<& /AssetTracker/Elements/Quicksearch &>
%#<BR>
%#<form method=get action="<%RT->Config->Get('WebPath')%>/index.html">
%#<& /Elements/Refresh, Name => 'HomeRefreshInterval', Default => $session {'home_refresh_interval'} &>
%#<div align=right><input type=submit value="<&|/l&>Go!</&>"></div>
%#</form>
</TD>
</TR>
<TR VALIGN=TOP>
<TD WIDTH=70% class="boxcontainer">
<& /AssetTracker/Elements/RecentAssets &>
</TD>
</TR>
</TABLE>
<%init>

if ( $ARGS{'q'} ) {
    my $query = $ARGS{'q'};

    if ( RT->Config->Get('EnableIP') && $query =~ m/^(\d+\.\d+\.\d+\.\d+)$/ ) {
        $m->comp("/AssetTracker/Search/Results.html", Query => "IP = '$query'", AutoForwardSingleResult => 1);
        return();
    }
    elsif ( $query =~ /^#?(\d+)$/ ) {
        RT::Interface::Web::Redirect(RT->Config->Get('WebURL')."AssetTracker/Asset/Display.html?id=".$1);
    }

    if ($m->callback( query => $query, %ARGS, CallbackName => 'SearchPreFilter' )) {
        return();
    }

    $m->comp("/AssetTracker/Search/Results.html", Query => "Name LIKE '$query' AND Status != 'retired'", AutoForwardSingleResult => 1);
    return();

}


if ($ARGS{'HomeRefreshInterval'}) {
    $session{'home_refresh_interval'} = $ARGS{'HomeRefreshInterval'};
}

</%init>
