<?php

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

//echo "page_top:$page_top<br>";
//$url_temp=$_SERVER["REQUEST_URI"];
//echo "This page URL:$url_temp<br>";
?>
<script LANGUAGE="JavaScript">       
function delFirm(No,flag,thisCheck)
{
	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
		window.location.href='<?php echo $PHP_SELF;?>?&delflag='+flag+'&delValue='+No;
}
function checkSrf(value)
{
	if(value=='')
		alert("This device's MSISDN(SCCP) is null, set it please!");
	return;
}
function openErr()
{
	alert('There is no more prefix to set!');
	return;
}
function openCos(level_4)
{
	level_4 += 1;
	var isShowSms=document.Set.isShowSms.value;
	var y = document.body.scrollTop;
	URL="./pps_cos.php?level_4=" + level_4+"&isShowSms="+isShowSms+"&sub_page_top="+y;
	
	window.location.href=URL;
}
function openSet(instanceNo,objIdStr,sysId,webname,setname,backurl)
{
	var tmpSetname;
	tmpSetname = setname;
	setname=escape(setname);
	webname=escape(webname);
	//backurl=escape(backurl);
	var add;
	y = document.body.scrollTop;
	backurl = backurl+'&scroll_y='+y;
	backurl=escape(backurl);
	
	var isShowSms=document.Set.isShowSms.value;
	
	
	URL="./paramconf.php?instanceNo="+instanceNo+"&objIdStr="+objIdStr+"&sysId="+sysId+"&webname="+webname+"&setname="+setname+"&backurl="+backurl+"&isShowSms="+isShowSms+"&sub_page_top="+y;	
	if(tmpSetname == 'Basic vmsSeg zone')
		URL="./vmsSeg.php?instanceNo="+instanceNo+"&backurl="+backurl+"&isShowSms="+isShowSms+"&sub_page_top="+y;	
	window.location.href=URL;
}
function openSetVmsSeg(instanceNo,objIdStr,sysId,webname,setname,backurl)
{
	setname=escape(setname);
	webname=escape(webname);
	//backurl=escape(backurl);
	var add;
	y = document.body.scrollTop;
	backurl = backurl+'&scroll_y='+y;
	backurl=escape(backurl);
	
	decodeURIComponent(setname);
	alert(setname);
	URL="./paramconf.php?instanceNo="+instanceNo+"&objIdStr="+objIdStr+"&sysId="+sysId+"&webname="+webname+"&setname="+setname+"&backurl="+backurl;	
	window.location.href=URL;
}
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;	
		if(param=='')
			URL += "scroll_y="+y;
		else 
			URL += "&scroll_y="+y;
	}
	window.location.href=URL;
}
function openSetPrefix(trunkgp,instanceNo,objIdStr,sysId,webname,setname,backurl)
{
	y = document.body.scrollTop;
	backurl = backurl+'&scroll_y='+y;
	backurl=escape(backurl);
	
	URL="./paramconf.php?instanceNo="+instanceNo+"&trunkgp="+trunkgp+"&objIdStr="+objIdStr+"&sysId="+sysId+"&webname="+webname+"&setname="+setname+"&backurl="+backurl+"&sub_page_top="+y;	
	window.location.href=URL;
}


//=======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
	function alert($msg)
	{
		echo "<script language=\"JavaScript\">\n";
		echo "alert('$msg')";
		echo "</script>\n";
	}
?>

<?php
//$smsFormatShow=isset($smsFormatShow) ? $smsFormatShow : 0;
//$smsFormatShow=0;
$scroll_y = isset($scroll_y) ? $scroll_y : 0;
echo "<body topmargin=\"0\" onLoad=\"self.scrollBy(0,$scroll_y);\" leftmargin=\"12\">";


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

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

$mtp3_sqlTable = 'OBJ_222.param_99';
$sqltable = 'OBJ_360.param_99';
$sqltable_conf = 'OBJ_360.paramConf';
$sqltable_sccp = 'OBJ_223.param_99';
$sysStatTable='OMC_PUB.sysStat';
$sysId = '360_99_99';
$net_paramTable		='OBJ_225.param_99';//xapp
$net_paramConf		='OBJ_225.paramConf';

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

$sysId_arr=array(
	array('oid'=>'2.1.1',		'sysid'=> '360_99_99',		'selectsysid'=>'-1'), 										
	array('oid'=>'2.1.2',		'sysid'=> '360_99_99',		'selectsysid'=>'-1'),
	array('oid'=>'2.1.3',		'sysid'=> '360_99_99',		'selectsysid'=>'-1'),
	array('oid'=>'2.1.5',		'sysid'=> '360_99_99',		'selectsysid'=>'-1'),
	
	array('oid'=>'2.1.19',		'sysid'=> '223_99_99',		'selectsysid'=>'-1'),
	array('oid'=>'2.1.147',		'sysid'=> '223_99_99',		'selectsysid'=>'-1'),
	array('oid'=>'2.1.153',		'sysid'=> '223_99_99',		'selectsysid'=>'-1'),
	
	array('oid'=>'2.8',			'sysid'=> '225_99_99',		'selectsysid'=>'-1'),
	
	array('oid'=>'2.2',			'sysid'=> '350_99_99',		'selectsysid'=>'-1'),

	array('oid'=>'2.1.1',		'sysid'=> '322_99_99',		'selectsysid'=>'-1'),
	array('oid'=>'2.1.2',		'sysid'=> '322_99_99',		'selectsysid'=>'-1'),
	array('oid'=>'2.1.3',		'sysid'=> '322_99_99',		'selectsysid'=>'-1'),
	array('oid'=>'2.1.4',		'sysid'=> '322_99_99',		'selectsysid'=>'-1'),
);

$SaveArr=array(
	array('oidstr'=>'2.1.6.2',	'setvalue'=>'01'	,'sysid'=>'360_99_99'),
	array('oidstr'=>'3.2',	'setvalue'=>'02'	,'sysid'=>'223_99_99'),		
	array('oidstr'=>'3.2',	'setvalue'=>'01'	,'sysid'=>'225_99_99'),		
	array('oidstr'=>'3.3',	'setvalue'=>'01'	,'sysid'=>'350_99_99'),		
);	

$url_add = './pps.php';

//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=\"./pps.php\";";
	} 
	else exit();
	echo "\n </script>";
}

