<?php

/*
** SellaNMS
** $Id: elementalerts_template.php,v 1.10 2006/01/24 07:08:09 sella Exp $
** Copyright (c) 2001 Digital Genesis Software, LLC. All Rights Reserved.
** Released under the GPL Version 2 License.
** http://www.digitalgenesis.com
*/

require_once('../config/config.php');
require_once('../libs/dgsutil/cgi.php');
require_once('../libs/util.php');

$data = getFormData();

$db = mysql_connect($config['databaseServer'], $config['databaseUsername'], $config['databasePassword']);
mysql_select_db($config['databaseName'], $db);

if ($data['router']) {
	$sql = sprintf("SELECT gui_event.id, UNIX_TIMESTAMP(gui_event.timestamp) AS stamp, gui_event.interface AS if_id, gui_event.channel, gui_event.state, gui_event.brief, interface_data.value AS if_name FROM gui_event, interface_data WHERE gui_event.element = '%d' AND interface_data.id = gui_event.interface AND interface_data.variable = '.1.3.6.1.2.1.2.2.1.2'", $data['router']);

	$result = mysql_query($sql, $db);
?>
	<TABLE WIDTH="100%" CELLSPACING="1" CELLPADDING="0" BORDER="0">
		<TR CLASS="tbltitle">
			<TD NOWRAP COLSPAN="5">&nbsp;Current Element Events: <?php printf('%s', mysql_affected_rows($db)); ?>&nbsp;</TD>
		</TR>
		<TR CLASS="tblhdr">
			<TD NOWRAP>&nbsp;Timestamp&nbsp;</TD>
			<TD NOWRAP>&nbsp;State&nbsp;</TD>
			<TD NOWRAP>&nbsp;Channel&nbsp;</TD>
			<TD NOWRAP>&nbsp;Interface&nbsp;</TD>
			<TD WIDTH="100%" NOWRAP>&nbsp;Event&nbsp;</TD>
		</TR>

<?php while ($row = mysql_fetch_array($result)) { ?>
		<TR CLASS="tblentry">
			<TD NOWRAP>&nbsp;<?php printf('%s', date($config['dateFormat'], $row['stamp'])); ?>&nbsp;</TD>
			<TD NOWRAP>&nbsp;<?php printf('%s', $row['state']); ?>&nbsp;</TD>
			<TD NOWRAP>&nbsp;<?php printf('%s', $row['channel']); ?>&nbsp;</TD>
			<TD NOWRAP>&nbsp;<?php printf('%s', $row['if_name']); ?>&nbsp;</TD>
			<TD NOWRAP>&nbsp;<?php printf('%s', $row['brief']); ?>&nbsp;</TD>
		</TR>
<?php } ?>

	</TABLE>
<?php } ?>

<?php

/*
** Local Variables:
** c-basic-offset: 3
** tab-width: 3
** End:
** vim:
** vim: noet ts=3 sw=3
*/

?>
