<?php
//require("../sub_inc/commfunc.php");
require("../sub_inc/operwebfunc.inc");
if ($DEBUG == 1) echo "<br>正在调试中！！";
?>
<script LANGUAGE="JavaScript">
function openSet(flag,instanceNo,urlParam)
{	var y=document.body.scrollTop;
	if (flag == "csrr")
	{
		URL='./csrr.php?advanced=<?php echo "$advanced";?>&instanceNo='+instanceNo+"&sub_page_top="+y;
		window.location.href=URL;
		//var setWindow = open(URL, 'newWin', 'toolbar=no,directories=no,menubar=no,scrollbars=yes,resizable=yes,status=yes,width=600,height=450');
		//setWindow.focus();
	}
	else if(flag == "VPLMNs")
	{		
		urlParam=escape(urlParam);
		URL="./paramconf.php?instanceNo="+instanceNo+"&objIdStr=no-2.1.12&sysId=330_99_99&setname=VPLMNs&webname=HLR"+"&backurl="+urlParam+"&sub_page_top="+y;
		window.location.href=URL;
	}
	else if(flag == "USSDEAE")
	{		
		urlParam=escape(urlParam);
		URL="./paramconf.php?instanceNo="+instanceNo+"&objIdStr=no-2.1.20.3&sysId=330_99_99&setname=USSDEAE&webname=HLR"+"&backurl="+urlParam+"&sub_page_top="+y;
		window.location.href=URL;
	}
	else if(flag == "IMSIRange")
	{		
		urlParam=escape(urlParam);
		URL="./paramconf.php?instanceNo="+instanceNo+"&objIdStr=no-2.2.0&sysId=223_99_99&setname=IMSIRange&webname=HLR"+"&backurl="+urlParam+"&sub_page_top="+y;
		window.location.href=URL;
	}
	else if(flag == "Regional")
	{		
		urlParam=escape(urlParam);
		URL="./paramconf.php?instanceNo="+instanceNo+"&objIdStr=no-2.1.14&sysId=330_99_99&setname=Regional&webname=HLR"+"&backurl="+urlParam+"&sub_page_top="+y;
		window.location.href=URL;
	}
	else if(flag == "RSA")
	{		
		urlParam=escape(urlParam);
		URL="./paramconf.php?instanceNo="+instanceNo+"&objIdStr=no-2.1.29&sysId=330_99_99&setname=RSA&webname=HLR"+"&backurl="+urlParam+"&sub_page_top="+y;
		window.location.href=URL;
	}			
	else if(flag == "faxGsmBcId")
	{		
		urlParam=escape(urlParam);
		URL="./paramconf.php?instanceNo="+instanceNo+"&objIdStr=no-2.1.17&sysId=330_99_99&setname=faxGsmBcId&webname=HLR"+"&backurl="+urlParam+"&sub_page_top="+y;
		window.location.href=URL;
	}			
	else if(flag == "dataGsmBcId")
	{		
		urlParam=escape(urlParam);
		URL="./paramconf.php?instanceNo="+instanceNo+"&objIdStr=no-2.1.18&sysId=330_99_99&setname=dataGsmBcIdGsmBcId&webname=HLR"+"&backurl="+urlParam+"&sub_page_top="+y;
		window.location.href=URL;
	}			
}
function openSetGTT(flag,instanceNo,ni,dpc,urlParam)
{	
	var y=document.body.scrollTop;
	urlParam=escape(urlParam);
	URL="./gttEdit.php?flag="+flag+"&instanceNo="+instanceNo+"&ni="+ni+"&DPC="+dpc+"&backurl="+urlParam+"&sub_page_top="+y;
	window.location.href=URL;
}
function delFirm(No,delname,thisCheck,secndDelNo)
{
	var delValue,x,y;
	x = document.body.scrollLeft;
	y = document.body.scrollTop;
    
	if(confirm('Do you want to delete the selected?') != true)
	{
		if(thisCheck.checked == true){
			thisCheck.checked=false;
		}else{
			thisCheck.checked=true;
		}
	}
	else{
		if(delname=='Regional')
			window.location.href='<?php echo "$PHP_SELF?advanced=$advanced";?>&delflag=1&delValue='+No;
		if(delname=='RSA')
			window.location.href='<?php echo "$PHP_SELF?advanced=$advanced";?>&delflag=RSA&delValue='+No;			
		if(delname=='VPLMNs')	
			window.location.href='<?php echo "$PHP_SELF?advanced=$advanced";?>&delflag=VPLMNs&delValue='+No;
		if(delname=='USSDEAE')	
			window.location.href='<?php echo "$PHP_SELF?advanced=$advanced";?>&delflag=USSDEAE&delValue='+No;
		if(delname=='faxGsmBcId')	
			window.location.href='<?php echo "$PHP_SELF?advanced=$advanced";?>&delflag=faxGsmBcId&delValue='+No;
		if(delname=='dataGsmBcId')	
			window.location.href='<?php echo "$PHP_SELF?advanced=$advanced";?>&delflag=dataGsmBcId&delValue='+No;
		if(delname=='ACS_DIGI')	
			window.location.href='<?php echo "$PHP_SELF?advanced=$advanced";?>&delflag=ACS_DIGI&delValue='+No+'&delValue2='+secndDelNo;
	}
}
function linkTo(url, param, backurl)
{
	y = document.body.scrollTop;
	if(backurl=='-1')
		URL = url + "?scroll_y=" + y + "&" + param;
	else
	{
		backurl = backurl+'?scroll_y='+y;
		backurl=escape(backurl);
		
		URL=url+"?backurl="+backurl+"&"+param;	
	}
	window.location.href=URL;
}

var statusmsg=""
function hidestatus()
{
	//window.status=statusmsg
	//return true
}

//=======This function called when click the more and hide button=========================
//Parameter
//where:specify which buttons group of more and hide to click
//num:specify how many the elements for showing
//oper:specify which button to click,more or hide
function clickOnMoreHide(where,num,oper)
{
	var cmd;
	//to change the more button to hide button or reverse
	if(oper=='show')
	{
		cmd="document.all.show"+where+".style.display='none'";
		eval(cmd);
		cmd="document.all.hide"+where+".style.display='block'";
		eval(cmd);
			
		for(var i=4;i<num;i++)
		{
			cmd="document.all."+where+i+".style.display='block'";
			eval(cmd);
		}
		
	}
	else
	{
		cmd="document.all.show"+where+".style.display='block'";
		eval(cmd);
		cmd="document.all.hide"+where+".style.display='none'";
		eval(cmd);
		
		for(var i=4;i<num;i++)
		{
			cmd="document.all."+where+i+".style.display='none'";
			eval(cmd);
		}
		
	}
	
}
</script>

<?php
$scroll_y = isset($scroll_y) ? $scroll_y : 0;

echo "<body topmargin=\"0\" onLoad=\"self.scrollBy(0,$scroll_y);\" leftmargin=\"12\">";

$backurl = "./hlr.php";
$sysId	= '330_99_99';

