<?php
require("../../inc/header.inc");
?>
<script LANGUAGE="JavaScript">  
function goPage(numberOfRec){
	
	
	
		var pageUrl,bgnNo,numberPerPage;
		pageNo=document.selectform.pageNo.value;

		numberPerPage='<?php echo "$numberPerPage";?>';
		numberPerPage=100;

		bgnNo=numberPerPage*(pageNo-1);
		var selSysTypeNo=document.selectform.selSysTypeNo.value;
		var selAlarmLevel=document.selectform.selAlarmLevel.value;

		baseUrl='<?php echo "$PHP_SELF?$basePageLink";?>';
		
		pageUrl="&bgnNo="+bgnNo+"&numberOfRecords="+numberOfRec+"&selSysTypeNo="+selSysTypeNo+"&selAlarmLevel="+selAlarmLevel;
		window.location.href=baseUrl+pageUrl;     
		
		
}      
</script>
<body leftmargin="15" rightmargin="10" onload="javascript:adjust_frame('down');" onresize="javascript:adjust_frame('down');" style="overflow:hidden;overflow-x:hidden;overflow-y:hidden;">

<?php
//&bgnNo=$bgnNo&numberOfRecords=numberOfRecords$basePageLink=$_REQUEST['basePageLink'];
$bgnNo=$_REQUEST['bgnNo'];
$numberOfRecords=$_REQUEST['numberOfRecords'];
$selSysTypeNo=$_REQUEST['selSysTypeNo'];
$selAlarmLevel=$_REQUEST['selAlarmLevel'];
$nextPageLink=$_REQUEST['nextPageLink'];
$prePageLink=$_REQUEST['prePageLink'];
$actMode=$_REQUEST['actMode'];
echo "<meta http-equiv=\"refresh\" content=\"10; url=$PHP_SELF?selSysTypeNo=$selSysTypeNo&selAlarmLevel=$selAlarmLevel&noop=$noop&nolog=1\">";
adjust_head_frame("down");
adjust_title_head_frame("down");
adjust_title_tail_frame("down");

adjust_content_head_frame("down");	
echo "<br>";



//*****
//$url_temp=$_SERVER["REQUEST_URI"];
//echo "This page URL:$url_temp<br>";
/*********************************************************      
 程序说明：         
    功能说明：告警查询的下部页面，查询显示
    调用关系：
    变量说明：

    作者：   
      
修改注释：      
NO.1      
姓名：            
时间：      
修改说明：      
*********************************************************/

$DEBUG = 0;

//if(!isset($selSysTypeNo)) $selSysTypeNo='all';
//==========================================================
//变量定义
//==========================================================
$dbName		= 'OMC_PUB';
$defTable	= 'sysAlarmConf';
$logTable	= 'sysAlarmLog';
$numberPerPage	= 100;		//每页纪录数
$orderByStr = "alarmTime DESC,sysTypeNo,sysNo,subSysNo";//排序顺序

//确定告警内容显示语言种类
if($language=='chn'){
	$alarmDesc	= alarmDesc_1; //chinese
}else{
	$alarmDesc	= alarmDesc_2;
}
 
//初始化设备名和设备编号数组，
//由于三张表一起查时，速度太慢，占用系统资源太大。
//所以系统类型编号对应的系统类型名称不从数据库中直接取。
//将数据到如数组，显示时，从数组中来取。
$device_sql ="SELECT sysTypeNo,sysTypeName 
			  FROM  $sysconf_table 
			  WHERE needHeartBeat >'0' 
			  ORDER BY sysTypeNo  
			  ";
$device_result = @mysqli_query($pubConn,$device_sql);
$device_rows = @mysqli_fetch_array($device_result);
echo mysqli_error($pubConn);
if($DEBUG)echo "<br>device_sql:$device_sql";
$i=0;
do{
	$sysTypeDef[$i][sysTypeNo]	= $device_rows[sysTypeNo];
	$sysTypeDef[$i][sysTypeName]= $device_rows[sysTypeName];
	$i++;
}while($device_rows = mysqli_fetch_array($device_result));