if(isset($doingOtherFlag))
{
	if($setVmsRouting==1)
	{
		$callType=4;
		$trunkgp=252;
		$oldPrefix = $oldValue;
		$newPrefix = $newValue;
		updatePrefix($oldPrefix,$newPrefix,$callType,$trunkgp);
		
		{//set tg 252 enable
			$levelWhere = getLevelWhere("2.1.4");
			$updSql = "update OBJ_322.param_99 set initValue='000000000B0302FF0000000000' where $levelWhere and instanceNo=252";
			mysqli_query($pubConn, $updSql);
		}//end set tg 252 enable
		exit;
	}
	{//get 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'));
		
		$sysId = "223_99_99";
	}//end get system ip
	if($setEmse==1)
	{
		//emse
		$oidStr = "2.1.19";
		setParamValue($mss_ip[0],$sysId,$oidStr,3);
		setParamValue($mss_ip[1],$sysId,$oidStr,4);
		
		{//get service number
			$service_num_arr = array(
				array('Hotline','Hotline'),
				array('Inquiry','Inquiry'),
				array('Recharge via recharge card','recharge_card'),
				array('Recharge via credit card','recharge_credit'),
				array('Third party recharge','third_party'),
				array('Customer care center','care_center'),
				array('Recharge number','recharge_num'),
			);
			
			$objWhereStr = getLevelWhere('2.1.2.2');
			$getsql = "select initValue from $sqltable where $objWhereStr";
			$result = mysqli_query($pubConn,$getsql);
			echo mysqli_error($pubConn);
			
			$i=0;
			while($service_row = mysqli_fetch_array($result))
			{
				${$service_num_arr[$i][1]} = trim(toAscii($service_row[0]));
				$i++;
			}
			
			$serviceNumArr = array(${$service_num_arr[1][1]},${$service_num_arr[2][1]});
		}//end get service number
		{//update smsc udp smpp parameters.
			$gtt_emse = $newValue;
			$smscTable = "OBJ_350.param_99";
			$updDataArr = array(
				array('value' => 'PPS', 'level_3' => '1', 'len' => 32),//name
				array('value' => 'PPS', 'level_3' => '2', 'len' => 30),		//system id
				array('value' => '123456', 'level_3' => '3', 'len' => 16),	//password
				array('value' => $gtt_emse, 'level_3' => '6', 'len' => 18), //opposite sccp number
				array('value' => '03', 'level_3' => '14', 'len' => 2)		//link flag
			);
			for($j=0; $j< sizeof($serviceNumArr); $j++)
			{
				$updDataArr[5] = array('value' => $serviceNumArr[$j], 'level_3' => '4', 'len' => 16);			//service number
				$instNo = $j;
				for($i=0; $i< sizeof($updDataArr); $i++)
				{
					if($i==3 || $i==4 || $i==5)
						$setValue = omc_keep_length($updDataArr[$i][value],'E',$updDataArr[$i][len],0);
					else
						$setValue = omc_keep_length(toHex($updDataArr[$i][value]),'0',$updDataArr[$i][len],0);
					$updSql = "update $smscTable set initValue='$setValue' where level_1=2 and level_2=2 and level_3={$updDataArr[$i][level_3]} and instanceNo=$instNo";
					mysqli_query($pubConn,$updSql);
					if($DEBUG) echo "<br>$updSql<br>";
				}
			}
		}//end update smsc udp smpp parameters.
	}
	if($setScf==1)
	{
		//scf
		$oidStr = "2.1.147";
		setParamValue($mss_ip[0],$sysId,$oidStr,3);
		setParamValue($mss_ip[1],$sysId,$oidStr,4);
	}
	if($setScfMap==1)
	{
		//scf_map
		$oidStr = "2.1.153";
		setParamValue($mss_ip[0],$sysId,$oidStr,3);
		setParamValue($mss_ip[1],$sysId,$oidStr,4);
	}
	
	exit;
}
if($_SERVER['REQUEST_METHOD'] == "POST")
{
	for($i=0; $i < 2; $i++)
	{
		$tmp = ${'srf'.$i.'_save'};
		if(isset($tmp))
		{
			$oid = '2.1.2.1.'.($i+1);
			$initValue_0 = omc_keep_length(toHex(${'srf'.$i}),'0','32',0);
			$objWhereStr = getLevelWhere($oid);
			$setsql = "update $sqltable set initValue = '$initValue_0' where $objWhereStr";
			mysqli_query($pubConn,$setsql);
			echo mysqli_error($pubConn);
			if($DEBUG) echo "<br>$setsql<br>";	
		}
	}
	if(isset($setSys) || isset($getSys))
	{
		if(isset($setSys))
		{
			echo "<br>Setting parameters<br>";
				
			SetParam($sysId_arr);	
			session_register("SetFlag");
						
			$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=\"./pps.php?smsShow=$smsShow&srfShow=$srfShow&vmsShow=$vmsShow&scroll_y=$scroll_y\";";
	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 .= ')';
	//echotest
	//echo "instNoWhereStr:$instNoWhereStr<hr>";
	if($delflag == 'vmsSeg')
	{
		$objWhereStr = getLevelWhere('2.1.5.5');
		$getsql = "select initValue from $sqltable_conf where $objWhereStr";
		$result = mysqli_query($pubConn,$getsql);
		echo mysqli_error($pubConn);
		$vmsSegOrg = mysqli_fetch_array($result);
		$init = $vmsSegOrg[0];
		
		$objWhereStr = getLevelWhere('2.1.5.5');
		$setsql = "update $sqltable set initValue = '$init'	where $objWhereStr and $instNoWhereStr ";
			
		mysqli_query($pubConn,$setsql);
		echo mysqli_error($pubConn);
		if($DEBUG) echo "<br>$setsql<br>";
	}
	else if($delflag == 'tar')
	{
		$objWhereStr = getLevelWhere('2.1.1.10');
		$getsql = "select initValue from $sqltable_conf where $objWhereStr";
		$result = mysqli_query($pubConn,$getsql);
		echo mysqli_error($pubConn);
		$tariff_org = mysqli_fetch_array($result);
		$init = $tariff_org[0];
		
		$objWhereStr = getLevelWhere('2.1.1.10');
		$setsql = "update $sqltable set initValue = '$init'	where $objWhereStr and $instNoWhereStr ";
			
		mysqli_query($pubConn,$setsql);
		echo mysqli_error($pubConn);
		if($DEBUG) echo "<br>$setsql<br>";
	}
	else if($delflag == 'sms')
	{
		$objWhereStr = getLevelWhere('2.1.1.6');
		$getsql = "select initValue from $sqltable_conf where $objWhereStr";
		$result = mysqli_query($pubConn,$getsql);
		echo mysqli_error($pubConn);
		$tariff_org = mysqli_fetch_array($result);
		$init = $tariff_org[0];
		
		$objWhereStr = getLevelWhere('2.1.1.6');
		$setsql = "update $sqltable set initValue = '$init'	where $objWhereStr and instanceNo = '$delValue' ";
		mysqli_query($pubConn,$setsql);
		
		$objWhereStr = getLevelWhere('2.1.1.7');
		$getsql = "select initValue from $sqltable_conf where $objWhereStr";
		$result = mysqli_query($pubConn,$getsql);
		echo mysqli_error($pubConn);
		$tariff_org = mysqli_fetch_array($result);
		$init = $tariff_org[0];
		
		$objWhereStr = getLevelWhere('2.1.1.7');
		$setsql = "update $sqltable set initValue = '$init'	where $objWhereStr and instanceNo = '$delValue' ";
		mysqli_query($pubConn,$setsql);
	}
	else if($delflag == 'thirdPar')
	{
		$objWhereStr = getLevelWhere('2.1.1.9');
		$getsql = "select initValue from $sqltable_conf where $objWhereStr";
		$result = mysqli_query($pubConn,$getsql);
		echo mysqli_error($pubConn);
		$thirdPart_org = mysqli_fetch_array($result);
		$init = $thirdPart_org[0];
		
		$objWhereStr = getLevelWhere('2.1.1.9');
		$setsql = "update $sqltable set initValue = '$init'	where $objWhereStr and $instNoWhereStr ";
			
		mysqli_query($pubConn,$setsql);
		echo mysqli_error($pubConn);
		if($DEBUG) echo "<br>$setsql<br>";
	}
	else if($delflag == 'mnpPrefix')
	{
		$objWhereStr = getLevelWhere('2.1.1.12');
		$getsql = "select initValue from $sqltable_conf where $objWhereStr";
		$result = mysqli_query($pubConn,$getsql);
		echo mysqli_error($pubConn);
		$mnpPrefix_org = mysqli_fetch_array($result);
		$init = $mnpPrefix_org[0];
		
		$setsql = "update $sqltable set initValue = '$init'	where $objWhereStr and $instNoWhereStr ";
	
		mysqli_query($pubConn,$setsql);
		echo mysqli_error($pubConn);
		if($DEBUG) echo "<br>$setsql<br>";
	}
	else if($delflag == 'dailing'||$delflag=='srf')
	{
		$sysId = '322_99_99';
	
		$sysIdArr	= explode('_',$sysId);
		$sysTypeNo	= $sysIdArr[0];
		$sysNo		= $sysIdArr[1];
		$subSysNo	= $sysIdArr[2];
	
		$objDb		= 'OBJ_'.$sysTypeNo;
		$paramTable = 'param_'.$sysNo;
				
		$oidstr = '2.1.2';
		$objWhereStr= '';
		$objWhereStr =getLevelWhere($oidstr);		
		
		$defSql = " SELECT initValue FROM paramConf WHERE $objWhereStr";
		$defRes = @mysqli_query($pubConn,$defSql);
		$row = @mysqli_fetch_array($defRes);
		
		$flagoffset = "10.7-10.7";			
		$row[initValue] = setBitValue($row[initValue],$flagoffset,0);
	
		$delSql = "UPDATE $paramTable SET initValue = '$row[initValue]' 
	            WHERE subSysNo = '$subSysNo' AND $objWhereStr AND $instNoWhereStr";
		if($DEBUG) echo "<br>delSql=$delSql";
		$delRes = @mysqli_query($pubConn,$delSql);
		echo mysqli_error($pubConn);
	
		$oidstr = '2.1.1';
		$objWhereStr= '';
		$objWhereStr =getLevelWhere($oidstr);		
		
		$defSql = " SELECT initValue FROM paramConf WHERE $objWhereStr";
		$defRes = @mysqli_query($pubConn,$defSql);
		$row = @mysqli_fetch_array($defRes);
		
		$delSql = "UPDATE $paramTable SET initValue = '$row[initValue]' 
	            WHERE subSysNo = '$subSysNo' AND $objWhereStr AND $instNoWhereStr";
		if($DEBUG) echo "<br>delSql=$delSql";
		$delRes = @mysqli_query($pubConn,$delSql);
		echo mysqli_error($pubConn);
		
		$oidstr = '2.1.3';
		$objWhereStr= '';
		$objWhereStr =getLevelWhere($oidstr);		
		
		$defSql = " SELECT initValue FROM paramConf WHERE $objWhereStr";
		$defRes = @mysqli_query($pubConn,$defSql);
		$row = @mysqli_fetch_array($defRes);
		
		$delSql = "UPDATE $paramTable SET initValue = '$row[initValue]' 
	            WHERE subSysNo = '$subSysNo' AND $objWhereStr AND $instNoWhereStr";
		if($DEBUG) echo "<br>delSql=$delSql";
		$delRes = @mysqli_query($pubConn,$delSql);
		echo mysqli_error($pubConn);	
	}
	else if($delflag == 'conv'||$delflag=='conv_srf')	//conv prefix
	{
		//=====get the default value =======================
		$database="OBJ_225";
		$sql="select initValue from paramConf where level_1=2 and level_2=8 ";
		$result=@mysqli_query($pubConn,$sql);
		$rows=@mysqli_fetch_array($result);
		$conv_default=$rows[initValue];
		//=========================
		$objWhereStr = getLevelWhere('2.8.0');	
		$setsql = "update $net_paramTable set initValue = '$conv_default' where $objWhereStr and $instNoWhereStr";		
		mysqli_query($pubConn,$setsql);
		echo mysqli_error($pubConn);
		if($DEBUG) echo "<br>$setsql<br>";
	}
}
									
//==========================================================
//输出并显示数据
//========================================================== 
echo "<form method=\"POST\" name=\"Set\" action=\"$PHP_SELF?smsShow=$smsShow&srfShow=$srfShow&vmsShow=$vmsShow&scroll_y=$scroll_y\">";
{//show header part
	//echo "<input type=hidden name=smsFormatShow value=$smsFormatShow>";
	echo "<table border=\"0\" width=\"100%\">";
	echo "<tr>";
	echo "<td width=\"50%\">";
	
	echo "Configuration > <a href=\"../overview/overview.php\">Network</a> > <a href=\"#\">PPS</a>";
	echo "<td width=\"50%\" align=\"right\" title=\"Help\">";
	$helpID = '2.1.1.6';
	showHelp($helpID);
	echo "</td>";
	echo "</tr>";
	echo "</table>";
	
{
	echo "<table width=\"100%\">";
	echo "<tr>";
		echo "<td width=\"70%\">";
			echo "<b>&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>";
}
}//end show header part

if(!isset($smsShow)&&!isset($srfShow)&&!isset($vmsShow))
	$smsShow=1;
if($smsShow==1)
{
	$bcSMS = '#E6E6E6';
	$smsShowStr = '';
}
else
{
	$bcSMS = '';
	$smsShowStr = 'none';
}
if($srfShow==1)
{
	$srfShowStr = '';
	$bcSRF = '#E6E6E6';
}
else
{
	$bcSRF = '';
	$srfShowStr = 'none';
}

if($vmsShow==1)
{
	$vmsShowStr = '';
	$bcVMS = '#E6E6E6';
}
else
{
	$bcVMS = '';
	$vmsShowStr = 'none';
}

$backurl = "./pps.php?smsShow=$smsShow&srfShow=$srfShow&vmsShow=$vmsShow";

echo "<table width=\"36%\">";
	echo "<tr>";
		echo "<td align=\"center\" bgcolor=\"$bcSMS\" width=\"12%\">";
			echo "<a href=\"./pps.php?scroll_y=$scroll_y&smsShow=1\"><b>PPS Service</b></a>";
		echo "</td>";
		echo "<td align=\"center\" bgcolor=\"$bcSRF\" width=\"12%\">";
			echo "<a href=\"./pps.php?scroll_y=$scroll_y&srfShow=1\"><b>SRF Service</b></a>";
		echo "</td>";
		echo "<td align=\"center\" bgcolor=\"$bcVMS\" width=\"12%\">";
			echo "<a href=\"./pps.php?scroll_y=$scroll_y&vmsShow=1\"><b>VMS Routing</b></a>";
		echo "</td>";
	echo "</tr>";
echo "</table>";

{// pps service.
echo "<TABLE  style=\"DISPLAY: $smsShowStr\" width=\"100%\"   border=\"1\"  cellpadding=\"1\" cellspacing=\"0\"  bordercolor=\"#666666\" bordercolordark=\"#FFFFFF\" bgcolor=\"#FFFFFF\">";
echo "<tr><th colspan=2><b>PPS Service</b></th></tr>";
{//signaling point
	$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')
	);
		
	$querysql = "select initValue from $mtp3_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]}<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 ++)
	{
		$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 $mtp3_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]);
		if($DEBUG)echo "getsql = $getsql<br>";
		if($DEBUG)echo "spc_$i=$row[$i]<br>";
	}
}

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;$row[$i]</td>";
echo "</tr></table></td>";
echo "</tr>";

//==========================================================
//输出Global Title
//========================================================== 
{//start emse

	echo "<tr>";
	echo "<td bgcolor=\"#E6E6E6\" ><b>$strE164Number(EMSE)</b></td><td><table width=100%>";
	$sysId = "223_99_99";
	$oidStr = "2.1.19";
	$instanceNo=0;
	echo "<td align=\"left\" width=50% >";
	$doingOtherUlr="$PHP_SELF?doingOtherFlag=1&setEmse=1";
		showParameter($sysId,$oidStr,2,1,$instanceNo,$doingOtherUlr);
	echo "</td>";
	echo "<td align=\"left\" width=50% >";
		showParameter($sysId,$oidStr,1,1);
	echo "</td>";
	echo "</table></td></tr>";
}//end emse
{//start scf
	$oidStr = "2.1.147";
	echo "<tr>";
	echo "<td bgcolor=\"#E6E6E6\" ><b>$strE164Number(SCF-CAP)</b></td>";
	echo "<td><table width=100%><tr>";
		echo "<td align=\"left\" width=50%>";
		$doingOtherUlr="$PHP_SELF?doingOtherFlag=1&setScf=1";
			showParameter($sysId,$oidStr,2,1,$instanceNo,$doingOtherUlr);
		echo "</td>";
		
		echo "<td align=\"left\" width=50% >";
			showParameter($sysId,$oidStr,1,1);
		echo "</td>";
	echo "</tr></table></td></tr>";
}//end scf	
{//start scf_map
	$oidStr = "2.1.153";
	$instanceNo=0;
	echo "<tr>";
	echo "<td bgcolor=\"#E6E6E6\" ><b>$strE164Number(SCF-MAP)</b></td>";
	echo "<td><table width=100%><tr>";
		echo "<td align=\"left\" width=50%>";
		$doingOtherUlr="$PHP_SELF?doingOtherFlag=1&setScfMap=1";
			showParameter($sysId,$oidStr,2,1,$instanceNo,$doingOtherUlr);
		echo "</td>";
		
		echo "<td align=\"left\" width=50% >";
			showParameter($sysId,$oidStr,1,1);
		echo "</td>";
	echo "</tr></table></td></tr>";
	echo "<tr >" ;
}//end scf_map	

	echo "<input type=\"hidden\" name=\"emse_init\" value=\"$emse_row[0]\">";
	echo "<input type=\"hidden\" name=\"scf_init\" value=\"$scf_row[0]\">";
	echo "<input type=\"hidden\" name=\"scf_map_init\" value=\"$scf_map_row[0]\">";

$sysId = "360_99_99";
//==========================================================
//输出CDR
//==========================================================
{
	echo "<tr>";
	echo "<td bgcolor = \"#E6E6E6\">";
	echo "<b>CDR flag</b></td>";
	$oidStr = '2.1.1.1';
	echo "<td>&nbsp;";
	showParameter($sysId,$oidStr,1,1);
	echo "</td>";
	echo "</tr>";
}