$nGetComm	= 0;
$nSetComm	= 3;

$pubDb = "OMC_PUB";
$sqltable_sccp = 'OBJ_223.param_99';
$sqlSccpConf = 'OBJ_223.paramConf';
$sqltable = 'OBJ_330.param_99';
$sqlConf = 'OBJ_330.paramConf';
$sqltable_spc = 'OBJ_222.param_99';
$mtp3_sqlTable = 'OBJ_222.param_99';
$sysStatTable='OMC_PUB.sysStat';

$sysinfo = 'OMC_PUB.sysInfo';
$sysTypeNo = '322';

$NI_arr=array('International','International spare','National','National spare');

$sysId_arr=array(
	array('oid'=>'2.1.6',		'sysid'=> '223_99_99',		'selectsysid'=>'-1'), 										
	array('oid'=>'2.2.0',		'sysid'=> '223_99_99',		'selectsysid'=>'-1'),
	array('oid'=>'2.4.0',		'sysid'=> '223_99_99',		'selectsysid'=>'-1'),
	
	array('oid'=>'2.1.11',		'sysid'=> '330_99_99',		'selectsysid'=>'-1'),
	array('oid'=>'2.1.12',		'sysid'=> '330_99_99',		'selectsysid'=>'-1'),
	array('oid'=>'2.1.13',		'sysid'=> '330_99_99',		'selectsysid'=>'-1'),
	array('oid'=>'2.1.14',		'sysid'=> '330_99_99',		'selectsysid'=>'-1'),
	array('oid'=>'2.1.15',		'sysid'=> '330_99_99',		'selectsysid'=>'-1'),
	array('oid'=>'2.1.16',		'sysid'=> '330_99_99',		'selectsysid'=>'-1'),
	array('oid'=>'2.1.17',		'sysid'=> '330_99_99',		'selectsysid'=>'-1'),
	array('oid'=>'2.1.18',		'sysid'=> '330_99_99',		'selectsysid'=>'-1'),
	array('oid'=>'2.1.20',		'sysid'=> '330_99_99',		'selectsysid'=>'-1'),
);

$SaveArr=array(
	array('oidstr'=>'3.2',	'setvalue'=>'02'	,'sysid'=>'223_99_99')				
);	
$getsql = "SELECT sysNo FROM $sysinfo where sysTypeNo = 330";
if($DEBUG) echo "getsql = $getsql<br>";
$Result = @mysqli_query($pubConn,$getsql);
while($Rows = mysqli_fetch_array($Result))
{
	$hlrSysId = "330_".$Rows[sysNo]."_0";
	$SaveArr[] = array('oidstr'=>'2.2.2',	'setvalue'=>'01'	,'sysid'=> $hlrSysId);
}

$spcTree_array = array(
array('INT',		'14-bit',	'spc_int_14',	 	'2.3.1'),
array('INT-S',  	'14-bit',	'spc_int_sp_14',	'2.3.2'),
array('NAT',		'14-bit',	'spc_nat_14',	 	'2.3.3'),
array('NAT-S',  	'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')
);

$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',						'02.0-02.7')
);

$hplmn_loc = array(
	'start' => '05.0-10.7',
	'end'   => '11.0-16.7'
);
	
//loading
if($load_flag == 1)
{
	echo "<br>Loading";
	
	GetParam($sysId_arr,1);//1 means return to overview if getting parameters fails.
			
	echo "<script LANGUAGE=\"JavaScript\">";
	if(!$DEBUG){
		echo "\n window.location.href=\"./hlr.php\";";
	} 
	else exit();
	echo "\n </script>";
}
$querysql = "select initValue from $sqltable_spc 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]}<br>";

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;
}

for($i = 0; $i < 4; $i ++)
{
	$levelWhere = getLevelWhere($spcTree_array[$spc_index[$i]][3]);
	$getsql = "select initValue from $sqltable_spc where $levelWhere ";
	$result = mysqli_query($pubConn,$getsql);
	$dpcRow[$i] = mysqli_fetch_array($result);
	$dpcRow[$i] = hexdec($dpcRow[$i][0]);
	if ($DEBUG )
	{
		echo "<br>getsql = $getsql<br>";
		echo "<br>spc_$i=$dpcRow[$i]";
	}
}
$niTypeArr = getNiType();
echo "<input type=\"hidden\" name=\"advanced\" value=\"$advanced\">";
if(isset($doingOtherFlag))
{
	{//set system ip
		for($i=0; $i < 2; $i++)
		{
			$getsql = "SELECT ip FROM $sysinfo where sysTypeNo = $sysTypeNo and sysNo = '$i'";
			if($DEBUG) echo "getsql = $getsql<br>";
			$ip_init = @mysqli_query($pubConn,$getsql);
			$ip_init = mysqli_fetch_array($ip_init);
			$ip_init = $ip_init[0];
			$ip_array = explode('.',$ip_init);
			
			for($j = 0;$j < sizeof($ip_array);$j++)
			{
				$ip = $ip_array[$j];
				$mss_ip[$i] .= omc_keep_length(dechex($ip),'0','2');
			}	
		}
		$mss_ip[0] = strtoupper(omc_keep_length($mss_ip[0],'0','8'));
		$mss_ip[1] = strtoupper(omc_keep_length($mss_ip[1],'0','8'));
		if($DEBUG)
		{
			echo "<br>mss0_ip = $mss_ip[0]<br>";	
			echo "mss1_ip = $mss_ip[1]<br>";	
		}
		
		$sysId = "223_99_99";
		//hlr
		if($setHlrGtt==1)
		{
			$oidStr = "2.1.6";
			setParamValue($mss_ip[0],$sysId,$oidStr,3);
			setParamValue($mss_ip[1],$sysId,$oidStr,4);
		}
	}//end set system ip
	exit;
}
if($_SERVER['REQUEST_METHOD'] == "POST")
{	
	if(isset($setSys) || isset($getSys))
	{
		if(isset($setSys))
		{
			echo "<br>Setting parameters<br>";
			SetParam($sysId_arr);	
			session_register("hlrSetFlag");
						
			$showType="Set";
			echo "<br>Sending save command<br>";
			SaveParam($SaveArr);
			echo "<script LANGUAGE=\"JavaScript\">";
			if(!$DEBUG)
				//echo "\n window.location.href=\"../overview/overview.php\";";
			echo "\n </script>";	
			//exit();	
		}
		else
		{ 
			echo "<br>Getting parameters<br>";
			session_register("GetFlag");
			GetParam($sysId_arr);
			$showType="Get";
		}
	}

	
	echo "<script LANGUAGE=\"JavaScript\">";
	if(!$DEBUG)
		echo "\n window.location.href=\"./hlr.php?advanced=$advanced\";";
	echo "\n </script>";	
	exit();			
}

