Location: PHPKode > projects > OpenDataCenter Network Management System > include/mainview_page/patch_panel.php
<?php
// ----------------------------------------------------------------------
// Copyright (C) 2007 by GREGORY LE BRAS
// ----------------------------------------------------------------------
// LICENSE
//
// This file is part of ODCNMS - Open DataCenter Network Management System
// 
// ODCNMS 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.
// 
// Foobar 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 Foobar; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
// ----------------------------------------------------------------------
// Original Author of file: GREGORY LE BRAS - http://www.odcnms.org/
// ----------------------------------------------------------------------
?>
<div class="title"><img src="images/patch_panel.gif" alt="Patch Panel" align="bottom"> <?php echo TXT_PATCH_PANEL; ?></div>
<?php
if (!isset($action))
{
?>
<form action="index.php?include=mainview&page=patch_panel&action=delete&delete=multiple" method="post" style="border:0px; margin:0px; padding:0px;" onsubmit="return confirm('<?php echo TXT_DELETE_CONFIRMATION; ?>');">
<table class="subtitle" width="100%" cellspacing="0" cellpadding="0">
	<tr>
		<td width="70%"><h4><img src="images/patch_panel.gif" alt="Patch Panel" align="top"> <?php echo TXT_ALL_PATCH_PANELS; ?></h4></td>
		<td width="30%" style="text-align:right"><input type="button" onClick="window.location='index.php?include=mainview&page=patch_panel&action=add'" value="<?php echo TXT_ADD; ?>" style="margin:0px;border: 1px solid #c0c0c0;background-color: #f6f6f6;"> <input type="submit" value="<?php echo TXT_DELETE_SELECTED; ?>" name="send_remove_ann" id="removeChecked" style="margin:0px;border: 1px solid #c0c0c0;background-color: #f6f6f6;" disabled></td>
	<tr>
</table>
<table class="sortable list" id="sortable" width="100%" cellspacing="2" cellpadding="3">
	<tr class="list_title">
		<td class="unsortable" width="2%" valign="top"><input type="checkbox" onclick="checkAllFields(1);" id="checkAll" style="border:0px;"></td>	
		<td width="20%"><?php echo TXT_NAME; ?></td>
		<td width="18%"><?php echo TXT_RACK; ?></td>
		<td width="11%"><?php echo TXT_PORT_DENSITY; ?></td>
		<td width="7%"><?php echo TXT_HEIGHT; ?></td>
		<td width="30%"><?php echo TXT_DESCRIPTION; ?></td>
		<td class="unsortable" width="12%"><?php echo TXT_ACTION; ?></td>
	</tr>
<?php
	$list1 = "list1"; 
	$list2 = "list2"; 
	$line_count = 0; 
	
	$request=mysql_query("SELECT * FROM $name_table_patch_panel ORDER BY name ASC") or die ("ERROR!");

	while($tmp_request=mysql_fetch_array($request))
	{
		$line_color = ($line_count % 2) ? $list1 : $list2;
		
		$request2=mysql_query("SELECT name,id FROM $name_table_rack WHERE id=\"$tmp_request[rack_id]\"") or die ("ERROR!");

		while($tmp_request2=mysql_fetch_array($request2))
		{
			$id_rack = $tmp_request2['id'];
			$name_rack = $tmp_request2['name'];
		}
	?>
		<tr class="<?php echo "$line_color"; ?>">
			<td width="2%" valign="top"><input class="boxes" type="checkbox" value="<?php echo $tmp_request['id']; ?>" name="delAnn[]" onclick="checkAllFields(2);" style="border:0px;"></td>				
			<td width="20%" valign="top"><?php print("<a href=\"index.php?include=mainview&page=patch_panel&action=view&id=$tmp_request[id]\">$tmp_request[name]</a>"); ?></td>
			<td width="20%" valign="top"><?php print("<a href=\"index.php?include=mainview&page=rack&action=view&id=$id_rack\">$name_rack</a>"); ?></td>
			<td width="10%" valign="top"><?php echo $tmp_request['port_density']; ?></td>
			<td width="6%" valign="top"><?php echo $tmp_request['height']; ?></td>
			<td width="30%" valign="top"><?php echo $tmp_request['description']; ?></td>
			<td width="12%" valign="top">[ <?php print("<a href=\"index.php?include=mainview&page=patch_panel&action=edit&id=$tmp_request[id]\">".TXT_EDIT."</a>"); ?> ] [ <?php print("<a href=\"index.php?include=mainview&page=patch_panel&action=delete&id=$tmp_request[id]\">".TXT_DELETE."</a>"); ?> ]</td>	
		</tr>
	<?php	
			$line_count++;
	}
?>	
</table>
</form>
<br><center><a href="javascript:history.go(-1);"><?php echo TXT_BACK; ?></a></center>
<?php
}
else if ($action == "view")
{
	include("patch_panel/view.php");
}
else
{
	$request=mysql_query("SELECT administrator FROM $name_table_users WHERE username=\"$login\"") or die ("ERROR!");

	while($tmp_request=mysql_fetch_array($request))
	{
		$user_privilege = $tmp_request['administrator'];
	}

	if (($user_privilege=="1") || ($user_privilege=="2"))
	{
		if ($action == "add")
		{
			include("patch_panel/add.php");
		}
		else if ($action == "edit")
		{
			include("patch_panel/edit.php");
		}
		else if ($action == "delete")
		{
			include("patch_panel/delete.php");
		}	
		else
		{
			include("pagenotfound.php");
		}
	}
	else
	{
		echo "<center><div id=\"status\" style=\"color:red\"><img src=\"images/forbidden.png\" alt=\"FORBIDDEN\"><br><br>";
		echo TXT_FORBIDDEN_ACTION;
		echo "</div></center>";
	}
}
?>
Return current item: OpenDataCenter Network Management System