//==========================================================
//输出Maximum balance
//==========================================================
{
	echo "<tr>";
	echo "<td bgcolor = \"#E6E6E6\">";
	echo "<b>Maximum balance</b></td>";
	$oidStr = '2.1.1.3';
	echo "<td>&nbsp;";
	showParameter($sysId,$oidStr,1,1);
	echo "</td>";
	echo "</tr>";
}
//==========================================================
//输出Blacklist threshold
//==========================================================
{
	echo "<tr>";
	echo "<td bgcolor = \"#E6E6E6\">";
	echo "<b>Blacklist threshold</b></td>";
	$oidStr = '2.1.1.2';
	echo "<td>&nbsp;";
	showParameter($sysId,$oidStr,1,1);
	echo "</td>";
	echo "</tr>";
}
//==========================================================
//输出Currency symbol
//==========================================================
{
	echo "<tr>";
	echo "<td bgcolor = \"#E6E6E6\">";
	echo "<b>Currency symbol</b></td>";
	$oidStr = '2.1.1.8';
	echo "<td>&nbsp;";
	showParameter($sysId,$oidStr,1,3);
	echo "</td>";
	echo "</tr>";
}
//==========================================================
//输出Prompt resolution
//==========================================================
{
	echo "<tr >";
	echo "<td bgcolor = \"#E6E6E6\"><b>Prompt resolution</b></td>";	
	echo "<td><table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" >";
	echo "<tr bgcolor = \"#E6E6E6\">";
	echo "<td width=30%>Currency resolution<td>";
	echo "<td width=30%>Date format<td>";
	echo "<td width=40%>Currency symbol position<td>";
	echo "</tr>";
	
	echo "<tr>";
	$oidStr="2.1.1.5";
	echo "<td width=30%>";
		showParameter($sysId, $oidStr,1,1);
	echo "<td>";
	echo "<td width=30%>";
		showParameter($sysId, $oidStr,2,1);
	echo "<td>";
	echo "<td width=30%>";
		showParameter($sysId, $oidStr,3,1);
	echo "<td>";
	echo "</tr>";
	echo "</table></td>";
	echo "</tr>";
}
//==========================================================
//输出Third party info.
//==========================================================
{
	$objWhereStr = getLevelWhere('2.1.1.9');
	$getsql = "select initValue from $sqltable_conf where $objWhereStr";
	$result = mysqli_query($pubConn,$getsql);
	echo mysqli_error($pubConn);
	$thirdPart_org = mysqli_fetch_array($result);
	$thirdPart_org = $thirdPart_org[0];
	if($DEBUG) echo "thirdPart_org = $thirdPart_org<br>";
	
	$objWhereStr = getLevelWhere('2.1.1.9');
	$getsql = "select initValue from $sqltable where $objWhereStr";
	$result = mysqli_query($pubConn,$getsql);
	echo mysqli_error($pubConn);
	
	$i = 0;
	$thirdPart_num = 0;
	while($thirdPart_row = mysqli_fetch_array($result))
	{
		$thirdPart_row = $thirdPart_row[0];
		if($thirdPart_row != $thirdPart_org)
		{
			$serverID[$thirdPart_num] = trim(toAscii(getBitValue($thirdPart_row,'00.0-07.7')));
			$serverPWD[$thirdPart_num] = trim(toAscii(getBitValue($thirdPart_row,'08.0-15.7')));
			$thirdPar_ins[$thirdPart_num]=$i;
			if($DEBUG)
			{
				echo "<br>serverID = $serverID[$thirdPart_num]<br>";
				echo "serverPWD = $serverPWD[$thirdPart_num]<br>";				
			}
			$thirdPart_num++;
		}
		else if(!isset($thirdPar_ins_unused))
		{
			$thirdPar_ins_unused = $i;
		}
		$i++;
	}
	
	if($thirdPart_num == 0) $nrow = $thirdPart_num + 2;
	else $nrow = $thirdPart_num + 1;
	$objIdStr = "no-2.1.1.9";
	$webname = "PPS";
	$setname = "Third party info";
	echo "<tr>";
	echo "<td bgcolor = \"#E6E6E6\"><table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\"><tr>";
	echo "<td><b>Third party info</b></td>";
	//alert($thirdPart_num);
	if($thirdPart_num>=8)
		echo "<td>&nbsp</td>";
	else	
		echo "<td align=right><a href=\"javascript:openSet('$thirdPar_ins_unused','$objIdStr','$sysId','$webname','$setname','$backurl')\"><font size=4>+</font></a></td>";
	echo "</tr></table></td>";
	
	if($thirdPart_num == 0)
		echo "<td>--</td>";
	else
	{
		echo "<td>";
		echo "<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" >";
		$flag = 'thirdPar';
		echo "<tr bgcolor = \"#E6E6E6\">";
		echo "<td width=10%>No.<td>";
		echo "<td width=40%>Service ID<td>";
		echo "<td width=40%>Service password<td>";
		/*echo "<td align=right width=10%>Delete<td>";*/
		echo "<td width=\"20%\" align=right><a href=\"javascript:delSelected('Set','$flag',0,$thirdPart_num)\" 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,$thirdPart_num)>";
		echo "</td>";
		echo "</tr>";
		for($i=0; $i < $thirdPart_num; $i++)
		{
			$inst = $thirdPar_ins[$i];
			$checkBoxName=$flag . 'checkBox_'.$i;
			$deleteNo = $flag . 'deleteno_'.$i;
			if($i>3)
				echo "<tr id='thirdPar$i' style=\"display:none\" onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";
			else
				echo "<tr id='thirdPar$i' onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";
			
			//echo "<tr>";
			echo "<td width=10%><a href=\"javascript:openSet('$inst','$objIdStr','$sysId','$webname','$setname','$backurl')\">$i</a><td>";
			echo "<td width=40%>$serverID[$i]<td>";
			echo "<td width=40%>$serverPWD[$i]<td>";
			/*echo "<td align=right width=10%><input type=\"checkbox\" name=\"$thirdPar_del_$i\" value=\"ON\" 
					onClick=\"javascript:delFirm('$thirdPar_ins[$i]','thirdPar',this)\" ><td>";*/
			echo "<td align=right><input type=\"checkbox\" name=\"$checkBoxName\" value=\"0\" onClick=\"javascript:selectToDel(this)\"></td>";
			echo "<input type=\"hidden\" name=\"$deleteNo\" value=\"$inst\"";
			echo "</tr>";
		}
		//===more button===
		if($thirdPart_num>4)
		{
			echo "<tr id='showthirdPar' style=\"display:block\"><td><a href=\"javascript:clickOnMoreHide('thirdPar',$thirdPart_num,'show')\">More >></a></td></tr>"; 
			echo "<tr id='hidethirdPar' style=\"display:none\"><td><a href=\"javascript:clickOnMoreHide('thirdPar',$thirdPart_num,'hide')\">Hide >></a></td></tr>"; 
		}
		echo "</table></td>";
	}
	echo "</tr>";
}
//==========================================================
//输出Basic tariff zone
//==========================================================
{
	$objWhereStr = getLevelWhere('2.1.1.10');
	$getsql = "select initValue from $sqltable_conf where $objWhereStr";
	$result = mysqli_query($pubConn,$getsql);
	echo mysqli_error($pubConn);
	$tariff_org = mysqli_fetch_array($result);
	$tariff_org = $tariff_org[0];
	if($DEBUG) echo "tariff_org = $tariff_org<br>";
	
	$objWhereStr = getLevelWhere('2.1.1.10');
	$getsql = "select initValue from $sqltable where $objWhereStr";
	$result = mysqli_query($pubConn,$getsql);
	echo mysqli_error($pubConn);
	
	$i = 0;
	$tariff_num = 0;
	while($tariff_row = mysqli_fetch_array($result))
	{
		$tariff_row = $tariff_row[0];
		if($tariff_row != $tariff_org)
		{
			$mcc[$tariff_num] = getBitValue($tariff_row,'00.0-01.7');
			$mnc[$tariff_num] = getBitValue($tariff_row,'02.0-02.7');
			$lac[$tariff_num] = hexdec(getBitValue($tariff_row,'03.0-04.7'));
			$cell_id[$tariff_num] = hexdec(getBitValue($tariff_row,'05.0-06.7'));
			$mo_tar[$tariff_num] = hexdec(getBitValue($tariff_row,'07.0-07.7'));
			$mt_tar[$tariff_num] = hexdec(getBitValue($tariff_row,'08.0-08.7'));
			$tar_ins[$tariff_num] = $i;
			if($DEBUG)
			{
				echo "<br>mcc = $mcc[$tariff_num]<br>";
				echo "mnc = $mnc[$tariff_num]<br>";
				echo "lac = $lac[$tariff_num]<br>";
				echo "cell_id = $cell_id[$tariff_num]<br>";
				echo "mo_tar = $mo_tar[$tariff_num]<br>";
				echo "mt_tar = $mt_tar[$tariff_num]<br>";
			}
			$tariff_num++;
		}
		else if(!isset($tar_ins_unused))
		{
			$tar_ins_unused = $i;
		}
		$i++;
	}
	
	if($tariff_num == 0) $nrow = $tariff_num + 2;
	else $nrow = $tariff_num + 1;
	
	$objIdStr = "no-2.1.1.10";
	$webname = "PPS";
	$setname = "Basic tariff zone";
	
	echo "<tr>";
	echo "<td bgcolor = \"#E6E6E6\"><table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\"><tr>";
	echo "<td><b>Basic tariff zone</b></td>";
	
	echo "<td align=right><a href=\"javascript:openSet('$tar_ins_unused','$objIdStr','$sysId','$webname','$setname','$backurl')\"><font size=4>+</font></a></td>";
	echo "</tr></table></td>";
	
	if($tariff_num == 0)
		echo "<td>--</td>";
	else
	{
		echo "<td>";
		echo "<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" >";
		echo "<tr bgcolor = \"#E6E6E6\">";
		$flag='tar';
		echo "<td width=10%>No.<td>";
		echo "<td width=12%>MCC<td>";
		echo "<td width=12%>MNC<td>";
		echo "<td width=12%>LAC<td>";
		echo "<td width=12%>Cell ID<td>";
		echo "<td width=12%>MO tariff<td>";
		echo "<td width=12%>MT tariff<td>";
		/*echo "<td align=right width=18%>Delete<td>";*/
		echo "<td width=\"20%\" align=right><a href=\"javascript:delSelected('Set','$flag',0,$tariff_num)\" 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,$tariff_num)>";
		echo "</td>";
		echo "</tr>";
		for($i=0; $i < $tariff_num; $i++)
		{
			$inst = $tar_ins[$i];
			$checkBoxName=$flag . 'checkBox_'.$i;
			$deleteNo = $flag . 'deleteno_'.$i;
			
			if($i>3)
				echo "<tr id='tar$i' style=\"display:none\" onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";
			else
				echo "<tr id='tar$i' onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";			  
			
		
			
			
			echo "<td width=10%><a href=\"javascript:openSet('$inst','$objIdStr','$sysId','$webname','$setname','$backurl')\">$i</a><td>";
			echo "<td width=12%>$mcc[$i]<td>";
			echo "<td width=12%>$mnc[$i]<td>";
			echo "<td width=12%>$lac[$i]<td>";
			echo "<td width=12%>$cell_id[$i]<td>";
			echo "<td width=12%>$mo_tar[$i]<td>";
			echo "<td width=12%>$mt_tar[$i]<td>";
			/*echo "<td align=right width=18%><input type=\"checkbox\" name=\"$tar_del_$i\" value=\"ON\" 
					onClick=\"javascript:delFirm('$tar_ins[$i]','tar',this)\" ><td>";*/
			echo "<td align=right><input type=\"checkbox\" name=\"$checkBoxName\" value=\"0\" onClick=\"javascript:selectToDel(this)\"></td>";
			echo "<input type=\"hidden\" name=\"$deleteNo\" value=\"$inst\"";
			echo "</tr>";
		}
		//====more button====
		if($tariff_num>4)
		{
			echo "<tr id='showtar' style=\"display:block\"><td><a href=\"javascript:clickOnMoreHide('tar',$tariff_num,'show')\">More >></a></td></tr>"; 
			echo "<tr id='hidetar' style=\"display:none\"><td><a href=\"javascript:clickOnMoreHide('tar',$tariff_num,'hide')\">Hide >></a></td></tr>"; 
		}
		echo "</table></td>";
	}
	echo "</tr>";
}


//==========================================================
//输出Support MNP
//========================================================== 
{
	echo "<tr>";
	echo "<td bgcolor = \"#E6E6E6\"><b>Support MNP</b></td>";
	$sysId = "360_99_99";
	$oidStr = '2.1.1.11';
	echo "<td>&nbsp;";
	showParameter($sysId,$oidStr,1,1);
	echo "</td>";
	echo "</tr>";
}