if ($DEBUG ) echo "delFlag = $delflag<br>";
if ($DEBUG ) echo "delNO = $delValue<br>";
if (isset($delflag))
{
	$delNoStr = rtrim($delNoStr,'.');
	$delNoArr = explode('.',$delNoStr);
	$instNoWhereStr = '';
	for($i=0; $i< sizeof($delNoArr); $i++)
	{
		if($i==0)
			$instNoWhereStr = "(instanceNo='$delNoArr[$i]'";
		else
			$instNoWhereStr .= " or instanceNo='$delNoArr[$i]'" ;
	}
	$instNoWhereStr .= ')';
	
	if($delflag=='Regional')
	{
		$getsql = "select initValue from $sqlConf where level_1 = '2' and level_2 = '1' and level_3 = '14'";  
		$rsl_org = @mysqli_query($pubConn,$getsql);
		$rsl_org = @mysqli_fetch_array($rsl_org);
		$rsl_org = $rsl_org[0];
		echo mysqli_error($pubConn);
		if ($DEBUG ) echo "rsl_org = $rsl_org<br>";
	
		$setsql = "update $sqltable set initValue = '$rsl_org' 
		where level_1 = '2' and level_2 = '1' and level_3 = '14' and $instNoWhereStr ";
		mysqli_query($pubConn,$setsql);
		echo mysqli_error($pubConn);
	}
	elseif($delflag=='IMSIRange' || $delflag=='MSISDNRange')
	{
		$defSql = " SELECT initValue FROM $sqlSccpConf WHERE level_1 = '2' and level_2 = '2' and level_3 = '0'";
		$defRes = @mysqli_query($pubConn,$defSql);
		$defrow = @mysqli_fetch_array($defRes);
		
		$setsql = "update $sqltable_sccp set initValue = '$defrow[initValue]' 
		where level_1 = '2' and level_2 = '2' and level_3 = '0' and $instNoWhereStr ";		
		mysqli_query($pubConn,$setsql);
		echo mysqli_error($pubConn);		
		
		$defSql = " SELECT initValue FROM $sqlSccpConf WHERE level_1 = '2' and level_2 = '4' and level_3 = '0'";
		$defRes = @mysqli_query($pubConn,$defSql);
		$defrow = @mysqli_fetch_array($defRes);		
		$setsql = "update $sqltable_sccp set initValue = '$defrow[initValue]' 
		where level_1 = '2' and level_2 = '4' and level_3 = '0' and $instNoWhereStr ";		
		mysqli_query($pubConn,$setsql);
		echo mysqli_error($pubConn);		
	}
	elseif($delflag=='VPLMNs')
	{	
		$defSql = " SELECT initValue FROM paramConf WHERE level_1 = '2' and level_2 = '1' and level_3 = '12'";
		$defRes = @mysqli_query($pubConn,$defSql);
		$defrow = @mysqli_fetch_array($defRes);

		$setsql = "update $sqltable set initValue = '$defrow[initValue]' 
		where level_1 = '2' and level_2 = '1' and level_3 = '12' and $instNoWhereStr ";		
		mysqli_query($pubConn,$setsql);
		echo mysqli_error($pubConn);		
	}
	elseif($delflag=='USSDEAE')
	{	
		$oidStr = "2.1.20.3";
		$levelWhere = getLevelWhere($oidStr);
		$defSql = " SELECT initValue FROM paramConf WHERE $levelWhere";
		$defRes = @mysqli_query($pubConn,$defSql);
		$defrow = @mysqli_fetch_array($defRes);

		$setsql = "update $sqltable set initValue = '$defrow[initValue]' 
		where $levelWhere and $instNoWhereStr ";		
		mysqli_query($pubConn,$setsql);
		echo mysqli_error($pubConn);		
	}
	elseif($delflag=='faxGsmBcId')
	{		
		$defSql = " SELECT initValue FROM paramConf WHERE level_1 = '2' and level_2 = '1' and level_3 = '17'";
		$defRes = @mysqli_query($pubConn,$defSql);
		$defrow = @mysqli_fetch_array($defRes);

		$setsql = "update $sqltable set initValue = '$defrow[initValue]' 
		where level_1 = '2' and level_2 = '1' and level_3 = '17' and instanceNo = '$delValue' ";		
		mysqli_query($pubConn,$setsql);
		echo mysqli_error($pubConn);		
	}
	elseif($delflag=='dataGsmBcId')
	{		
		$defSql = " SELECT initValue FROM paramConf WHERE level_1 = '2' and level_2 = '1' and level_3 = '18'";
		$defRes = @mysqli_query($pubConn,$defSql);
		$defrow = @mysqli_fetch_array($defRes);

		$setsql = "update $sqltable set initValue = '$defrow[initValue]' 
		where level_1 = '2' and level_2 = '1' and level_3 = '18' and instanceNo = '$delValue' ";		
		mysqli_query($pubConn,$setsql);
		echo mysqli_error($pubConn);		
	}
	elseif($delflag=='RSA')
	{
		$getsql = "select initValue from $sqlConf where level_1 = '2' and level_2 = '1' and level_3 = '29'";  
		$rsl_org = @mysqli_query($pubConn,$getsql);
		$rsl_org = @mysqli_fetch_array($rsl_org);
		$rsl_org = $rsl_org[0];
		echo mysqli_error($pubConn);
		if ($DEBUG ) echo "rsl_org = $rsl_org<br>";
	
		$setsql = "update $sqltable set initValue = '$rsl_org' 
		where level_1 = '2' and level_2 = '1' and level_3 = '29' and instanceNo = '$delValue' ";
		mysqli_query($pubConn,$setsql);
		echo mysqli_error($pubConn);		
	}
	elseif($delflag=='ACS_DIGI')
	{
		if($DEBUG)echo "<br><br><b>Deleteing access digits instance $delValue of RA $delValue2</b>";

		//delete access_digits
		$setsql = "update $sqltable set initValue = '$access_digit_default'
			where level_1 = '2' and level_2 = '1' and level_3 = '30' and instanceNo = '$delValue'";
		mysqli_query($pubConn,$setsql);
		echo mysqli_error($pubConn);		
		
		//delete prefix
		delete_prefix_of_RA($delValue2);
	}	
}																									
//==========================================================
//输出并显示数据
//========================================================== 
echo "<form method=\"POST\" name=\"Set\" action=\"$PHP_SELF?advanced=$advanced\">";

echo "<table border=\"0\" width=\"100%\">";
echo "<tr>";
echo "<td width=\"50%\">";
echo "Configuration > <a href=\"../overview/overview.php\">Network</a> > <a href=\"#\">HLR</a>";
echo "<td width=\"50%\" align=\"right\" title=\"Help\">";
$helpId = '2.1.1.3';
showHelp($helpId);
echo "</td>";
echo "</tr>";
echo "</table>";
echo "<br>";

