Location: PHPKode > projects > Helpdesk Solutions > helpdesk/scripts/admin/admin_buildings.php
<?
include($DOCUMENT_ROOT.'/helpdesk/include/database.php');
include($DOCUMENT_ROOT.'/helpdesk/include/new_user.php');

session_start();

if ($valid != "yes") {
	header("Location: /helpdesk/login.php");
	exit;
}

$head = "Add a Building";
$bttm_menu = " &nbsp;&nbsp;<a class=bttm_menu href='/helpdesk/scripts/main_adminmenu.php'>Main Menu</a>&nbsp;&nbsp;|
				&nbsp;&nbsp;<a class=bttm_menu href='/helpdesk/scripts/admin/admin_menu.php'>Prefs Menu</a>&nbsp;&nbsp;|
				&nbsp;&nbsp;<a class=bttm_menu href='/helpdesk/logout.php'>Log Out</a>&nbsp;&nbsp;|
";

if ($submit_new) {
	if ($stat_get_name_new) {
		
		$sql = "INSERT INTO buildings (build_id, build_name) VALUES ('','$stat_get_name_new')";
		//echo $sql;
		$result = mysql_query($sql,$conn);
	} else {
		$warning .= "<td class=warning>** Cannot add to system - No data in the field";
	}
}
if ($remove_sub) {
	if ($remove) {
		$sql = "DELETE FROM buildings WHERE build_id='$remove'"; //drop the whole line with id of ....
		$result = mysql_query($sql,$conn);
		//echo $sql;
	} else {
		$warning .= "<td class=warning>** You did not select a field to delete.";
	}
}


if ($submit) {
	for ($i = $stat_count;$i>'0';$i--) {
		if ($stat_get_name[$i]) {
			$temp = mysql_query("UPDATE buildings SET build_name = '$stat_get_name[$i]' WHERE build_id = '$hidden[$i]'",$conn);
		} else {
			$warning = "<td class=warning>** Changes NOT saved. Please ensure all fields have data entered";
		}
	}
	if (!$warning) { $warning = "<td class=success>** Changes successfully saved"; }
}



$head = "Configure the Problem Catagories";
$stat_count = '0';

$sql = "SELECT * FROM buildings";
$result = mysql_query($sql,$conn);
while ($row = mysql_fetch_array($result)) {
	$stat_id = $row['build_id'];
	$stat_name = $row['build_name'];

	if (!$stat_count) {
		$stat_count = '1';
	} else {
		$stat_count++;
	}
	//$stat_name = addslashes($stat_name2);
	//echo $stat_name;

	$table .= "<tr class=standard_2><td nowrap class=redtext>Catagory No. $stat_count<td> - <td><input type=text name=stat_get_name[$stat_count] value=\"$stat_name\" size=30><td><input type=radio name=remove value='$stat_id'><input type=hidden name=hidden[$stat_count] value='$stat_id'>";

}

$table .= "<tr class=standard_2><td nowrap class=redtext>New Catagory<td> - <td><input type=text name=stat_get_name_new size=30><td><input type=submit name=submit_new value='Add'>";

$bottom = "
<h1>Configure the Problem Catagories</h1>

Here you may add extra fields or rename existing fields to suit your requirements. The names added here will be displayed on the Add a User screen.<br><br>
To remove a field, click a radio button next to the field you wish to remove and then press the 'Remove Field' button below.
<br>
<br>
<form method=get action='$phpself'>
<table>
$table
<input type=hidden name=stat_count value='$stat_count'>
<tr><td colspan=2><br><input type=submit name=submit value='Save Changes'><td><br><input type=submit name=remove_sub value='Remove Field'>
</table>
</form>
";


include($DOCUMENT_ROOT.'/helpdesk/include/template.inc.php');
?>
Return current item: Helpdesk Solutions