<?php
//Include the head file
require("../../inc/header.inc");
?>
<style type="text/css">
<!--
.style3 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 8pt;background: url(--.gif); border: 0px;  height: 16px;}
-->
</style>
<body>
	
	
<?php
//================================data define===============================================
//$card_status[platNo][cardNo]    due to: refresh time,Layer1,Layer2,cpuLoad,0-normal 1-abnormal
//$card_refreshTime[platNo][cardNo]
//$card_clock[platNo][cardNo]
//$card_sync[platNo][cardNo]
//$card_version[platNo][cardNo]
//$card_HWaddr[platNo][cardNo]
//$card_type[platNo][cardNo]
for($i=0;$i<2;$i++)
{
	for($j=0;$j<16;$j++)
	{
		$card_status[$i][$j]="--";
		$card_refreshTime[$i][$j]="--";
		$card_refreshTime_full[$i][$j]="--";
		$card_clock[$i][$j]="--";
		$card_sync[$i][$j]="--";
		$card_version[$i][$j]="--";
		$card_HWaddr[$i][$j]="--";
		$card_type[$i][$j]="--";
	}
}
//$port_e1Install[platNo][cardNo][portNo]  port enable or disable
//$port_layer1[platNo][cardNo][portNo]
//$port_layer2[platNo][cardNo][portNo]
//$port_echoCanceller[platNo][cardNo][portNo]
//$port_channel[platNo][cardNo][portNo]
//$port_type[platNo][cardNo][portNo]
for($i=0;$i<2;$i++)
{
	for($j=0;$j<16;$j++)
	{
		for($k=0;$k<8;$k++)
		{
	
			$port_layer1[$i][$j][$k]="--";
			$port_layer2[$i][$j][$k]="--";
			$port_echoCanceller[$i][$j][$k]="--";
			$port_channel[$i][$j][$k]="--";
			$port_type[$i][$j][$k]="--";
			
			$port_e1Install[$i][$j][$k]="--";
			$port_e1L2Install[$i][$j][$k]="--";
		}
	}
}


//===============================initial==================================================
$database=$omc_db;
$table_name="sysStat";
$dueDate = date("Y-m-d H:i:s",mktime(date("H"),date("i"),date("s")-$heatbeat_overtime,date("m"),date("d"),date("Y")));

//echo "$database--$table_name--$dueDate<br>";
//begin bit
$ver_bgn	=	18;	//version
$typ_bgn	=	21;	//subsys type
$ins_bgn	=	22;	//e1 installed
$inl_bgn	=   23; //e1 layer2 installed
$phy_bgn	=	24;	//e1 layer1(physical layer)
$tra_bgn	=	25;	//e1 layer2(transport layer)
$can_bgn	=	26;	//echo canceller status
$cpu_bgn	=	27;	//cpu loading
$loc_bgn	=	28;	//lock status
$fre_bgn	=	29;	//frequency
$pow_bgn	=	30;	//power card and master clock
$pra_bgn	=	31; //E1 FRAMER status
$ch_bgn		=	31; 
$att_bgn	=	39;

$HWaddr_bgn	=	17;
$msc_bgn_byt=19;

//========================Get the data from database sysTypeNo=111============================

$selSql = " SELECT sysTypeNo,sysNo,subSysNo,detailStat,updateTime FROM OMC_PUB.sysStat 
			WHERE sysTypeNo=111 AND (sysNo='0' OR sysNo='1')";
			
$selRes = @mysqli_query($pubConn,$selSql);
$selRow = @mysqli_fetch_array($selRes);
echo mysqli_error($pubConn);