{
	echo "<table width=\"100%\">";
	echo "<tr>";
		echo "<td width=\"70%\">&nbsp";
			//echo "<b>Home Location Register:&nbsp;&nbsp;</b>";
		echo "</td>";
		echo "<td width=\"20%\" align=\"right\">";
				echo "<input type=\"submit\" title=\"$strTitleGet\" name=\"getSys\" value=\"$strGet\" class=\"button\" style=\"cursor:pointer; left: 1; top: 2; width: 60; height: 25; position: relative\">";
				echo "&nbsp;&nbsp;&nbsp;";
				echo "<input type=\"submit\" title=\"$strTitleSet\" name=\"setSys\" value=\"$strSet\" class=\"button\" style=\"cursor:pointer; left: 1; top: 2; width: 60; height: 25; position: relative\">";
			echo "</td>";
		echo "<td width=\"10%\">";
			echo "<p align=\"right\"><a href=\"../overview/overview.php?scroll_y=$page_top\"><img align=absBottom border=0 src=\"../../images/left.gif\" width=\"14\" height=\"14\">$strBack</a>";
		echo "</td>";
	echo "</tr>";
	echo "</table>";
}
?>

<TABLE  width=100%   border="1"  cellpadding="1" cellspacing="0"  bordercolor="#666666" bordercolordark="#FFFFFF" bgcolor="#FFFFFF"> 
<?php
{//Signaling point
	
	echo "<tr>" ;
	echo "<td width=\"20%\" bgcolor=\"#E6E6E6\"><b>Signaling point code</b></td>";
	echo "<td><table width=100%><tr>";
	for($i=0; $i<4; $i++)
		echo "<td  width=\"25%\" align=\"left\">{$spcTree_array[$i][0]}&nbsp;:&nbsp;{$spcTree_array[$spc_index[$i]][1]}&nbsp;:&nbsp;$dpcRow[$i]</td>";
	echo "</tr></table></td>";
	echo "</tr>";
}//end Signaling point

{//gtt
	$sysId = "223_99_99";
	$oidStr = "2.1.6";
	$instanceNo=0;
	echo "<tr >" ;
	echo "<td bgcolor=\"#E6E6E6\"  ><b>$strE164Number</b></td><td><table width=100%>";
		echo "<td align=\"left\" width=\"50%\">";
		$doingOtherUlr="$PHP_SELF?doingOtherFlag=1&setHlrGtt=1";
			showParameter($sysId,$oidStr,2,1,$instanceNo,$doingOtherUlr);
		echo "</td>";
		
		echo "<td align=\"left\" width=\"50%\">";
			showParameter($sysId,$oidStr,1,1,$instanceNo,$doingOtherUlr);
		echo "</td>";
	echo "</table></td></tr>";
}//end gtt

//==========================================================
//取GTT数据
//========================================================== 
/*byte26: subsystem number (SSN), function with DPC for GTT over SCCP,
4=OMC, 6=HLR,
7=VLR, 8=MSC, 9=EIR, 10=AuC, 11=SMSC , 254=AIF, 147=PPSSCF 
*/

$getsql = "select initValue from $sqltable_sccp
where level_1 = '2' and level_2 = '1' and level_3 = '6' ";
$result = @mysqli_query($pubConn,$getsql);
$sccp_row = @mysqli_fetch_array($result);
echo mysqli_error($pubConn);
$ni_hlr= hexdec(getBitValue($sccp_row[0],"0.0-0.7"));
$gtt = getBitValue($sccp_row[0],"1.0-10.7");
$gtt = str_replace('F','',$gtt);
$setGttDPC=$dpcRow[$ni_hlr];

$getsql = "select initValue,instanceNo from $sqltable_sccp
where level_1 = '2' and level_2 = '2' and level_3 = '0'";
$result = @mysqli_query($pubConn,$getsql);
echo mysqli_error($pubConn);

$n = 0;
$m = 0;
while($gtt_row = @mysqli_fetch_array($result))
{
	$flag = BinDec(getBitValue($gtt_row[0],'0.0-0.7'));	
	$ssn = hexdec(getBitValue($gtt_row[0],'27.0-27.7'));
	$indicator = hexdec(getBitValue($gtt_row[0],'23.0-23.7'));
	$dpc = hexdec(getBitValue($gtt_row[0],'24.0-26.7'));
	if ($flag == 1 && $ssn == 6 && $indicator==$ni_hlr && $dpc==$dpcRow[$ni_hlr])
	{
		$TT = hexdec(getBitValue($gtt_row[0],$GTTtableConfArr[13][1]));	
		$numberPlan=hexdec(getBitValue($gtt_row[0],$GTTtableConfArr[3][1]));	

		if($niTypeArr[$ni_hlr]==0)//ITU
		{
			$imsiFlag = ($numberPlan==6 || $numberPlan==7);
			$msisdnFlag = ($numberPlan==1);
		}
		else
		{
			$imsiFlag = ($TT == 9);
			$msisdnFlag = ($TT == 14 || $TT == 10||$TT == 142); 
		}
		if($imsiFlag)//imsi
		{
			$imsi_inst[$n] = $gtt_row[instanceNo];
			$imsi_start[$n] = getBitValue($gtt_row[0],'3.0-12.7');	
			$imsi_start[$n] = str_replace('F','',$imsi_start[$n]);
			if($imsi_start[$n] == '')
				$imsi_start[$n] = 0;
			$imsi_end[$n] = getBitValue($gtt_row[0],'13.0-22.7');	
			$imsi_end[$n] = str_replace('F','',$imsi_end[$n]);
			if($imsi_end[$n] == '')
				$imsi_end[$n] = 0;
				
			$n++;
			if ($DEBUG ) echo "imsi_start=$imsi_start<br>";
			if ($DEBUG ) echo "imsi_end=$imsi_end<br>";
			if ($DEBUG ) echo "imsi_no=$imsi_no<br>";
		}
		else if($msisdnFlag)
		{
			$msisdn_inst[$m] = $gtt_row[instanceNo];
			$msisdn_start[$m] = getBitValue($gtt_row[0],'3.0-12.7');	
			$msisdn_start[$m] = str_replace('F','',$msisdn_start[$m]);
			if($msisdn_start[$m] == '')
				$msisdn_start[$m] = 0;
			$msisdn_end[$m] = getBitValue($gtt_row[0],'13.0-22.7');	
			$msisdn_end[$m] = str_replace('F','',$msisdn_end[$m]);
			if($msisdn_end[$m] == '')
				$msisdn_end[$m] = 0;
			
			$m++;
			if ($DEBUG ) echo "msisdn_start=$msisdn_start<br>";
			if ($DEBUG ) echo "msisdn_end=$msisdn_end<br>";
			if ($DEBUG ) echo "msisdn_no=$msisdn_no<br>";
		}
		$imsiFlag=$msisdnFlag=0;
	}
}
if ($DEBUG ) echo "imsi_no=$imsi_no<br>";
if ($DEBUG ) echo "msisdn_no=$msisdn_no<br>";

