<?php

require("../sub_inc/commfunc.php");
$helpId = "2.1.1.5"; 
$DEBUG = 0;


if($DEBUG) echo "<br>正在调试中！！";
//==========================================================
//变量定义
//==========================================================
$pubDb			= 'OMC_PUB';
$paramTable		='OBJ_223.param_99';
$paramConf		='OBJ_223.paramConf';
$maxNum = 30;
/*
GTT table
[unit]On/off[u]00.0-00.7[u]select
[v]1[opt]on
[v]0[opt]off
[unit]Numbering plan[u]01.0-01.7[u]select
[v]1[opt]MSISDN
[v]6[opt]IMSI
[v]7[opt]E.214 GT
[unit]Start GT number[u]02.0-11.7[u]input
[v]keepHex-low-E
[unit]End GT number[u]12.0-21.7[u]input
[v]keepHex-low-E
[unit]Network indicator[u]22.0-22.7[u]select
[v]0[opt]0
[v]1[opt]1
[v]2[opt]2
[v]3[opt]3
[unit]Destination point code[u]23.0-25.7[u]input
[v]toDec-high-0
[unit]SSN[u]26.0-26.7[u]input
[v]toDec-high-0
[unit]Route indicator[u]27.0-27.7[u]select
[v]0[opt]route on GT
[v]1[opt]route on SSN
[unit]Replaced start digit[u]28.0-28.7[u]input
[v]keepHex-high-0
[unit]Replaced end digit[u]29.0-29.7[u]input
[v]keepHex-high-0
[unit]Outgoing number plan[u]30.0-30.7[u]select
[v]1[opt]MSISDN
[v]6[opt]IMSI
[v]7[opt]E.214 GT
[unit]Replacing digits[u]31.0-40.7[u]input
[v]keepHex-low-E
*/
//==========================================================
//数据处理
//==========================================================
$objIdStr='2.2';

$GTTtableConfArr=array(
	array('Start number',		'03.0-12.7'),
	array('End number',			'13.0-22.7'),
	array('On/off',					'00.0-00.7'),
	array('Numbering plan',			'01.0-01.7'),
	array('Network indicator',		'23.0-23.7'),
	array('DPC',					'24.0-26.7'),
	array('SSN',					'27.0-27.7'),
	array('Route indicator',		'28.0-28.7'),
	array('Address indicator',		'29.0-29.7'),
	array('Replaced start digit',	'30.0-30.7'),
	array('Replaced end digit',		'31.0-31.7'),
	array('Outgoing number plan',	'32.0-32.7'),
	array('Replacing digits',		'33.0-42.7'),
	array('TT',						'2.0-2.7')
);

$NetIdConfArr=array(
	array('0','International'),
	array('1','Inter-S'),
	array('2','National'),
	array('3','National-S')
);

$numPlanConfArr=array(
	array('0','--'),
	array('1','MSISDN'),
	array('6','IMSI'),
	array('7','E.214 GT')
);

$addressIdConfArr=array(
	array('00','NULL'),
	array('01','DPC'),
	array('02','SSN'),
	array('03','DPC+SSN'),
	array('04','GT'),
	array('05','GT+DPC'),
	array('06','GT+SSN'),
	array('07','GT+DPC+SSN')
);

function showNumber($number){
	$newNumber =str_replace('F','',$number);
	if($newNumber == ''){
		$newNumber='--';
	}
	return($newNumber);
}

?>

<form name="selectform">
<?php
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=\"#\">GTT overview</a>";
echo "</td>";
echo "<td width=\"50%\" align=\"right\" title=\"Help\">";
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>";
echo "</tr>";
echo "</table>";
echo "<br>";

?>
<table border="1" width="100%" cellpadding="1" cellspacing="0" bordercolor="#666666" bordercolordark="#FFFFFF">
<?php 
echo "<tr bgcolor=\"#E6E6E6\">";
echo "<td>No.</td>";
echo "<td>Title</td>";
echo "<td>Start number</td>";
echo "<td>End number</td>";
echo "<td>Enable</td>";
echo "<td>NP</td>";
echo "<td>TT</td>";
echo "<td>NI</td>";
echo "<td>DPC</td>";
echo "<td>SSN</td>";
echo "<td>Router ID</td>";
echo "<td>Address ID</td>";
echo "<td>Rep-start</td>";
echo "<td>Rep-End</td>";
echo "<td>ONP</td>";
echo "<td>Rep-number</td>";
echo "</tr>";

$levelStr=getLevelWhere($objIdStr);
$defSql = "select initValue from $paramConf WHERE $levelStr ";
$defRes = mysqli_query($pubConn, $defSql);
$defRow = mysqli_fetch_array($defRes);
if($DEBUG) echo "<br>defSql = $defSql";
$getSql="SELECT initValue,instanceNo  FROM $paramTable 
			WHERE $levelStr and initValue!='{$defRow[0]}'";