//需要被查询的字段名
$selectFieldList="$logTable.sysTypeNo,sysNo,subSysNo,$logTable.compCode,$logTable.alarmCode,alarmLevel,$alarmDesc ,alarmTime,clearTime,clearMode,clearInfo";

//显示列表时的表头标题
$noop=0;
if($noop!=1)
{
	if ($selectedLanguage == 'eng')
		$showFieldArr=array('System','Alarm level','Events','Alarm time','Clear time','Clear');
	elseif ($selectedLanguage == 'chn')
		$showFieldArr=array('系统号','告警等级','描述','告警时间','清除时间','清除');
}
else
{
	if ($selectedLanguage == 'eng')
		$showFieldArr=array('System','Alarm level','Events','Alarm time','Clear time');
	elseif ($selectedLanguage == 'chn')
		$showFieldArr=array('系统号','告警等级','描述','告警时间','清除时间');
}
 
//==========================================================
//输入变量
//==========================================================
//==========================================================
//数据处理
//==========================================================
//告警手动清除

if($actMode == 'clear')
{

	$compCode=$_REQUEST['compCode'];
	$alarmCode=$_REQUEST['alarmCode'];
	$alarmTime=$_REQUEST['alarmTime'];
	$alarmLevel=$_REQUEST['alarmLevel'];
	$sysTypeNo=$_REQUEST['sysTypeNo'];
	$sysNo=$_REQUEST['sysNo'];
	$subSysNo=$_REQUEST['subSysNo'];
	//告警清除时需要的变量
if($DEBUG) echo "<br>actMode	= $actMode";
if($DEBUG) echo "<br>sysTypeNo	= $sysTypeNo";
if($DEBUG) echo "<br>sysNo		= $sysNo";
if($DEBUG) echo "<br>subSysNo	= $subSysNo";
if($DEBUG) echo "<br>compCode	= $compCode";
if($DEBUG) echo "<br>alarmCode	= $alarmCode";
if($DEBUG) echo "<br>alarmTime	= $alarmTime";
if($DEBUG) echo "<br>clearMode	= $clearMode";
//上部页面传入的变量
if($DEBUG) echo "<br>selAlarmLevel	= $selAlarmLevel";
if($DEBUG) echo "<br>selSysTypeNo	= $selSysTypeNo";
//翻页或选择页面时传入的变量,需要包含上部页面传入的变量
if($DEBUG) echo "<br>bgnNo			= $bgnNo";
if($DEBUG) echo "<br>numberOfRecords= $numberOfRecords";
$bssDbConn=mysqli_connect($$OMC_server[0]['host'],$OMC_server[0]['user'],$OMC_server[0]['password'], "BssOmcDb");
	if($sysTypeNo == 500)
	{
		// Clear this alarm in OMCR_ALARMEVENT and OMCR_BSSTREE

	    $sqlstring = "UPDATE OMCR_ALARMEVENT SET Severity=0, ClearTime=NOW()" .
	                 " WHERE bssid=$sysNo" .
	                 " AND ObjectId='$rmObjectid'" .
	                 " AND EventTime='$alarmTime'";
	    //echo $sqlstring . "<BR><br>";
	    $result=mysqli_query($bssDbConn,$sqlstring);
	
	    $sqlstring = "SELECT min(Severity) FROM OMCR_ALARMEVENT" .
	                 " WHERE bssid=$sysNo" .
	                 " AND ObjectId='$Objectid'" .
	                 " AND Severity>0 AND Severity<=3";
	    //echo $sqlstring . "<BR>";
	    $result=mysqli_query($bssDbConn,$sqlstring);
	    $row = mysqli_fetch_row($result);
	
	    if ( $row[0] == null ) //  All alarm cleared
	         $row[0] = 0;
	
	    $sqlstring = "UPDATE OMCR_BSSTREE SET MaxSeverity=" . $row[0] .
	                 " WHERE bssid=$sysNo" .
	                 " AND ObjectId='$rmObjectid'";
	    //echo $sqlstring . "<BR>";
	    $result=mysqli_query($pubConn,$sqlstring);
	    
	   
	}
	else
	{
		$clearAlarmSql=" UPDATE $logTable
					 SET clearTime=CURRENT_TIMESTAMP,clearMode='1',clearBy='$userInfo[ID]' 
					 WHERE sysTypeNo	= '$sysTypeNo' 
						AND sysNo		= '$sysNo' 
						AND subSysNo	= '$subSysNo' 
						AND compCode	= '$compCode' 
						AND alarmCode	= '$alarmCode'
						AND alarmTime	= '$alarmTime'
				   ";
		 if($DEBUG) 
		 echo "<br>clearAlarmSql=$clearAlarmSql";
		 $result=mysqli_query($pubConn	,$clearAlarmSql);
		 echo mysqli_error($pubConn);
	}
	/*
		echo "\n<script language=\"JavaScript\">\n";
		echo "parent.header.document.getElementById(\"searchID\").click();\n";
		echo "</script>\n";
	*/
}
if($selSysTypeNo==500)
{
	//echo "selSysTypeNo:$selSysTypeNo<br>";
	$dbName		= 'BssOmcDb';
	$defTable	= 'BssOmcDb.OMCR_ALARMCODE';
	$logTable	= 'BssOmcDb.OMCR_ALARMEVENT';
	$orderByStr = "EventTime DESC,bssid";//排序顺序
	$numberPerPage	= 100;		//每页纪录数
	
	$whereStr = "";
	if($selAlarmLevel == 'all'){
		$whereStr .="(1)";
	}elseif( $selAlarmLevel == 'unclear'){
		if(strlen($whereStr) > 0){
			$whereStr .=" AND (ClearTime  is null or ClearTime='0')";
		}else{
			$whereStr .=" (ClearTime  is null  or ClearTime='0')";
		}
	}elseif( $selAlarmLevel == 'cleared'){
		if(strlen($whereStr) > 0){
			$whereStr .=" AND ClearTime > '0' ";
		}else{
			$whereStr .=" ClearTime > '0' ";
		}
	}else{
		if(strlen($whereStr) > 0){
			$whereStr .=" AND AlarmLevel = '$selAlarmLevel' AND (ClearTime  is null or ClearTime='0')";
		}else{
			$whereStr .=" AlarmLevel = '$selAlarmLevel' AND (ClearTime  is null or ClearTime='0')";
		}	
	}
	//echo "selAlarmLevel:$selAlarmLevel<br>";
	//echo "logTable:$logTable<br>";
	if($DEBUG) echo "<br>whereStr=$whereStr";
		
	//首次查询，查出符合条件的纪录条数，并在以后的页面跳转中传递。
	if(!$numberOfRecords){
		$bgnNo=0;
		$countSql="SELECT  count(*) as totalNum FROM $logTable WHERE $whereStr";
		if($DEBUG) echo "<br>countSql=$countSql";
		$result=mysqli_query($bssDbConn,$countSql);
		echo mysqli_error($bssDbConn);
		$record = @mysqli_fetch_array($result);
		$numberOfRecords = $record[0];
		
		if($DEBUG) echo "<br>numberOfRecords=$numberOfRecords";
		//插入日志
		insertLog("Veiw Alarm Log");
	}
	$thisPageOtherNum = $numberOfRecords;
	//找到需要显示的纪录
	//$selectFieldList="bssid,AlarmLevel,EventInfo ,alarmTime,clearTime,clearMode,clearInfo";
	$selectFieldList="500 as sysTypeNo,bssid as sysNo,0 as subSysNo,Severity as alarmLevel,EventInfo as $alarmDesc ,EventTime as alarmTime,ClearTime as clearTime,0 as clearMode,ObjectId";
	if($numberOfRecords > 0){ 
		$showSql=" SELECT  $selectFieldList FROM $logTable WHERE $whereStr
					ORDER BY $orderByStr LIMIT $bgnNo, $numberPerPage ";
		if($DEBUG) echo "<br>showSql=$showSql";
		$result=@mysqli_query($bssDbConn,$showSql);
		echo mysqli_error($bssDbConn);
		$rows=@mysqli_fetch_array($result);
	
		//下面是控制分页显示需要传递的变量传递变量  
		if ($numberOfRecords >= 1) {
			$nextBgnNo = $bgnNo + $numberPerPage;  //本页的结束数目  
			if ($nextBgnNo > $numberOfRecords){  
				$nextBgnNo = $numberOfRecords;  
			}  
			$t1 = $bgnNo + 1;  
			$prevBgnNo = $bgnNo - $numberPerPage;  
			if ($prevBgnNo < 0) {  
				$prevBgnNo = 0;  
			}
			$basePageLink	="selSysTypeNo=$selSysTypeNo&selAlarmLevel=$selAlarmLevel&numberOfRecords=$numberOfRecords";
			$prePageLink	="bgnNo=$prevBgnNo";
			$nextPageLink	="bgnNo=$nextBgnNo";
		}  
		$showBgnNo=$bgnNo+1;
	}
}
else
{
	//根据上部页面传来的变量，生成查询条件
	if( strlen($selSysTypeNo) > 0){
		if( $selSysTypeNo != 'all'){
			$whereStr .=" $logTable.sysTypeNo = '$selSysTypeNo'";
		}
		
		if($selAlarmLevel == 'all'){
			$whereStr .=" ";
		}elseif( $selAlarmLevel == 'unclear'){
			if(strlen($whereStr) > 0){
				$whereStr .=" AND clearTime = '0000-00-00 00:00:00' ";
			}else{
				$whereStr .=" clearTime = '0000-00-00 00:00:00' ";
			}
		}elseif( $selAlarmLevel == 'cleared'){
			if(strlen($whereStr) > 0){
				$whereStr .=" AND clearTime <> '0000-00-00 00:00:00' ";
			}else{
				$whereStr .=" clearTime <> '0000-00-00 00:00:00' ";
			}
		}else{
			if(strlen($whereStr) > 0){
				$whereStr .=" AND alarmLevel = '$selAlarmLevel' AND clearTime = '0000-00-00 00:00:00'";
			}else{
				$whereStr .=" alarmLevel = '$selAlarmLevel' AND clearTime = '0000-00-00 00:00:00'";
			}	
		}
	}else{
		if(strlen($whereStr) < 1){	
			$whereStr =" clearTime = '0000-00-00 00:00:00' ";
		}
	}
	
	if($DEBUG) echo "<br>whereStr=$whereStr";
	
	//查询基本条件
	if(strlen($whereStr) > 10){
		$bascWhereStr ="
					AND $logTable.sysTypeNo = $defTable.sysTypeNo 
					AND $logTable.compCode  = $defTable.compCode 
					AND $logTable.alarmCode = $defTable.alarmCode
					";
	}else{
		$bascWhereStr ="
					$logTable.sysTypeNo = $defTable.sysTypeNo 
					AND $logTable.compCode  = $defTable.compCode 
					AND $logTable.alarmCode = $defTable.alarmCode
					";
	}
	
	//首次查询，查出符合条件的纪录条数，并在以后的页面跳转中传递。
	if($selSysTypeNo=='all' || !isset($selSysTypeNo)|| strlen($selSysTypeNo)==0)
	{//get $bssWhereStr
		$bssDB		= 'BssOmcDb';
		$bssLogTable	= 'BssOmcDb.OMCR_ALARMEVENT';
		$bssOrderByStr = "EventTime DESC,bssid";//排序顺序
	
		$bssWhereStr = "";
		if($selAlarmLevel == 'all'){
			$bssWhereStr .="(1)";
		}elseif( strlen($selAlarmLevel)==0 || $selAlarmLevel == 'unclear'){
			if(strlen($bssWhereStr) > 0){
				$bssWhereStr .=" AND (ClearTime  is null or ClearTime='0000-00-00 00:00:00')";
			}else{
				$bssWhereStr .=" (ClearTime  is null  or ClearTime='0000-00-00 00:00:00')";
			}
		}elseif( $selAlarmLevel == 'cleared'){
			if(strlen($bssWhereStr) > 0){
				$bssWhereStr .=" AND ClearTime <> '0000-00-00 00:00:00' ";
			}else{
				$bssWhereStr .=" ClearTime <> '0000-00-00 00:00:00' ";
			}
		}else{
			if(strlen($bssWhereStr) > 0){
				$bssWhereStr .=" AND AlarmLevel = '$selAlarmLevel' AND (ClearTime  is null or ClearTime='0000-00-00 00:00:00')";
			}else{
				$bssWhereStr .=" AlarmLevel = '$selAlarmLevel' AND (ClearTime  is null or ClearTime='0000-00-00 00:00:00')";
			}	
		}
		if($DEBUG) echo "<br>bssWhereStr=$bssWhereStr";
	}//end get $bssWhereStr

	if(!$numberOfRecords){
		if(!isset($bgnNo))
			$bgnNo=0;
		$countSql="SELECT  count(*) as totalNum
					FROM $logTable,$defTable
					WHERE $whereStr
					$bascWhereStr
					";
		if($DEBUG) echo "<br>countSql=$countSql";
		$result=mysqli_query($pubConn,$countSql);
		echo mysqli_error($pubConn);
		$record = @mysqli_fetch_array($result);
		$numberOfRecords = $record[0];
		
		if($DEBUG) 
		echo "<br>numberOfRecords=$numberOfRecords";
		if($selSysTypeNo=='all' || !isset($selSysTypeNo)|| strlen($selSysTypeNo)==0)
		{
			if(!$numberofBSS){
				//$bgnNo=0;
				$countSql="SELECT  count(*) as totalNum FROM $bssLogTable WHERE $bssWhereStr";
				if($DEBUG) echo "<br>countBSSSql=$countSql";
				$bssResult=mysqli_query($pubConn,$countSql);
				echo mysqli_error($pubConn);
				$bssRecord = @mysqli_fetch_array($bssResult);
				$numberofBSS = $bssRecord[0];
			}
			$numberOfRecords +=$numberofBSS;	
		}
				
		if($DEBUG) echo "<br>numberofBSS=$numberofBSS";
		//插入日志
		if($nolog != 1)
			insertLog("View Alarm Log");
	}

	//找到需要显示的纪录
	if($numberOfRecords > 0){ 
		$showSql=" SELECT  $selectFieldList
					FROM $logTable,$defTable
					WHERE $whereStr
					$bascWhereStr
					ORDER BY $orderByStr
					LIMIT $bgnNo, $numberPerPage
				";
		if($DEBUG) echo "<br>showSql=$showSql";
		$result=@mysqli_query($pubConn,$showSql);
		echo mysqli_error($pubConn);
		$thisPageOtherNum = @mysqli_num_rows($result);
		$rows=@mysqli_fetch_array($result);
	
		if($DEBUG)echo "<br>thisPageOtherNum:$thisPageOtherNum";

		if($selSysTypeNo=='all' || !isset($selSysTypeNo)|| strlen($selSysTypeNo)==0)
		if($thisPageOtherNum==0 || $thisPageOtherNum< $numberPerPage)
		{
			//echo "$thisPageOtherNum< $numberPerPage";
			$countSql="SELECT  count(*) as totalNum
					FROM $logTable,$defTable
					WHERE $whereStr
					$bascWhereStr
						";
			if($DEBUG) echo "<br>countSql=$countSql";
			$cntResult=mysqli_query($pubConn,$countSql);
			echo mysqli_error($pubConn);
			$record = @mysqli_fetch_array($cntResult);
			$otherTotalNum = $record[0];
			
			$bssBgnNo = $bgnNo+$thisPageOtherNum-$otherTotalNum;
			$selectFieldList="500 as sysTypeNo,bssid as sysNo,0 as subSysNo,Severity as alarmLevel,EventInfo as $alarmDesc ,EventTime as alarmTime,ClearTime as clearTime,0 as clearMode,ObjectId";
			
			$showSql=" SELECT  $selectFieldList FROM $bssLogTable WHERE $bssWhereStr
						ORDER BY $bssOrderByStr LIMIT $bssBgnNo, $numberPerPage ";
			if(0) 
			echo "<br>bssShowSql=$showSql";
			$bss_Result=@mysqli_query($pubConn,$showSql);
			echo mysqli_error($pubConn);	
			$thisPageBSSNum = @mysqli_num_rows($bss_Result);
			$bss_Rows=@mysqli_fetch_array($bss_Result);
		}
		
		//下面是控制分页显示需要传递的变量传递变量  
		if ($numberOfRecords >= 1) {
			
			$nextBgnNo = $bgnNo + $numberPerPage;  //本页的结束数目  
			
			if ($nextBgnNo > $numberOfRecords){  
				$nextBgnNo = $numberOfRecords;  
			}  
			$t1 = $bgnNo + 1;  
			$prevBgnNo = $bgnNo - $numberPerPage;  
			if ($prevBgnNo < 0) {  
				$prevBgnNo = 0;  
			}
			$basePageLink	="selSysTypeNo=$selSysTypeNo&selAlarmLevel=$selAlarmLevel&numberOfRecords=$numberOfRecords";
			$prePageLink	="bgnNo=$prevBgnNo";
			$nextPageLink	="bgnNo=$nextBgnNo";
			
		}  
		$showBgnNo=$bgnNo+1;
	}
}//end else.
//==========================================================
//输出并显示数据
//==========================================================