{
	{//imsi range
		$nrow = $n + 1;
		$getsql = "SELECT initValue,instanceNo from $sqltable_sccp
				 where level_1 = '2' and level_2 = '2' and level_3 = '0'
				 and initValue like '00%'";
		$result = mysqli_query($pubConn,$getsql);
	
		echo "<tr>" ;
		echo "<td bgcolor=\"#E6E6E6\" >";
		echo "<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" ><tr >";
		echo "<td align=left><b>IMSI range</b></td>";
		if($imsi_new = mysqli_fetch_array($result)){
			echo "<td align=\"right\"><a onMouseover=\"return hidestatus()\" href=\"javascript:openSetGTT('imsi','{$imsi_new[instanceNo]}','$ni_hlr','$setGttDPC','$PHP_SELF?advanced=$advanced')\"><font size=4>+</font></a></td>";
		}
		echo "</tr></table></td>";
		
		if($n == 0)
		{
			echo "<td >&nbsp;--</td>";
		}
		else
		{
			echo "<td>";
			echo "<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" >";
			$flag = 'IMSIRange';
			echo "<tr bgcolor=\"#E6E6E6\">";
			echo "<td width=\"10%\">No.</td>";
			echo "<td width=\"40%\">Start</td>";
			echo "<td width=\"40%\">End</td>";
			echo "<td width=\"10%\" align=right><a href=\"javascript:delSelected('Set','$flag',0,$n)\" title=\"Delete all selected.\">Delete</a>";
			echo "<input type=\"checkbox\" name=\"seleceAll\" title=\"Select all to delete\"  value=\"1\" onClick=selectAllToDel('Set','$flag',this,0,$n)>";
			echo "</td>";
			for($i=0; $i < $n; $i++)
			{		
				$checkBoxName=$flag . 'checkBox_'.$i;
				$deleteNo = $flag . 'deleteno_'.$i;
				if($i>3)
					echo "<tr id='IMSIRange$i' style=\"display:none\" onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";
				else
					echo "<tr id='IMSIRange$i' style=\"display:block\" onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";
				//echo "<tr  onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";
				echo "<td width=10%><a onMouseover=\"return hidestatus()\" href=\"javascript:openSetGTT('imsi','{$imsi_inst[$i]}','$ni_hlr','$setGttDPC','$PHP_SELF?advanced=$advanced')\">&nbsp;$i</a></td>";
				echo "<td width=40%>$imsi_start[$i]</td>";
				echo "<td width=40%>$imsi_end[$i]</td>";
				echo "<td width=10% align=right><input type=\"checkbox\" name=\"$checkBoxName\" value=\"0\" onClick=\"javascript:selectToDel(this)\"></td>";
				echo "<input type=\"hidden\" name=\"$deleteNo\" value=\"{$imsi_inst[$i]}\"";	
				echo "</tr>"; 
			}
			//==============the more and hide button===================
			
			if($n>4)
			{
			
					echo "<tr id='showIMSIRange' style=\"display:block\"><td><a href=\"javascript:clickOnMoreHide('IMSIRange',$n,'show')\">More >></a></td></tr>"; 
					echo "<tr id='hideIMSIRange' style=\"display:none\"><td><a href=\"javascript:clickOnMoreHide('IMSIRange',$n,'hide')\">Hide >></a></td></tr>"; 
			}
			
			echo "</table></td>";
		}
		echo "</tr>";
	}//end imsi range
	
	{//msisdn range
		$nrow = $m + 1;
		$getsql = "SELECT initValue,instanceNo from $sqltable_sccp
				 where level_1 = '2' and level_2 = '2' and level_3 = '0'
				 and initValue like '00%'";
		//echo "<td>$getsql</td>"; 
		$result = mysqli_query($pubConn,$getsql);
		echo "<tr>" ;
		echo "<td bgcolor=\"#E6E6E6\" >";
		echo "<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" ><tr >";
		echo "<td align=left><b>MSISDN range</b></td>";
		if($msisdn_new = mysqli_fetch_array($result)){
			echo "<td align=\"right\"><a onMouseover=\"return hidestatus()\" href=\"javascript:openSetGTT('msisdn','{$msisdn_new[instanceNo]}','$ni_hlr','$setGttDPC','$PHP_SELF?advanced=$advanced')\"><font size=4>+</font></a></td>";
		}
		echo "</tr></table></td>";
		
		if($m == 0)
		{
			echo "<td >&nbsp;--</td>";
		}
		else
		{
			echo "<td>";
			echo "<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" >";
			$flag = 'MSISDNRange';
			echo "<tr bgcolor=\"#E6E6E6\">";
			echo "<td width=\"10%\">No.</td>";
			echo "<td width=\"40%\">Start</td>";
			echo "<td width=\"40%\">End</td>";
			echo "<td width=\"10%\" align=right><a href=\"javascript:delSelected('Set','$flag',0,$m)\" title=\"Delete all selected.\">Delete</a>";
			echo "<input type=\"checkbox\" name=\"seleceAll\" title=\"Select all to delete\"  value=\"1\" onClick=selectAllToDel('Set','$flag',this,0,$m)>";
			echo "</td>";
		
			for($i=0; $i < $m; $i++)
			{		
				$checkBoxName=$flag . 'checkBox_'.$i;
				$deleteNo = $flag . 'deleteno_'.$i;
				if($i>3)
					echo "<tr id='MSISDNRange$i' style=\"display:none\" onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";
				else
					echo "<tr id='MSISDNRange$i' onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";
				//echo "<tr  onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";
				echo "<td width=10%><a onMouseover=\"return hidestatus()\" href=\"javascript:openSetGTT('msisdn','{$msisdn_inst[$i]}','$ni_hlr','$setGttDPC','$PHP_SELF?advanced=$advanced')\">&nbsp;$i</a></td>";
				echo "<td width=40%>$msisdn_start[$i]</td>";
				echo "<td width=40%>$msisdn_end[$i]</td>";
			
				echo "<td width=10% align=right><input type=\"checkbox\" name=\"$checkBoxName\" value=\"0\" onClick=\"javascript:selectToDel(this)\"></td>";
				echo "<input type=\"hidden\" name=\"$deleteNo\" value=\"{$msisdn_inst[$i]}\"";	
				echo "</tr>"; 
			}
			//===============more button==============
			if($m>4)
			{
					echo "<tr id='showMSISDNRange' style=\"display:block\"><td><a href=\"javascript:clickOnMoreHide('MSISDNRange',$m,'show')\">More >></a></td></tr>"; 
					echo "<tr id='hideMSISDNRange' style=\"display:none\"><td><a href=\"javascript:clickOnMoreHide('MSISDNRange',$m,'hide')\">Hide >></a></td></tr>"; 
			}
			echo "</table></td>";
		}
		echo "</tr>";
	}//end msisdn range
}

{//HPLMN SN Range
	$sysId = "330_99_99";
	$oidStr = "2.1.11";
	echo "<tr>";
	echo "<td align=\"left\" bgcolor = \"#E6E6E6\"><b>VLR SN range</b></td>";
	echo "<td><table width=100%><tr>";
		echo "<td align=\"left\" width=50%>Start:&nbsp;";
			showParameter($sysId,$oidStr,3,1);
		echo "</td>";
		echo "<td align=\"left\" width=50%>End:&nbsp;";
			showParameter($sysId,$oidStr,4,1);
		echo "</td>";
	echo "</tr></table></td>";
	echo "</tr>";
}