do{
	//If there is not any card,then break
	if(!$selRow)
		break;
	
	$platNo = $selRow[sysNo];
	$cardNo = $selRow[subSysNo];
	$hex_mes = $selRow[detailStat];
	$bin_mes='';
	if($DEBUG) echo "<br>hex_mes=$hex_mes";
	for($i=0;$i<strlen($hex_mes);$i++){
		$sig_hex_mes=substr($hex_mes,$i,1);
		$sig_dec_mes=HexDec($sig_hex_mes);
		$sig_bin_mes=DecBin($sig_dec_mes);
		$sig_bin_mes=omc_keep_length($sig_bin_mes,0,4);
		$bin_mes.=$sig_bin_mes;
	}
	if($DEBUG) echo "<br>bin_mes=$bin_mes";
	//=============card status===============
	$card_status[$platNo][$cardNo] = 0;
	//==============card refresh time==============
	$card_refreshTime[$platNo][$cardNo]=$selRow[updateTime];
	$card_refreshTime_full[$platNo][$cardNo]=$selRow[updateTime];
	
	
	if($card_refreshTime[$platNo][$cardNo] <= $dueDate)
	{
		$card_status[$platNo][$cardNo]=1;
	}
	

	//================version===============
	$bin_ver_0=substr($bin_mes,$ver_bgn*8,8);
	$dec_ver_0=BinDec($bin_ver_0);
	
	$bin_ver_1=substr($bin_mes,($ver_bgn+1)*8,8);
	$dec_ver_1=BinDec($bin_ver_1);
	$dec_ver_1=omc_keep_length($dec_ver_1,0,2);

	$bin_ver_2=substr($bin_mes,($ver_bgn+2)*8,8);
	$dec_ver_2=BinDec($bin_ver_2);
	$dec_ver_2=omc_keep_length($dec_ver_2,0,2);

	$card_version[$platNo][$cardNo]= $dec_ver_0.".".$dec_ver_1.".".$dec_ver_2;
	
	 

	//===============card type==================
	$bin_typ = substr($bin_mes,$typ_bgn*8,8);
	$card_type[$platNo][$cardNo]= BinDec($bin_typ);

	//==================e1 install===============
	for($i=0;$i<8;$i++){
		$bin_ins=substr($bin_mes,$ins_bgn*8+7-$i,1);
		$port_e1Install[$platNo][$cardNo][$i]=BinDec($bin_ins);		
		
		
	}


	//==============e1 layer2 install==============
	for($i=0;$i<8;$i++)
	{
		$bin_inl=substr($bin_mes,$inl_bgn*8+7-$i,1);
		$port_e1L2Install[$platNo][$cardNo][$i]=BinDec($bin_inl);
	}

	//================e1 layer1=============
	for($i=0;$i<8;$i++){
		$bin_phy=substr($bin_mes,$phy_bgn*8+7-$i,1);
		$port_layer1[$platNo][$cardNo][$i] = BinDec($bin_phy);
		
		if($port_e1Install[$platNo][$cardNo][$i] == 0){
			$port_layer1[$platNo][$cardNo][$i]=2;
		}


		if($port_layer1[$platNo][$cardNo][$i] == 1){
			$card_status[$platNo][$cardNo]=1;
		}
	}

	//=============e1 layer2================
	for($i=0;$i<8;$i++) {
		$bin_tra=substr($bin_mes,$tra_bgn*8+7-$i,1);
		$port_layer2[$platNo][$cardNo][$i]=BinDec($bin_tra);
		if($port_e1Install[$platNo][$cardNo][$i] == 0 || $port_e1L2Install[$platNo][$cardNo][$i] == 0){
			$port_layer2[$platNo][$cardNo][$i]=2;
		}
		if($port_layer2[$platNo][$cardNo][$i] == 0){
			$card_status[$platNo][$cardNo]=1;
		}
	}

	//===========echo canceller status=========
	for($i=0;$i<8;$i++){
		$bin_can=substr($bin_mes,$can_bgn*8+7-$i,1);
		$port_echoCanceller[$platNo][$cardNo][$i]=BinDec($bin_can);
		if($port_e1Install[$platNo][$cardNo][$i] == 0){
			$port_echoCanceller[$platNo][$cardNo][$i] = 0;
		}
  }

	//============cpu loading===============
	$bin_cpu=substr($bin_mes,$cpu_bgn*8,8);
	$dec_cpu=BinDec($bin_cpu);
	if($DEBUG) echo "<br>dec_cpu=$dec_cpu";

	$cpu_load=change2point($dec_cpu/126);
	if($cpu_load>100){
		$cpu_load=100;
	}
	elseif($cpu_load<0){
		$cpu_load=0;
	}
	if($DEBUG) 
		echo "<br>cpu_load=$cpu_load";
	if($cpu_load>90){
		$card_status[$platNo][$cardNo] = 1;
	}

  //===========card sync================
	$bin_loc = substr($bin_mes,$loc_bgn*8,8);
	$card_sync[$platNo][$cardNo] = BinDec($bin_loc);

	//===========master clock=============
	$bin_mas = substr($bin_mes,$pow_bgn*8+7,1);
	$card_clock[$platNo][$cardNo] = BinDec($bin_mas);

}while($selRow = @mysqli_fetch_array($selRes));



//==========================Get the data from database sysTypeNo=112=========================
$selSql = " SELECT sysTypeNo,sysNo,subSysNo,detailStat,updateTime FROM OMC_PUB.sysStat 
			WHERE sysTypeNo=112";
$selRes = @mysqli_query($pubConn,$selSql);
$selRow = @mysqli_fetch_array($selRes);
echo mysqli_error($pubConn);

do{
	if(!$selRow)
		break;
	$platNo = $selRow[sysNo];
	$cardNo = $selRow[subSysNo];
	$hex_mes = $selRow[detailStat];
	if($DEBUG) echo "<br>hex_mes=$hex_mes";

	$card_HWaddr[$platNo][$cardNo] = substr($hex_mes,$HWaddr_bgn*2,12);
}while($selRow = @mysqli_fetch_array($selRes));



