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

<?php
$response="";
global $pubConn;
$confInfo=GetConfInfo();
if(strcasecmp($confInfo[SystemType],"MCMS") == 0)
	$sql="select * from OMC_PUB.sysInfo where sysTypeNo=0 order by sysTypeNo asc,sysNo asc ";
else	
	$sql="select * from OMC_PUB.sysInfo where sysTypeNo=0 or sysTypeNo=320 or sysTypeNo=390 or sysTypeNo=395 order by sysTypeNo asc,sysNo asc ";
	
//echo "$sql<br>";
$res=mysqli_query($pubConn,$sql);
$num=mysqli_num_rows($res);

if($num == 0)
{
	$response.="tr,blank_line,block;";
	for($i=0;$i<16;$i++)
		$response.="tr,tr_{$i},none;";
}
else
{
	$response.="tr,blank_line,none;";
	for($i=0;$i<16;$i++)
	{
		if($i<$num)
		{
			$row=@mysqli_fetch_array($res);
			$sysTypeNo=$row['sysTypeNo']-0;
			$sysNo=$row[sysNo]-0;
			$diskInfo=GetDiskInfo($sysTypeNo,$sysNo);
			$response.="tr,tr_{$i},block;";
			//if($diskInfo[DiskCount][Value] > 0)
				$response.="td,td_{$i}_0,<a href=\"./diskStatus.php?sysTypeNo=$sysTypeNo&sysNo=$sysNo\">{$diskInfo[ServerName][Value]}</a>,{$diskInfo[ServerName][Color]};";
			//else
			//	$response.="td,td_{$i}_0,{$diskInfo[ServerName][Value]},{$diskInfo[ServerName][Color]};";
				
			$response.="td,td_{$i}_1,{$diskInfo[DiskCount][Value]},{$diskInfo[DiskCount][Color]};";
			for($j=0;$j<6;$j++)
			{
				$id=2+$j;
				if($j<$diskInfo[DiskCount][Value])
					echo "td,td_{$i}_{$id},{$diskInfo[$j][DiskState][Value]},{$diskInfo[$j][DiskState][Color]};";
				else
					$response.="td,td_{$i}_{$id},--,#000000;";
			}
			$response.="td,td_{$i}_8,{$diskInfo[UpdateTime][Value]},{$diskInfo[UpdateTime][Color]};";
		}
		else
		{
			$response.="tr,tr_{$i},none;";
		}
	}	
}

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