?>



<form name="selectform" action="./alarmList_down.php" method="post">
<?php  
echo "<input type=\"hidden\" value=\"$selSysTypeNo\" name=\"selSysTypeNo\">";
echo "<input type=\"hidden\" value=\"$selAlarmLevel\" name=\"selAlarmLevel\">";
echo "<input type=\"hidden\" value=\"$noop\" name=\"noop\">";
if($numberOfRecords == 0){
	echo "<br><font size =\"3\" color=\"#000000\">Currently there is no alarm!</font>";  
	exit();
}

?>

<TABLE  border="0" width="100%" cellpadding="2" cellspacing="0" bordercolor="#666666" bordercolordark="#FFFFFF">      
  <TR>
	<TD >
		<?php 
			echo "$strDisplayRecords<FONT color=#0000ff>&nbsp;$showBgnNo - $nextBgnNo</FONT>, ";
			echo "($strTotal:$numberOfRecords)";   
		?>
	</TD>
	<TD align="right">   
		<?php 
			// NEW: Display a link for the previous set of records.  
			if ($bgnNo != 0) { 
				echo "<a href=\"$PHP_SELF?$basePageLink&$prePageLink\">"; 
				echo "Previous&nbsp;<IMG alt=$strPreviousPage align=absBottom border=0  src=../../images/left.gif ></a>&nbsp;";  
			}else{
				echo "<font color=\"#808080\">Previous&nbsp;</font><IMG alt=$strPreviousPage align=absBottom border=0  src=../../images/left_1.gif ></a>&nbsp;"; 
			}  
		  
			//根据纪录条数，算出页码数，本页页码
			if($numberOfRecords > 0){
				$totalPageNum = ceil($numberOfRecords / $numberPerPage );
				$pageNo = $bgnNo / $numberPerPage + 1;
			}

			echo "<SELECT size=\"1\" name=\"pageNo\" onChange=\"javasript:goPage($numberOfRecords)\">";
			for($i=1;$i<=$totalPageNum;$i++){
				if($i== $pageNo){
					echo "<option  selected  value=\"$i\" >$i</option>";
				}else{
					echo "<option value=\"$i\">$i</option>";
				}
			}
			echo "</SELECT>";

			// NEW: Display a link for the next set of records.  
			if ($nextBgnNo != $numberOfRecords && $numberOfRecords >0) {  
				echo "<a href=\"$PHP_SELF?$basePageLink&$nextPageLink\">";
				echo "<IMG alt=$strNextPage align=absBottom border=0  src=../../images/right.gif>&nbsp;Next</a>"; 
			}else{
				echo "<IMG alt=$strNextPage align=absBottom border=0  src=../../images/right_1.gif ><font color=\"#808080\">&nbsp;Next</font>";
			} 
		?>
	</TD>
  </TR>  
