<?/*
Copyright (C) 2003 Media Net Link, Inc. Danville, CA 94526 USA

This file is part of AthenaRMS.

AthenaRMS is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

AthenaRMS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/?>
<?PHP

require_once 'server_functions.php';

globalize_request_keys('searchstring');

if ((isset($searchstring))) {
  $lowerstring=strtolower($searchstring);
  $lowerstring="%$lowerstring%";
  $heading = "Search Results for \"$searchstring\"";
  $sql="select topic, help_id
        from help
        where lower(topic) like ?
        or  lower(description) like ? ";
  $h = $dbi->prepare($sql);
  $result = $dbi->execute( $h, array($lowerstring, $lowerstring) );
}
else {
  $heading = "Index";
  $sql="select a.topic, a.help_id
        from help a, link_help_map b
        where b.page_id = ?
        and a.help_id = b.help_id
	order by b.order_id";
  $h = $dbi->prepare($sql);
  $result = $dbi->execute( $h, array($_REQUEST['page_id']) );
}

if (DB::isError($result)) {
  echo("<font color=\"red\"><pre>\n" 
    . $result->getMessage() . "\n" . $result->getUserInfo()
    . "\n</pre>\n");
  return;
}

  $i = 1;
  $rows_returned = 0;
?>
<HTML>
<HEAD>
<TITLE>AthenaRMS Help</TITLE>
<LINK REL="stylesheet" HREF="<?= $web_root ?>/includes/css/global.css" TYPE="text/css">
</HEAD>
<BODY BGCOLOR="white" LEFTMARGIN="0" TOPMARGIN="0" MARGINWIDTH="0" 
  MARGINHEIGHT="0">
<TABLE CELLPADDING="1" BORDER="0" CELLSPACING="0" WIDTH="300">
<TR>
<TD CLASS="firstrowhelp">&nbsp;&nbsp;&nbsp;<?= $heading ?></TD>
</TR>
</TABLE>

<TABLE CELLPADDING="0" BORDER="0" CELLSPACING="0" WIDTH="300">

<?PHP
  while ($row = $result->fetchRow()) {
    $rows_returned = 1;
    $class = ($i % 2) ? 'offhelp' : 'onhelp';
?>
<TR CLASS="<?= $class ?>">
<TD CLASS="<?= $class ?>"><LI class="helpbullets">&nbsp;<A HREF="detail.php?page_id=<?= $_REQUEST['page_id'] ?>&help_id=<?= $row[1] ?>" CLASS="textsm"><?= $row[0] ?></A></LI></TD>
</TR>
<?PHP
    $i++;
  }
 if (!$rows_returned) {
  if ((isset($searchstring)) && ($i==1)) {
?>
<TR CLASS="offhelp">
<TD ALIGN="RIGHT">
<TABLE CELLPADDING="0" CELLSPACING="0" BORDER="0">
<TR>
<TD CLASS="btns-bar"><A HREF="body.php?page_id=<?= $_REQUEST['page_id'] ?>" CLASS="nobold">index</A>
</TR>
</TABLE></TD>
</TR>
<TR CLASS="offhelp">
<TD CLASS="body">There was no help available for your search. Please try another search term, or optionally, submit a question to the AthenaRMS developers.</TD>
</TR>
<?PHP
  }
  else {
?>
<TR CLASS="offhelp">
<TD CLASS="body">There is presently no help available for this page. You may search by topic below, or submit a question to the AthenaRMS Developers.</TD>
</TR>
<?PHP
  }
?>
<TR CLASS="offhelp">
<TD CLASS="body" ALIGN="CENTER"><A HREF="question.php?page_id=<?= $_REQUEST['page_id'] ?>&help_id=<?= $_REQUEST['help_id'] ?>"><IMG SRC="<?= $web_root ?>/img/btn-send-question.gif" WIDTH="87" HEIGHT="16" VSPACE="15" BORDER="0"></A></TD>
</TR>
<?PHP
 }
?>
</TABLE> </BODY>
</HTML>