//==========================================================
//输出VPLMNs SN Range
//========================================================== 
$objWhereStr = getLevelWhere('2.1.12');

$defSql = " SELECT initValue FROM paramConf WHERE $objWhereStr";
$defRes = @mysqli_query($pubConn,$defSql);
$defrow = @mysqli_fetch_array($defRes);


$getsql = "SELECT initValue,instanceNo from $sqltable where $objWhereStr AND initValue !='$defrow[initValue]'";
$result = mysqli_query($pubConn,$getsql);
if($DEBUG) echo "<br>getsql:$getsql";
$n=0;
while($vplmn_init = mysqli_fetch_array($result))
{
	$init = $vplmn_init[initValue];
	$vp_insno[$n] = $vplmn_init[instanceNo];
	$vp_CC[$n] = str_replace('E','',getBitValue($init,'00.0-01.7'));
	$vp_NDC[$n] = str_replace('E','',getBitValue($init,'02.0-04.7'));
	$vp_sn_start[$n] = str_replace('E','',getBitValue($init,$hplmn_loc['start']));
	$vp_sn_end[$n]	= str_replace('E','',getBitValue($init,$hplmn_loc['end']));	
  $n++;	
}

$nrow = $n + 1;
$getsql = "SELECT initValue,instanceNo from $sqltable where $objWhereStr AND initValue ='$defrow[initValue]'";
$result = mysqli_query($pubConn,$getsql);

echo "<tr>" ;
echo "<td bgcolor=\"#E6E6E6\" >";
echo "<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" ><tr >";
echo "<td align=left><b>VPLMNs</b></td>";
if($vplmn_new = mysqli_fetch_array($result)){
	echo "<td align=\"right\"><a onMouseover=\"return hidestatus()\" href=\"javascript:openSet('VPLMNs','$vplmn_new[instanceNo]','$PHP_SELF?advanced=$advanced')\"><font size=4>+</font></a></td>";
}
echo "</tr></table></td>";

if($n == 0)
{
	echo "<td >&nbsp;--</td>";
}
else
{
	$flag = 'VPLMNs';
	echo "<td>";
	echo "<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" >";
	echo "<tr bgcolor=\"#E6E6E6\">";
	echo "<td width=\"5%\">No.</td>";
	echo "<td width=\"15%\">CC</td>";
	echo "<td width=\"15%\">NDC</td>";
	echo "<td width=\"25%\">Start SN</td>";
	echo "<td width=\"25%\">End SN</td>";
	echo "<td width=\"15%\" align=right><a href=\"javascript:delSelected('Set','$flag',0,$n)\" title=\"Delete all selected.\">Delete</a>";
	echo "<input type=\"checkbox\" name=\"seleceAll\" title=\"Select all to delete\"  value=\"1\" onClick=selectAllToDel('Set','$flag',this,0,$n)>";
	echo "</td>";
	echo "</tr>";

	for($i=0; $i < $n; $i++)
	{		
		$checkBoxName=$flag . 'checkBox_'.$i;
		$deleteNo = $flag . 'deleteno_'.$i;
		$vp_CC[$i] = strlen($vp_CC[$i])==0 ? '--' : $vp_CC[$i];
		$vp_NDC[$i] = strlen($vp_NDC[$i])==0 ? '--' : $vp_NDC[$i];
		$vp_sn_start[$i] = strlen($vp_sn_start[$i])==0 ? '--' : $vp_sn_start[$i];
		$vp_sn_end[$i] = strlen($vp_sn_end[$i])==0 ? '--' : $vp_sn_end[$i];
		
		if($i>3)
			echo "<tr id='VPLMNs$i' style=\"display:none\" onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";
		else
			echo "<tr id='VPLMNs$i' onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";
		
		//echo "<tr  onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";
		echo "<td width=5%><a onMouseover=\"return hidestatus()\" href=\"javascript:openSet('VPLMNs','$vp_insno[$i]','$PHP_SELF?advanced=$advanced')\">&nbsp;$vp_insno[$i]</a></td>";
		echo "<td width=15%>$vp_CC[$i]</td>";
		echo "<td width=15%>$vp_NDC[$i]</td>";
		echo "<td width=25%>$vp_sn_start[$i]</td>";
		echo "<td width=25%>$vp_sn_end[$i]</td>";
		echo "<td align=right><input type=\"checkbox\" name=\"$checkBoxName\" value=\"0\" onClick=\"javascript:selectToDel(this)\"></td>";
		echo "<input type=\"hidden\" name=\"$deleteNo\" value=\"{$vp_insno[$i]}\"";	
		echo "</tr>"; 
	}
	
	if($n>4)
	{	
		echo "<tr id='showVPLMNs' style=\"display:block\"><td width=20%><a href=\"javascript:clickOnMoreHide('VPLMNs',$n,'show')\">More >></a></td></tr>"; 
		echo "<tr id='hideVPLMNs' style=\"display:none\"><td width=20%><a href=\"javascript:clickOnMoreHide('VPLMNs',$n,'hide')\">Hide >></a></td></tr>"; 
	}
	echo "</table></td>";
}
echo "</tr>";

