<%doc>

Performs a general search in the database, looking into every field of every table.

</%doc>


<%args>
$q
</%args>

<%init>

my %linksto;
my $results;
eval {
    $results = Netdot::Model->search_all_tables($q);
};
if ( my $e = $@ ){
    $m->comp("/generic/error.mhtml", error=>$e);
}
my $DEBUG = 0;
if ( $DEBUG ) {
    print "<pre>", Dumper($results), "</pre>";
    $m->abort;
}
my $numtbls = scalar keys %$results;

</%init>


<div class="containeroutside">

<div class="containerheadleftoutside">
  <strong>Netdot General Search</strong>
% if ( $numtbls ){
    <br>Found matches in <% $numtbls %> tables:
% }
</div>
<div class="containerheadrightoutside">
  <form action="search.html" method="POST">
    <input type="text" name="q" size="25" value="<% $q %>">
    <input name="submit" value="Submit" type="submit">
  </form>
</div>

%   if( $numtbls < 1 || ! %$results ) {
      <div class="container">
         No matching records were found.
      </div>
%   } else {
%     foreach my $tbl ( sort { $a cmp $b } keys %$results ) {
%       my @objs;
%       map { push @objs, $results->{$tbl}->{$_} } keys %{ $results->{$tbl} };
        <div class="container">
	  <div class="containerheadleft"><% $tbl %></div>
	  <div class="containerheadright">&nbsp;</div>
	  <div class="containerbodyoutside">
	    <& sortresults.mhtml, table => $tbl, object => \@objs, view => "row", withedit => 1 &>
	  </div>
	</div>

%     } # end foreach tbl
%   } # end else

</div>