//===========================Get the data from database sysTypeNo=320=======================


$selSql = " SELECT sysNo,subSysNo,detailStat,updateTime FROM OMC_PUB.sysStat 
			WHERE sysTypeNo=320 AND (sysNo='0' OR sysNo='1')";
$selRes = @mysqli_query($pubConn,$selSql);
$selRow = @mysqli_fetch_array($selRes);
echo mysqli_error($pubConn);


do
{
	if(!$selRow)
		break;
	$platNo = $selRow[sysNo];
	$hex_mes = $selRow[detailStat];
	if($DEBUG) echo "<br>hex_mes=$hex_mes";
	
	$bin_mes='';
	for($i=0;$i<strlen($hex_mes);$i++){
		$sig_hex_mes=substr($hex_mes,$i,1);
		$sig_dec_mes=HexDec($sig_hex_mes);
		$sig_bin_mes=DecBin($sig_dec_mes);
		$sig_bin_mes=omc_keep_length($sig_bin_mes,0,4);
		$bin_mes.=$sig_bin_mes;
	}
	if($DEBUG)echo "<br>bin_mes=$bin_mes";


	for($i=0;$i<128;$i++)
	{
		$cardNo = floor($i/8);
		$portNo=$i%8;
		//=================port type========================
		if($DEBUG)echo "<br>i=$i";
		$BinStatus=substr($bin_mes,($msc_bgn_byt+24)*8+$i*8,3);
		$DecStatus=BinDec($BinStatus);
		if($DEBUG)echo "<br>DecStatus=$DecStatus";
		$port_type[$platNo][$cardNo][$portNo]=$DecStatus;
		//===============port channel======================
		$BinAttribute=substr($bin_mes,($msc_bgn_byt+24)*8+$i*8+3,5);
		$DecAttribute=BinDec($BinAttribute);
		if($DEBUG)
			echo "<br>DecAttribute=$DecAttribute";
		
		if($port_e1Install[$platNo][$cardNo][$portNo]=="--")
		{
			$port_channel[$platNo][$cardNo][$portNo]="--";
		}
		else
			$port_channel[$platNo][$cardNo][$portNo]=$DecAttribute;
		
	}

}while($selRow = @mysqli_fetch_array($selRes));

//==============================format the data======================================
$card_status_format=array(0=>"Y",1=>"N","--"=>"--");
$card_clock_format=array(0=>"Slave",1=>"Master","--"=>"--");
$card_sync_format=array(0=>"Init",1=>"Search",2=>"Locked",3=>"Threshold",4=>"Adjust",5=>"HoldOver",6=>"StopAtOppm",7=>"Idle","--"=>"--");
$card_type_format=array(0=>"E1",1=>"T1","--"=>"--");
for($i=0;$i<2;$i++)
{
	for($j=0;$j<16;$j++)
	{
		$card_status[$i][$j]=$card_status_format[$card_status[$i][$j]];
		$card_clock[$i][$j]=$card_clock_format[$card_clock[$i][$j]];
		$card_sync[$i][$j]=$card_sync_format[$card_sync[$i][$j]];
		
		if(strlen($card_refreshTime[$i][$j])>5)
			$card_refreshTime[$i][$j]=substr($card_refreshTime[$i][$j],11,8);
		
		if(strlen($card_refreshTime[$i][$j])<3)
		{
			$card_HWaddr[$i][$j]="--";
		}
		else
		{
			if(strlen($card_HWaddr[$i][$j])>5)
			{
				$temp="";
				for($z=0;$z<5;$z++)
				{
					$temp.=substr($card_HWaddr[$i][$j],$z*2,2);
					$temp.=":";
				}
				$temp.=substr($card_HWaddr[$i][$j],10,2);
				$card_HWaddr[$i][$j]=$temp;
				
			}
		}	
		$card_type[$i][$j]=$card_type_format[$card_type[$i][$j]];
	}
}


