<?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/port.gif" alt="Port" align="bottom"> <?php echo TXT_PORT; ?></div>
<?php
if (!isset($action))
{
$requestcount=mysql_query("SELECT count(*) FROM $name_table_port") or die ("ERROR!");
$all_ports = mysql_fetch_array($requestcount);
if ((!isset($num)) && (!isset($start)))
{
$num = 20;
$start = 1;
$num2 = $num;
$startnext = $start + $num;
if ($all_ports[0] < $num)
{
$next = "";
$previous = "";
}
else
{
$next = "<input type=\"button\" onClick=\"window.location='index.php?include=mainview&page=port&start=$startnext&num=$num'\" value=\"".TXT_NEXT."\" style=\"margin:0px;border: 1px solid #c0c0c0;background-color: #f6f6f6;\">";
$previous = "";
}
}
else if ($start=="1")
{
$start = 1;
$num2 = $num;
$startnext = $start + $num;
$next = "<input type=\"button\" onClick=\"window.location='index.php?include=mainview&page=port&start=$startnext&num=$num'\" value=\"".TXT_NEXT."\" style=\"margin:0px;border: 1px solid #c0c0c0;background-color: #f6f6f6;\">";
$previous = "";
}
else
{
$num2 = $num + $start;
$startnext = $start + $num;
$startprevious = $start - $num;
if ($startnext > $all_ports[0])
{
$previous = "<input type=\"button\" onClick=\"window.location='index.php?include=mainview&page=port&start=$startprevious&num=$num'\" value=\"".TXT_PREVIOUS."\" style=\"margin:0px;border: 1px solid #c0c0c0;background-color: #f6f6f6;\">";
$next = "";
}
else
{
$next = "<input type=\"button\" onClick=\"window.location='index.php?include=mainview&page=port&start=$startnext&num=$num'\" value=\"".TXT_NEXT."\" style=\"margin:0px;border: 1px solid #c0c0c0;background-color: #f6f6f6;\">";
$previous = "<input type=\"button\" onClick=\"window.location='index.php?include=mainview&page=port&start=$startprevious&num=$num'\" value=\"".TXT_PREVIOUS."\" style=\"margin:0px;border: 1px solid #c0c0c0;background-color: #f6f6f6;\">";
}
}
?>
<table class="subtitle" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td width="70%"><h4><img src="images/port.gif" alt="Port" align="top"> <?php echo TXT_ALL_PORTS; ?> <span style="font-weight:normal;font-size: 80%;margin-left: 20px;"><?php echo TXT_RESULTS; ?> <b><?php echo "$start"; ?></b> - <b><?php echo "$num2"; ?></b> <?php echo TXT_OF; ?> <b><?php echo "$all_ports[0]";?></b></span></h4></td>
<td width="30%" style="text-align:right"><input type="button" onClick="window.location='index.php?include=mainview&page=link&action=add'" value="<?php echo TXT_ADD_LINK; ?>" style="margin:0px;border: 1px solid #c0c0c0;background-color: #f6f6f6;"> <input type="button" onClick="window.location='index.php?include=mainview&page=port&display=all&start=1&num=<?php echo $all_ports[0]; ?>'" value="<?php echo TXT_DISPLAY_ALL; ?>" style="margin:0px;border: 1px solid #c0c0c0;background-color: #f6f6f6;"> <?php if (!isset($display)) echo "$previous $next";?></td>
<tr>
</table>
<table class="sortable list" id="sortable" width="100%" cellspacing="2" cellpadding="3">
<tr class="list_title">
<td width="20%"><?php echo TXT_PATCH_PANEL; ?></td>
<td width="10%"><?php echo TXT_RACK; ?></td>
<td width="20%"><?php echo TXT_NAME; ?></td>
<td width="22%"><?php echo TXT_DESCRIPTION; ?></td>
<td class="unsortable" width="12%"><?php echo TXT_ACTION; ?></td>
</tr>
<?php
$list1 = "list1";
$list2 = "list2";
$line_count = 0;
$start_sql = $start - 1;
$request=mysql_query("SELECT * FROM $name_table_port ORDER BY patch_panel_id,id ASC LIMIT $start_sql,$num") or die ("ERROR!");
while($tmp_request=mysql_fetch_array($request))
{
$line_color = ($line_count % 2) ? $list1 : $list2;
$request2=mysql_query("SELECT name,id,rack_id FROM $name_table_patch_panel WHERE id=\"$tmp_request[patch_panel_id]\"") or die ("ERROR!");
while($tmp_request2=mysql_fetch_array($request2))
{
$id_patch_panel = $tmp_request2['id'];
$name_patch_panel = $tmp_request2['name'];
$id_rack = $tmp_request2['rack_id'];
}
$request3=mysql_query("SELECT name,id FROM $name_table_rack WHERE id=\"$id_rack\"") or die ("ERROR!");
while($tmp_request3=mysql_fetch_array($request3))
{
$name_rack = $tmp_request3['name'];
}
?>
<tr class="<?php echo "$line_color"; ?>">
<td width="20%" valign="top"><?php print("<a href=\"index.php?include=mainview&page=patch_panel&action=view&id=$id_patch_panel\">$name_patch_panel</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="20%" valign="top"><?php print("<a href=\"index.php?include=mainview&page=port&action=view&id=$tmp_request[id]\">$tmp_request[name]</a>"); ?></td>
<td width="22%" valign="top"><?php echo $tmp_request['description']; ?></td>
<td width="12%" valign="top">[ <?php print("<a href=\"index.php?include=mainview&page=port&action=edit&id=$tmp_request[id]\">");
echo TXT_EDIT;
echo "</a>"; ?> ] [ <?php print("<a href=\"index.php?include=mainview&page=port&action=view&id=$tmp_request[id]\">");
echo TXT_VIEW;
echo "</a>"; ?> ]</td>
</tr>
<?php
$line_count++;
}
?>
</table>
<br><center><a href="javascript:history.go(-1);"><?php echo TXT_BACK; ?></a></center>
<?php
}
else if ($action == "view")
{
include("port/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("port/add.php");
}
else if ($action == "edit")
{
include("port/edit.php");
}
else if ($action == "delete")
{
include("port/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>";
}
}
?>