<?php
require("../../inc/lib.inc");
require("./function.inc");
?>

<?php
$response="";
$td_opt=",,";
$tr_opt=";;";

$diskInfo=GetDiskInfo($sysTypeNo,$sysNo);
//print_r($diskInfo);

$response.="td{$td_opt}td_card_name{$td_opt}{$diskInfo[CardName][Value]}{$td_opt}{$diskInfo[CardName][Color]}{$tr_opt}";
$response.="td{$td_opt}td_disk_count{$td_opt}{$diskInfo[DiskCount][Value]}{$td_opt}{$diskInfo[DiskCount][Color]}{$tr_opt}";
$response.="td{$td_opt}td_update_time{$td_opt}{$diskInfo[UpdateTime][Value]}{$td_opt}{$diskInfo[UpdateTime][Color]}{$tr_opt}";

if($diskInfo[DiskCount][Value]>0)
	$response.="tr{$td_opt}blank_line{$td_opt}none{$tr_opt}";
else
	$response.="tr{$td_opt}blank_line{$td_opt}block{$tr_opt}";
	

for($index=0;$index<6;$index++)
{
	if($index < $diskInfo[DiskCount][Value])
	{
		$response.="tr{$td_opt}tr_{$index}{$td_opt}block{$tr_opt}";
		$response.="td{$td_opt}td_{$index}_1{$td_opt}{$diskInfo[$index][DiskState][Value]}{$td_opt}{$diskInfo[$index][DiskState][Color]}{$tr_opt}";
		$response.="td{$td_opt}td_{$index}_2{$td_opt}{$diskInfo[$index][DiskSize][Value]}{$td_opt}{$diskInfo[$index][DiskSize][Color]}{$tr_opt}";
		$response.="td{$td_opt}td_{$index}_3{$td_opt}{$diskInfo[$index][VendorID][Value]}{$td_opt}{$diskInfo[$index][VendorID][Color]}{$tr_opt}";
		$response.="td{$td_opt}td_{$index}_4{$td_opt}{$diskInfo[$index][ProductID][Value]}{$td_opt}{$diskInfo[$index][ProductID][Color]}{$tr_opt}";
		$response.="td{$td_opt}td_{$index}_5{$td_opt}{$diskInfo[$index][DiskSlot][Value]}{$td_opt}{$diskInfo[$index][DiskSlot][Color]}{$tr_opt}";
		$response.="td{$td_opt}td_{$index}_6{$td_opt}{$diskInfo[$index][DiskERRC][Value]}{$td_opt}{$diskInfo[$index][DiskERRC][Color]}{$tr_opt}";
		$response.="td{$td_opt}td_{$index}_7{$td_opt}{$diskInfo[$index][OptProg][Value]}{$td_opt}{$diskInfo[$index][OptProg][Color]}{$tr_opt}";
	}
	else
	{
		$response.="tr{$td_opt}tr_{$index}{$td_opt}none{$tr_opt}";
	}
}

//Alarm
$omcSysNo=getOmcSysNo();
$confInfo=GetConfInfo();
if($sysTypeNo == 0)
{
	if(strcmp($confInfo[SystemType],"MCSS")==0)
		$reg_rule="^2{$sysNo}.$";
	else
		$reg_rule="^1{$sysNo}.$";
}
else if($sysTypeNo == 320)
{
	$reg_rule="^3{$sysNo}.$";
}
else if($sysTypeNo == 390)
{
	$reg_rule="^4{$sysNo}.$";
}
else if($sysTypeNo == 395)
{
	$reg_rule="^5{$sysNo}.$";
}

$sql="select * from sysAlarmLog where sysTypeNo=234 and sysNo={$omcSysNo} and clearMode=0 and compCode regexp '{$reg_rule}' order by alarmTime desc";
$res=mysqli_query($pubConn,$sql);
$num=mysqli_num_rows($res);
if($num > 0)
{
	$message="<center><font size=2 color=blue>{$diskInfo[ServerName][Value]} Alarm List</font></center>";
	$message.="<table width=100% border=1 cellpadding=1 cellspacing=0 bordercolor=#666666 bordercolordark=#FFFFFF bgcolor=\"#ffffff\">";
	$message.="<tr bgcolor=\"#E6E6E6\">";
	$message.="<td>Alarm Level</td>";
	$message.="<td>Events</td>";
	$message.="<td>Alarm Time</td>";
	$message.="</tr>";
	
	for($i=0;$i<$num;$i++)
	{
		$row=mysqli_fetch_array($res);
		$alarmTime=$row[alarmTime];
		$tmpsql="select * from sysAlarmConf where sysTypeNo=234 and compCode='$row[compCode]' and alarmCode='$row[alarmCode]' ";
		$tmpres=@mysqli_query($pubConn,$tmpsql);
		echo mysqli_error($pubConn);
		$tmprow=@mysqli_fetch_array($tmpres);
		$alarmLevel=$tmprow[alarmLevel];
		if(trim($tmprow[alarmDesc_2]) == "")
			$message.="<tr style=\"display:none\">";
		else
			$message.="<tr>";
		$message.="<td>{$alarmLevelDefArr[$alarmLevel][remark]}</td>";
		$message.="<td>{$tmprow[alarmDesc_2]}</td>";
		$message.="<td>$alarmTime</td>";
		$message.="</tr>";
	}
	$message.="</table>";
	
	$response.="alarm{$td_opt}AlarmTable{$td_opt}{$message}{$tr_opt}";
}
else
{
	$response.="alarm{$td_opt}AlarmTable{$td_opt}none{$tr_opt}";
}

//system("echo '$response'>>/tmp/test.txt");

echo $response;
?>