if(1)
{
	//==========================================================
	//输出CSRR
	//========================================================== 
	echo "<tr>";
	echo "<td rowspan = \"2\" bgcolor = \"#E6E6E6\">";
	echo "<b>CSRR type</b></td>";
	echo "</tr>";
	
	echo "<tr><td>";
	for ($i=0; $i < 8; $i++)
	{
		$getsql = "select initValue from $sqltable
		where level_1 = '2' and level_2 = '1' and level_3 = '13' and instanceNo ='$i' ";  
		$result = @mysqli_query($pubConn,$getsql);
		$row = @mysqli_fetch_array($result);
		echo mysqli_error($pubConn);
		$row = $row[0];
		
		echo "<a onMouseover=\"return hidestatus()\" href=\"javascript:openSet('csrr','$i',0)\">&nbsp;$i&nbsp;</a>&nbsp;&nbsp;&nbsp;&nbsp;";
		/*
		echo "<td >";
		echo "<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" ><tr>";
		echo "<td width=30%><a onMouseover=\"return hidestatus()\" href=\"javascript:openSet('csrr','$i',0)\">&nbsp;$i</a></td>";
		echo "<td>$row</td>";
		echo "</tr></table>";
		echo "</td>";
		*/
	}
	echo "&nbsp;&nbsp;&nbsp;&nbsp;</td></tr>";
	
	//==========================================================
	//输出Regional subscription zone code list
	//========================================================== 
	$getsql = "select initValue from $sqlConf
	where level_1 = '2' and level_2 = '1' and level_3 = '14' ";
	$reg_org = @mysqli_query($pubConn,$getsql);
	$reg_org = @mysqli_fetch_array($reg_org);
	$reg_def = $reg_org[0];
	
	$getsql = "select initValue ,instanceNo from $sqltable
	where level_1 = '2' and level_2 = '1' and level_3 = '14' and initValue !='$reg_def' ";
	$reg_result = mysqli_query($pubConn,$getsql);
	echo mysqli_error($pubConn);
	$n = 0;
	while($reg_row = mysqli_fetch_array($reg_result))
	{
		$cntryCode[$n] = str_replace('E','',getBitValue($reg_row[initValue],'00.0-01.7'));
		$nationalDesCode[$n] = str_replace('E','',getBitValue($reg_row[initValue],'02.0-04.7'));
		$zoneCode[$n] = hexdec(getBitValue($reg_row[initValue],'05.0-06.7'));	
		$reg_ins[$n] = $reg_row[instanceNo];
		$n++;
	}
	$nrow = $n + 2;
	$getsql = "select initValue ,instanceNo from $sqltable
	where level_1 = '2' and level_2 = '1' and level_3 = '14' and initValue ='$reg_def' ";
	$reg_new = mysqli_query($pubConn,$getsql);
	echo mysqli_error($pubConn);
	$regnew = mysqli_fetch_array($reg_new);
	echo "<tr>" ;
	echo "<td bgcolor=\"#E6E6E6\" >";
	echo "<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" ><tr >";
	echo "<td align=left><b>Regional subscription zone code list</b></td>";
	echo "<td align=\"right\"><a onMouseover=\"return hidestatus()\" href=\"javascript:openSet('Regional','$regnew[instanceNo]','$PHP_SELF?advanced=$advanced')\"><font size=4>+</font></a></td>";
	echo "</tr></table></td>";
	
	if($n == 0)
	{
		echo "<td >&nbsp;--</td>";
	}
	else
	{
		echo "<td>";
		echo "<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" >";
		$flag = 'Regional';
		echo "<tr bgcolor=\"#E6E6E6\">";
		echo "<td width=10%>No.</td>";
		echo "<td width=20%>CC</td>";
		echo "<td width=20%>NDC</td>";
		echo "<td width=30%>ZC</td>";
			
		echo "<td width=\"20%\" align=right><a href=\"javascript:delSelected('Set','$flag',0,$n)\" title=\"Delete all selected.\">Delete</a>";
		echo "<input type=\"checkbox\" name=\"seleceAll\" title=\"Select all to delete\"  value=\"1\" onClick=selectAllToDel('Set','$flag',this,0,$n)>";
		echo "</td>";
		echo "</tr>";
		for($i=0; $i < $n; $i++)
		{		
			$checkBoxName=$flag . 'checkBox_'.$i;
			$deleteNo = $flag . 'deleteno_'.$i;
			if($i>3)
				echo "<tr id='Regional$i' style=\"display:none\" onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";
			else
				echo "<tr id='Regional$i' onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";
			//echo "<tr  onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";
			echo "<td width=10%><a onMouseover=\"return hidestatus()\" href=\"javascript:openSet('Regional','$reg_ins[$i]','$PHP_SELF?advanced=$advanced')\">&nbsp;$reg_ins[$i]</a></td>";
			echo "<td width=20%>$cntryCode[$i]</td>";
			echo "<td width=20%>$nationalDesCode[$i]</td>";
			echo "<td width=30%>$zoneCode[$i]</td>";
			echo "<td align=right><input type=\"checkbox\" name=\"$checkBoxName\" value=\"0\" onClick=\"javascript:selectToDel(this)\"></td>";
			echo "<input type=\"hidden\" name=\"$deleteNo\" value=\"{$reg_ins[$i]}\"";	
			echo "</tr>";  
		}
		//======more button=======
		if($n>4)
		{		
			echo "<tr id='showRegional' style=\"display:block\"><td><a href=\"javascript:clickOnMoreHide('Regional',$n,'show')\">More >></a></td></tr>"; 	
			echo "<tr id='hideRegional' style=\"display:none\"><td><a href=\"javascript:clickOnMoreHide('Regional',$n,'hide')\">Hide >></a></td></tr>"; 
		}
		echo "</table></td>";
	}
	echo "</tr>";
}

//==========================================================
//输出CDR
echo "<tr>";
echo "<td bgcolor = \"#E6E6E6\">";
echo "<b>CDR</b></td>";
	echo "<td>&nbsp;";
	$sysId = "330_99_99";
	$oidStr = "2.1.16";
	showParameter($sysId,$oidStr,1,1);
	echo "</td>";
echo "</tr>";

//==========================================================
//输出USSD Format
//==========================================================
{
	echo "<tr>";
	echo "<td bgcolor = \"#E6E6E6\">";
	echo "<b>USSD format</b></td>";
	echo "<td>&nbsp;";
	$sysId = "330_99_99";
	$oidStr = "2.1.20.1";
	showParameter($sysId,$oidStr,1,3);
	echo "</td>";
	echo "</tr>";
}//end 输出USSD Format