</TABLE> 
<table border="1" width="100%"  cellpadding="1" cellspacing="0"  bordercolor="#666666" bordercolordark="#FFFFFF">
  <tr bgcolor="#E6E6E6">
    <?php
	$i=0;
	for($i=0;$i<sizeof($showFieldArr);$i++){
		echo "<td align=\"center\">";
		echo "$showFieldArr[$i]";
		echo "</td>";
	}
	?>
  </tr>
 
  <?php  
if($thisPageOtherNum>0)
do
{
	if($selSysTypeNo==500)
	{
		$sysName = "BSS_".$rows[sysNo]."_".$rows[subSysNo];
	}
	else
	{
		for($i=0; $i < sizeof($sysTypeDef); $i++){
			if($rows[sysTypeNo] == $sysTypeDef[$i][sysTypeNo]){
				$sysName=$sysTypeDef[$i][sysTypeName].'_'.$rows[sysNo].'_'.$rows[subSysNo];
				$sysId=$rows[sysTypeName].'_'.$rows[sysNo].'_'.$rows[subSysNo];
				
				break;
			}
		}
		if(strlen($sysName) < 3){
			$sysName='unknown';
			//continue;
		}
	}
	$sysTypeNo	=$rows[sysTypeNo];
	$sysNo		=$rows[sysNo];
	$subSysNo	=$rows[subSysNo];
	$compCode	=$rows[compCode];
	$alarmCode	=$rows[alarmCode];
	$alarmLevel	=$rows[alarmLevel];
	$descript	=$rows[$alarmDesc];
	$alarmTime	=$rows[alarmTime];
	$clearTime	=$rows[clearTime];
	$clearMode	=$rows[clearMode];
	$sysName=getSystemNameBySysTypeNo($sysTypeNo).'_'.$rows[sysNo].'_'.$rows[subSysNo];;
	echo "<tr>";
	echo "<td align=\"right\">";
	echo "&nbsp; $sysName";
	echo "</td>";

	echo "<td align=\"left\">";
	$alarmLevelRemark=$alarmLevelDefArr[$alarmLevel][remark];
	echo "<font color=\"{$alarmLevelDefArr[$alarmLevel][color]}\">&nbsp; $alarmLevelRemark</font>";
	echo "</td>";

	echo "<td align=\"left\">";
	echo "&nbsp; $descript";
	echo "</td>";
	
	echo "<td align=\"right\">";
	echo "&nbsp; $alarmTime";
	echo "</td>";

	echo "<td align=\"right\">";
	echo "&nbsp; $clearTime";
	echo "</td>";
	
	if($noop!=1)
	{
		echo "<td align=\"center\">";
		if($clearTime == "0000-00-00 00:00:00"){
			if($sysTypeNo==500){
				echo "<a href=\"$PHP_SELF?actMode=clear&sysTypeNo=$sysTypeNo&sysNo=$sysNo&subSysNo=$subSysNo";
				echo "&compCode=$compCode&alarmCode=$alarmCode&alarmTime=$alarmTime&alarmLevel=$alarmLevel";
				echo "&selSysTypeNo=$selSysTypeNo&selAlarmLevel=$selAlarmLevel&bgnNo=$bgnNo&rmObjectid=$rows[ObjectId]";
				echo "\"><img src=\"../../images/delete.gif\" border=\"0\"></a>";
			}else{
				
				echo "<a href=\"$PHP_SELF?actMode=clear&sysTypeNo=$sysTypeNo&sysNo=$sysNo&subSysNo=$subSysNo";
				echo "&compCode=$compCode&alarmCode=$alarmCode&alarmTime=$alarmTime&alarmLevel=$alarmLevel";
				echo "&selSysTypeNo=$selSysTypeNo&selAlarmLevel=$selAlarmLevel&bgnNo=$bgnNo";
				echo "\"><img src=\"../../images/delete.gif\" border=\"0\"></a>";
			}
			
		}elseif( $clearTime != '0000-00-00 00:00:00' && $clearMode == 1){
			echo "--";
		}elseif( $clearTime != '0000-00-00 00:00:00' && $clearMode == 0){
			echo "--";
		}
		echo "</td>";
	}
	echo "</tr>";
}while($rows=mysqli_fetch_array($result));