//==========================================================
//输出MNP Prefix.
//==========================================================
{
	$objWhereStr = getLevelWhere('2.1.1.12');
	$getsql = "select initValue from $sqltable_conf where $objWhereStr";
	$result = mysqli_query($pubConn,$getsql);
	echo mysqli_error($pubConn);
	$mnpPrefix_org = mysqli_fetch_array($result);
	$mnpPrefix_org = $mnpPrefix_org[0];
	if($DEBUG) echo "mnpPrefix_org = $mnpPrefix_org<br>";
	
	$getsql = "select initValue from $sqltable where $objWhereStr";
	$result = mysqli_query($pubConn,$getsql);
	echo mysqli_error($pubConn);
	
	$i = 0;
	$mnpPrefix_num = 0;
	while($mnpPrefix_row = mysqli_fetch_array($result))
	{
		$mnpPrefix_row = $mnpPrefix_row[0];
		if($mnpPrefix_row != $mnpPrefix_org)
		{
			$mnpPrefix[$mnpPrefix_num] = trim(toAscii(getBitValue($mnpPrefix_row,'00.0-15.7')));
			$mnpPrefix_ins[$mnpPrefix_num]=$i;
			if($DEBUG)
			{
				echo "<br>mnpPrefix = $mnpPrefix[$mnpPrefix_num]<br>";			
			}
			$mnpPrefix_num++;
		}
		else if(!isset($mnpPrefix_ins_unused))
		{
			$mnpPrefix_ins_unused = $i;
		}
		$i++;
	}
	
	if($mnpPrefix_num == 0) 
		$nrow = $mnpPrefix_num + 2;
	else 
		$nrow = $mnpPrefix_num + 1;
	$objIdStr = "no-2.1.1.12";
	$webname = "PPS";
	$setname = "MNP Prefix";
	echo "<tr>";
	echo "<td bgcolor = \"#E6E6E6\"><table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\"><tr>";
	echo "<td><b>MNP prefix</b></td>";
	echo "<td align=right><a href=\"javascript:openSet('$mnpPrefix_ins_unused','$objIdStr','$sysId','$webname','$setname','$backurl')\"><font size=4>+</font></a></td>";
	echo "</tr></table></td>";
	
	if($mnpPrefix_num == 0)
		echo "<td>--</td>";
	else
	{
		echo "<td>";
		echo "<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" >";
		$flag = 'mnpPrefix';
		echo "<tr bgcolor = \"#E6E6E6\">";
		echo "<td width=10%>No.<td>";
		echo "<td width=40%>MNP prefix<td>";
		echo "<td width=30%>&nbsp;<td>";
	
		echo "<td width=\"20%\" align=right><a href=\"javascript:delSelected('Set','$flag',0,$mnpPrefix_num)\" 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,$mnpPrefix_num)>";
		echo "</td>";
		echo "</tr>";
		for($i=0; $i < $mnpPrefix_num; $i++)
		{
			$inst = $mnpPrefix_ins[$i];
			$checkBoxName=$flag . 'checkBox_'.$i;
			$deleteNo = $flag . 'deleteno_'.$i;
			echo "<tr>";
			echo "<td width=10%><a href=\"javascript:openSet('$inst','$objIdStr','$sysId','$webname','$setname','$backurl')\">$i</a><td>";
			echo "<td width=40%>$mnpPrefix[$i]<td>";
			echo "<td width=30%>&nbsp;<td>";
			echo "<td align=right><input type=\"checkbox\" name=\"$checkBoxName\" value=\"0\" onClick=\"javascript:selectToDel(this)\"></td>";
			echo "<input type=\"hidden\" name=\"$deleteNo\" value=\"$inst\"";
			echo "</tr>";
		}
		echo "</table></td>";
	}
	echo "</tr>";
}
	
/*
//==========================================================
//输出License
//========================================================== 
{
	echo "<tr>";
	echo "<td bgcolor = \"#E6E6E6\"><b>License control</b></td>";
	$sysId = "360_99_99";
	$oidStr = '2.1.1.4';
	echo "<td>&nbsp;";
	showParameter($sysId,$oidStr,1,1,0,'','','Update');
	echo "</td>";
	echo "</tr>";
}
*/
//==========================================================
//输出COS
//==========================================================
{
	echo "<tr>";
	echo "<td bgcolor = \"#E6E6E6\">";
	echo "<b>COS parameters</b></td>";
	echo "<td>";
		echo "<table>";
		echo "<tr>";
			for($i=0; $i<16; $i++)
			{
				echo "<td>&nbsp;&nbsp;";
				echo "<a href=javascript:openCos($i)>&nbsp;$i&nbsp;</a>";
				echo "&nbsp;&nbsp;</td>";
			}
		echo "</tr>";
		echo "</table>";
	echo "</td>";
	echo "</tr>";
}
if($smsFormatShow==1)
{
	$showStr = '';
	$cmdShowStr = "none";
}
else
{
	$showStr = "none";
	$cmdShowStr = '';
}
echo "<tr style=\"DISPLAY: $cmdShowStr\">";
	echo "<td>&nbsp;</td>";
	echo "<td align=\"right\"><a href=\"./pps.php?scroll_y=$scroll_y&smsShow=$smsShow&smsFormatShow=1\"><b>More >><b></a></td>";
echo "</tr>";

//==========================================================
//输出SMS format
//==========================================================
{
	$smEncodeTypeArr = array(0 => '7 bit', 4 => 'Octet', 8 => 'Unicode');
	$objWhereStr = getLevelWhere('2.1.1.6');
	$defSql = "select initValue from $sqltable_conf where $objWhereStr";
	$defRes = mysqli_query($pubConn,$defSql);
	$defRow = mysqli_fetch_array($defRes);
	$smsDefValue = $defRow[initValue];
	
	$getsql = "select initValue from $sqltable where $objWhereStr";
	$result = mysqli_query($pubConn,$getsql);
	echo mysqli_error($pubConn);
	
	$i = 0;
	$sms_num = 0;
	while($sms_row = mysqli_fetch_array($result))
	{
		$sms_row = strtoupper($sms_row[0]);
		$enable_flag = getBitValue($sms_row,'0.4-0.7');
//		if($sms_row != $smsDefValue)
//		{
			$encode[$sms_num] = hexdec(getBitValue($sms_row,'00.0-00.7'));
			$acc_balance[$sms_num] = trim(toAscii(getBitValue($sms_row,'01.0-31.7')));
			$expire[$sms_num] = trim(toAscii(getBitValue($sms_row,'32.0-63.7')));
			$recharge[$sms_num] = trim(toAscii(getBitValue($sms_row,'64.0-111.7')));
			
			if($DEBUG)
			{
				echo "<br>encode[$sms_num] = $encode[$sms_num]<br>";
				echo "acc_balance[$sms_num] = $acc_balance[$sms_num]<br>";
				echo "expire[$sms_num] = $expire[$sms_num]<br>";
				echo "recharge[$sms_num] = $recharge[$sms_num]<br>";
			}
			
			$objWhereStr = getLevelWhere('2.1.1.7');
			$getsql = "select initValue from $sqltable where $objWhereStr and instanceNo=$i";
			$lc_result = mysqli_query($pubConn,$getsql);
			echo mysqli_error($pubConn);
			$last_call_row = mysqli_fetch_array($lc_result);
			$last_call_row = $last_call_row[0];
			
			$last_sent[$sms_num] = trim(toAscii(getBitValue($last_call_row,'00.0-31.7')));
			$to[$sms_num] = trim(toAscii(getBitValue($last_call_row,'72.0-79.7')));
			$recv_on[$sms_num] = trim(toAscii(getBitValue($last_call_row,'32.0-63.7')));
			$from[$sms_num] = trim(toAscii(getBitValue($last_call_row,'80.0-87.7')));
			$at[$sms_num] = trim(toAscii(getBitValue($last_call_row,'64.0-71.7')));
			
			if($DEBUG)
			{
				echo "<br>last_sent[$sms_num] = $last_sent[$sms_num]<br>";
				echo "to[$sms_num] = $to[$sms_num]<br>";
				echo "recv_on[$sms_num] = $recv_on[$sms_num]<br>";
				echo "from[$sms_num] = $from[$sms_num]<br>";
				echo "at[$sms_num] = $at[$sms_num]<br>";
			}
			
			$sms_ins[$sms_num] = $i;
			$sms_num++;
//		}
//		if(!isset($tar_ins_unused))
//		{
//			$sms_ins_unused = $i;
//		}
		$i++;
	}
	
	$nrow = ($sms_num + 1) * 2;
	
	echo "<tr style=\"DISPLAY: $showStr\">";
	echo "<td bgcolor = \"#E6E6E6\"><table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\"><tr>";
	echo "<td><b>SMS format</b></td>";
//	echo "<td align=right><a href='./paramconf.php?instanceNo=$sms_ins_unused&objIdStr=no-2.1.1.6
//			&sysId=$sysId&webname=format&setname=SMS format&backurl=./pps.php'>+</a></td>";
	echo "</tr></table></td>";
	
	echo "<td>";//start
	echo "<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" >";
	echo"<tr bgcolor = \"#E6E6E6\">";
	echo "<td width=10%>Language<td>";
	echo "<td width=15%>SM encoding<td>";
	echo "<td width=30%>Account balance<td>";
	echo "<td width=15%>Expire in<td>";
	echo "<td width=30%>Recharge in time<td>";
	echo "</tr>";
	
	$objIdStr = "no-2.1.1.6";
	$webname = "PPS";
	$setname = "SMS format";
	for($i=0; $i < $sms_num; $i++)
	{
		$inst = $sms_ins[$i];		
		echo "<tr onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";
		echo "<td width=10%><a href=\"javascript:openSet('$inst','$objIdStr','$sysId','$webname','$setname','$backurl')\">{$sms_ins[$i]}</a><td>";
		echo "<td width=15%>{$smEncodeTypeArr[$encode[$i]]}<td>";
		echo "<td width=30%>$acc_balance[$i]<td>";
		echo "<td width=15%>$expire[$i]<td>";
		echo "<td width=30%>$recharge[$i]<td>";
		echo "</tr>";
	}
	echo "</table>";
	echo "<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" >";
	echo "<tr bgcolor = \"#E6E6E6\">";
	echo "<td width=10%>Language<td>";
	echo "<td width=25%>Last call sent on<td>";
	echo "<td width=15%>To<td>";
	echo "<td width=25%>Received on<td>";
	echo "<td width=15%>From<td>";
	echo "<td width=10%>At<td>";
//	echo "<td width=10% align=right>Delete<td>";
	echo "</tr>";
	
	$objIdStr = "no-2.1.1.7";
	$webname = "PPS";
	$setname = "SMS format";
	for($i=0; $i < $sms_num; $i++)
	{
		$inst = $sms_ins[$i];
		echo "<tr onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";
		echo "<td width=10%><a href=\"javascript:openSet('$inst','$objIdStr','$sysId','$webname','$setname','$backurl')\">{$sms_ins[$i]}</a><td>";
		echo "<td width=25%>$last_sent[$i]<td>";
		echo "<td width=15%>$to[$i]<td>";
		echo "<td width=25%>$recv_on[$i]<td>";
		echo "<td width=15%>$from[$i]<td>";
		echo "<td width=10%>$at[$i]<td>";
//		echo "<td width=10% align=right><input type=\"checkbox\" name=\"$sms_del_$i\" value=\"ON\" 
//				onClick=\"javascript:delFirm('$sms_ins[$i]','sms',this)\" ><td>";
		echo "</tr>";
	}
	echo "</table>";
	
	echo "</td>";//end
}
echo "<tr style=\"DISPLAY: $showStr\">";
	echo "<td>&nbsp;</td>";
	echo "<td align=\"right\"><a href=\"./pps.php?scroll_y=$scroll_y&&smsShow=$smsShow&smsFormatShow=0\"><b>Hide <<</b></a></td>";
echo "</tr>";

echo "<input type=\"hidden\" name=\"smsShow\" value=\"$smsShow\"";
echo "<input type=\"hidden\" name=\"srfShow\" value=\"$srfShow\"";
echo "<input type=\"hidden\" name=\"vmsShow\" value=\"$vmsShow\"";
echo "<input type=\"hidden\" name=\"smsFormatShow\" value=\"$smsFormatShow\"";

echo "</table>";
}//end pps service.

