Location: PHPKode > projects > OpenDataCenter Network Management System > include/mainview_page/patch_panel/delete.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/
// ----------------------------------------------------------------------
?>
<?php
if (!isset($delete))
{
	$request=mysql_query("SELECT * FROM $name_table_patch_panel WHERE id=\"$_GET[id]\"") or die ("ERROR!");

	while($tmp_request=mysql_fetch_array($request))
	{
?>
<form method="post" action="index.php?include=mainview&page=patch_panel&action=delete&delete=ok&id=<?php echo $id;?>" name="delete_patch_panel">
	<fieldset class="form">
		<legend><img src="images/delete.gif" alt="Edit" align="top"> <?php echo TXT_DELETE; ?> <?php echo TXT_PATCH_PANEL; ?></legend>
		<label><?php echo TXT_RACK; ?></label>
		<select name="rack" READONLY DISABLED>
			<?php
			$request2=mysql_query("SELECT name,id FROM $name_table_rack WHERE id!=\"$tmp_request[rack_id]\" ORDER BY name ASC") or die ("ERROR!");

			while($tmp_request2=mysql_fetch_array($request2))
			{				
				echo "<option value=\"$tmp_request2[id]\">$tmp_request2[name]</option>\n";
			}
			
			$request3=mysql_query("SELECT name,id FROM $name_table_rack WHERE id=\"$tmp_request[rack_id]\"") or die ("ERROR!");
			
			while($tmp_request3=mysql_fetch_array($request3))
			{
				echo "<option value=\"$tmp_request3[id]\" SELECTED>$tmp_request3[name]</option>\n";				
			}			
			?>
		</select>
		<label><?php echo TXT_NAME; ?></label>
		<input type="text" name="name" size="50" value="<?php echo $tmp_request['name']; ?>" READONLY DISABLED><br>
		<label><?php echo TXT_PORT_DENSITY; ?></label>
		<select name="port_density" READONLY DISABLED>
			<option value="<?php echo "$tmp_request[port_density]"; ?>" SELECTED><?php echo "$tmp_request[port_density]"; ?> <?php echo TXT_PORTS; ?></option>
			<option value="12">12 <?php echo TXT_PORTS; ?></option>
			<option value="16">16 <?php echo TXT_PORTS; ?></option>
			<option value="24">24 <?php echo TXT_PORTS; ?></option>
			<option value="32">32 <?php echo TXT_PORTS; ?></option>
			<option value="48">48 <?php echo TXT_PORTS; ?></option>
			<option value="96">96 <?php echo TXT_PORTS; ?></option>
		</select>
		<label><?php echo TXT_HEIGHT; ?></label>
		<select name="height" READONLY DISABLED>
			<option value="<?php echo "$tmp_request[height]"; ?>" SELECTED><?php echo "$tmp_request[height]"; ?> U</option>
			<option value="1">1 U</option>
			<option value="2">2 U</option>
			<option value="4">4 U</option>			
		</select>
		<label><?php echo TXT_DESCRIPTION; ?></label>
		<textarea name="description" rows="10" cols="50" READONLY DISABLED><?php echo $tmp_request['description']; ?></textarea><br>
		<input type="submit" name="submit" value="Delete" onClick="return confirmDelete();"> <input type="button" value="Back" onClick="javascript:history.go(-1);">
	</fieldset>
</form>
 <script language="JavaScript" type="text/javascript">
	 var frmvalidator = new Validator("delete_patch_panel");
		 frmvalidator.addValidation("rack","req","Please enter the rack of the patch_panel");
		 frmvalidator.addValidation("name","req","Please enter the name of the patch_panel");
		 frmvalidator.addValidation("name","maxlen=255",
"Max length for patch_panel is 255");
</script>
<?php
	}
}
else if ($delete=="ok")
{
	$query=mysql_query("DELETE FROM $name_table_patch_panel WHERE id=$id");
	$request_port=mysql_query("SELECT id FROM $name_table_port WHERE patch_panel_id=\"$id\"") or die ("ERROR!");

	while($tmp_request_port=mysql_fetch_array($request_port))
	{
		$query3=mysql_query("DELETE FROM $name_table_link_port_port WHERE port_id=$tmp_request_port[id] OR port2_id=$tmp_request_port[id]");
		$query4=mysql_query("DELETE FROM $name_table_link_port_interface WHERE port_id=$tmp_request_port[id]");
	}
	
	$query5=mysql_query("DELETE FROM $name_table_port WHERE patch_panel_id=$id");
	if(!$query)
	{
		echo "<center><div id=\"status\" style=\"color:red\"><img src=\"images/warning.png\" alt=\"WARNING\"><br><br>";
		echo TXT_DATABASE_ERROR;
		echo "</div><br><a href=\"javascript:history.go(-2);\">";
		echo TXT_BACK;
		echo "</a></center>";
	}
	else
	{
		$query2=mysql_query("DELETE FROM $name_table_port WHERE patch_panel_id=$id");
		
		$currentdate = date('Y-m-d');
		$currenttime = date("H:i:s"); 
	
		user_log ($_SESSION['login'],$name_table_users,$name_table_users_log,"delete","patch panel","$id",$mysql_hostname,$mysql_username,$mysql_password,$mysql_database);
		
		foreach ($syslog_server as $arrayvalue)
		{
			$syslog = new Syslog();
			$syslog->SetFacility(13);
			$syslog->SetSeverity(5);
			$syslog->SetProcess('odcnms');
			$syslog->SetHostname('');
			$syslog->SetFqdn('');
			$syslog->SetIpFrom('');		
			$syslog->SetContent($currentdate.' '.$currenttime.' user: '.$_SESSION['login'].' - delete patch panel '.$id);
			$syslog->SetServer($arrayvalue);
			$syslog->Send();
		}	
		
		echo "<center><div id=\"status\" style=\"color:green\"><img src=\"images/info.png\" alt=\"INFO\"><br><br>";
		echo TXT_SUCCESSFULLY_DELETE_PATCH_PANEL;
		echo "</div><br><a href=\"javascript:history.go(-2);\">";
		echo TXT_BACK;
		echo "</a></center>";
	}

}
else if ($delete=="multiple")
{
	foreach ($_POST['delAnn'] as $id)
	{
		$query=mysql_query("DELETE FROM $name_table_patch_panel WHERE id=$id");
		$request_port=mysql_query("SELECT id FROM $name_table_port WHERE patch_panel_id=\"$id\"") or die ("ERROR!");

		while($tmp_request_port=mysql_fetch_array($request_port))
		{
			$query3=mysql_query("DELETE FROM $name_table_link_port_port WHERE port_id=$tmp_request_port[id] OR port2_id=$tmp_request_port[id]");
			$query4=mysql_query("DELETE FROM $name_table_link_port_interface WHERE port_id=$tmp_request_port[id]");
		}

		$query5=mysql_query("DELETE FROM $name_table_port WHERE patch_panel_id=$id");
		
		$currentdate = date('Y-m-d');
		$currenttime = date("H:i:s"); 
	
		user_log ($_SESSION['login'],$name_table_users,$name_table_users_log,"delete","patch panel","$id",$mysql_hostname,$mysql_username,$mysql_password,$mysql_database);
		
		foreach ($syslog_server as $arrayvalue)
		{
			$syslog = new Syslog();
			$syslog->SetFacility(13);
			$syslog->SetSeverity(5);
			$syslog->SetProcess('odcnms');
			$syslog->SetHostname('');
			$syslog->SetFqdn('');
			$syslog->SetIpFrom('');		
			$syslog->SetContent($currentdate.' '.$currenttime.' user: '.$_SESSION['login'].' - delete patch panel '.$id);
			$syslog->SetServer($arrayvalue);
			$syslog->Send();
		}	
		
	}
	
	if(!$query)
	{
		echo "<center><div id=\"status\" style=\"color:red\"><img src=\"images/warning.png\" alt=\"WARNING\"><br><br>";
		echo TXT_DATABASE_ERROR;
		echo "</div><br><a href=\"javascript:history.go(-2);\">";
		echo TXT_BACK;
		echo "</a></center>";
	}
	else
	{
		echo "<center><div id=\"status\" style=\"color:green\"><img src=\"images/info.png\" alt=\"INFO\"><br><br>";
		echo TXT_SUCCESSFULLY_DELETE_PATCH_PANEL;
		echo "</div><br><a href=\"javascript:history.go(-2);\">";
		echo TXT_BACK;
		echo "</a></center>";
	}		
}
?>
Return current item: OpenDataCenter Network Management System