if($thisPageBSSNum>0)
do
{
	$sysName = "BSS_".$bss_Rows[sysNo]."_".$bss_Rows[subSysNo];
	$sysTypeNo	=$bss_Rows[sysTypeNo];
	$sysNo		=$bss_Rows[sysNo];
	$subSysNo	=$bss_Rows[subSysNo];
	$compCode	=$bss_Rows[compCode];
	$alarmCode	=$bss_Rows[alarmCode];
	$alarmLevel	=$bss_Rows[alarmLevel];
	$descript	=$bss_Rows[$alarmDesc];
	$alarmTime	=$bss_Rows[alarmTime];
	$clearTime	=$bss_Rows[clearTime];
	$clearMode	=$bss_Rows[clearMode];
	
	echo "<tr>";
	echo "<td align=\"right\">";
	echo "&nbsp; $sysName";
	echo "</td>";

	echo "<td align=\"left\">";
	$alarmLevelRemark=$alarmLevelDefArr[$alarmLevel][remark];
	echo "<font color=\"{$alarmLevelDefArr[$alarmLevel][color]}\">&nbsp; $alarmLevelRemark</font>";
	echo "</td>";

	echo "<td align=\"left\">";
	echo "&nbsp; $descript";
	echo "</td>";
	
	echo "<td align=\"right\">";
	echo "&nbsp; $alarmTime";
	echo "</td>";

	echo "<td align=\"right\">";
	echo "&nbsp; $clearTime";
	echo "</td>";
	if($noop!=1)
		echo "<td align=\"center\">";
	if($clearTime == '0000-00-00 00:00:00' && $noop!=1){
		if($sysTypeNo==500){
			echo "<a href=\"$PHP_SELF?actMode=clear&sysTypeNo=$sysTypeNo&sysNo=$sysNo&subSysNo=$subSysNo";
			echo "&compCode=$compCode&alarmCode=$alarmCode&alarmTime=$alarmTime&alarmLevel=$alarmLevel";
			echo "&selSysTypeNo=$selSysTypeNo&selAlarmLevel=$selAlarmLevel&bgnNo=$bgnNo&rmObjectid=$bss_Rows[ObjectId]";
			echo "\"><img src=\"../../images/delete.gif\" border=\"0\"></a>";
		}else{
			echo "<a href=\"$PHP_SELF?actMode=clear&sysTypeNo=$sysTypeNo&sysNo=$sysNo&subSysNo=$subSysNo";
			echo "&compCode=$compCode&alarmCode=$alarmCode&alarmTime=$alarmTime&alarmLevel=$alarmLevel";
			echo "&selSysTypeNo=$selSysTypeNo&selAlarmLevel=$selAlarmLevel&bgnNo=$bgnNo";
			echo "\"><img src=\"../../images/delete.gif\" border=\"0\"></a>";
		}
	}elseif( $clearTime != '0000-00-00 00:00:00' && $clearMode == 1 && $noop!=1){
		echo "--";
	}elseif( $clearTime != '0000-00-00 00:00:00' && $clearMode == 0 && $noop!=1){
		echo "--";
	}
	echo "</td>";
	echo "</tr>";
}while($bss_Rows=@mysqli_fetch_array($bss_Result));
?>
</table>
</form> 
<?php 
adjust_content_tail("down");
?>
</body>
</html>