$port_enable_format=array(0=>"--",1=>"Y","--"=>"--");
$port_layer1_format=array(0=>"Y",1=>"N",2=>"--","--"=>"--");
$port_layer2_format=array(0=>"N",1=>"Y",2=>"--","--"=>"--");
$port_echoCanceller_format=array(0=>"--",1=>"Y","--"=>"--");
$port_type_format=array(0=>"TUP",1=>"ISUP",2=>"AIF",3=>"ISDN-NT",4=>"ISDN-LT",5=>"CI-CNF",6=>"CI-INT",7=>"--","--"=>"--");
for($i=0;$i<2;$i++)
{
	for($j=0;$j<16;$j++)
	{
		for($k=0;$k<8;$k++)
		{
			if($card_status[$i][$j] == "--")
			{
				$port_e1Install[$i][$j][$k]="--";
				$port_layer1[$i][$j][$k]="--";
				$port_layer2[$i][$j][$k]="--";
				$port_echoCanceller[$i][$j][$k]="--";
				$port_type[$i][$j][$k]="--";
			}
			else
			{
				$port_e1Install[$i][$j][$k]=$port_enable_format[$port_e1Install[$i][$j][$k]];
				$port_layer1[$i][$j][$k]=$port_layer1_format[$port_layer1[$i][$j][$k]];
				$port_layer2[$i][$j][$k]=$port_layer2_format[$port_layer2[$i][$j][$k]];
				$port_echoCanceller[$i][$j][$k]=$port_echoCanceller_format[$port_echoCanceller[$i][$j][$k]];
				$port_type[$i][$j][$k]=$port_type_format[$port_type[$i][$j][$k]];
			}
		}
	}
}
//============================clear button=============================================
if($clear){
	for($i=0;$i<2;$i++)
	{
		for($j=0;$j<16;$j++)
		{
			$card_status[$i][$j]="--";
			$card_refreshTime[$i][$j]="--";
			$card_clock[$i][$j]="--";
			$card_sync[$i][$j]="--";
			$card_version[$i][$j]="--";
			$card_HWaddr[$i][$j]="--";
			$card_type[$i][$j]="--";
		}
	}
	
	for($i=0;$i<2;$i++)
	{
		for($j=0;$j<16;$j++)
		{
			for($k=0;$k<8;$k++)
			{
		
				$port_layer1[$i][$j][$k]="--";
				$port_layer2[$i][$j][$k]="--";
				$port_echoCanceller[$i][$j][$k]="--";
				$port_channel[$i][$j][$k]="--";
				$port_type[$i][$j][$k]="--";
				
				$port_e1Install[$i][$j][$k]="--";
				$port_e1L2Install[$i][$j][$k]="--";
			}
		}
	}
	//==================clear the record in the database=========================
	$db=$omc_db;
	$delSql = " Delete FROM OMC_PUB.sysStat
				WHERE sysTypeNo='111' 
					
				";
		//echo "<br>delSql=$delSql";
		$delRes = @mysqli_query($pubConn,$delSql);
		$tmpSql="SELECT sysTypeNo FROM sysConf WHERE needInstall = 1";
		$tmpRes = mysqli_query($pubConn,$tmpSql);
		$tmpRow = @mysqli_fetch_array($tmpRes);
		$i=0;
		do{
			if($i==0)
				$tmpWhere="sysTypeNo != $tmpRow[sysTypeNo]";
			else
				$tmpWhere=$tmpWhere." AND sysTypeNo != $tmpRow[sysTypeNo]";
			$i++;
		}while($tmpRow = @mysqli_fetch_array($tmpRes));
		
		//echo "tmpWhere=$tmpWhere";
		
		$delSql = " Delete FROM OMC_PUB.sysInfo WHERE $tmpWhere";
		//echo "<br>delSql=$delSql";
		$delRes = @mysqli_query($pubConn,$delSql);
		echo mysqli_error($pubConn);
		
		$delSql = "Delete FROM OMC_PUB.sysLedStat";
		//echo "<br>delSql=$delSql";
		$delRes = @mysqli_query($pubConn,$delSql);
		echo mysqli_error($pubConn);
}
//==========================test the data===================================================
/*
echo "==================card attribute=================<br>";
for($i=0;$i<2;$i++)
{
	for($j=0;$j<16;$j++)
	{	
		echo "CSC-$i-Card-$j-status:{$card_status[$i][$j]}<br>";
		echo "CSC-$i-Card-$j-refreshTime:{$card_refreshTime[$i][$j]}<br>";
		echo "CSC-$i-Card-$j-clock:{$card_clock[$i][$j]}<br>";
		echo "CSC-$i-Card-$j-sync:{$card_sync[$i][$j]}<br>";
		echo "CSC-$i-Card-$j-version:{$card_version[$i][$j]}<br>";
		echo "CSC-$i-Card-$j-HWaddr:{$card_HWaddr[$i][$j]}<br>";
		echo "CSC-$i-Card-$j-type:{$card_type[$i][$j]}<br>";
	}
}

echo "==================port attribute=================<br>";
for($i=0;$i<2;$i++)
{
	for($j=0;$j<16;$j++)
	{
		for($k=0;$k<8;$k++)
		{
			
			echo "CSC-$i-Card-$j-Port-$k-enable:{$port_e1Install[$i][$j][$k]}<br>";
			echo "CSC-$i-Card-$j-Port-$k-layer1:{$port_layer1[$i][$j][$k]}<br>";
			echo "CSC-$i-Card-$j-Port-$k-layer2:{$port_layer2[$i][$j][$k]}<br>";
			echo "CSC-$i-Card-$j-Port-$k-echoCanceller:{$port_echoCanceller[$i][$j][$k]}<br>";
			echo "CSC-$i-Card-$j-Port-$k-channel:{$port_channel[$i][$j][$k]}<br>";
			echo "CSC-$i-Card-$j-Port-$k-type:{$port_type[$i][$j][$k]}<br>";
			
			//$port_e1Install[$i][$j][$k]="--";
			//$port_e1L2Install[$i][$j][$k]="--";
		}
	}
}
*/


