<?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(_("Setup") . " - " . _("Templates Editor"));

$qID = $DB->getTextValue($ID);
$query = "SELECT * FROM templates WHERE (ID = $qID)";
$DB = Config::Database();
$result = $DB->getRow($query);
$ID = $result["ID"];
$templname = $result["templname"];
$name = $result["name"];
$type = $result["type"];
$os = $result["os"];
$osver = $result["osver"];
$processor = $result["processor"];
$processor_speed = $result["processor_speed"];
$location = $result["location"];
$serial = $result["serial"];
$otherserial = $result["otherserial"];
$ramtype = $result["ramtype"];
$ram = $result["ram"];
$network = $result["network"];
$ip = $result["ip"];
$mac = $result["mac"];
$hdspace = $result["hdspace"];
$comments = $result["comments"];
$flags_server = $result["flags_server"];
$flags_surplus = $result["flags_surplus"];
$new_date = date("Y-m-d H:i:s");
$iface = $result["iface"];

printf(_('Use this form to edit template "%s".'), $templname);
PRINT '<a href="'.Config::AbsLoc('users/setup-templates.php').'">'._("Back to Templates").'</a><br>';
PRINT "<table width=100% border=1 noshade>";
PRINT '<form method=post action="'.Config::AbsLoc('users/setup-templates-update.php').'">';
PRINT '<tr bgcolor=#CCCCCC><td colspan=2><font face="Arial, Helvetica">';
$new_date = date("Y-m-d H:i:s");
PRINT "<strong>"._("Editing Template")." <input type=hidden name=ID value=\"$ID\">
		<input type=text name=templname value=\"$templname\" 
		size=40></strong>";

PRINT "</font></td></tr>";
PRINT "<tr bgcolor=#DDDDDD><td><font face=\"Arial, Helvetica\">"._("Name:")."<br>
		<input type=text name=name value=\"$name\" size=24></font>
		</td><td><font face=\"Arial, Helvetica\">"._("Type").":<br>";
Dropdown_value("dropdown_type", "type", $type);
PRINT "</font></td></tr>";
PRINT "<tr bgcolor=#DDDDDD><td><font face=\"Arial, Helvetica\">"._("Location").":<br>";
Dropdown_value("dropdown_locations", "location", $location);
PRINT "</font></td><td><font face=\"Arial, Helvetica\">"._("OS:")."<br>";
Dropdown_value("dropdown_os", "os", $os);
PRINT "</font></td></tr>";
PRINT "<tr bgcolor=#DDDDDD><td><font face=\"Arial, Helvetica\">"._("OS Version").
		":<br><input type=text size=5 name=osver value=\"$osver\">
		</font></td><td><font face=\"Arial, Helvetica\">"._("Processor").":<br>";
Dropdown_value("dropdown_processor", "processor", $processor);

PRINT "</font></td></tr>";
PRINT "<tr bgcolor=#DDDDDD><td><font face=\"Arial, Helvetica\">"._("Processor Speed").":<br><input type=text name=processor_speed size=4 value=\"$processor_speed\"></font></td><td><font face=\"Arial, Helvetica\">Serial Number:<br><input type=text name=serial size=35 value=\"$serial\"></font></td></tr>";
PRINT "<tr bgcolor=#DDDDDD><td><font face=\"Arial, Helvetica\">"._("Other Serial Number:")."<br><input type=text size=25 name=otherserial value=\"$otherserial\"></font></td><td><font face=\"Arial, Helvetica\">"._("Hard Drive Space (in gigabytes)").":<br> <input type=text name=hdspace size=5 value=\"$hdspace\"> </font></td></tr>";
PRINT "<tr bgcolor=#DDDDDD><td><font face=\"Arial, Helvetica\">"._("RAM Type").":<br>";
Dropdown_value("dropdown_ram", "ramtype", $ramtype);
PRINT "</font></td><td><font face=\"Arial, Helvetica\">"._("RAM Amount (in MB)").
		":<br><input type=text name=ram value=\"$ram\" size=5>
		</font></td></tr>";
PRINT "<tr bgcolor=#DDDDDD><td><font face=\"Arial, Helvetica\">".
		_("Network Card Brand/Type").":<br>";
Dropdown_value("dropdown_network", "network", $network);
PRINT "</font></td><td><font face=\"Arial, Helvetica\">"._("IP Address").":<br>
		<input type=text name=ip value=\"$ip\" size=16></font>
		</td></tr>";
PRINT "<tr bgcolor=#DDDDDD><td><font face=\"Arial, Helvetica\">".
		_("MAC/Network Address").":<br><input type=text name=mac 
		value=\"$mac\"></font></td><td>"._("Comments").":<br><textarea cols=20 
		rows=5 name=comments wrap=soft>$comments</textarea></font>
		</td></tr>";
if (!@$contact)
{
	$contact = '';
}
if (!@$contact_num)
{
	$contact_num = '';
}
PRINT "<tr bgcolor=#DDDDDD><td><font face=\"Arial, Helvetica\">"._("Contact Person:")."<br><input type=text name=contact size=20 value=\"$contact\"></font></td><td><font face=\"Arial, Helvetica\">"._("Contact Number").":<br><input type=text name=contact_num value=\"$contact_num\"></font></td></tr>";
PRINT "<tr bgcolor=#DDDDDD><td colspan=2><font face=\"Arial, Helvetica\"> ";
__("Network Interface");
PRINT ":<br>";
Dropdown_value("dropdown_iface", "iface", $iface);
PRINT "</td></tr>"; 
  PRINT "<tr bgcolor=#DDDDDD><td colspan=2><font face=\"Arial, Helvetica\">
  		Flags: ";
  if ($flags_server == 1) {
  	PRINT "<input type=checkbox name=flags_server value=yes checked>";
  } else {
  	PRINT "<input type=checkbox name=flags_server value=yes>";
  }

  PRINT " "._("Server (constantly running)")."</font>";

  if ($flags_surplus == 1) {
         PRINT "<input type=checkbox name=flags_surplus value=yes checked>";
  } else {
	 PRINT "<input type=checkbox name=flags_surplus value=yes>";
  }
  PRINT " Surplus</font></td></tr>";

PRINT "<tr bgcolor=#CCCCCC><td><input type=submit value=\""._("Update")."\"></td>
		<td><input type=Reset value=\""._("Reset")."\"></form></td></tr></table>";
PRINT "<br>";
templcompsoftShow($ID);
PRINT "<br>";	
