<?php
/*********************************************************      
 程序说明:         
    功能说明:所有已知系统列表

    调用关系:调用: connectdb.inc，inc/header.inc     
              被调用:      
 
    变量说明:$device_table;
              $language_type是公共变量在config.inc文件定义

     返回值:无

 作者: 
      
修改注释:      
NO.1      
姓名:            
时间:      
修改说明:      
*********************************************************/    
require("../../inc/header.inc");
$DEBUG = 0;

$pubDb			= 'OMC_PUB';
$sysConfTable	= 'OMC_PUB.sysConf';
$alarmDefTable	= 'OMC_PUB.sysAlarmConf';

$sysTypeNo=$_REQUEST['sysTypeNo'];
if($DEBUG) echo "<br>sysTypeNo=$sysTypeNo";
$sysTypeNo=isset($sysTypeNo)?$sysTypeNo:0;
if($DEBUG) echo "<br>sysTypeNo=$sysTypeNo";

//选择语言版本
if($language == 'eng'){
	$descField=alarmDesc_2; //语种2
}else{	
	$descField=alarmDesc_1; //语种1(默认语种)
}
?>



<script LANGUAGE="JavaScript"> 
function chgMenu()
{      
	var baseUrl,urlAdd,url;      
	baseUrl='<?php echo"$PHP_SELF?sysTypeNo=";?>';
	urlAdd=document.confForm.sysTypeNo.options[document.confForm.sysTypeNo.selectedIndex].value;      
	url = baseUrl+urlAdd;
	window.location=url;      
}
</script>
<body onload="javascript:adjust();" onresize="javascript:adjust();" leftmargin="15" style="overflow:hidden;overflow-x:hidden;overflow-y:hidden;">

<form method="POST" name=confForm action="./alarmDefConf.php" >
<?php
adjust_head();
adjust_title_head();
echo "<table id=\"table_up\" border=\"0\" width=\"100%\">";
	echo "<tr>";
		echo "<td width=\"50%\">";
		echo "Template > Alarm Configuration";
		echo "</td>";
		echo "<td width=\"50%\" align=\"right\" title=\"Help\">";
		//showHelp($helpId);
		echo "</td>";
	echo "</tr>";
	echo "<tr>";
		echo "<td align=\"left\">";

$listSql = "SELECT sysTypeName,sysTypeNo 
			FROM $sysConfTable	
			ORDER BY sysTypeNo
			";
if($DEBUG) echo "<br>listSql = $listSql<br>";
$listResult = mysqli_query($pubConn,$listSql);
echo mysqli_error($pubConn);

echo "<select size=1 name=\"sysTypeNo\"  onChange=\"javascript:chgMenu()\">";
if($sysTypeNo == 999){
	echo "<option value=\"999\">All</option>";
}else{
	echo "<option value=\"999\" selected>All</option>";
}
while($listRows=@mysqli_fetch_array($listResult)){
	if($sysTypeNo == $listRows[sysTypeNo]){
		echo "<option value=\"$listRows[sysTypeNo]\" selected>$listRows[sysTypeName]</option>";	
	}else{
		echo "<option value=\"$listRows[sysTypeNo]\">$listRows[sysTypeName]</option>";	
	}
}
echo "</select>";
echo "&nbsp;&nbsp;&nbsp;&nbsp;";

if($sysTypeNo != 999){
	echo "<input type=\"submit\" name=\"add\" value=\"Add alarm\" class=\"button\">";
	echo "<input type=\"hidden\" name=\"mode\" value=\"add\">";
}

		echo "</td>";
		echo "<td width=\"50%\" align=\"right\" title=\"Help\">";

		echo "</td>";
	echo "</tr>";
echo "</table>";
adjust_title_tail();
adjust_content_head();
echo "<br>";




?>
<table  border="1" width="100%" cellpadding="2" cellspacing="0"  bordercolor="#666666" bordercolordark="#FFFFFF" bgcolor="#FFFFFF" > 
 <tr bgcolor="#E6E6E6">    
	<td width="100%" colspan="12" align="center">
		<font size=3><b><?php echo "System Alarm Define List"; ?></b></font>
	</td>
  </tr>