//===================================show the data in table==================================
//==========================online help=======================
{
	
	echo "<div style=\"position:absolute;top:0;left:815;\" id=\"helpId\">";
	$helpId="1.2.1";
	showHelp($helpId);
	echo "</div>";
	
}

echo "$strSysStatus > $strCentralOffice > MSC-CSC";
echo "<p align=\"right\"><a href=\"$returnRoute\" target=\"contents\"><img align=absBottom border=0 src=\"../../images/left.gif\" width=\"14\" height=\"14\">$strBack</a>";
echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
echo "<a href=\"$PHP_SLEF?clear=1\" target=\"_self\"><img align=absBottom border=0 src=\"../../images/delete.gif\" width=\"14\" height=\"14\">$strClear</a>";

echo "<form name=\"csuStatusForm\" method=\"post\">";
echo "<table border=\"0\" width=100%>";
	echo "<tr>";
		echo "<td width=49%><p align=\"center\"><font color=\"#0000FF\" size=\"2\">CSC0-8K E1/T1 Card  $strStatusInfo</font></p></td>";
		echo "<td width=2%>&nbsp;</td>";
		echo "<td width=49%><p align=\"center\"><font color=\"#0000FF\" size=\"2\">CSC1-8K E1/T1 Card $strStatusInfo</font></p></td>";
	echo "</tr>";
	
	//==============================csc0 table===============================================
	echo "<td width=49% height=\"1\">";
			echo "<table border=\"1\" cellpadding=\"1\" cellspacing=\"0\" bordercolor=\"#666666\"  bordercolordark=\"#FFFFFF\">"; 
				echo "<tr bgcolor=\"#E6E6E6\">";
					echo "<td width=2%>ID</td>";
					echo "<td width=2%>Type</td>";
					echo "<td width=5%>$strBasicStatus</td>";
					echo "<td width=12%>$strRefreshTime</td>";
					echo "<td width=9%>Clock/Sync</td>";
					echo "<td width=7%>Version</td>";
					echo "<td width=12%>HWaddr</td>";
					
				echo "</tr>";
				for($i=0;$i<16;$i++)
				{
					
					echo "<tr>";
					//==ID===
					$showId = omc_keep_length($i,0,2);
					echo "<td>$showId</td>";
					
					//==type==
					$tempV=$card_type[0][$i];
					$tempN="plat0card".$i."type";
					if(strcmp($card_type[0][$i],"--")==0)
						$tempC="#000000";
					else	
						$tempC="#0000FF";
					echo "<td><input size=4 type=input readonly value=\"$tempV\" style=color:$tempC name=\"$tempN\" class=\"style3\"></td>";
					
					
					//==status==
					$tempV=$card_status[0][$i];
					$tempN="plat0card".$i."status";
					
					if(strcmp($tempV,"Y")==0)
						$tempC="blue";
					else if(strcmp($tempV,"N")==0)	
					  $tempC="red";
					else
						$tempC="black";  
					echo "<td><input size=2 type=input readonly value=\"$tempV\" style=color:$tempC name=\"$tempN\" class=\"style3\"></td>";
					//==refresh time==
					$tempV=$card_refreshTime[0][$i];
					
					$tmp_total=explode(" ",$card_refreshTime_full[0][$i]);
					$tmp_year_month_day=explode("-",$tmp_total[0]);
					$tmp_hour_minute_second=explode(":",$tmp_total[1]);
					$tmp_now=time();
					$tmp_fresh=mktime($tmp_hour_minute_second[0],$tmp_hour_minute_second[1],$tmp_hour_minute_second[2],$tmp_year_month_day[1],$tmp_year_month_day[2],$tmp_year_month_day[0]);
	
					
					$tempN="plat0card".$i."refreshtime";
					$slot=$tmp_now-$tmp_fresh;
					if(strlen($card_refreshTime[0][$i])>5)
					{
						//if($card_refreshTime[0][$i]>$dueDate)
						if($slot<=40)
							$tempC="#0000FF";
						else
							$tempC="#FF0000";
					}
					else
						$tempC="#000000";
					//echo "<td><input size=7 type=input readonly value=\"$tempV\" style=color:$tempC name=\"$tempN\" class=\"style3\"></td>";
					echo "<td><input size=7 type=input readonly value=\"$tempV\" style=color:$tempC name=\"$tempN\" class=\"style3\"></td>";
					
					//==clock sync==
					$tempV=$card_clock[0][$i]."/".$card_sync[0][$i];
					if($card_clock[0][$i]=="--")
						$tempV="--";		
					$tempN="plat0card".$i."clocksync";
					if(strcmp($card_sync[0][$i],"--")==0)
						$tempC="#000000";
					else	
						$tempC="#0000FF";
					echo "<td><input size=9 type=input readonly value=\"$tempV\" style=color:$tempC name=\"$tempN\" class=\"style3\"></td>";
					//==version==
					$tempV=$card_version[0][$i];
					$tempN="plat0card".$i."version";
					if(strcmp($card_version[0][$i],"--")==0)
						$tempC="#000000";
					else	
						$tempC="#0000FF";
					echo "<td><input size=6 type=input readonly value=\"$tempV\" style=color:$tempC name=\"$tempN\" class=\"style3\"></td>";
					//==HWaddr==
					$tempV=$card_HWaddr[0][$i];
					$tempN="plat0card".$i."hwaddr";
					if(strcmp($card_HWaddr[0][$i],"--")==0)
						$tempC="#000000";
					else	
						$tempC="#0000FF";
					echo "<td><input size=17 type=input readonly value=\"$tempV\" style=color:$tempC name=\"$tempN\" class=\"style3\"></td>";
					
					echo "</tr>";
				}
			
			echo "</table>";	
	echo "</td>";
	echo "<td width=1%>&nbsp;</td>";		
	//================================csc1 table================================================
	echo "<td width=49% height=\"1\">";
			echo "<table border=\"1\" cellpadding=\"1\" cellspacing=\"0\" bordercolor=\"#666666\"  bordercolordark=\"#FFFFFF\">"; 
				echo "<tr bgcolor=\"#E6E6E6\">";
					echo "<td width=2%>ID</td>";
					echo "<td width=2%>Type</td>";
					echo "<td width=5%>$strBasicStatus</td>";
					echo "<td width=12%>$strRefreshTime</td>";
					echo "<td width=9%>Clock/Sync</td>";
					echo "<td width=7%>Version</td>";
					echo "<td width=12%>HWaddr</td>";
					
				echo "</tr>";
				for($i=0;$i<16;$i++)
				{
					
					echo "<tr>";
					//==ID===
					$showId = omc_keep_length($i,0,2);
					echo "<td>$showId</td>";
					
					//==type==
					$tempV=$card_type[1][$i];
					$tempN="plat1card".$i."type";
					if(strcmp($card_type[1][$i],"--")==0)
						$tempC="#000000";
					else	
						$tempC="#0000FF";
					echo "<td><input size=4 type=input readonly value=\"$tempV\" style=color:$tempC name=\"$tempN\" class=\"style3\"></td>";
					
					//==status==
					$tempV=$card_status[1][$i];
					$tempN="plat1card".$i."status";
					
					if(strcmp($tempV,"Y")==0)
						$tempC="blue";
					else if(strcmp($tempV,"N")==0)	
					  $tempC="red";
					else
						$tempC="black";  
					echo "<td><input size=2 type=input readonly value=\"$tempV\" style=color:$tempC name=\"$tempN\" class=\"style3\"></td>";
					//==refresh time==
					$tempV=$card_refreshTime[1][$i];
					$tempN="plat1card".$i."refreshtime";
					
					$tmp_total=explode(" ",$card_refreshTime_full[1][$i]);
					$tmp_year_month_day=explode("-",$tmp_total[0]);
					$tmp_hour_minute_second=explode(":",$tmp_total[1]);
					$tmp_now=time();
					$tmp_fresh=mktime($tmp_hour_minute_second[0],$tmp_hour_minute_second[1],$tmp_hour_minute_second[2],$tmp_year_month_day[1],$tmp_year_month_day[2],$tmp_year_month_day[0]);
	
					
					$slot=$tmp_now-$tmp_fresh;
					if(strlen($card_refreshTime[1][$i])>5)
					{
						//if($card_refreshTime[1][$i]<=$dueDate)
						if($slot<=40)
							$tempC="#0000FF";
						else
							$tempC="#FF0000";
					}
					else
						$tempC="#000000";
					echo "<td><input size=7 type=input readonly value=\"$tempV\" style=color:$tempC name=\"$tempN\" class=\"style3\"></td>";
					//==clock sync==
					$tempV=$card_clock[1][$i]."/".$card_sync[1][$i];
					if($card_clock[1][$i]=="--")
						$tempV="--";		
					$tempN="plat1card".$i."clocksync";
					if(strcmp($card_sync[1][$i],"--")==0)
						$tempC="#000000";
					else	
						$tempC="#0000FF";
					echo "<td><input size=9 type=input readonly value=\"$tempV\" style=color:$tempC name=\"$tempN\" class=\"style3\"></td>";
					//==version==
					$tempV=$card_version[1][$i];
					$tempN="plat1card".$i."version";
					if(strcmp($card_version[1][$i],"--")==0)
						$tempC="#000000";
					else	
						$tempC="#0000FF";
					echo "<td><input size=6 type=input readonly value=\"$tempV\" style=color:$tempC name=\"$tempN\" class=\"style3\"></td>";
					//==HWaddr==
					$tempV=$card_HWaddr[1][$i];
					$tempN="plat1card".$i."hwaddr";
					if(strcmp($card_HWaddr[1][$i],"--")==0)
						$tempC="#000000";
					else	
						$tempC="#0000FF";
					echo "<td><input size=17 type=input readonly value=\"$tempV\" style=color:$tempC name=\"$tempN\" class=\"style3\"></td>";
					
					echo "</tr>";
				}				
			echo "</table>";	
	echo "</td>";
  echo "</tr>";
  
  echo "<tr>";
		echo "<td width=49%><p align=\"center\"><font color=\"#0000FF\" size=\"2\">$strPane0Status</font></p></td>";
		echo "<td width=2%>&nbsp;</td>";
		echo "<td width=49%><p align=\"center\"><font color=\"#0000FF\" size=\"2\">$strPane1Status</font></td>";
	echo "</tr>";   
  
  echo "<tr>";
		//<!--			left CSC 0 details		-->
		echo "<td width=49%>"; 
			echo "<table border=\"1\" cellpadding=\"1\" cellspacing=\"0\" bordercolor=\"#666666\"  bordercolordark=\"#FFFFFF\">"; 
			for($i=0;$i<16;$i++)
			{
				echo "<tr bgcolor=\"#C0C0C0\">"; 
						echo "<td width=6%>Slot</td>";
						echo "<td width=6%>Port</td>";
						echo "<td width=6% title=\"Enable\">EN</td>";
						echo "<td width=6% title=\"Physical layer\">L1</td>";
						echo "<td width=6% title=\"Transport\">L2</td>";
						echo "<td width=6% title=\"Echo canceller\">EC</td>";
						echo "<td width=6% title=\"Channel\">CH</td>";
						echo "<td width=7% title=\"Port type\">TY</td>";
				echo "</tr>";
				for($j=0;$j<8;$j++)
				{
					echo "<tr>";
					//==slot==
					echo "<td>$i</td>";
					//==port==
					echo "<td>$j</td>";
					//==status==
					$tempV=$port_e1Install[0][$i][$j];
					$tempN="plat0card".$i."port".$j."status";
					if(strcmp($port_e1Install[0][$i][$j],"Y")==0)
						$tempC="#0000FF";
					else if(strcmp($port_e1Install[0][$i][$j],"N")==0)
						$tempC="#FF0000";	
					else	
						$tempC="#000000";	
					echo "<td><input size=4 type=input readonly value=\"$tempV\" style=color:$tempC name=\"$tempN\" class=\"style3\"></td>";
					//==layer1==
					$tempV=$port_layer1[0][$i][$j];
					$tempN="plat0card".$i."port".$j."layer1";
					if(strcmp($port_layer1[0][$i][$j],"Y")==0)
						$tempC="#0000FF";
					else if(strcmp($port_layer1[0][$i][$j],"N")==0)
						$tempC="#FF0000";
					else
					  $tempC="#000000";		
					echo "<td><input size=4 type=input readonly value=\"$tempV\" style=color:$tempC name=\"$tempN\" class=\"style3\"></td>";
					//==layer2==
					$tempV=$port_layer2[0][$i][$j];
					$tempN="plat0card".$i."port".$j."layer2";
					if(strcmp($port_layer2[0][$i][$j],"Y")==0)
						$tempC="#0000FF";
					else if(strcmp($port_layer2[0][$i][$j],"N")==0)
						$tempC="#FF0000";
					else
					  $tempC="#000000";
					echo "<td><input size=4 type=input readonly value=\"$tempV\" style=color:$tempC name=\"$tempN\" class=\"style3\"></td>";
					//==echo canceller==
					$tempV=$port_echoCanceller[0][$i][$j];
					$tempN="plat0card".$i."port".$j."echocanceller";
					if(strcmp($port_echoCanceller[0][$i][$j],"Y")==0)
						$tempC="#0000FF";
					else if(strcmp($port_echoCanceller[0][$i][$j],"N")==0)
						$tempC="#FF0000";
					else
					  $tempC="#000000";
					echo "<td><input size=4 type=input readonly value=\"$tempV\" style=color:$tempC name=\"$tempN\" class=\"style3\"></td>";
					//==channel==
					$tempV=$port_channel[0][$i][$j];
					$tempN="plat0card".$i."port".$j."channel";
					if(strcmp($port_channel[0][$i][$j],"--")==0)
						$tempC="#000000";
					else
					  $tempC="#0000FF";
					echo "<td><input size=4 type=input readonly value=\"$tempV\" style=color:$tempC name=\"$tempN\" class=\"style3\"></td>";
					//==type==
					$tempV=$port_type[0][$i][$j];
					$tempN="plat0card".$i."port".$j."type";
					if(strcmp($port_type[0][$i][$j],"--")==0)
						$tempC="#000000";
					else
					  $tempC="#0000FF";
					echo "<td><input size=7 type=input readonly value=\"$tempV\" style=color:$tempC name=\"$tempN\" class=\"style3\"></td>";
					
					echo "</tr>";
				}
			}
			echo "</table>";	
  	echo "</td>";
  	echo "<td width=2%></td>";
  	//<!--			right CSC 1 details		-->
  	echo "<td width=49%>"; 
			echo "<table border=\"1\" cellpadding=\"1\" cellspacing=\"0\" bordercolor=\"#666666\"  bordercolordark=\"#FFFFFF\">"; 
			for($i=0;$i<16;$i++)
			{
				echo "<tr bgcolor=\"#C0C0C0\">"; 
						echo "<td width=6%>Slot</td>";
						echo "<td width=6%>Port</td>";
						echo "<td width=6% title=\"Enable\">EN</td>";
						echo "<td width=6% title=\"Physical layer\">L1</td>";
						echo "<td width=6% title=\"Transport\">L2</td>";
						echo "<td width=6% title=\"Echo canceller\">EC</td>";
						echo "<td width=6% title=\"Channel\">CH</td>";
						echo "<td width=7% title=\"Port type\">TY</td>";
				echo "</tr>";
				for($j=0;$j<8;$j++)
				{
					echo "<tr>";
					//==slot==
					echo "<td>$i</td>";
					//==port==
					echo "<td>$j</td>";
					//==status==
					$tempV=$port_e1Install[1][$i][$j];
					$tempN="plat1card".$i."port".$j."status";
					if(strcmp($port_e1Install[1][$i][$j],"Y")==0)
						$tempC="#0000FF";
					else if(strcmp($port_e1Install[1][$i][$j],"N")==0)
						$tempC="#FF0000";	
					else	
						$tempC="#000000";	
					echo "<td><input size=4 type=input readonly value=\"$tempV\" style=color:$tempC name=\"$tempN\" class=\"style3\"></td>";
					//==layer1==
					$tempV=$port_layer1[1][$i][$j];
					$tempN="plat1card".$i."port".$j."layer1";
					if(strcmp($port_layer1[1][$i][$j],"Y")==0)
						$tempC="#0000FF";
					else if(strcmp($port_layer1[1][$i][$j],"N")==0)
						$tempC="#FF0000";
					else
					  $tempC="#000000";		
					echo "<td><input size=4 type=input readonly value=\"$tempV\" style=color:$tempC name=\"$tempN\" class=\"style3\"></td>";
					//==layer2==
					$tempV=$port_layer2[1][$i][$j];
					$tempN="plat1card".$i."port".$j."layer2";
					if(strcmp($port_layer2[1][$i][$j],"Y")==0)
						$tempC="#0000FF";
					else if(strcmp($port_layer2[1][$i][$j],"N")==0)
						$tempC="#FF0000";
					else
					  $tempC="#000000";
					echo "<td><input size=4 type=input readonly value=\"$tempV\" style=color:$tempC name=\"$tempN\" class=\"style3\"></td>";
					//==echo canceller==
					$tempV=$port_echoCanceller[1][$i][$j];
					$tempN="plat1card".$i."port".$j."echocanceller";
					if(strcmp($port_echoCanceller[1][$i][$j],"Y")==0)
						$tempC="#0000FF";
					else if(strcmp($port_echoCanceller[1][$i][$j],"N")==0)
						$tempC="#FF0000";
					else
					  $tempC="#000000";
					echo "<td><input size=4 type=input readonly value=\"$tempV\" style=color:$tempC name=\"$tempN\" class=\"style3\"></td>";
					//==channel==
					$tempV=$port_channel[1][$i][$j];
					$tempN="plat1card".$i."port".$j."channel";
					if(strcmp($port_channel[1][$i][$j],"--")==0)
						$tempC="#000000";
					else
					  $tempC="#0000FF";
					echo "<td><input size=4 type=input readonly value=\"$tempV\" style=color:$tempC name=\"$tempN\" class=\"style3\"></td>";
					//==type==
					$tempV=$port_type[1][$i][$j];
					$tempN="plat1card".$i."port".$j."type";
					if(strcmp($port_type[1][$i][$j],"--")==0)
						$tempC="#000000";
					else
					  $tempC="#0000FF";
					echo "<td><input size=7 type=input readonly value=\"$tempV\" style=color:$tempC name=\"$tempN\" class=\"style3\"></td>";
					
					echo "</tr>";
				}
			}
			echo "</table>";	
  	echo "</td>";
echo "</table>";	
echo "</form>";

?>
</body>