{//srf service.
echo "<TABLE  style=\"DISPLAY: $srfShowStr\" width=\"100%\"   border=\"1\"  cellpadding=\"1\" cellspacing=\"0\"  bordercolor=\"#666666\" bordercolordark=\"#FFFFFF\" bgcolor=\"#FFFFFF\">";
echo "<tr><th colspan=2><b>SRF Service</b></th></tr>";

//==========================================================
//输出SRF MSISDN
//==========================================================
{
	$objWhereStr = getLevelWhere('2.1.2.1.1');
	$getsql = "select initValue from $sqltable where $objWhereStr";
	if($DEBUG) 
		echo "<br>getsql = $getsql<br>";
	$result = mysqli_query($pubConn,$getsql);
	echo mysqli_error($pubConn);
	$srf0_row = mysqli_fetch_array($result);
	if($srf0_row[0] == 0)
		$srf0 = '--';
	else
		$srf0 = (toAscii($srf0_row[0]));
	
	$objWhereStr = getLevelWhere('2.1.2.1.2');
	$getsql = "select initValue from $sqltable where $objWhereStr";
	$result = mysqli_query($pubConn,$getsql);
	if($DEBUG) echo "<br>getsql = $getsql<br>";
	echo mysqli_error($pubConn);
	$srf1_row = mysqli_fetch_array($result);
	if($srf1_row[0] == 0)
		$srf1 = '--';
	else
		$srf1 = trim(toAscii($srf1_row[0]));
	
	if($DEBUG) echo "<br>srf0 = $srf0<br>";
	if($DEBUG) echo "srf1_row = $srf1_row[0]<br>";

	echo "<tr>";
	echo "<td width=\"15%\" rowspan='2' bgcolor = \"#E6E6E6\"><b>SRF MSISDN</b></td>";
	echo "<td width=\"85%\"><table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" ><tr>";
	echo "<td width=30%>SRF0<td>";
	if(isset($srf0_edit))
	{
 		echo "<td align=\"left\" width=\"70%\">";
		echo "<select name = \"srf0\">";
		for($i=0; $i<sizeof($vssArr); $i++)
		{
			if($i==sizeof($vssArr)-1)
				$showName = $vssArr[$i][name];
			else	
				$showName = "{$vssArr[$i][name]}({$vssArr[$i][srf]})";
				
			echo "<option value=\"{$vssArr[$i][srf]}\" ";
			if(strcmp($srf0,$vssArr[$i][srf])==0)
				echo "selected";
			echo ">$showName</option>";
		}
		echo "</select>";
		echo "<input type=\"submit\" name=\"srf0_save\" value=\"save\" onmouseover=\"this.className='style4'\" 
			onmouseout=\"this.className='style3'\" class=\"style3\">";
		echo "</td>";

	}
	else
	{
		for($i=0; $i<sizeof($vssArr); $i++)
		{
			if(strcmp($srf0,$vssArr[$i][srf])==0)
			{
				$showSrf0 = "{$vssArr[$i][name]}({$vssArr[$i][srf]})";
				break;
			}
		}
		if(!isset($showSrf0)) $showSrf0 = $srf0;
		if(sizeof($vssArr)==0)
			echo "<td align=\"left\" width=70%><a href=\"javascript:alert('Set VSS device first!');\">--</a>&nbsp;</td>"  ;  
		else
			echo "<td align=\"left\" width=70%><a href=javascript:linkTo('./pps.php','srf0_edit=1&srfShow=1','-1')>$showSrf0</a>&nbsp;</td>"  ;  
	}
	
	echo "</tr></table></td>";
	echo "</tr>";
	echo "<tr>";
	echo "<td><table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" ><tr>";
	echo "<td width=30%>SRF1<td>";
	
	if(isset($srf1_edit))
	{
		echo "<td align=\"left\" width=\"70%\">";
		echo "<select name = \"srf1\">";
		for($i=0; $i<sizeof($vssArr); $i++)
		{
			if($i==sizeof($vssArr)-1)
				$showName = $vssArr[$i][name];
			else	
				$showName = "{$vssArr[$i][name]}({$vssArr[$i][srf]})";
				
			echo "<option value=\"{$vssArr[$i][srf]}\" ";
			if(strcmp($srf1,$vssArr[$i][srf])==0)
				echo "selected";
			echo ">$showName</option>";
			
		}
		echo "</select>";
		echo "<input type=\"submit\" name=\"srf1_save\" value=\"save\" onmouseover=\"this.className='style4'\" 
			onmouseout=\"this.className='style3'\" class=\"style3\">";
		echo "</td>"  ;  
	}
	else
	{
		for($i=0; $i<sizeof($vssArr); $i++)
		{
			if(strcmp($srf1,$vssArr[$i][srf])==0)
			{
				$showSrf1 = "{$vssArr[$i][name]}({$vssArr[$i][srf]})";
				break;
			}
		}
		if(!isset($showSrf1)) $showSrf1 = $srf1;
		if(sizeof($vssArr)==0)
			echo "<td align=\"left\" width=70%><a href=\"javascript:alert('Set VSS device first!');\">--</a>&nbsp;</td>"  ;  
		else
			echo "<td align=\"left\" width=70%><a href=javascript:linkTo('./pps.php','srf1_edit=1&srfShow=1','-1')>$showSrf1</a>&nbsp;</td>"  ;  
	}
	
	echo "</tr></table></td>";
	echo "</tr>";
}
//==========================================================
//输出Service number
//==========================================================
{
	$service_num_arr = array(
		array('Hotline','2.1.2.2.1'),
		array('Inquiry','2.1.2.2.2'),
		array('Recharge via recharge card','2.1.2.2.3'),
		array('Recharge via credit card','2.1.2.2.4'),
		array('Third party recharge','2.1.2.2.5'),
		array('Customer care center','2.1.2.2.6'),
		array('Recharge number','2.1.2.2.7'),
	);	
	$nrow = sizeof($service_num_arr) + 1;
	echo "<tr>";
	echo "<td rowspan='$nrow' bgcolor = \"#E6E6E6\"><table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" ><tr>";
	echo "<td><b>Service number</b></td>";
	echo "</tr></table></td>";
	echo "</tr>";

	for($i=0; $i < sizeof($service_num_arr); $i++)
	{
		echo "<tr>";
		echo "<td><table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" ><tr>";
		echo "<td width=30%>{$service_num_arr[$i][0]}</td>";
		echo "<td width=70%>";
			$oidStr = $service_num_arr[$i][1];
			showParameter($sysId, $oidStr,1,1);
		echo "</td>";
		echo "</tr></table></td>";
		echo "</tr>";
	}
}
//==========================================================
//输出Service key
//==========================================================
/*
{
	$service_key_arr = array(
		array('Inquiry','2.1.2.3.2'),
		array('Recharge via recharge card','2.1.2.3.3'),
		array('Recharge via credit card','2.1.2.3.4'),
		array('Set favorite number','2.1.2.3.5'),
		array('Select language','2.1.2.3.6'),
		array('Set password','2.1.2.3.7'),
	);
	$nrow = sizeof($service_key_arr) + 1;
	echo "<tr>";
	echo "<td rowspan='$nrow' bgcolor = \"#E6E6E6\"><table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" ><tr>";
	echo "<td><b>Service key</b></td>";
	echo "</tr></table></td>";
	echo "</tr>";
	for($i=0; $i < sizeof($service_key_arr); $i++)
	{
		echo "<tr>";
		echo "<td><table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" ><tr>";
		echo "<td width=30%>{$service_key_arr[$i][0]}<td>";
		echo "<td width=70%>";
			$oidStr = $service_key_arr[$i][1];
			showParameter($sysId,$oidStr,1,1);
		echo "</td>";
		echo "</tr></table></td>";
		echo "</tr>";
	}
}
*/

//=================输出SRF prefix=====================

{
	
	

	//输出SRF prefix
	{//get all local prefix
		
		//find prefix
		$localPrefixTg = 250;
		
		
		//=======set the 250 trunk group enable=======
		$database="OBJ_322";
		$sql="update param_99 set initValue = '000000000B0302FF0000000000000000'
				where level_1 = '2' and level_2 = '1' and level_3 = '4' and instanceNo ='$localPrefixTg'";
		$result=@mysqli_query($pubConn,$sql);
		$rows=@mysqli_fetch_array($result);
			
		mysqli_query($pubConn,$sql);

		
		
		
		
		$sysId = '322_99_99';
		
		$sysIdArr	= explode('_',$sysId);
		$sysTypeNo	= $sysIdArr[0];
		$sysNo		= $sysIdArr[1];
		$subSysNo	= $sysIdArr[2];
		
		$objDb		= 'OBJ_'.$sysTypeNo;
		$paramTable = 'param_'.$sysNo;
		
		{//get all enable prefix No
		$oidstr = '2.1.2';
		$objWhereStr= '';
		$objWhereStr =getLevelWhere($oidstr);		
		
		$defSql = " SELECT initValue,instanceNo FROM $paramTable WHERE $objWhereStr	and instanceNo<252 ORDER BY instanceNo";
		//echo $defSql;
		$defRes = @mysqli_query($pubConn,$defSql);
		echo mysqli_error($pubConn);
		$offset_enable = "10.7-10.7";
		$offset_Properties = "10.2-10.3";	
		$offset_calltype = "10.4-10.6";
		$prefix_num=0;	
		while($row = @mysqli_fetch_array($defRes))
		{
			$prefix_enable=bindec(getBitValue($row[initValue],$offset_enable));
			$prefix_property=bindec(getBitValue($row[initValue],$offset_Properties));
			$prefix_calltype=bindec(getBitValue($row[initValue],$offset_calltype));

			$flag = ($prefix_enable && $prefix_property!=2 && $prefix_calltype == 4);
			if($flag)
			{
				$enablePrefix[$prefix_num][inst_no]=$row[instanceNo];
				$enablePrefix[$prefix_num][init_value]=$row[initValue];
				$prefix_num++;
			}
			if($prefix_enable==0 && !isset($unused_ins))
				$unused_ins = $row[instanceNo];
		}	
		}//end get enable prefix No
		{
		$oidstr = '2.1.3';
		$objWhereStr= '';
		$objWhereStr =getLevelWhere($oidstr);	
		
		$paramSql = " SELECT initValue,readValue,instanceNo FROM $paramTable  
					WHERE subSysNo = '$subSysNo' AND  $objWhereStr and instanceNo<252
					ORDER BY instanceNo 
					";
		//echo "<br>paramSql: $paramSql";
		$Result_1 = mysqli_query($pubConn,$paramSql);	
		$prefix_no=0;
		$valid_num=0;	
		while($Row_1 = mysqli_fetch_array($Result_1))
		{
			if($Row_1[instanceNo]==$enablePrefix[$prefix_no][inst_no])
			{
				$tmpTg=hexdec($Row_1[initValue]);
				//echo "<br>{$Row_1[instanceNo]}->tmpTg: $tmpTg";
				if($tmpTg == $localPrefixTg)
				{
					$validPrefix[$valid_num][inst_no] = $enablePrefix[$prefix_no][inst_no];
					$validPrefix[$valid_num][init_value] = $enablePrefix[$prefix_no][init_value];
					$validPrefix[$valid_num][tg] = $tmpTg;
					$valid_num++;
				}
				$prefix_no++;
			}
			if($prefix_no >= $prefix_num)
				break;		
		}
		}
		{//get prefix value
		$oidstr = '2.1.1';
		$objWhereStr= '';
		$objWhereStr =getLevelWhere($oidstr);	
		
		$paramSql = " SELECT initValue,readValue,instanceNo FROM $paramTable WHERE subSysNo = '$subSysNo' AND  $objWhereStr and instanceNo<252 ORDER BY instanceNo ";
	//				echo "$paramSql";
		$Result_1 = mysqli_query($pubConn,$paramSql);	
		$prefix_no=0;			
		while($Row_1 = mysqli_fetch_array($Result_1))
		{
			if($Row_1[instanceNo]==$validPrefix[$prefix_no][inst_no])
			{
				$tempprefix=strtoupper($Row_1[initValue]);
				$prefix = explode('E',$tempprefix);
				if($prefix[0] =="")
					$prefix[0]="--";
				$validPrefix[$prefix_no][prefix]=$prefix[0];
				//echo "<br>".$validPrefix[$prefix_no][prefix];
				$prefix_no++;
			}
			if($prefix_no >= $valid_num)
				break;		
		}
		}//end get prefix value
	}//end get all local prefix
	$objIdStr='no-2.1.1-2.1.2';
	$sysId = '322_99_99';
	$webname="PPS";
	$setname="Prefix";
	
	echo "<tr>" ;
		echo "<td bgcolor=\"#E6E6E6\">";
		
			echo "<table width=100% cellpadding=\"1\" cellspacing=\"0\" >";
				echo "<tr>";
				echo "<td align=left><b>SRF prefix</b></td>";
				//alert("backurl  ".$backurl);
				//openSetPrefix('$localPrefixTg','$unused_ins','$objIdStr','$sysId','$webname','$setname','$backurl')
				echo "<td align=\"right\"><a href=\"javascript:openSetPrefix('$localPrefixTg','$unused_ins','$objIdStr','$sysId','$webname','$setname','$backurl')\"><font size=4>+</font></a></td>";
				echo "</tr>";
			echo "</table>";
			
		echo "</td>";
		if($valid_num == 0) echo "<td>&nbsp;--</td>";
		else
		{
			$flag = 'srf';
		echo "<td>";
		
			echo "<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\">";
			echo "<tr bgcolor=\"#E6E6E6\">";
				echo "<td width=\"10%\">No.</td>";
				echo "<td width=\"15%\">Prefix</td>";
				echo "<td width=\"15%\">TON-in</td>";
				echo "<td width=\"15%\">TON-out</td>";
				echo "<td width=\"15%\">Properties</td>";
				echo "<td width=\"15%\">Call Type</td>";
				//echo "<td >CDR</td>";
				$addurl = 'srfShow=1';
				//javascript:delSelected('Set','$flag',0,$valid_num,'$addurl')
				echo "<td width=\"15%\" align=right><a href=\"javascript:delSelected('Set','$flag',0,$valid_num,'$addurl')\" 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,$valid_num)>";
				echo "</td>";
			echo "</tr>";
			
			$TON_in 	= array('Spare','MSISDN','Unkown','NDD','IDD','Spare');
			$TON_out 	= array('Spare','MSISDN','Unkown','NDD','IDD','Spare');
			$Properties = array('Trunk','MSISDN','MSRN','MSC');	
			$callTypeArr= array('Normal Call','Emergency','MCT','VMS','IN');
			for($i=0;$i < $valid_num;$i++)
			{
				$checkBoxName=$flag . 'checkBox_'.$i;
				$deleteNo = $flag . 'deleteno_'.$i;
				
				$tmpInitValue = $validPrefix[$i][init_value];
				$tmpInst	= $validPrefix[$i][inst_no];
				
				if($i>3)
					echo "<tr id='dailing$i' style=\"display:none\" onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";
				else
					echo "<tr id='dailing$i' onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";
				
				echo "<td width=\"10%\"><a  href=\"javascript:openSetPrefix('$localPrefixTg','$tmpInst','$objIdStr','$sysId','$webname','$setname','$backurl')\">$i</a></td>";
					//javascript:openSetPrefix('$localPrefixTg','{$validPrefix[$i][inst_no]}','$objIdStr','$sysId','$webname','$setname','$backurl')
				//echo "<tr  onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";
					//echo "<td width=\"10%\"><a  href=\"#\">$i</a></td>";
					$oTON_in		= BinDec(getBitValue($tmpInitValue,'0.0-0.3'));
					$oTON_out 		= BinDec(getBitValue($tmpInitValue,'0.4-0.7'));
					$oProperties 	= BinDec(getBitValue($tmpInitValue,'10.2-10.3'));
					$oCallType      = BinDec(getBitValue($tmpInitValue,'10.4-10.6'));
					$oCDR			= BinDec(getBitValue($tmpInitValue,'10.0-10.0'));
					$oCDR			= ($oCDR) ? ("ON") : ("OFF");
					
					$oRano			= $validPrefix[$i][prefix];
					echo "<td width=\"15%\">$oRano&nbsp</td>";
					echo "<td width=\"15%\">$TON_in[$oTON_in]&nbsp;</td>";
					echo "<td width=\"15%\">$TON_out[$oTON_out]&nbsp;</td>";
					echo "<td width=\"15%\">$Properties[$oProperties]&nbsp;</td>";
					echo "<td width=\"15%\">$callTypeArr[$oCallType]&nbsp;</td>";
				//		echo "<td >$oCDR&nbsp</td>";
				
					echo "<td align=right><input type=\"checkbox\" name=\"$checkBoxName\" value=\"0\" onClick=\"javascript:selectToDel(this)\"></td>";
					echo "<input type=\"hidden\" name=\"$deleteNo\" value=\"{$validPrefix[$i][inst_no]}\"";	
				echo "</tr>";	
			}
			
			//====more button=========
			if($valid_num>4)
			{
					echo "<tr id='showdailing' style=\"display:block\"><td><a href=\"javascript:clickOnMoreHide('dailing',$valid_num,'show')\">More >></a></td></tr>"; 
					echo "<tr id='hidedailing' style=\"display:none\"><td><a href=\"javascript:clickOnMoreHide('dailing',$valid_num,'hide')\">Hide >></a></td></tr>"; 
			}
			echo "</table>";
			
		echo "</td>";
		}
	echo "</tr>";


}//end 输出 SRF prefix








//=====================SRF prefix manipulation==================
{
	$objIdStr='no-2.8';
	$sysId = '225_99_99';
	$webname="SRF";
	$setname="Prefix manipulation";

	$oidStr = '2.8.0';
	$levelWhere = getLevelWhere($oidStr);
	
	//get default value of local prefix(conv prefix)
	$getsql = "select initValue from $net_paramConf where $levelWhere";  
	$conv_pre_def = @mysqli_query($pubConn,$getsql);
	$conv_pre_def = @mysqli_fetch_array($conv_pre_def);
	$conv_pre_def = $conv_pre_def[0];
	echo mysqli_error($pubConn);
	if($DEBUG) echo "conv_pre_def = $conv_pre_def<br>";

	$getsql = "select initValue,instanceNo from $net_paramTable where $levelWhere and initValue!='$conv_pre_def'";  
	$result = @mysqli_query($pubConn,$getsql);
	echo mysqli_error($pubConn);
	$convNo=0;
	while($pre_row = @mysqli_fetch_array($result))
	{
		$nameFlag = toAscii(getBitValue($pre_row[initValue],'35.0-42.7'));
		if($nameFlag == $webname)
		{
			$convPrefix[$convNo][initValue]=$pre_row[initValue];
			$convPrefix[$convNo][inst_no] = $pre_row[instanceNo];
			$prefix = getBitValue($pre_row[initValue],'00.0-15.7');
			if($convPrefix != 0)
				$prefix = toAscii($prefix);
			else
				$prefix = '--';
			$addDigs = getBitValue($pre_row[initValue],'18.0-33.7');
			if($addDigs != 0)
				$addDigs = toAscii($addDigs);
			else
				$addDigs = '--';
			$convPrefix[$convNo][prefix] = $prefix;
			$convPrefix[$convNo][delLen] = hexdec(getBitValue($pre_row[initValue],'16.0-16.7'));
			$convPrefix[$convNo][addLen] = hexdec(getBitValue($pre_row[initValue],'17.0-17.7'));
			$convPrefix[$convNo][addDigs] = $addDigs;
			$convPrefix[$convNo][valiLen] = hexdec(getBitValue($pre_row[initValue],'34.0-34.7'));
			//echo "<br>convPrefix[$convNo][prefix]:{$convPrefix[$convNo][initValue]}";
			$convNo++;
		}
	}//end while
	$getsql = "select initValue,instanceNo from $net_paramTable where $levelWhere and initValue='$conv_pre_def'";  
	//echo "<br>getsql: $getsql;";
	$result = @mysqli_query($pubConn,$getsql);
	$Row = @mysqli_fetch_array($result);
	$newConvInst=$Row[instanceNo];
	$conv_nrow = $convNo + 1;
	
	echo "<tr>" ;
	echo "<td bgcolor=\"#E6E6E6\">";
	echo "<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" ><tr >";
	echo "<td align=left><b>$setname</b></td>";
	echo "<td align=\"right\">";
	if($newConvInst=='')
	{
		echo "<a href=\"javascript:openErr()\"><font size=4>+</font></a></td>";
	}
	else
		echo "<a href=\"javascript:openSet('$newConvInst','$objIdStr','$sysId','$webname','$setname','$backurl')\"><font size=4>+</font></a></td>";
	echo "</tr></table></td>";
	if($convNo == 0) echo "<td>&nbsp;--</td>";
	else
	{
		echo "<td>";
		echo "<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\">";
		$flag = 'conv_srf';
		echo "<tr bgcolor=\"#E6E6E6\">";
			echo "<td width=\"10%\">No.</td>";
			echo "<td width=\"15%\">Prefix</td>";
			echo "<td width=\"15%\">Delete length</td>";
			echo "<td width=\"15%\">Add length</td>";
			echo "<td width=\"15%\">Add digits</td>";
			echo "<td width=\"15%\">Valid length</td>";
			$addurl='srfShow=1';
			echo "<td width=\"15%\" align=right><a href=\"javascript:delSelected('Set','$flag',0,$convNo,'$addurl')\" 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,$convNo)>";
			echo "</td>";
		echo "</tr>";
		for($i=0; $i< $convNo; $i++)
		{
			$checkBoxName=$flag . 'checkBox_'.$i;
			$deleteNo = $flag . 'deleteno_'.$i;
			if($i>3)
				echo "<tr id='conv$i' style=\"display:none\" onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";		
			else
				echo "<tr id='conv$i' onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";
			
			
			//echo "<tr  onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";
				echo "<td width=\"10%\"><a href=\"javascript:openSet('{$convPrefix[$i][inst_no]}','$objIdStr','$sysId','$webname','$setname','$backurl')\">$i</a></td>";
		
				echo "<td width=\"15%\">{$convPrefix[$i][prefix]}&nbsp</td>";
				echo "<td width=\"15%\">{$convPrefix[$i][delLen]}&nbsp;</td>";
				echo "<td width=\"15%\">{$convPrefix[$i][addLen]}&nbsp;</td>";
				echo "<td width=\"15%\">{$convPrefix[$i][addDigs]}&nbsp;</td>";
				echo "<td width=\"15%\">{$convPrefix[$i][valiLen]}&nbsp;</td>";
				
				echo "<td width=\"15%\" align=right><input type=\"checkbox\" name=\"$checkBoxName\" value=\"0\" onClick=\"javascript:selectToDel(this)\"></td>";
				echo "<input type=\"hidden\" name=\"$deleteNo\" value=\"{$convPrefix[$i][inst_no]}\"";	
			echo "</tr>";
		}
		
		//===more button====
		if($convNo>4)
		{
			echo "<tr id='showconv' style=\"display:block\"><td><a href=\"javascript:clickOnMoreHide('conv',$convNo,'show')\">More >></a></td></tr>"; 
			echo "<tr id='hideconv' style=\"display:none\"><td><a href=\"javascript:clickOnMoreHide('conv',$convNo,'hide')\">Hide >></a></td></tr>"; 
		}
		echo "</table>";
		echo "</td>";
	}
	echo "</tr>";
}







$sysId="360_99_99";
if(0)
{//IVR Location
	
	$oidStr="2.1.2.4";
	echo "<tr>";
	echo "<td bgcolor = \"#E6E6E6\">";
	echo "<b>IVR Location</b></td>";
	echo "<td><table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" ><tr>";
	echo "<td width=\"30%\">Inquiry:&nbsp;";
		showParameter($sysId, $oidStr,1,1);
	echo "</td>";
	echo "<td width=\"70%\">Recharge:&nbsp;";
		showParameter($sysId, $oidStr,2,1);
	echo "</td>";
	echo "</tr></table></td>";
	echo "</tr>";
}
echo "</table>";
}//end srf service.