<?php
if ($selectedLanguage == 'eng'){
	echo "<tr>";
	echo "<td>sysTypeName</td>";
	echo "<td>compCode</td>";
	echo "<td>alarmCode</td>";
	echo "<td>alarmLevel</td>";
	echo "<td>Level_1</td>";
	echo "<td>Level_2</td>";
	echo "<td>instanceNo</td>";
	echo "<td>EventCode</td>";
	echo "<td>Descript</td>";
	echo "<td>---</td>";
	echo "<td>---</td>";
	echo "</tr>";
}
elseif ($selectedLanguage == 'chn'){
	echo "<tr>";
	echo "<td>系统类型</td>";
	echo "<td>compCode</td>";
	echo "<td>告警代码</td>";
	echo "<td>告警级别</td>";
	echo "<td>&nbsp;</td>";
	echo "<td>&nbsp;</td>";
	echo "<td>&nbsp;</td>";
	echo "<td>&nbsp;</td>";	
	echo "<td>描述</td>";
	echo "<td>&nbsp;</td>";
	echo "<td>&nbsp;</td>";
	echo "</tr>";
}

if($DEBUG) echo "<br>sysTypeNo=$sysTypeNo";

if($sysTypeNo == 999){
	if($DEBUG) echo "<br>sysTypeNo=$sysTypeNo";
	$listSql = "SELECT sysTypeName,compCode,alarmCode,alarmLevel,$sysConfTable.sysTypeNo,$descField,level_1 ,level_2,instanceNo,EventCode 
				FROM $sysConfTable,$alarmDefTable
				WHERE $sysConfTable.sysTypeNo = $alarmDefTable.sysTypeNo
				ORDER BY $alarmDefTable.sysTypeNo,$alarmDefTable.compCode,$alarmDefTable.alarmCode";
}else{
	$listSql = "SELECT sysTypeName,compCode,alarmCode,alarmLevel,$descField,level_1 ,level_2,instanceNo,EventCode,$sysConfTable.sysTypeNo
				FROM $sysConfTable,$alarmDefTable
				WHERE $sysConfTable.sysTypeNo = $alarmDefTable.sysTypeNo
					AND $alarmDefTable.sysTypeNo = '$sysTypeNo'
				ORDER BY $alarmDefTable.sysTypeNo,$alarmDefTable.compCode,$alarmDefTable.alarmCode";
}
if($DEBUG) echo "<br>listSql = $listSql<br>";
$listResult = mysqli_query($pubConn,$listSql);
echo mysqli_error($pubConn);

$alarmLevelDef=array('cleared','Critical','Major','Minor','Warning','Indeterminate');

while($listRows=@mysqli_fetch_array($listResult)){
	if($oldSysTypeNo != $listRows[sysTypeNo]){
		$oldSysTypeNo = $listRows[sysTypeNo];
		echo "<tr bgcolor=\"#CCFFCC\">";
	}else{
		echo "<tr>";
	}
	echo "<td>$listRows[sysTypeName]</td>";
	echo "<td>$listRows[compCode]</td>";
	echo "<td>$listRows[alarmCode]</td>";
	if($listRows[alarmLevel] > 5){
		echo "<td>Unknown</td>";
	}else{
		echo "<td>{$alarmLevelDef[$listRows[alarmLevel]]}</td>";
	}

	echo "<td>$listRows[level_1]&nbsp;</td>";
	echo "<td>$listRows[level_2]&nbsp;</td>";
	echo "<td>$listRows[instanceNo]&nbsp;</td>";
	echo "<td>$listRows[EventCode]</td>";
	
	echo "<td>$listRows[$descField]</td>";
//	echo "<td><a href=\"./alarmDefConf.php?sysTypeNo=$sysTypeNo&compCode=$listRows[compCode]";
	echo "<td><a href=\"./alarmDefConf.php?sysTypeNo=$listRows[sysTypeNo]&compCode=$listRows[compCode]";
	echo "&alarmCode=$listRows[alarmCode]&mode=edit\">$strEdit</a></td>";
//	echo "<td><a href=\"./alarmDefConf.php?sysTypeNo=$sysTypeNo&compCode=$listRows[compCode]";
	echo "<td><a href=\"./alarmDefConf.php?sysTypeNo=$listRows[sysTypeNo]&compCode=$listRows[compCode]";
	echo "&alarmCode=$listRows[alarmCode]&mode=delete\">$strDelete</a></td>";
	echo "</tr>";
}
echo "</table>";
echo "</FROM>";
adjust_content_tail();
?>