<?php
#    IRM - The Information Resource Manager
#    Copyright (C) 1999 Yann Ramin
#
#    This program 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.
#
#    This program 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 (in file COPYING) 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., 675 Mass Ave, Cambridge, MA 02139, USA.
#
################################################################################
include("../include/irm.inc");
require_once 'lib/Config.php';
require_once 'include/i18n.php';

AuthCheck("tech");

commonHeader(_("Knowledge Base Setup"));
__("Welcome to the IRM Knowledge Base Setup utility.  Here you can add, modify, or delete a category from the IRM Knowledge Base.");
?>
<hr noshade>
<?php
$query = "SELECT * FROM kbcategories";
$DB = Config::Database();
$data = $DB->getAll($query);
foreach ($data as $result)
{
  	$id = $result["ID"];
  	$categoryname = $result["name"];
  	$parentID = $result["parentID"];
	$fullcategoryname  = kbcategoryname($id);
  	PRINT '<form method=post action="'.Config::AbsLoc('users/setup-knowledgebase-update.php').'">';
	PRINT "<table width=100% border=1 noshade bordercolor=#000000>
			<tr bgcolor=#CCCCCC><td colspan=2><strong>$fullcategoryname
			</strong></td></tr>";
  	PRINT "<tr bgcolor=#DDDDDD>";
  	PRINT "<td><font face=\"arial, helvetica\">";
	__("Category Name:");
	PRINT "<br><input type=text size=\"65%\" 
			name=categoryname value=\"$categoryname\">";
  	PRINT "</font></td>";
	PRINT "<td><font face=\"arial, helvetica\">";
	__("As a subcategory of: ");
	kbcategoryList($parentID);
	PRINT "</font></td>\n";
	PRINT "\n</tr>\n";
  	PRINT "<tr bgcolor=#CCCCCC><td valign=center><input type=hidden 
			name=id value=\"$id\"><input type=submit 
			value=Update></form></td><td valign=center>";
	PRINT '<form method=get action="'.Config::AbsLoc('users/setup-knowledgebase-del.php').'">';
	PRINT "<input type=hidden 
			name=id value=\"$id\"><input type=hidden name=categoryname 
			value=\"$categoryname\"><input type=submit 
			value=Delete></form></td></tr></table>";
  	PRINT "<br>";
}
PRINT "<a name=\"add\"></a><hr noshade><h4>";
__("Add a Category");
PRINT '</h4><form method=post action="'.Config::AbsLoc('users/setup-knowledgebase-add.php').'">';
PRINT "<table width=100% 
		border=1 noshade bordercolor=#000000><tr bgcolor=#CCCCCC>
		<td colspan=2><strong>";
__("New Category");
PRINT "</strong></td></tr>";
PRINT "<tr bgcolor=#DDDDDD> <td><font face=\"arial, helvetica\">";
__("Name:");
PRINT "<br> <input type=text size=\"65%\" name=categoryname></td>";
PRINT "<td><font face=\"arial, helvetica\">";
__("As a subcategory of: ");
		kbcategoryList(0);
		PRINT "</td>";
PRINT "</tr>";
PRINT "<tr bgcolor=#CCCCCC><td colspan=2><input type=submit value=Add>
		</td></tr></table></form>";

commonFooter();