if($DEBUG) echo "<BR>getSql=$getSql";
$result	=mysqli_query($pubConn,$getSql);
echo mysqli_error($pubConn);

$levelStr_1 = getLevelWhere("2.4");
while($rows	=mysqli_fetch_array($result)){
	$instanceNo=$rows[instanceNo];
	$value=$rows[0];
	if($DEBUG) echo "<BR>value=$value";	
	$startDigit	=getBitValue($value,$GTTtableConfArr[0][1]);
	//if($startDigit == 'FFFFFFFFFFFFFFFFFFFF') continue;
	$startDigit	=showNumber($startDigit);
	$endDigit	=getBitValue($value,$GTTtableConfArr[1][1]);
	$endDigit	=showNumber($endDigit);
	$enableFlag	=getBitValue($value,$GTTtableConfArr[2][1]);
	if($enableFlag > 0){
		$enableFlag ='Y';
	}else{
		$enableFlag ='N';
	}


	$numPlan	=getBitValue($value,$GTTtableConfArr[3][1]);
	for($j=0;$j<sizeof($numPlanConfArr);$j++){
		if($numPlan == $numPlanConfArr[$j][0]){
			$numPlanName = $numPlanConfArr[$j][1];
			break;
		}
	}
	$NetID		=getBitValue($value,$GTTtableConfArr[4][1]);
	for($j=0;$j<sizeof($NetIdConfArr);$j++){
		if($NetID == $NetIdConfArr[$j][0]){
			$NetIDName = $NetIdConfArr[$j][1];
			break;
		}
	}
	$SPC		=hexdec(getBitValue($value,$GTTtableConfArr[5][1]));
	$SSN		=hexdec(getBitValue($value,$GTTtableConfArr[6][1]));
	$RouterID	=getBitValue($value,$GTTtableConfArr[7][1]);
	$adressID	=getBitValue($value,$GTTtableConfArr[8][1]);
	for($j=0;$j<sizeof($addressIdConfArr);$j++){
		if($adressID == $addressIdConfArr[$j][0]){
			$adressIDName = $addressIdConfArr[$j][1];
			break;
		}
	}
	$Rep_start	=getBitValue($value,$GTTtableConfArr[9][1]);
	$Rep_end	=getBitValue($value,$GTTtableConfArr[10][1]);
	$OutNumPlan	=getBitValue($value,$GTTtableConfArr[11][1]);
	for($j=0;$j<sizeof($numPlanConfArr);$j++){
		if($OutNumPlan == $numPlanConfArr[$j][0]){
			$OutNumPlanName = $numPlanConfArr[$j][1];
			break;
		}
	}
	$Rep_digit	=getBitValue($value,$GTTtableConfArr[12][1]);
	$Rep_digit	=showNumber($Rep_digit);
	
	$TT	=hexdec(getBitValue($value,$GTTtableConfArr[13][1]));
	
	unset($Title);
	$hexDpc = omc_keep_length(dechex($SPC),0,6);
	$tmpSql = "SELECT initValue,instanceNo  FROM $paramTable
			WHERE $levelStr_1 and instanceNo=$instanceNo";
	if($DEBUG)
	    echo "<BR>tmpSql=$tmpSql";
	$tmpResult	=mysqli_query($pubConn,$tmpSql);
	$tmpRows	=mysqli_fetch_array($tmpResult);
	$Title	=toAscii(getBitValue($tmpRows[0],"3.0-12.7"));
			
	if(ord($Title)==0)
		$Title="--";
		
	if($instanceNo == $setInstanceNo &&$objIdStr==$setObjIdStr)
		echo "<tr bgcolor=#CCFFCC>";
	else
		echo "<tr onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";
	//echo "<td><a href=\"javascript:openSet('$objIdStr','$instanceNo')\">";
	//echo "$instanceNo</a>&nbsp;</td>";
	echo "<td>$instanceNo</td>";
	echo "<td>$Title</td>";
	echo "<td>$startDigit&nbsp;</td>";
	echo "<td>$endDigit&nbsp;</td>";
	echo "<td>$enableFlag&nbsp;</td>";
	echo "<td>$numPlanName&nbsp;</td>";
	echo "<td>$TT&nbsp;</td>";
	echo "<td>$NetIDName&nbsp;</td>";
	echo "<td>$SPC&nbsp;</td>";
	echo "<td>$SSN&nbsp;</td>";
	echo "<td>$RouterID&nbsp;</td>";
	echo "<td>$adressIDName&nbsp;</td>";
	echo "<td>$Rep_start&nbsp;</td>";
	echo "<td>$Rep_end&nbsp;</td>";
	echo "<td>$OutNumPlanName&nbsp;</td>";
	echo "<td>$Rep_digit&nbsp;</td>";
	echo "</tr>";
}

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