{//vms routing
echo "<TABLE  style=\"DISPLAY: $vmsShowStr\" width=\"100%\"   border=\"1\"  cellpadding=\"1\" cellspacing=\"0\"  bordercolor=\"#666666\" bordercolordark=\"#FFFFFF\" bgcolor=\"#FFFFFF\">";
echo "<tr><th colspan=2><b>VMS Routing</b></th></tr>";

//==========================================================
//输出Call routing to VMS (VMS server no 2.1.5.1 - 2.1.5.3)
//==========================================================
{
	$call_routing_vms_arr = array(
		array('VMS Service No. - PLMN','PLMN_ServerNo','2.1.5.1'),
		array('VMS Service No. - PSTN','PSTN_ServerNo','2.1.5.2'),
		array('VMS Leave Message No.','LeaveMessageNo','2.1.5.3'),
		array('Routing Rule.','routingRule','2.1.5.4'),
	);
	$nrow = sizeof($call_routing_vms_arr) + 1;
	echo "<tr>";
	echo "<td width=\"15%\" rowspan='$nrow' bgcolor = \"#E6E6E6\"><table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" ><tr>";
	echo "<td><b>Call routing to VMS</b></td>";
	echo "</tr></table></td>";
	echo "</tr>";
	for($i=0; $i < sizeof($call_routing_vms_arr); $i++)
	{
		$oidStr = $call_routing_vms_arr[$i][2];
		if($i==3)
		{
			echo "<tr>";
			echo "<td><table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" ><tr>";
			echo "<td width=50%>route by:&nbsp;";
				showParameter($sysId, $oidStr,1,1);
			echo "</td>";
			echo "<td width=50%>route:&nbsp;";
				showParameter($sysId, $oidStr,2,1);
			echo "</td>";
			echo "</tr></table></td>";
			echo "</tr>";
		}
		else
		{
			echo "<tr>";
			echo "<td><table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" ><tr>";
			echo "<td width=30%>{$call_routing_vms_arr[$i][0]}<td>";
			echo "<td align=\"left\" width=\"70%\">";
			$doingOtherUlr="$PHP_SELF?doingOtherFlag=1&setVmsRouting=1";
				showParameter($sysId, $oidStr,1,1,0,$doingOtherUlr);
			echo "</td>";
			echo "</tr></table></td>";
			echo "</tr>";
		}
	}
}
//==========================================================
//输出Call routing to VMS (VMS user segments 2.1.5.5)
//==========================================================
{
	$objWhereStr = getLevelWhere('2.1.5.5');
	$getsql = "select initValue from $sqltable_conf where $objWhereStr";
	$result = mysqli_query($pubConn,$getsql);
	echo mysqli_error($pubConn);
	$vmsSeg_org = mysqli_fetch_array($result);
	$vmsSeg_org = $vmsSeg_org[0];
	if($DEBUG) echo "vmsSeg_org=$vmsSeg_org<br>";
	
	$objWhereStr = getLevelWhere('2.1.5.5');
	$getsql = "select initValue from $sqltable where $objWhereStr";
	$result = mysqli_query($pubConn,$getsql);
	echo mysqli_error($pubConn);
	
	$i = 0;
	$vmsSeg_num = 0;
	while($vmsSeg_row = mysqli_fetch_array($result))
	{
		$vmsSeg_row = $vmsSeg_row[0];
		if(strcmp($vmsSeg_row,$vmsSeg_org)!=0)
		{
			$startMSISDN[$vmsSeg_num] = trim(toAscii(getBitValue($vmsSeg_row,'00.0-15.7')));
			$endMSISDN[$vmsSeg_num] = trim(toAscii(getBitValue($vmsSeg_row,'16.0-31.7')));
			$servNumPLMN[$vmsSeg_num] = trim(toAscii(getBitValue($vmsSeg_row,'32.0-47.7')));
			$servNumPSTN[$vmsSeg_num] = trim(toAscii(getBitValue($vmsSeg_row,'48.0-63.7')));
			$numberDeposit[$vmsSeg_num] = trim(toAscii(getBitValue($vmsSeg_row,'64.0-79.7')));
			$vmsSeg_ins[$vmsSeg_num] = $i;
			$vmsSeg_num++;
		}
		else if(!isset($vmsSeg_ins_unused))
		{
			$vmsSeg_ins_unused = $i;
		}
		$i++;
	}
	
	if($vmsSeg_num == 0) $nrow = $vmsSeg_num + 2;
	else $nrow = $vmsSeg_num + 1;
	
	$objIdStr = "no-2.1.5.5";
	$webname = "PPS";
	$setname = "Basic vmsSeg zone";
	//alert($vmsSeg_num);
	echo "<tr bgcolor = \"#E6E6E6\">";
	echo "<td rowspan='$nrow'><table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\"><tr>";
	echo "<td><b>VMS user segments</b></td>";
	if($vmsSeg_num>=128)
		echo "<td>&nbsp</td>";
	else
		echo "<td align=right><a href=\"javascript:openSet('$vmsSeg_ins_unused','$objIdStr','$sysId','$webname','$setname','$backurl')\"><font size=4>+</font></a></td>";
	echo "</tr></table></td>";
	
	{//get all vss serv number
		for($i=0; $i < $vmsSeg_num; $i++)
		{
			for($j=0; $j< sizeof($vssSegArr)-1; $j++)//vss serv number
			{
				$vms_objDB 			= "OBJ_390";
				$vms_paramTable 	= 'param_99';
				$oidstr = "2.2.1.1";
				$objWhereStr = getLevelWhere($oidstr);
				$tmpInstNo = $vssSegArr[$j][sysNo];
				$getsql = "select initValue from $vms_paramTable where $objWhereStr and instanceNo='$tmpInstNo'";
				$result = @mysqli_query($pubConn,$getsql);
				$row = @mysqli_fetch_array($result);
	
				$PLMNServNo = getBitValue($row[0],'08.0-15.7');
				$PLMNServNo = str_replace('F','',$PLMNServNo);
				
				$PSTNServNo = getBitValue($row[0],'16.0-23.7');
				$PSTNServNo = str_replace('F','',$PSTNServNo);
				
				$LeaveMessNo = getBitValue($row[0],'24.0-31.7');
				$LeaveMessNo = str_replace('F','',$LeaveMessNo);
				
				if(strcmp($PLMNServNo,$servNumPLMN[$i])==0
					&&strcmp($PSTNServNo,$servNumPSTN[$i])==0
					&&strcmp($LeaveMessNo,$numberDeposit[$i])==0)
					
				{
					$vssNameArr[$i] = $vssSegArr[$j][name];
					break;
				}
			}//end vss serv number
			if(!isset($vssNameArr[$i]))
			{
				$vssNameArr[$i] = $servNumPLMN[$i] = $servNumPSTN[$i] = $numberDeposit[$i] = '--';
			}
		}
	}//end get vss serv number
	if($vmsSeg_num == 0)
	{
		echo "<tr><td>&nbsp--</td></tr>";
	}
	else
	{
		$flag = 'vmsSeg';
		echo "<td><table width=\"100%\" style=\"border-style:none\" cellpadding=\"1\" cellspacing=\"0\" ><tr>";
		echo "<td width=10%>No.<td>";
		echo "<td width=13%>Start MSISDN<td>";
		echo "<td width=13%>End MSISDN<td>";
		echo "<td width=13%>VSS Name<td>";
		echo "<td width=13%>PLMN Num<td>";
		echo "<td width=13%>PSTN Num<td>";
		echo "<td width=13%>Deposit Num<td>";
		/*echo "<td align=right width=17%>Delete<td>";*/
		echo "<td width=\"12%\" align=right><a href=\"javascript:delSelected('Set','$flag',0,$vmsSeg_num)\" 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,$vmsSeg_num)>";
		echo "</td>";
		echo "</tr></table></td>";
		echo "</tr>";
	}
	//========================================
if($vmsSeg_num!=0)
{
	echo "<tr><td rowspan=$vmsSeg_num>";
	echo "<table border=0>";
	for($i=0; $i < $vmsSeg_num; $i++)
	{
		$inst = $vmsSeg_ins[$i];
		$checkBoxName=$flag . 'checkBox_'.$i;
		$deleteNo = $flag . 'deleteno_'.$i;
				
		//echo "<tr>";
	
		//echo "<td><table width=\"100%\" style=\"\" cellpadding=\"1\" cellspacing=\"0\" >";
		if($i>3)
			echo "<tr id='vmsSeg$i' style=\"display:none\">";
		else
			echo "<tr id='vmsSeg$i' style=\"display:block\">";
		
		echo "<td width=10%><a href=\"javascript:openSet('$inst','$objIdStr','$sysId','$webname','$setname','$backurl')\">$i</a><td>";

		echo "<td width=13%>$startMSISDN[$i]</td>";
		echo "<td width=13%>$endMSISDN[$i]</td>";
		echo "<td width=13%>$vssNameArr[$i]</td>";
		echo "<td width=13%>$servNumPLMN[$i]</td>";
		echo "<td width=13%>$servNumPSTN[$i]</td>";
		echo "<td width=13%>$numberDeposit[$i]</td>";
		/*echo "<td align=right width=17%><input type=\"checkbox\" name=\"$vmsSeg_del_$i\" value=\"ON\" 
				onClick=\"javascript:delFirm('$vmsSeg_ins[$i]','tar',this)\" ><td>";*/
		echo "<td width=12% align=right><input type=\"checkbox\" name=\"$checkBoxName\" value=\"0\" onClick=\"javascript:selectToDel(this)\"></td>";
		echo "<input type=\"hidden\" name=\"$deleteNo\" value=\"$inst\"";	
		echo "</tr>";
		
		
		
	}
	
			if($vmsSeg_num>4)
			{
				echo "<tr id='showvmsSeg' style=\"display:block\"><td><a href=\"javascript:clickOnMoreHide('vmsSeg',$vmsSeg_num,'show')\">More >></a></td></tr>"; 
				echo "<tr id='hidevmsSeg' style=\"display:none\"><td><a href=\"javascript:clickOnMoreHide('vmsSeg',$vmsSeg_num,'hide')\">Hide >></a></td></tr>"; 
			}
		
	echo "</table>";
	echo "</td></tr>";
}
	for($i=0;$i<$vmsSeg_num-1;$i++)
	{
		echo "<tr></tr>";
	}
	
	//=========================================
	
}
{//输出dailing prefix
	{//get all local prefix
		//直接指定TG＝252作为local prefix
		//find prefix
		$localPrefixTg = 252;
		$sysId = '322_99_99';
		
		$sysIdArr	= explode('_',$sysId);
		$sysTypeNo	= $sysIdArr[0];
		$sysNo		= $sysIdArr[1];
		$subSysNo	= $sysIdArr[2];
		
		$objDb		= 'OBJ_'.$sysTypeNo;
		$paramTable = 'param_'.$sysNo;
		
		{//get all enable prefix No
		$oidstr = '2.1.2';
		$objWhereStr= '';
		$objWhereStr =getLevelWhere($oidstr);		
		
		$defSql = " SELECT initValue,instanceNo FROM $paramTable WHERE $objWhereStr	and instanceNo<252 ORDER BY instanceNo";
		//echo $defSql;
		$defRes = @mysqli_query($pubConn,$defSql);
		echo mysqli_error($pubConn);
		$offset_enable = "10.7-10.7";
		$offset_Properties = "10.2-10.3";	
		$offset_calltype = "10.4-10.6";
		$prefix_num=0;	
		while($row = @mysqli_fetch_array($defRes))
		{
			$prefix_enable=bindec(getBitValue($row[initValue],$offset_enable));
			$prefix_property=bindec(getBitValue($row[initValue],$offset_Properties));
			$prefix_calltype=bindec(getBitValue($row[initValue],$offset_calltype));

			$flag = ($prefix_enable && $prefix_property!=2 && $prefix_calltype == 4);
			if($flag)
			{
				$enablePrefix[$prefix_num][inst_no]=$row[instanceNo];
				$enablePrefix[$prefix_num][init_value]=$row[initValue];
				$prefix_num++;
			}
			if($prefix_enable==0 && !isset($unused_ins))
				$unused_ins = $row[instanceNo];
		}	
		}//end get enable prefix No
		{
		$oidstr = '2.1.3';
		$objWhereStr= '';
		$objWhereStr =getLevelWhere($oidstr);	
		
		$paramSql = " SELECT initValue,readValue,instanceNo FROM $paramTable  
					WHERE subSysNo = '$subSysNo' AND  $objWhereStr and instanceNo<252
					ORDER BY instanceNo 
					";
		//echo "<br>paramSql: $paramSql";
		$Result_1 = mysqli_query($pubConn,$paramSql);	
		$prefix_no=0;
		$valid_num=0;	
		while($Row_1 = mysqli_fetch_array($Result_1))
		{
			if($Row_1[instanceNo]==$enablePrefix[$prefix_no][inst_no])
			{
				$tmpTg=hexdec($Row_1[initValue]);
				//echo "<br>{$Row_1[instanceNo]}->tmpTg: $tmpTg";
				if($tmpTg == $localPrefixTg)
				{
					$validPrefix[$valid_num][inst_no] = $enablePrefix[$prefix_no][inst_no];
					$validPrefix[$valid_num][init_value] = $enablePrefix[$prefix_no][init_value];
					$validPrefix[$valid_num][tg] = $tmpTg;
					$valid_num++;
				}
				$prefix_no++;
			}
			if($prefix_no >= $prefix_num)
				break;		
		}
		}
		{//get prefix value
		$oidstr = '2.1.1';
		$objWhereStr= '';
		$objWhereStr =getLevelWhere($oidstr);	
		
		$paramSql = " SELECT initValue,readValue,instanceNo FROM $paramTable WHERE subSysNo = '$subSysNo' AND  $objWhereStr and instanceNo<252 ORDER BY instanceNo ";
	//				echo "$paramSql";
		$Result_1 = mysqli_query($pubConn,$paramSql);	
		$prefix_no=0;			
		while($Row_1 = mysqli_fetch_array($Result_1))
		{
			if($Row_1[instanceNo]==$validPrefix[$prefix_no][inst_no])
			{
				$tempprefix=strtoupper($Row_1[initValue]);
				$prefix = explode('E',$tempprefix);
				if($prefix[0] =="")
					$prefix[0]="--";
				$validPrefix[$prefix_no][prefix]=$prefix[0];
				//echo "<br>".$validPrefix[$prefix_no][prefix];
				$prefix_no++;
			}
			if($prefix_no >= $valid_num)
				break;		
		}
		}//end get prefix value
	}//end get all local prefix
	$objIdStr='no-2.1.1-2.1.2';
	$sysId = '322_99_99';
	$webname="PPS";
	$setname="Prefix";
	
	echo "<tr>" ;
		echo "<td bgcolor=\"#E6E6E6\">";
			echo "<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" ><tr >";
			echo "<td align=left><b>VMS prefix</b></td>";
			echo "<td align=\"right\"><a href=javascript:openSetPrefix('$localPrefixTg','$unused_ins','$objIdStr','$sysId','$webname','$setname','$backurl')><font size=4>+</font></a></td>";
			echo "</tr></table>";
		echo "</td>";
		if($valid_num == 0) echo "<td>&nbsp;--</td>";
		else
		{
			$flag = 'dailing';
		echo "<td>";
			echo "<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\">";
			echo "<tr bgcolor=\"#E6E6E6\">";
				echo "<td width=\"10%\">No.</td>";
				echo "<td width=\"15%\">Prefix</td>";
				echo "<td width=\"15%\">TON-in</td>";
				echo "<td width=\"15%\">TON-out</td>";
				echo "<td width=\"15%\">Properties</td>";
				echo "<td width=\"15%\">Call Type</td>";
				//echo "<td >CDR</td>";
				$addurl = 'vmsShow=1';
				echo "<td width=\"15%\" align=right><a href=\"javascript:delSelected('Set','$flag',0,$valid_num,'$addurl')\" 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,$valid_num)>";
				echo "</td>";
			echo "</tr>";
			
			$TON_in 	= array('Spare','MSISDN','Unkown','NDD','IDD','Spare');
			$TON_out 	= array('Spare','MSISDN','Unkown','NDD','IDD','Spare');
			$Properties = array('Trunk','MSISDN','MSRN','MSC');	
			$callTypeArr= array('Normal Call','Emergency','MCT','VMS','IN');
			for($i=0;$i < $valid_num;$i++)
			{
				$checkBoxName=$flag . 'checkBox_'.$i;
				$deleteNo = $flag . 'deleteno_'.$i;
				
				$tmpInitValue = $validPrefix[$i][init_value];
				$tmpInst	= $validPrefix[$i][inst_no];
				
				if($i>3)
					echo "<tr id='dailing$i' style=\"display:none\" onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";
				else
					echo "<tr id='dailing$i' onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";
				
				
				//echo "<tr  onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";
					echo "<td width=\"10%\"><a  href=javascript:openSetPrefix('$localPrefixTg','{$validPrefix[$i][inst_no]}','$objIdStr','$sysId','$webname','$setname','$backurl')>$i</a></td>";
					$oTON_in		= BinDec(getBitValue($tmpInitValue,'0.0-0.3'));
					$oTON_out 		= BinDec(getBitValue($tmpInitValue,'0.4-0.7'));
					$oProperties 	= BinDec(getBitValue($tmpInitValue,'10.2-10.3'));
					$oCallType      = BinDec(getBitValue($tmpInitValue,'10.4-10.6'));
					$oCDR			= BinDec(getBitValue($tmpInitValue,'10.0-10.0'));
					$oCDR			= ($oCDR) ? ("ON") : ("OFF");
					
					$oRano			= $validPrefix[$i][prefix];
					echo "<td width=\"15%\">$oRano&nbsp</td>";
					echo "<td width=\"15%\">$TON_in[$oTON_in]&nbsp;</td>";
					echo "<td width=\"15%\">$TON_out[$oTON_out]&nbsp;</td>";
					echo "<td width=\"15%\">$Properties[$oProperties]&nbsp;</td>";
					echo "<td width=\"15%\">$callTypeArr[$oCallType]&nbsp;</td>";
				//		echo "<td >$oCDR&nbsp</td>";
				
					echo "<td align=right><input type=\"checkbox\" name=\"$checkBoxName\" value=\"0\" onClick=\"javascript:selectToDel(this)\"></td>";
					echo "<input type=\"hidden\" name=\"$deleteNo\" value=\"{$validPrefix[$i][inst_no]}\"";	
				echo "</tr>";	
			}
			
			//====more button=========
			if($valid_num>4)
			{
					echo "<tr id='showdailing' style=\"display:block\"><td><a href=\"javascript:clickOnMoreHide('dailing',$valid_num,'show')\">More >></a></td></tr>"; 
					echo "<tr id='hidedailing' style=\"display:none\"><td><a href=\"javascript:clickOnMoreHide('dailing',$valid_num,'hide')\">Hide >></a></td></tr>"; 
			}
			echo "</table>";
		echo "</td>";
		}
	echo "</tr>";
}//end 输出 Dialing prefix

{//输出 conv prefix
	$objIdStr='no-2.8';
	$sysId = '225_99_99';
	$webname="PPS";
	$setname="Prefix manipulation";

	$oidStr = '2.8.0';
	$levelWhere = getLevelWhere($oidStr);
	
	//get default value of local prefix(conv prefix)
	$getsql = "select initValue from $net_paramConf where $levelWhere";  
	$conv_pre_def = @mysqli_query($pubConn,$getsql);
	$conv_pre_def = @mysqli_fetch_array($conv_pre_def);
	$conv_pre_def = $conv_pre_def[0];
	echo mysqli_error($pubConn);
	if($DEBUG) echo "conv_pre_def = $conv_pre_def<br>";

	$getsql = "select initValue,instanceNo from $net_paramTable where $levelWhere and initValue!='$conv_pre_def'";  
	$result = @mysqli_query($pubConn,$getsql);
	echo mysqli_error($pubConn);
	$convNo=0;
	while($pre_row = @mysqli_fetch_array($result))
	{
		$nameFlag = toAscii(getBitValue($pre_row[initValue],'35.0-42.7'));
		if($nameFlag == $webname)
		{
			$convPrefix[$convNo][initValue]=$pre_row[initValue];
			$convPrefix[$convNo][inst_no] = $pre_row[instanceNo];
			$prefix = getBitValue($pre_row[initValue],'00.0-15.7');
			if($convPrefix != 0)
				$prefix = toAscii($prefix);
			else
				$prefix = '--';
			$addDigs = getBitValue($pre_row[initValue],'18.0-33.7');
			if($addDigs != 0)
				$addDigs = toAscii($addDigs);
			else
				$addDigs = '--';
			$convPrefix[$convNo][prefix] = $prefix;
			$convPrefix[$convNo][delLen] = hexdec(getBitValue($pre_row[initValue],'16.0-16.7'));
			$convPrefix[$convNo][addLen] = hexdec(getBitValue($pre_row[initValue],'17.0-17.7'));
			$convPrefix[$convNo][addDigs] = $addDigs;
			$convPrefix[$convNo][valiLen] = hexdec(getBitValue($pre_row[initValue],'34.0-34.7'));
			//echo "<br>convPrefix[$convNo][prefix]:{$convPrefix[$convNo][initValue]}";
			$convNo++;
		}
	}//end while
	$getsql = "select initValue,instanceNo from $net_paramTable where $levelWhere and initValue='$conv_pre_def'";  
	//echo "<br>getsql: $getsql;";
	$result = @mysqli_query($pubConn,$getsql);
	$Row = @mysqli_fetch_array($result);
	$newConvInst=$Row[instanceNo];
	$conv_nrow = $convNo + 1;
	
	echo "<tr>" ;
	echo "<td bgcolor=\"#E6E6E6\">";
	echo "<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" ><tr >";
	echo "<td align=left><b>$setname</b></td>";
	echo "<td align=\"right\">";
	if($newConvInst=='')
	{
		echo "<a href=\"javascript:openErr()\"><font size=4>+</font></a></td>";
	}
	else
		echo "<a href=\"javascript:openSet('$newConvInst','$objIdStr','$sysId','$webname','$setname','$backurl')\"><font size=4>+</font></a></td>";
	echo "</tr></table></td>";
	if($convNo == 0) echo "<td>&nbsp;--</td>";
	else
	{
		echo "<td>";
		echo "<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\">";
		$flag = 'conv';
		echo "<tr bgcolor=\"#E6E6E6\">";
			echo "<td width=\"10%\">No.</td>";
			echo "<td width=\"15%\">Prefix</td>";
			echo "<td width=\"15%\">Delete length</td>";
			echo "<td width=\"15%\">Add length</td>";
			echo "<td width=\"15%\">Add digits</td>";
			echo "<td width=\"15%\">Valid length</td>";
			
			
			
			
			$addurl = 'vmsShow=1';
			echo "<td width=\"15%\" align=right><a href=\"javascript:delSelected('Set','$flag',0,$convNo,'$addurl')\" 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,$convNo)>";
			echo "</td>";
		echo "</tr>";
		for($i=0; $i< $convNo; $i++)
		{
			$checkBoxName=$flag . 'checkBox_'.$i;
			$deleteNo = $flag . 'deleteno_'.$i;
			if($i>3)
				echo "<tr id='conv$i' style=\"display:none\" onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";		
			else
				echo "<tr id='conv$i' onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";
			
			
			//echo "<tr  onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";
				echo "<td width=\"10%\"><a href=\"javascript:openSet('{$convPrefix[$i][inst_no]}','$objIdStr','$sysId','$webname','$setname','$backurl')\">$i</a></td>";
		
				echo "<td width=\"15%\">{$convPrefix[$i][prefix]}&nbsp</td>";
				echo "<td width=\"15%\">{$convPrefix[$i][delLen]}&nbsp;</td>";
				echo "<td width=\"15%\">{$convPrefix[$i][addLen]}&nbsp;</td>";
				echo "<td width=\"15%\">{$convPrefix[$i][addDigs]}&nbsp;</td>";
				echo "<td width=\"15%\">{$convPrefix[$i][valiLen]}&nbsp;</td>";
				
				echo "<td width=\"15%\" align=right><input type=\"checkbox\" name=\"$checkBoxName\" value=\"0\" onClick=\"javascript:selectToDel(this)\"></td>";
				echo "<input type=\"hidden\" name=\"$deleteNo\" value=\"{$convPrefix[$i][inst_no]}\"";	
			echo "</tr>";
		}
		
		//===more button====
		if($convNo>4)
		{
			echo "<tr id='showconv' style=\"display:block\"><td><a href=\"javascript:clickOnMoreHide('conv',$convNo,'show')\">More >></a></td></tr>"; 
			echo "<tr id='hideconv' style=\"display:none\"><td><a href=\"javascript:clickOnMoreHide('conv',$convNo,'hide')\">Hide >></a></td></tr>"; 
		}
		echo "</table>";
		echo "</td>";
	}
	echo "</tr>";
}



//==========================================================
//输出Command
//========================================================== 
/*
{
	echo "<tr><td bgcolor=\"#E6E6E6\" ><b>Command</b></td>";
	echo "<td ><table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" ><tr>";
	echo "<td width=10%>PPS0</td>";
	echo "<td width=10%><a href='$PHP_SELF'>Lock</a></td>";
	echo "<td width=10%>PPS1</td>";
	echo "<td><a href='$PHP_SELF'>Lock</a></td>";
	echo "</tr></table></td></tr>";
}
*/
echo "</table>";
}//end vms routint
?>
<?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>";
}
if(!isset($smsFormatShow))
	$smsFormatShow=0;
echo "<input type=\"hidden\" name=\"isShowSms\" value=$smsFormatShow>";
echo "</form>";


//echo "<hr>smsFormatShow:$smsFormatShow<hr>";
?>