{//UG-CSI 
	echo "<tr>";
	echo "<td bgcolor = \"#E6E6E6\">";
	echo "<b>UG-CSI</b></td>";
	echo "<td><table width=\"100%\">";
	$sysId = "330_99_99";
	$oidStr = "2.1.20.2";
	echo "<tr>";
	echo "<td width=\"30%\">Service Code&nbsp;";
	showParameter($sysId,$oidStr,1,1);
	echo "</td>";
	echo "<td width=\"30%\">Number Plan + MSISDN&nbsp;";
	showParameter($sysId,$oidStr,2,1);
	echo "</td>";	
	echo "</tr>";
	echo "</table></td>";
	echo "</tr>";
}//end UG-CSI
//output ussd eae
{
	//$relayTypeArr = array("SMPP","MAP");
	$levelWhere = getLevelWhere("2.1.20.3");
	$ussdEAE_defsql = "select initValue from $sqlConf where $levelWhere";
	$ussdEAE_defresult = @mysqli_query($pubConn,$ussdEAE_defsql);
	$ussdEAE_defrow = @mysqli_fetch_array($ussdEAE_defresult);
	$ussdEAE_def = $ussdEAE_defrow[0];
	
	$ussdEAE_sql = "select instanceNo,initValue from $sqltable where $levelWhere and initValue != '$ussdEAE_def'";
	$ussdEAE_result = mysqli_query($pubConn,$ussdEAE_sql);
	$n=0;
	while($ussdEAE_row = mysqli_fetch_array($ussdEAE_result))
	{
		$ussdEaeArr[$n][inst] = $ussdEAE_row[instanceNo];
		$ussdEaeArr[$n][smppNumber] = toAscii(getBitValue($ussdEAE_row[initValue],'00.0-08.7'));
		$ussdEaeArr[$n][ussdCode] = toAscii(getBitValue($ussdEAE_row[initValue],'9.0-12.7'));
		//$ussdEaeArr[$n][relayType] = hexdec(getBitValue($ussdEAE_row[initValue],'14.0-14.7'));
		$n++;
	}
	$nrow = $n + 1;
	$getsql = "SELECT initValue,instanceNo from $sqltable where $levelWhere AND initValue = '$ussdEAE_def'";
	$result = mysqli_query($pubConn,$getsql);
	
	echo "<tr>" ;
	echo "<td bgcolor=\"#E6E6E6\" >";
	echo "<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" ><tr >";
	echo "<td align=left><b>USSDEAE</b></td>";
	if($USSDEAE_new = mysqli_fetch_array($result)){
		echo "<td align=\"right\"><a onMouseover=\"return hidestatus()\" href=\"javascript:openSet('USSDEAE','$USSDEAE_new[instanceNo]','$PHP_SELF?advanced=$advanced')\"><font size=4>+</font></a></td>";
	}
	echo "</tr></table></td>";
	
	if($n == 0)
	{
		echo "<td >&nbsp;--</td>";
	}
	else
	{
		$flag = 'USSDEAE';
		echo "<td>";
		echo "<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" >";
		echo "<tr bgcolor=\"#E6E6E6\">";
		echo "<td width=\"10%\">No.</td>";
		echo "<td width=\"30%\">SMPP Number</td>";
		echo "<td width=\"30%\">USSD Code</td>";
		//echo "<td width=\"15%\">Relay Type</td>";
		echo "<td width=\"15%\" align=right><a href=\"javascript:delSelected('Set','$flag',0,$n)\" title=\"Delete all selected.\">Delete</a>";
		echo "<input type=\"checkbox\" name=\"seleceAll\" title=\"Select all to delete\"  value=\"1\" onClick=selectAllToDel('Set','$flag',this,0,$n)>";
		echo "</td>";
		echo "</tr>";
	
		for($i=0; $i < $n; $i++)
		{		
			$checkBoxName=$flag . 'checkBox_'.$i;
			$deleteNo = $flag . 'deleteno_'.$i;
	
			$ussdEaeArr[$i][smppNumber] = strlen($ussdEaeArr[$i][smppNumber]) == 0 ? '--' : $ussdEaeArr[$i][smppNumber];
			$ussdEaeArr[$i][ussdCode] = strlen($ussdEaeArr[$i][ussdCode]) == 0 ? '--' : $ussdEaeArr[$i][ussdCode];
			//$ussdEaeArr[$i][relayType];
			$tmpInst = $ussdEaeArr[$i][inst];
			if($i>3)
				echo "<tr id='USSDEAE$i' style=\"display:none\" onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";
			else
				echo "<tr id='USSDEAE$i' onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";
			//echo "<tr  onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";
			echo "<td width=10%><a onMouseover=\"return hidestatus()\" href=\"javascript:openSet('USSDEAE','$tmpInst','$PHP_SELF?advanced=$advanced')\">&nbsp;{$ussdEaeArr[$i][inst]}</a></td>";
			echo "<td width=30%>{$ussdEaeArr[$i][smppNumber]}</td>";
			echo "<td width=30%>{$ussdEaeArr[$i][ussdCode]}</td>";
			/*echo "<td width=15%>{$relayTypeArr[$ussdEaeArr[$i][relayType]]}</td>";*/
			echo "<td align=right><input type=\"checkbox\" name=\"$checkBoxName\" value=\"0\" onClick=\"javascript:selectToDel(this)\"></td>";
			echo "<input type=\"hidden\" name=\"$deleteNo\" value=\"{$ussdEaeArr[$i][inst]}\"";	
			echo "</tr>"; 
		}
		//==more button=======
		if($n>4)
		{
			echo "<tr id='showUSSDEAE' style=\"display:block\"><td><a href=\"javascript:clickOnMoreHide('USSDEAE',$n,'show')\">More >></a></td></tr>"; 
			echo "<tr id='hideUSSDEAE' style=\"display:none\"><td><a href=\"javascript:clickOnMoreHide('USSDEAE',$n,'hide')\">Hide >></a></td></tr>"; 
		}
		echo "</table></td>";
	}
	echo "</tr>";
}//end output ussd eae

$getSql="SELECT detailStat FROM $sysStatTable WHERE sysTypeNo='330' ORDER BY sysNo,subSysNo";
if ($DEBUG ) echo "<BR>getSql=$getSql";
$result	=mysqli_query($pubConn,$getSql);
$rows=mysqli_fetch_array($result);
		
$max_lic=hexdec(substr($rows[0],44,8));
$used_lic=hexdec(substr($rows[0],52,8));
		
$license_arr=array(
	array('Subscriber',	'used_lic'),
	array('License',	'max_lic')	
);

if($DEBUG)
{
	echo "<br>Max = $max_lic<br>";	
	echo "Used = $used_lic<br>";
}
	echo "<tr>";
	echo "<td bgcolor = \"#E6E6E6\"><b>{$license_arr[0][0]}</b></td>";
	echo "<td>&nbsp;${$license_arr[0][1]}</td>";
	echo "</tr>";
/*		
	{//license
		echo "<tr >" ;
		echo "<td bgcolor=\"#E6E6E6\"  ><b>License control</b></td>";
		echo "<td>&nbsp;";
	    	$sysId = '330_99_99';
			$oidStr = "2.1.15";
			showParameter($sysId,$oidStr,1,1,0,'','','Update');
		echo "</td>";	
		echo "</tr>";
	}//end license
*/
//==========================================================
//输出Command
//========================================================== 
/*
echo "<tr><td bgcolor=\"#E6E6E6\" ><b>Command</b></td>";
echo "<td ><table width=100%><tr>";
echo "<td width=10%>HLR0</td>";
echo "<td width=10%><a onMouseover=\"return hidestatus()\" href='$PHP_SELF?advanced=$advanced'>Lock</a></td>";
echo "<td width=10%>HLR1</td>";
echo "<td><a onMouseover=\"return hidestatus()\" href='$PHP_SELF?advanced=$advanced'>Lock</a></td>";
echo "</tr></table></td></tr>";
*/
echo "<input type=\"hidden\" name=\"gtt_init\" value=\"$sccp_row[0]\">";
echo "<input type=\"hidden\" name=\"sup_init\" value=\"$sup_rwo[0]\">";


?>
<?php
{
	echo "<table width=\"100%\">";
	echo "<tr>";
		echo "<td width=\"70%\">";
			echo "&nbsp;&nbsp;";
		echo "</td>";
		echo "<td width=\"20%\" align=\"right\">";
				echo "<input type=\"submit\" title=\"$strTitleGet\" name=\"getSys\" value=\"$strGet\" class=\"button\" style=\"cursor:pointer; left: 1; top: 2; width: 60; height: 25; position: relative\">";
				echo "&nbsp;&nbsp;&nbsp;";
				echo "<input type=\"submit\" title=\"$strTitleSet\" name=\"setSys\" value=\"$strSet\" class=\"button\" style=\"cursor:pointer; left: 1; top: 2; width: 60; height: 25; position: relative\">";
			echo "</td>";
		echo "<td width=\"10%\">";
			echo "<p align=\"right\"><a href=\"../overview/overview.php?scroll_y=$page_top\"><img align=absBottom border=0 src=\"../../images/left.gif\" width=\"14\" height=\"14\">$strBack</a>";
		echo "</td>";
	echo "</tr>";
	echo "</table>";
}
echo "</form>";
?>
</body>
