<?php
require("../../inc/header.inc");
$DEBUG = 0;
if($DEBUG) echo "<br>正在调试中！！";
?>

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

<?php

if ($DEBUG) echo "back_page=$back_page";
$helpID = "1.1.1";

$nProcFail = 0;//failure
$nWaitProc = 1;//wait
$nInProc   = 2;
$nOutProc  = 3;

$nGetComm = 0;
$nSetComm = 3;
	
$maxNum = 120;

$sqltable = 'OBJ_222.param_99';
$pubdb = 'OMC_PUB';

$spcTree_array = array(
	array('International',		'14-bit',	'spc_int_14',	 '2.3.1'),
	array('International spare','14-bit','spc_int_sp_14', '2.3.2'),
	array('National',			'14-bit',	'spc_nat_14',	 '2.3.3'),
	array('National spare',		'14-bit','spc_nat_sp_14', '2.3.4'),
	array('International',		'24-bit',	'spc_int_24',	 '2.3.5'),
	array('International spare','24-bit','spc_int_sp_24', '2.3.6'),
	array('National',			'24-bit',	'spc_nat_24',	 '2.3.7'),
	array('National spare',		'24-bit','spc_nat_sp_24', '2.3.8')
//	array('International',		'ITU',	'spc_int_14',	 '2.3.1'),
//	array('International spare','ITU','spc_int_sp_14', '2.3.2'),
//	array('National',			'ITU',	'spc_nat_14',	 '2.3.3'),
//	array('National spare',		'ITU','spc_nat_sp_14', '2.3.4'),
//	array('International',		'ANSI',	'spc_int_24',	 '2.3.5'),
//	array('International spare','ANSI','spc_int_sp_24', '2.3.6'),
//	array('National',			'ANSI',	'spc_nat_24',	 '2.3.7'),
//	array('National spare',		'ANSI','spc_nat_sp_24', '2.3.8')	
);

$querysql = "select initValue from $sqltable where level_1 = '2' and level_2 = '2'  and level_3 = '0'";
$result = mysqli_query($pubConn,$querysql);
$indicator = mysqli_fetch_array($result);
echo mysqli_error($pubConn);
if($DEBUG)echo "<br>indicator = {$indicator[0]}";

for($i = 0; $i < 4; $i++)
{
	$flag = getBitValue($indicator[0],"0.$i");
	if ($flag == 0)
		$spc_index[$i] = $i;
	else
		$spc_index[$i] = $i+4;
	$j=	$i+4;
	$flag = getBitValue($indicator[0],"0.$j");
	if ($flag == 0)
		$spc_index[$j] = $j+4;
	else
		$spc_index[$j] = $j+8;		
}

for($i = 0; $i < 4; $i ++)
{
	$level_array = explode('.',$spcTree_array[$spc_index[$i]][3]);
	
	for($j = 0;$j < sizeof($level_array);$j ++)
	{
		$level_no = $j + 1;
		${level_.$level_no} = $level_array[$j];
	}
	$getsql = "select initValue from $sqltable 
	where level_1 = '$level_1' and level_2 = '$level_2' and level_3 = '$level_3' ";
	$result = mysqli_query($pubConn,$getsql);
	$row[$i] = mysqli_fetch_array($result);
	$row[$i] = hexdec($row[$i][0]);
	echo mysqli_error($pubConn);
	if($DEBUG)echo "<br>getsql = $getsql";
	if($DEBUG)echo "{$row[$i]}";
}
																			
//==========================================================
//输出并显示数据
//========================================================== 
echo "<form method=\"POST\" name=\"Set\" action=\"$PHP_SELF\">";

?>

<?php
echo "<table border=\"0\" width=\"100%\">";
echo "<tr>";
echo "<td width=\"50%\">";
$BackName = strtoupper(substr($back_page,2,strlen($back_page)-6));
echo "Configuration > <a href=\"../overview/overview.php\">Network</a> > <a href=\"$back_page\">$BackName</a> > <a href=\"#\">MSC SP</a>";

echo "<td width=\"50%\" align=\"right\" title=\"Help\">";
showHelp($helpId);
echo "</td>";
echo "</tr>";
echo "</table>";
echo "<br>";
echo "<br>";

echo "<table width=\"100%\">";
echo "<tr><td>";
echo "<b>MSC SP local:&nbsp;&nbsp;</b></td>";
echo "<td align=\"right\"><b><a href=./ACNview.php?instanceNo=0&objIdStr=2.7.1&sysTypeNo=222&setname=ACN&operType='input'&back_page=$back_page>ACN</a>setting</b></td>";
echo "<td>";
echo "<p align=\"right\"><a href=\"$back_page\"><img align=absBottom border=0 
	src=\"../../images/left.gif\" width=\"14\" height=\"14\">$strBack</a>";
echo "</td></tr>";
echo "</table>";
?>

<TABLE  width=100%   border="1"  cellpadding="1" cellspacing="0"  bordercolor="#666666" bordercolordark="#FFFFFF" bgcolor="#FFFFFF"> 

<?php
echo "<tr >" ;
echo "<td bgcolor=\"#E6E6E6\"  width=25% ><b>Network indicator</b></td>";
echo "<td bgcolor=\"#E6E6E6\"  width=25% ><b>SPC length</b></td>";
//echo "<td bgcolor=\"#E6E6E6\"  width=25% ><b>SPC type</b></td>";
echo "<td bgcolor=\"#E6E6E6\"  width=25% ><b>SPC</b></td>";
echo "</td>";
echo "</tr>";

for ($i = 0; $i < 4; $i++)
{
	echo "<tr>";
	echo "<td>{$spcTree_array[$spc_index[$i]][0]}</td>";
	echo "<td>{$spcTree_array[$spc_index[$i]][1]}</td>";
//	echo "<td>{$spcTree_array[$spc_index[$i+4]][1]}</td>";
	echo "<td>{$row[$i]}</td>"  ;  
	echo "</tr>";
}
?>

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