<?php
require("../sub_inc/commfunc.php");
$helpId = "2.1.1.2"; 
$DEBUG = 0;

if($DEBUG) echo "<br>正在调试中！！";
//==========================================================
//变量定义
//==========================================================
$pubDb			= 'OMC_PUB';
$db	= "OBJ_222";
$paramTable		='OBJ_222.param_99';
$objIdStr	='2.4.1';
$maxNum = 30;

$nGetComm	= 0;
$nSetComm	= 3;

$sysId		='222_99_99';
$instanceNo	='0';

$nProcFail = 0;//failure
$nWaitProc = 1;//wait
$nInProc   = 2;
$nOutProc  = 3;
?>
<?php
//==========================================================
//输入变量
//==========================================================
if($DEBUG) echo "<br>setInstanceNo=$setInstanceNo";
if($DEBUG) echo "<BR>setObjIdStr  =$setObjIdStr";
//==========================================================
//数据处理
//==========================================================
//处理get/set命令

$linksetOid	='2.4.1';
$objIdStr	='2.4.1';
$linksetConfArr=array(
	array('Linkset DPC','0.0-2.7'),
	array('Network indicator','3.0-3.1'),
	array('Linkset loopback','3.3-3.3'),
	array('Linkset title','7.0-16.7')
	);
$NetIdConfArr=array(
	array('00','International'),
	array('01','International spare'),
	array('10','National'),
	array('11','National spare')
);

//==========================================================
//输出并显示数据
//==========================================================
if($DEBUG) echo "<BR>";
?>

<body topmargin="0" leftmargin="12">

<?php
echo "<form method=\"POST\" name=\"setForm\" action=\"$PHP_SELF\">";
echo "<table border=\"0\" width=\"100%\">";
echo "<tr>";
echo "<td width=\"50%\">";
echo "Configuration > <a href=\"../overview/overview.php?scroll_y=1000\">Network</a> > <a href=\"#\">Linkset overview</a>";
echo "</td>";
echo "<td width=\"50%\" align=\"right\" title=\"Help\">";
//showHelp($helpId);
echo "</td>";
echo "<td>";
echo "<p align=\"right\"><a href=\"../../element/overview/overview.php?scroll_y=1000\"><img align=absBottom border=0 src=\"../../images/left.gif\" width=\"14\" height=\"14\">$strBack</a>";
echo "</td></tr>";
echo "</table>";

echo "<br>";
echo "</form>";
?>

<table rules=rows border="1" width="100%" cellpadding="1" cellspacing="0" bordercolor="#666666" bordercolordark="#FFFFFF">
<?php 
echo "<tr bgcolor=\"#E6E6E6\">";
echo "<td>No.</td>";
echo "<td>Titile</td>";
echo "<td>Opposite point code</td>";
echo "<td>Network indicator</td>";
echo "<td>Loop back</td>";
echo "</tr>";


$levelArr=explode('.',$linksetOid);
for($j=0;$j<sizeof($levelArr);$j++){
	$levelNo=$j+1;
	${"level_$levelNo"}=$levelArr[$j];
	if($DEBUG) echo "<BR>levelArr[$j]={$levelArr[$j]}";
}

$defSql	= "SELECT initValue from paramConf 
			WHERE level_1='$level_1' AND level_2='$level_2' AND level_3='$level_3'
		";
if($DEBUG)	echo "defSql=$defSql<br>";
$defRes	= mysqli_query($pubConn,$defSql);
$defRow = mysqli_fetch_array($defRes);
$defaultValue	= $defRow[initValue];
if($DEBUG)	echo "defaultValue=$defaultValue<br>";

$getSql="SELECT initValue,instanceNo  FROM $paramTable 
			WHERE level_1='$level_1' AND level_2='$level_2' AND level_3='$level_3'
		";
if($DEBUG) echo "<BR>getSql=$getSql";
$result	=mysqli_query($pubConn,$getSql);
echo mysqli_error($pubConn);

while($rows	=mysqli_fetch_array($result)){
	$instanceNo=$rows[instanceNo];
	$value=$rows[0];
	if($rows[initValue] == $defaultValue){
		continue;
	}
	
	
	$OPC		=getBitValue($value,$linksetConfArr[0][1]);
	$OPC = hexdec($OPC);
	$NetID		=getBitValue($value,$linksetConfArr[1][1]);
	$loopFlag	=getBitValue($value,$linksetConfArr[2][1]);
	$title		=toAscii(getBitValue($value,$linksetConfArr[3][1]));
	if($objIdStr == $setObjIdStr && $instanceNo == $setInstanceNo){
		echo "<tr bgcolor=\"#CCFFCC\">";
	}else{
		echo "<tr onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";
	}
	echo "<td>";
	echo "$instanceNo</td>";
	echo "<td>$title</td>";
	echo "<td>$OPC</td>";

	echo "<td>";
	if($DEBUG) echo "NetID=$NetID<BR>";
	for($i=0;$i<sizeof($NetIdConfArr);$i++){
		if($NetID == $NetIdConfArr[$i][0]){
			echo "{$NetIdConfArr[$i][1]}";
			break;
		}
	}
	echo "</td><td>";
	if($DEBUG) echo "loopFlag=$loopFlag<BR>";
	if($loopFlag > 0){
		echo "Enable";
	}else{
		echo "Disable";
	}
	echo "</td>";
	echo "</tr>";
}



?>
</table>
</form>
&nbsp;
</body>
</html>
