<?php 
/*********************************************************      
VMS  configuration.

*********************************************************/

require("../sub_inc/operwebfunc.inc");
$helpId = "2.1.3.2";
$DEBUG = 0;

if(!isset($slctLanguage))
	$slctLanguage=0;
//==========================================================
//变量定义
//==========================================================
//Spname

{//设备类型 与设备编号
	getElementInfo($infoNo,$elementInfoArr);
	$this_sysNo = $TypeNo = $elementInfoArr[sysNo];
	$TypeIn = $elementInfoArr[typeValue];
	$webname = $elementInfoArr[webName];
	$Spname = $elementInfoArr[eleName];
}
$sysId = "390_".$TypeNo."_0";
$pubDb	 = 'OMC_PUB';

{//get heartbeat	
	$db="OMC_PUB";
	$sql = "SELECT detailStat,updateTime FROM sysStat WHERE sysTypeNo='390' AND sysNo='$TypeNo' AND subSysNo='0'"; 
	//echo "$sql";
	if($DEBUG)echo "<br>sql=$sql";
	$res=mysqli_query($pubConn,$sql);
	$row=@mysqli_fetch_array($res);
	//echo mysqli_error($pubConn);
	
	$due_date	= date("Y-m-d H:i:s",mktime(date("H"),date("i"),date("s")-$heatbeat_overtime,date("m"),date("d"),date("Y")));
	$ove_date	= date("Y-m-d H:i:s",mktime(date("H"),date("i"),date("s")+$heatbeat_overtime,date("m"),date("d"),date("Y")));
	
	$hex_mes=$row[detailStat];
	$refresh_time=$row[updateTime];
	//echo $heatbeat_overtime;
	
	$bin_mes='';
	for($i=0;$i<strlen($hex_mes);$i++)
	{
		$sig_hex_mes=substr($hex_mes,$i,1);
		$sig_dec_mes=HexDec($sig_hex_mes);
		$sig_bin_mes=DecBin($sig_dec_mes);
		$sig_bin_mes=omc_keep_length($sig_bin_mes,0,4);
		$bin_mes.=$sig_bin_mes;
	}
	if($DEBUG)echo "<br>bin_mes=$bin_mes";
	$stt_e0		=	45+22; //E1 #0 status (bit 0: 0/1 not in used / in used; bit 1: 0/1 link not ok / link ok)
	$stt_e1		=	46+22; //E1 #1 status
	$licenseByte = 	58+22;
	$licenseFlg = hexdec(substr($hex_mes,$licenseByte*2,2));//1:aas 2:vms 3:both
	//echo "<br>licenseFlg:$licenseFlg";
	//Field08 E1#0 status (bit 0: 0/1 not in used / in used; bit 1: 0/1 link not ok / link ok)
	for($i=0;$i<2;$i++)
	{
		$binSttE0=substr($bin_mes,$stt_e0*8+7-$i,1);
		$sttE0[$i]=BinDec($binSttE0);
		if($DEBUG)echo "<br>sttE0[$i]=$sttE0[$i]";
	}

	if(!$sttE0[0])
	{
		$sttE0[1] = 2;
	}

	//Field09 E1#1 status
	for($i=0;$i<2;$i++)
	{
		$binSttE1=substr($bin_mes,$stt_e1*8+7-$i,1);
		$sttE1[$i]=BinDec($binSttE1);
		if($DEBUG)echo "<br>sttE1[$i]=$sttE1[$i]";
	}

	if(!$sttE1[0])
	{
		$sttE1[1] = 2;
	}
}//end get heartbeat
$aasDisable = $vmsDisable = 0;
if($licenseFlg == 3)
{
	$bothShow = 1;
}
else if($licenseFlg == 2)
{
	$setAAS = 1;
	$setVMS = 0;
	$vmsDisable = 1;
}
else if($licenseFlg == 1)
{
	$setVMS = 1;
	$setAAS = 0;
	$aasDisable = 1;
}
else
{
	$hideBoth=1;
}
if(!isset($setAAS)&&!isset($setVMS))
	$setAAS=1;
$backurl_un = "$PHP_SELF?trunkgp=$trunkgp&infoNo=$infoNo&linkset=$linkset&selectedSysId=$selectedSysId&setAAS=$setAAS&setVMS=$setVMS&slctLanguage=$slctLanguage";
$selfurl = "$PHP_SELF?trunkgp=$trunkgp&infoNo=$infoNo&linkset=$linkset&selectedSysId=$selectedSysId&slctLanguage=$slctLanguage";
$backurl = urlencode($backurl_un);
function goLastWeb()
{
	global $backurl_un;
	global $scroll_y;
	echo "<script LANGUAGE=\"JavaScript\">";
	echo "\n window.location.href=\"$backurl_un&scroll_y=$scroll_y\";";
	echo "\n </script>";
	exit();
}
$NetIdConfArr=array('International','International-S','National','National-S');

?>
<script LANGUAGE="JavaScript">  
	function linkTo(url, param)
	{
		y = document.body.scrollTop;
		URL = url + "&scroll_y=" + y + "&" + param;
		window.location.href=URL;
	}
	
	function selectLanguge(item)
	{
		var base_url,url_add,url; 
		y = document.body.scrollTop;
		base_url='<?php echo"$PHP_SELF?trunkgp=$trunkgp&infoNo=$infoNo&linkset=$linkset&selectedSysId=$selectedSysId&setAAS=$setAAS&setVMS=$setVMS&slctLanguage=";?>';
		url_add=item.value;
		url=base_url+url_add+'&scroll_y='+y;
		window.location.href=url; 
	}
</script>

<script LANGUAGE="JavaScript"> 	
var timer;
function getLinkSta()
{
	var TypeNo=<?php echo $TypeNo;  ?>;
	var ulr="getVMSLinkSta.php?typeNo="+TypeNo;
	var browser = navigator.appName;
	if(browser == "Microsoft Internet Explorer")
	{
		request_o = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else
	{
		request_o = new XMLHttpRequest();
	}
	//alert(request_o);
	
	//alert(ulr);
	request_o.open("GET",ulr,"false");

	request_o.onreadystatechange = updateLinkSta; 

	request_o.send(null);
}

function updateLinkSta()
{	
	if(request_o.readyState == 4)
	{
		var strResult = request_o.responseText;
		var arrResult = strResult.split("###");
		var link0_st = arrResult[0];
		var link1_st = arrResult[1];	
		//alert(strResult);
		
		var linkStaArr = new Array("N","Y","--");
		var color0,color1;
		
		if(link0_st==1)
			color0="#0000ff";
		else if(link0_st==2)
			color0="#000000";
		else
			color0="#ff0000";
		
		if(link1_st==1)
			color1="#0000ff";
		else if(link1_st==2)
			color1="#000000";
		else
			color1="#ff0000";
		
		document.getElementById("link0_state").innerHTML = linkStaArr[link0_st];
		document.getElementById("link1_state").innerHTML = linkStaArr[link1_st];
		document.getElementById("link0_state").style.color = color0;
		document.getElementById("link1_state").style.color = color1;
	}
}

function OnSetTimer()
{
	timer = window.setInterval("getLinkSta()",10000);
}
</script>

<?php
$scroll_y = isset($scroll_y) ? $scroll_y : 0;
if($hideBoth==1)
	echo "<body topmargin=\"0\" leftmargin=\"12\">";
else
	echo "<body topmargin=\"0\" onLoad=\"OnSetTimer();self.scrollBy(0,$scroll_y);\" onunload=\"clearInterval(timer);\" leftmargin=\"12\">";

$objDB 			= "OBJ_390";
$paramTable 	= 'param_99';

$vms_sysId 		= "390_99_99";
$vms_slctSysId 	= "390_" . $TypeNo . "_0";

$vms_mtp3_sysId = "222_8_" . $TypeNo;
$vms_mtp3_slctSysId = "-1";

$mtp3_sysId 	= "222_99_99";
$mtp3_slctSysId = "-1";

$msc_sysId 		= "322_99_99";
$msc_slctSysId 	= "-1";

$vms_sccp_sysId = "223_8_" . $TypeNo;
$vms_sccp_slctSysId = "-1";

$iptrans_sysId 	= "221_0_".$TypeNo;

$vms_oidsysArr=array(
	array('oid' => '2.1',			'sysid' => $vms_sysId,		'selectsysid' => $vms_slctSysId),										
	array('oid' => '2.2',			'sysid' => $vms_sysId,		'selectsysid' => $vms_slctSysId),										
	array('oid' => '2.3',			'sysid' => $vms_sysId,		'selectsysid' => $vms_slctSysId),
	array('oid' => '2.4',			'sysid' => $vms_sysId,		'selectsysid' => $vms_slctSysId)									
);

$pub_oidsysArr=array(
	array('oid'=>'2.2',			'sysid'=> $mtp3_sysId,	'selectsysid'=> $mtp3_slctSysId),
	array('oid'=>'2.4.1',		'sysid'=> $mtp3_sysId,	'selectsysid'=> $mtp3_slctSysId),
	array('oid'=>'2.3',			'sysid'=> $mtp3_sysId,	'selectsysid'=> $mtp3_slctSysId),	//获得wxc2 dpc
	
	
	array('oid'=>'2.1.1',		'sysid'=> $msc_sysId,	'selectsysid'=> $msc_slctSysId),	
	array('oid'=>'2.1.2',		'sysid'=> $msc_sysId,	'selectsysid'=> $msc_slctSysId),
	array('oid'=>'2.1.3',		'sysid'=> $msc_sysId,	'selectsysid'=> $msc_slctSysId),
	array('oid'=>'2.1.4',		'sysid'=> $msc_sysId,	'selectsysid'=> $msc_slctSysId),
	array('oid'=>'2.1.6',		'sysid'=> $msc_sysId,	'selectsysid'=> $msc_slctSysId)
);

$mtp3_vms_oidsysArr=array(
	array('oid'=>'2.2',			'sysid'=> $vms_mtp3_sysId,	'selectsysid'=> $vms_mtp3_slctSysId), 	
	array('oid'=>'2.3',			'sysid'=> $vms_mtp3_sysId,	'selectsysid'=> $vms_mtp3_slctSysId),	//vms dpc		
	array('oid'=>'2.4.1',		'sysid'=> $vms_mtp3_sysId,	'selectsysid'=> $vms_mtp3_slctSysId), //vms linkset			
	array('oid'=>'2.6',			'sysid'=> $vms_mtp3_sysId,	'selectsysid'=> $vms_mtp3_slctSysId), //vms route	
		
	array('oid'=>'2.2',			'sysid'=> '223_99_99',		'selectsysid'=> '-1'),			
	array('oid'=>'2.1.8',		'sysid'=> $vms_sccp_sysId,	'selectsysid'=> $vms_sccp_slctSysId),	
	array('oid'=>'2.2',			'sysid'=> $vms_sccp_sysId,	'selectsysid'=> $vms_sccp_slctSysId),
	
);

$SaveArr=array(
	array('oidstr'=>'3.1',	'setvalue'=>'01'	,'sysid'=> $vms_sysId,		'selectsysid'=> $vms_slctSysId),
	array('oidstr'=>'3.7',	'setvalue'=>'02'	,'sysid'=> $vms_mtp3_sysId,	'selectsysid'=> $vms_mtp3_slctSysId),
	array('oidstr'=>'3.2',	'setvalue'=>'02'	,'sysid'=> $vms_sccp_sysId,	'selectsysid'=> $vms_sccp_slctSysId),
	array('oidstr'=>'3.2',	'setvalue'=>'02'	,'sysid'=> '223_99_99',		'selectsysid'=>'-1'),
	array('oidstr'=>'3.2',	'setvalue'=>'B5'	,'sysid'=> '322_99_99',		'selectsysid'=>'-1'),
);
{//DPC
	$DPC_sysId = '222_99_99';
	
	$DPC_sysIdArr	= explode('_',$DPC_sysId);
	$DPC_sysTypeNo	= $DPC_sysIdArr[0];
	$DPC_sysNo		= $DPC_sysIdArr[1];
	$DPC_subSysNo	= $DPC_sysIdArr[2];
	
	$DPC_oidstr = '2.4.1';
	$DPC_objWhereStr= '';	
	$DPC_objWhereStr =getLevelWhere($DPC_oidstr);
	$DPC_objDb		= 'OBJ_'.$DPC_sysTypeNo;
	$DPC_paramTable = 'param_'.$DPC_sysNo;		
	
	$DPC_paramSql = " SELECT initValue,readValue,instanceNo FROM $DPC_paramTable  
				WHERE $DPC_objWhereStr AND instanceNo ='$linkset' 
				";
	if($DEBUG) echo "$DPC_paramSql<br>";
	$DPC_Result = mysqli_query($pubConn,$DPC_paramSql);
	$DPC_Row	= mysqli_fetch_array($DPC_Result);
	$DPC= hexdec(getBitValue($DPC_Row[initValue],'0.0-2.7'));
	$NetID 		= bindec(getBitValue($DPC_Row[initValue],'3.0-3.1'));		
}

if(isset($doingOtherFlag))
{
	if($setPLMNServNo || $setPSTNServNo || $setLeaveMessNo||$setCheckMessNo)
	{
		$callType = 0;//normal
		
		$prefix_instance_no=updatePrefix($oldValue,$newValue,$callType,$trunkgp);
		//=======================to set the cli type to IDD   =========
		//=======================get the initValue ============
		$database="OBJ_322";
		$sql="select initValue from param_99 where level_1=2 and level_2=1 and level_3=2 and instanceNo='$prefix_instance_no' ";
		$result=@mysqli_query($pubConn,$sql);
		$rows=@mysqli_fetch_array($result);
		$old_initValue=$rows[initValue];
		$new_initValue=substr($old_initValue,0,35);
		//set cli type to IDD
		$new_initValue.="2";
		$new_initValue.=substr($old_initValue,36,4);
	////=======
		$objDB="OBJ_322";
		$oidstr = "2.1.2";
		$objWhereStr = getLevelWhere($oidstr);		
		
		$updSql = "update param_99 set initValue='$new_initValue' where $objWhereStr and instanceNo='$prefix_instance_no'";
		mysqli_query($pubConn,$updSql);
		//=======================================
	
		$vms_tmpOidArr=array(
			array('oid'=>'2.1.1',		'sysid'=> $msc_sysId,	'selectsysid'=> $msc_slctSysId),	
			array('oid'=>'2.1.2',		'sysid'=> $msc_sysId,	'selectsysid'=> $msc_slctSysId),
			array('oid'=>'2.1.3',		'sysid'=> $msc_sysId,	'selectsysid'=> $msc_slctSysId),
			array('oid' => '2.2.1.1',		'sysid' => $vms_sysId,	'selectsysid' => '-1')
		);
		SetParam($vms_tmpOidArr);
		exit;
	}
	if(isset($setSCCP_MSISDN))
	{
		{//set VMS SCCP 2.1.8
			$ipSql = "SELECT sysNo,subSysNo,ip FROM sysInfo
					WHERE sysTypeNo='390' AND sysNo='$TypeNo' AND subSysNo='0'
				";
			$ipResult= mysqli_query($pubConn,$ipSql);
			$Row=mysqli_fetch_array($ipResult);
			
			$IP	= explode('.',$Row[ip]);	
			$IP[0] = omc_keep_length(dechex($IP[0]),"0","2");
			$IP[1] = omc_keep_length(dechex($IP[1]),"0","2");
			$IP[2] = omc_keep_length(dechex($IP[2]),"0","2");
			$IP[3] = omc_keep_length(dechex($IP[3]),"0","2");
			$VMS_ip = $IP[0].$IP[1].$IP[2].$IP[3];	
			
			$sysId = "223_8_" . $TypeNo;
			$oidStr = '2.1.8';	
			$otherWhereStr = "and subSysNo=$TypeNo";
			setParamValue($VMS_ip,$sysId,$oidStr,3,0,$otherWhereStr);
			setParamValue($NetID,$sysId,$oidStr,1,0,$otherWhereStr);
		}//end set VMS SCCP 2.1.8
		$SCCP_MSISDN = $newValue;
		$SCCP_MSISDN_old = $oldValue;
		{//set Dailing prefix
			$callType = 0;//normal
			$prefix_instance_no=updatePrefix($SCCP_MSISDN_old,$SCCP_MSISDN,$callType,$trunkgp);
			//=======================to set the cli type to IDD   =========
			//=======================get the initValue ============
			$database="OBJ_322";
			$sql="select initValue from param_99 where level_1=2 and level_2=1 and level_3=2 and instanceNo='$prefix_instance_no' ";
			$result=@mysqli_query($pubConn,$sql);
			$rows=@mysqli_fetch_array($result);
			$old_initValue=$rows[initValue];
			$new_initValue=substr($old_initValue,0,35);
			//set cli type to IDD
			$new_initValue.="2";
			$new_initValue.=substr($old_initValue,36,4);
		////=======
			$objDB="OBJ_322";
			$oidstr = "2.1.2";
			$objWhereStr = getLevelWhere($oidstr);		
			
			$updSql = "update param_99 set initValue='$new_initValue' where $objWhereStr and instanceNo='$prefix_instance_no'";
			mysqli_query($pubConn,$updSql);
			//=======================================
			
			
			
		}//end set Dailing prefix
		if($newValue===$oldValue) exit;
		{//SCF-- GTT table param_99
			$sccp_objDB = 'OBJ_223';
			$tmpTable = 'param_99';
			$tmpConf = 'paramConf';
			$oidstr = '2.2';		
			$objWhereStr = getLevelWhere($oidstr);
			$getSql="SELECT instanceNo,initValue FROM $tmpTable WHERE $objWhereStr AND initValue LIKE '01%' ";
			if(0) echo "<BR>getSql=$getSql";
			$result	=mysqli_query($pubConn,$getSql);
			$haveSeted = 0;
			while($rows	=mysqli_fetch_array($result))
			{
				$tmpStartSCCP_MSISDN = getBitValue($rows[initValue],'03.0-12.7');
				$tmpStartSCCP_MSISDN = str_replace('F','',$tmpStartSCCP_MSISDN);
				
				$tmpEndSCCP_MSISDN = getBitValue($rows[initValue],'13.0-22.7');
				$tmpEndSCCP_MSISDN = str_replace('F','',$tmpEndSCCP_MSISDN);
				
				$tmpNi = hexdec(getBitValue($rows[initValue],'23.0-23.7'));
				$tmpDpc = hexdec(getBitValue($rows[initValue],'24.0-26.7'));
				$tmpSSN = hexdec(getBitValue($rows[initValue],'27.0-27.7'));
				if(strcmp($tmpStartSCCP_MSISDN,$SCCP_MSISDN_old)==0
					&& strcmp($tmpStartSCCP_MSISDN,$tmpEndSCCP_MSISDN)==0 && $tmpSSN == 0)
				{
					//echo "<br>$tmpStartSCCP_MSISDN<br>$SCCP_MSISDN_old";
					$tmpInstanceNo = $rows[instanceNo];
					$haveSeted = 1;
					break;
				}
				//echo "<br>$tmpStartSCCP_MSISDN<br>$SCCP_MSISDN_old<br>";
			}
			//exit;
			if($haveSeted)
			{
				$setInstNo = $tmpInstanceNo;
			}
			else
			{
				$getSql="SELECT instanceNo,initValue FROM $tmpTable WHERE $objWhereStr AND initValue LIKE '00%' ";
				if(0) echo "<BR>getSql=$getSql";
				$result	=mysqli_query($pubConn,$getSql);
				$rows	=mysqli_fetch_array($result);
				$setInstNo = $rows[instanceNo];
			}
			$niTypeArr = getNiType();
			if($niTypeArr[$NetID]==0)//ITU
			{
				$TT = '00';
				$NP = '01';
			}
			else
			{
				$TT = '0E';
				$NP = '00';
			}
			if(strlen($SCCP_MSISDN)==0)
			{
				$rows[initValue] = "000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000000000000000FFFFFFFFFFFFFFFFFFFF";
			}
			else
			{
				$rows[initValue] = setBitValue($rows[initValue],'0.0-0.7','01');//flag
				$rows[initValue] = setBitValue($rows[initValue],'01.0-01.7',$NP);//SCCP_MSISDN
				$rows[initValue] = setBitValue($rows[initValue],'02.0-02.7',$TT);//SCCP_MSISDN
				$tmp = omc_keep_length($SCCP_MSISDN,'F',20,0);
				$rows[initValue] = setBitValue($rows[initValue],'03.0-12.7',$tmp);//
				$rows[initValue] = setBitValue($rows[initValue],'13.0-22.7',$tmp);//
				$tmp = omc_keep_length($NetID,'0',2);
				$rows[initValue] = setBitValue($rows[initValue],'23.0-23.7',$tmp);//NI
				$tmp = omc_keep_length(dechex($DPC),'0',6);
				$rows[initValue] = setBitValue($rows[initValue],'24.0-26.7',$tmp);//DPC WXC2sp		
				$tmp = omc_keep_length(dechex(0),'0',2);
				$rows[initValue] = setBitValue($rows[initValue],'27.0-27.7',$tmp);//SSN=0
				$tmp = omc_keep_length(dechex(7),'0',2);
				$rows[initValue] = setBitValue($rows[initValue],'29.0-29.7',$tmp);//Address indicator
			}
			$rows[initValue] = strtoupper($rows[initValue]);
			//echo "<br>rows[initValue]:{$rows[initValue]}";
			$updflag = "UPDATE $tmpTable SET initValue = '$rows[initValue]' 
		        			WHERE $objWhereStr and instanceNo='$setInstNo'
		        			";								
		  if(0) echo "<br>$updflag<br>";
		  //exit;
			mysqli_query($pubConn,$updflag);
			echo mysqli_error($pubConn);
			
			{//set gtt attribution from 2.4
				$selSql = "select initValue from $tmpTable where level_1='2' and level_2='4' and instanceNo='$instanceNo'";
				$Result = mysqli_query($pubConn,$selSql);
				$Row = mysqli_fetch_array($Result);
				$setValue = $Row[initValue];
				$eleName = $Spname;
				$tmpEleName = omc_keep_length(toHex($eleName),"0",20,"0");
				
				$setValue = setBitValue($setValue,'3.0-12.7',$tmpEleName);
				
				$updSql = "update $tmpTable set initValue = '$setValue' where level_1='2' and level_2='4' and instanceNo='$setInstNo'";
				mysqli_query($pubConn,$updSql);
				echo mysqli_error($pubConn);
			}//end set gtt attribution form 2.4			
		}//end gtt table.
		
		$vms_tmpOidArr=array(
			array('oid'=>'2.1.1',		'sysid'=> $msc_sysId,	'selectsysid'=> $msc_slctSysId),	
			array('oid'=>'2.1.2',		'sysid'=> $msc_sysId,	'selectsysid'=> $msc_slctSysId),
			array('oid'=>'2.1.3',		'sysid'=> $msc_sysId,	'selectsysid'=> $msc_slctSysId),
			array('oid'=>'2.1.8',		'sysid'=> $vms_sccp_sysId,	'selectsysid'=> $vms_sccp_slctSysId)
		);
		SetParam($vms_tmpOidArr);
		
		$sccpSaveArr=array(
			array('oidstr'=>'3.2',	'setvalue'=>'02', 'sysid'=> $vms_sccp_sysId, 'selectsysid'=> $vms_sccp_slctSysId)	
		);
		SaveParam($sccpSaveArr);
		$sccpResetArr=array(
			array('oidstr'=>'3.2',	'setvalue'=>'00', 'sysid'=> $vms_sccp_sysId, 'selectsysid'=> $vms_sccp_slctSysId)	
		);
		SaveParam($sccpResetArr);
		
		exit;
	}//end if(isset($SCCP_MSISDN_save))
}//

if($_SERVER['REQUEST_METHOD'] == "POST")
{	
	{//Signaling/Traffic
		if(isset($LicenseCtl_save))
		{
			$tmp = "LicenseCtl";		
			$tmp = ${$tmp};
			$tmp = omc_keep_length($tmp,'0',16);
			$oidstr = "2.5";
			$objWhereStr = getLevelWhere($oidstr);
			$updflag = "UPDATE $paramTable SET initValue = '$tmp' 
		        			WHERE $objWhereStr and instanceNo='$TypeNo'";
	
			mysqli_query($pubConn,$updflag);
			echo mysqli_error($pubConn);
			$tmp_vms_oidsysArr=array(
				array('oid' => '2.5',			'sysid' => $vms_sysId,		'selectsysid' => $vms_slctSysId),										
			);
			SetParam($tmp_vms_oidsysArr);
			$i=0;
			while(1)
			{
				echo "<img border=\"0\" src=\"../../images/arrow.gif\" width=\"10\" height=\"10\">";
				flush();
				sleep(1);
				$i++;
				if($i>10)
					break;
			}
			goLastWeb();
		}
	}
	if($setVMS==1)
	{
		//Basic Parameters
		{
			if(isset($SMSC_port_save)
			 ||isset($SMSC0_ip_save)
			 ||isset($SMSC1_ip_save)
			 ||isset($setSys))
			{
				$oidstr = "2.2.1.6";
				$objWhereStr = getLevelWhere($oidstr);
				$getsql = "select initValue from $paramTable 
									where $objWhereStr
									";
				$result = @mysqli_query($pubConn,$getsql);
				$row = @mysqli_fetch_array($result);
				$setValue=$row[0];
				
				$tmp = dechex($SMSC_port);
				$tmp = omc_keep_length($tmp,'0',4);
				$setValue = setBitValue($setValue,'00.0-01.7',$tmp);
				
				$IP	= explode('.',$SMSC0_ip);
				$IP[0] = omc_keep_length(dechex($IP[0]),"0","2");
				$IP[1] = omc_keep_length(dechex($IP[1]),"0","2");
				$IP[2] = omc_keep_length(dechex($IP[2]),"0","2");
				$IP[3] = omc_keep_length(dechex($IP[3]),"0","2");
				$tmp = $IP[0].$IP[1].$IP[2].$IP[3];
				$setValue = setBitValue($setValue,'02.0-05.7',$tmp);
				
				$IP	= explode('.',$SMSC1_ip);	
				$IP[0] = omc_keep_length(dechex($IP[0]),"0","2");
				$IP[1] = omc_keep_length(dechex($IP[1]),"0","2");
				$IP[2] = omc_keep_length(dechex($IP[2]),"0","2");
				$IP[3] = omc_keep_length(dechex($IP[3]),"0","2");
				$tmp = $IP[0].$IP[1].$IP[2].$IP[3];
				$setValue = setBitValue($setValue,'06.0-09.7',$tmp);
				
				$updflag = "UPDATE $paramTable SET initValue = '$setValue' 
			        			WHERE $objWhereStr
			        			";								
				if($DEBUG) echo "$updflag<br>";
				mysqli_query($pubConn,$updflag);
				echo mysqli_error($pubConn);
				if(!isset($setSys))
					goLastWeb();
			}
			
			if(isset($PPS0_ip_save)||isset($PPS1_ip_save)||isset($setSys))
			{
				$oidstr = "2.2.1.7";
				$objWhereStr = getLevelWhere($oidstr);
				$getsql = "select initValue from $paramTable 
									where $objWhereStr
									";
				$result = @mysqli_query($pubConn,$getsql);
				$row = @mysqli_fetch_array($result);
				$setValue=$row[0];
		
				$IP	= explode('.',$PPS0_ip);
				$IP[0] = omc_keep_length(dechex($IP[0]),"0","2");
				$IP[1] = omc_keep_length(dechex($IP[1]),"0","2");
				$IP[2] = omc_keep_length(dechex($IP[2]),"0","2");
				$IP[3] = omc_keep_length(dechex($IP[3]),"0","2");
				$tmp = $IP[0].$IP[1].$IP[2].$IP[3];
				$setValue = setBitValue($setValue,'02.0-05.7',$tmp);
				
				$IP	= explode('.',$PPS1_ip);	
				$IP[0] = omc_keep_length(dechex($IP[0]),"0","2");
				$IP[1] = omc_keep_length(dechex($IP[1]),"0","2");
				$IP[2] = omc_keep_length(dechex($IP[2]),"0","2");
				$IP[3] = omc_keep_length(dechex($IP[3]),"0","2");
				$tmp = $IP[0].$IP[1].$IP[2].$IP[3];
				$setValue = setBitValue($setValue,'06.0-09.7',$tmp);
				
				$updflag = "UPDATE $paramTable SET initValue = '$setValue' 
			        			WHERE $objWhereStr
			        			";								
				if($DEBUG) echo "$updflag<br>";
				mysqli_query($pubConn,$updflag);
				echo mysqli_error($pubConn);
				if(!isset($setSys))
					goLastWeb();
			}
		}
	}
	if(isset($setSys) || isset($getSys))
	{
		if(isset($setSys))
		{
			echo "<br>Setting parameters<br>";
			SetParam($vms_oidsysArr);				
			SetParam($pub_oidsysArr);				
			SetParam($mtp3_vms_oidsysArr);	
						
			SaveParam($SaveArr);
		}
		else
		{ 
			echo "<br>Getting parameters<br>";
			GetParam($vms_oidsysArr);
			GetParam($mtp3_vms_oidsysArr);
		}
	}
}
if($setSys || $getSys  || $undoSet)
{
	echo "<br><br><h4><font color=\"#0000ff\">Finished!</font></h4>";
	if($DEBUG) exit();
	goLastWeb();
}


echo "<form method=\"POST\" name=\"setForm\" action=\"$backurl_un&scroll_y=$scroll_y\">";

{//show head part
	echo "<table border=\"0\" width=\"100%\">";
	echo "<tr>";
	echo "<td width=\"50%\">";
	//echo "$strConfiguration > $strNetwork > VMS";
	echo "Configuration > <a href=\"../overview/overview.php\">Network</a> > <a href=\"#\">VSS</a>";
	echo "</td>";
	echo "<td width=\"50%\" align=\"right\" title=\"Help\">";
	showHelp($helpId);
	echo "</td>";
	echo "</tr>";
	echo "</table>";
	echo "<br>";
	
	//checkDevices(390);

	{
		echo "<table width=\"100%\">";
		echo "<tr>";
			echo "<td width=\"70%\">";
				echo "<b>VSS System</b>&nbsp;&nbsp;$Spname";
			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=\"javascript:backpage(0,'../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 "<input type=\"hidden\" name=\"linkset\" value=\"$linkset\">";
		echo "<input type=\"hidden\" name=\"trunkgp\" value=\"$trunkgp\">";
		echo "<input type=\"hidden\" name=\"scroll_y\" value=\"$scroll_y\">";
		echo "<input type=\"hidden\" name=\"infoNo\" value=\"$infoNo\">";
		echo "</table>";
		echo "<br>";
	}
}
if($hideBoth == 1)
{
	echo "<table>";
		echo "<tr >";
			echo "<td >Input License Please:&nbsp;</td>";
			echo "<td>";
				echo "<input type = \"text\" name = \"LicenseCtl\"	value = \"\" size = \"18\" maxlength = \"16\" class=\"text\">&nbsp;";
				echo "<input type=\"submit\" name=\"LicenseCtl_save\" value=\"Save\" onmouseover=\"this.className='style4'\" 	onmouseout=\"this.className='style3'\" class=\"style3\">";
			echo "</td>";
		echo "</tr >";
	echo "</table>";
	exit;
}
{//get parameters

	
	{//WXC2 OPC		
		$oidstr = '2.2';
		$vms_link_Db = 'OBJ_222';	
		$vms_link_Table  = 'param_99';
		
		$subSysNo = 99;
		$objWhereStr= '';
		$objWhereStr =getLevelWhere($oidstr);
		$paramSql = " SELECT initValue,readValue,instanceNo FROM $vms_link_Table  
					WHERE $objWhereStr AND subSysNo = '$subSysNo'
					";
		if($DEBUG) echo "$paramSql<br>";			
		$vms_Result = mysqli_query($pubConn,$paramSql);
		$vms_Row	= mysqli_fetch_array($vms_Result);
									
		$NIbit	= getBitValue($vms_Row[initValue],"0.$NetID");
		$tmp	= $NetID+1+$NIbit*4;
		$oidstr = '2.3.'.$tmp;
		$objWhereStr= '';
		$objWhereStr =getLevelWhere($oidstr);
		$updSql = "SELECT initValue FROM $vms_link_Table
				   WHERE $objWhereStr AND instanceNo = '0' AND subSysNo = '$subSysNo'
								";
		$Result	= mysqli_query($pubConn,$updSql);
		$Row	= mysqli_fetch_array($Result);
		$WXC2OPC = hexdec($Row[initValue]);
	}
	
	{//MG IP
		$oidstr = "2.1.6";
		$objWhereStr = getLevelWhere($oidstr);
		$getsql = "select initValue from $paramTable 
							where $objWhereStr order by instanceNo";
		$result = @mysqli_query($pubConn,$getsql);
		$row = @mysqli_fetch_array($result);
		$mgIp = getBitValue($row[0],'0.0-3.7');
		for($i=0; $i<4; $i++)
		{
			$tmp = hexdec(substr($mgIp,$i*2,2));
			$mgIp_0 .= $tmp . '.';
		}
		$mgIp_0 = rtrim($mgIp_0,'.');
		
		$row = @mysqli_fetch_array($result);
		$mgIp = getBitValue($row[0],'0.0-3.7');
		for($i=0; $i<4; $i++)
		{
			$tmp = hexdec(substr($mgIp,$i*2,2));
			$mgIp_1 .= $tmp . '.';
		}
		$mgIp_1 = rtrim($mgIp_1,'.');
	}
	{//SMSC address
		$oidstr = "2.2.1.6";
		$objWhereStr = getLevelWhere($oidstr);
		$getsql = "select initValue from $paramTable 
							where $objWhereStr
							";
		$result = @mysqli_query($pubConn,$getsql);
		$row = @mysqli_fetch_array($result);
		//SMSC_port
		$SMSC_port = hexdec(getBitValue($row[0],'0.0-1.7'));
		//SMSC0 IP
		$hexip = getBitValue($row[0],'2.0-5.7');
		$ip[0]=hexdec(getBitValue($hexip,"0.0-0.7"));
		$ip[1]=hexdec(getBitValue($hexip,"1.0-1.7"));
		$ip[2]=hexdec(getBitValue($hexip,"2.0-2.7"));
		$ip[3]=hexdec(getBitValue($hexip,"3.0-3.7"));
		$SMSC0_ip = $ip[0] . "." . $ip[1] . "." . $ip[2] . "." . $ip[3];
		//SMSC1 IP
		$hexip = getBitValue($row[0],'6.0-9.7');
		$ip[0]=hexdec(getBitValue($hexip,"0.0-0.7"));
		$ip[1]=hexdec(getBitValue($hexip,"1.0-1.7"));
		$ip[2]=hexdec(getBitValue($hexip,"2.0-2.7"));
		$ip[3]=hexdec(getBitValue($hexip,"3.0-3.7"));
		$SMSC1_ip = $ip[0] . "." . $ip[1] . "." . $ip[2] . "." . $ip[3];
	}
	
	{//PPS address
		$oidstr = "2.2.1.7";
		$objWhereStr = getLevelWhere($oidstr);
		$getsql = "select initValue from $paramTable 
							where $objWhereStr
							";
		$result = @mysqli_query($pubConn,$getsql);
		$row = @mysqli_fetch_array($result);
		
		//PPS0 IP
		$hexip = getBitValue($row[0],'2.0-5.7');
		$ip[0]=hexdec(getBitValue($hexip,"0.0-0.7"));
		$ip[1]=hexdec(getBitValue($hexip,"1.0-1.7"));
		$ip[2]=hexdec(getBitValue($hexip,"2.0-2.7"));
		$ip[3]=hexdec(getBitValue($hexip,"3.0-3.7"));
		$PPS0_ip = $ip[0] . "." . $ip[1] . "." . $ip[2] . "." . $ip[3];
		//PPS1 IP
		$hexip = getBitValue($row[0],'6.0-9.7');
		$ip[0]=hexdec(getBitValue($hexip,"0.0-0.7"));
		$ip[1]=hexdec(getBitValue($hexip,"1.0-1.7"));
		$ip[2]=hexdec(getBitValue($hexip,"2.0-2.7"));
		$ip[3]=hexdec(getBitValue($hexip,"3.0-3.7"));
		$PPS1_ip = $ip[0] . "." . $ip[1] . "." . $ip[2] . "." . $ip[3];
	}

	{//Link0 type
		$oidstr = "2.1.8";
		$objWhereStr = getLevelWhere($oidstr);
		$getsql = "select initValue from $paramTable 
							where $objWhereStr";
		$result = @mysqli_query($pubConn,$getsql);
		$row = @mysqli_fetch_array($result);
		$link0_type = hexdec($row[initValue]);
	}
	{//Link1 type
		$oidstr = "2.1.8";
		$objWhereStr = getLevelWhere($oidstr);
		$getsql = "select initValue from $paramTable 
							where $objWhereStr";
		$result = @mysqli_query($pubConn,$getsql);
		$row = @mysqli_fetch_array($result);
		$link1_type = hexdec($row[initValue]);
	}
	{//encode_rule0
		$oidstr = "2.1.9";
		$objWhereStr = getLevelWhere($oidstr);
		$getsql = "select initValue from $paramTable 
							where $objWhereStr";
		$result = @mysqli_query($pubConn,$getsql);
		$row = @mysqli_fetch_array($result);
		$encode_rule0 = hexdec($row[initValue]);
	}
	{//encode_rule1 
		$oidstr = "2.1.9";
		$objWhereStr = getLevelWhere($oidstr);
		$getsql = "select initValue from $paramTable 
							where $objWhereStr";
		$result = @mysqli_query($pubConn,$getsql);
		$row = @mysqli_fetch_array($result);
		$encode_rule1 = hexdec($row[initValue]);
	}
	{//ISUP_TYPE_LK0
		$oidstr = "2.1.10";
		$objWhereStr = getLevelWhere($oidstr);
		$getsql = "select initValue from $paramTable 
							where $objWhereStr";
		$result = @mysqli_query($pubConn,$getsql);
		$row = @mysqli_fetch_array($result);
		$ISUP_TYPE_LK0 = hexdec($row[initValue]);
	}
	{//ISUP_TYPE_LK1 
		$oidstr = "2.1.10";
		$objWhereStr = getLevelWhere($oidstr);
		$getsql = "select initValue from $paramTable 
							where $objWhereStr";
		$result = @mysqli_query($pubConn,$getsql);
		$row = @mysqli_fetch_array($result);
		$ISUP_TYPE_LK1 = hexdec($row[initValue]);
	}
	{//SCCP 2.1.8 MSISDN
		$sccp_objDB = 'OBJ_223';
		$tmpTable = 'param_8';
		$oidstr = '2.1.8';	
		$objWhereStr = getLevelWhere($oidstr);	
		$getsql = "select initValue from $tmpTable 
					where $objWhereStr";
		$result = @mysqli_query($pubConn,$getsql);
		$row = @mysqli_fetch_array($result);
		$SCCP_MSISDN_value = getBitValue($row[0],"01.0-10.7");
		$SCCP_MSISDN_value = str_replace('F','',$SCCP_MSISDN_value);
		echo "<input type=\"hidden\" name=\"SCCP_MSISDN_old\" value=\"$SCCP_MSISDN_value\">";
	}
	{//SCCP SCF --- MSISDN(SCF_num) arwean
		$sccp_objDB = 'OBJ_223';
		$tmpTable = 'param_99';
		$oidstr = '2.1.147';
		$objWhereStr = getLevelWhere($oidstr);
		$getsql = "select initValue from $tmpTable 
							where $objWhereStr
							";
		$result = @mysqli_query($pubConn,$getsql);
		$row = @mysqli_fetch_array($result);
		$SCF_num	= getBitValue($row[initValue],"01.0-10.7");
		$SCF_num = str_replace('F','',$SCF_num);
		echo "<input type=\"hidden\" name=\"SCF_num\" value=\"$SCF_num\">";
	}
	
	{//link0 status

		$vmsLink0_status=$sttE0[1];
		$vmsLink1_status=$sttE1[1];
		if($vmsLink0_status==1)
			$color_vmsLink0_stat='blue';
		elseif($vmsLink0_status==0)
			$color_vmsLink0_stat='red';
			
		if($vmsLink1_status==1)
			$color_vmsLink1_stat='blue';
		elseif($vmsLink1_status==0)
			$color_vmsLink1_stat='red';
	}
}//end get parameters

$linkStaArr=array("N","Y","--");
if($setAAS==1)
	$bcAAS = '#E6E6E6';
else
	$bcAAS = '';
if($setVMS==1)
	$bcVMS = '#E6E6E6';
else
	$bcVMS = '';
echo "<table width=\"24%\">";
	echo "<tr>";
		if($aasDisable != 1)
		{
			echo "<td align=\"center\" bgcolor=\"$bcAAS\" width=\"12%\">";
				echo "<a href=\"$selfurl&setAAS=1\"><b>AAS Service</b></a>";
			echo "</td>";
		}
		if($vmsDisable != 1)
		{
			echo "<td align=\"center\" bgcolor=\"$bcVMS\" width=\"12%\">";
				echo "<a href=\"$selfurl&setVMS=1\"><b>VMS Service</b></a>";
			echo "</td>";
		}
	echo "</tr>";
	echo "<input type=\"hidden\" name=\"setAAS\" value=\"$setAAS\">";
	echo "<input type=\"hidden\" name=\"setVMS\" value=\"$setVMS\">";
echo "</table>";
echo "</table>";
{//Signaling/Traffic
echo "<table border=\"1\" width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" bordercolor=\"#666666\" bordercolordark=\"#FFFFFF\"> ";
	echo "<tr><th colspan=\"2\"><b>Signaling/Traffic</b></th></tr>";
	echo "<tr>";
		echo "<td width=\"15%\" bgcolor=\"#E6E6E6\">Signaling Point Code</td>";
		echo "<td>$DPC</td>";
		echo "<input type=\"hidden\" name=\"DPC\" value=\"$DPC\">";
	echo "</tr>";
	
	echo "<tr >";
		echo "<td bgcolor=\"#E6E6E6\" >Network Indicator</td>";
		echo "<td>$NetIdConfArr[$NetID]";
		echo "<input type=\"hidden\" name=\"NetID\" value=\"$NetID\">";
		echo "</td>";
	echo "</tr >";
	echo "<input type=\"hidden\" name=\"WXC2OPC\" value=\"$WXC2OPC\">";
	{//network number
		echo "<tr >";
			echo "<td bgcolor=\"#E6E6E6\">Network Number</td>";
			echo "<td><table width=\"100%\"><tr>";
			echo "<td width=\"15%\">CC:</td>";
			echo "<td width=\"35%\">";
			$sysId="390_99_99";
			$oidStr = "2.1.3";
			showParameter($sysId,$oidStr,1,1);
						
			echo "</td>";
			echo "<td width=\"15%\">NDC:</td>";
			echo "<td width=\"35%\">";
			$oidStr = "2.1.4";
			showParameter($sysId,$oidStr,1,1);
			echo "</td>";
			echo "</tr>";
			echo "<tr>";
			if($setAAS)
			{
				echo "<td width=\"15%\">MSISDN(SCCP):</td>";
				echo "<td width=\"35%\">";
				$sysId="223_8_" . $TypeNo;
				$oidStr = "2.1.8";
				$instanceNo = 0;
				$otherWhereStr = "and subSysNo=$TypeNo";
				$doingOtherUlr="$PHP_SELF?doingOtherFlag=1&setSCCP_MSISDN=1&infoNo=$infoNo&linkset=$linkset&trunkgp=$trunkgp";
				showParameter($sysId,$oidStr,2,1,$instanceNo,$doingOtherUlr,$otherWhereStr);
				echo "</td>";
			}
			if($setVMS)
			{
//				echo "<td width=\"15%\">MSISDN(local):</td>";
//				echo "<td width=\"35%\">$local_MSISDN</td>";
				echo "<input type=\"hidden\" name = \"SCCP_MSISDN\"	value = \"$SCCP_MSISDN_value\">";
			}
			echo "</tr></table></td>";
		echo "</tr>";
	}//end network number	
	
	{//star link
		echo "<tr >";
		echo "<td width=\"15%\" bgcolor=\"#E6E6E6\">Link</td>";	
		echo "<td><table width=\"100%\">";
		echo "<tr>";
		echo "<td width=\"5%\"><b>No</b></td>"; 
		echo "<td width=\"15%\"><b>E1/T1</b></td>"; 
		echo "<td width=\"15%\"><b>ITU/ANSI</b></td>";
		echo "<td width=\"20%\"><b>A/MU LAW</b></td>";
		echo "<td width=\"15%\"><b>CIC</b></td>";
		echo "<td width=\"25%\"><b>MG IP</b></td>";
		echo "<td width=\"5%\"><b>Status</b></td>";
		echo "</tr>";
		
		echo "<tr>";
			echo "<td>0</td>"; 
			echo "<td rowspan=\"2\">";	
				$sysId="390_99_99";
				$oidStr = "2.1.8";
				showParameter($sysId,$oidStr,1,1);				
			echo"</td>"; 
			
			echo "<td rowspan=\"2\">";
				$oidStr = "2.1.10";
				showParameter($sysId,$oidStr,1,1);				
			echo "</td>";
					
			echo "<td rowspan=\"2\">";	
				$oidStr = "2.1.9";
				showParameter($sysId,$oidStr,1,1);				
			echo"</td>"; 
		
			echo "<td>";
				$oidStr = "2.1.7"; 
				showParameter($sysId,$oidStr,1,1);			
			echo "</td>";	
			
			$i=0;
			$mgIpName = "mgIp_".$i;
			$mgIp = $$mgIpName;
			echo "<td>$mgIp</td>";
			$linkStateId = "link".$i."_state";
			$colorState = ${"color_vmsLink".$i."_stat"};
			$vmsLinkState = ${"vmsLink".$i."_status"};
			echo "<td><span id=\"$linkStateId\" style=\"color:$colorState\">{$linkStaArr[$vmsLinkState]}</span></td>";	
		echo "</tr>";
			
		echo "<tr>";
			echo "<td>1</td>";
			echo "<td>";
				$oidStr = "2.1.7"; 
				showParameter($sysId,$oidStr,2,1);			
			echo "</td>";	
			$i=1;
			$mgIpName = "mgIp_".$i;
			$mgIp = $$mgIpName;
			echo "<td>$mgIp</td>";
			$linkStateId = "link".$i."_state";
			$colorState = ${"color_vmsLink".$i."_stat"};
			$vmsLinkState = ${"vmsLink".$i."_status"};
			echo "<td><span id=\"$linkStateId\" style=\"color:$colorState\">{$linkStaArr[$vmsLinkState]}</span></td>";	

		echo "</tr>";
		
		echo "</table></td></tr>";
	}//end link
	if($licenseFlg==2)	$licenseStr = 'AAS';
	else if($licenseFlg==1)	$licenseStr = 'VMS';
	else if($licenseFlg==3)	$licenseStr = 'AAS and VMS';
	else	$licenseStr = 'Error';
	echo "<tr >";
		echo "<td bgcolor=\"#E6E6E6\" >License Control</td>";
		echo "<td>";
			if(isset($LicenseCtl_edit))
			{
				echo "<input type = \"text\" name = \"LicenseCtl\"	value = \"$LicenseCtl\" size = \"18\" maxlength = \"16\" class=\"text\">&nbsp;";
				echo "<input type=\"submit\" name=\"LicenseCtl_save\" value=\"save\" onmouseover=\"this.className='style4'\" 	onmouseout=\"this.className='style3'\" class=\"style3\">";
			}
			else
			{
				echo "<a href=javascript:linkTo('$backurl_un','LicenseCtl_edit=1')>$licenseStr</a>";
			}	
		echo "</td>";
	echo "</tr >";
	

echo "</table>";
}
echo "<br>";
if($setVMS)
{//Basic Parameters
echo "<table border=\"1\" width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" bordercolor=\"#666666\" bordercolordark=\"#FFFFFF\"> ";
	echo "<tr><th colspan=\"2\"><b>Basic Parameters</b></th></tr>";
	echo "<tr>";
	echo "<td width=\"15%\" bgcolor=\"#E6E6E6\">VMS Number</td>";
	echo "<td><table width=\"100%\">";
	{//show VMS Number
		echo "<tr>";
			echo "<td width=\"15%\">MSISDN:</td>";	
			echo "<td colspan=\"3\" width=\"85%\">";
			$sysId = "390_99_99";
			$oidStr = "2.2.1.1";
			$instanceNo=$TypeNo;
			showParameter($sysId,$oidStr,1,1,$instanceNo);
			echo "</td>";
		echo "</tr>";		
		echo "<tr>";
			echo "<td width=\"15%\">Service No. PLMN:</td>";
			echo "<td width=\"35%\">";
			$doingOtherUlr="$PHP_SELF?doingOtherFlag=1&setPLMNServNo=1&trunkgp=$trunkgp";
			showParameter($sysId,$oidStr,2,1,$instanceNo,$doingOtherUlr);
			echo "</td>";
			
			echo "<td width=\"15%\">Service No. PSTN:</td>";
			echo "<td width=\"35%\">";
			$doingOtherUlr="$PHP_SELF?doingOtherFlag=1&setPSTNServNo=1&trunkgp=$trunkgp";
			showParameter($sysId,$oidStr,3,1,$instanceNo,$doingOtherUlr);
			echo "</td>";
		echo "</tr>";		
		echo "<tr>";
			echo "<td width=\"15%\">Leave message:</td>";
			echo "<td width=\"35%\">";
			$doingOtherUlr="$PHP_SELF?doingOtherFlag=1&setLeaveMessNo=1&trunkgp=$trunkgp";
			showParameter($sysId,$oidStr,4,1,$instanceNo,$doingOtherUlr);
			echo "</td>";
			echo "<td width=\"15%\">Check message:</td>";
			echo "<td width=\"35%\">";
			$doingOtherUlr="$PHP_SELF?doingOtherFlag=1&setCheckMessNo=1&trunkgp=$trunkgp";
			showParameter($sysId,$oidStr,5,1,$instanceNo,$doingOtherUlr);
			echo "</td>";
		echo "</tr>";
	}
	echo "</table></td>";	
	echo "</tr>";
	
	echo "<tr>";
	echo "<td width=\"15%\" bgcolor=\"#E6E6E6\">SMPP Parameter</td>";	
	echo "<td><table width=\"100%\">";
	{//show ESME Parameter
		echo "<tr>";
			echo "<td width=\"15%\">SMPP ID:</td>";
			echo "<td width=\"35%\">";
			$sysId = "390_99_99";
			$oidStr = "2.2.1.2";
			$instanceNo=$TypeNo;
			showParameter($sysId,$oidStr,1,3,$instanceNo);
			echo "</td>";
			echo "<td width=\"15%\">SMPP type:</td>";
			echo "<td width=\"35%\">";
			$sysId = "390_99_99";
			$oidStr = "2.2.1.4";
			$instanceNo=$TypeNo;
			showParameter($sysId,$oidStr,1,3,$instanceNo);
			echo "</td>";
		echo "</tr>";			
		echo "<tr>";
			echo "<td width=\"15%\">SMPP password:</td>";
			echo "<td colspan=\"3\" width=\"85%\">";
			$sysId = "390_99_99";
			$oidStr = "2.2.1.3";
			$instanceNo=$TypeNo;
			showParameter($sysId,$oidStr,1,3,$instanceNo);
			echo "</td>";
		echo "</tr>";
	}
	echo "</table></td>";	
	echo "</tr>";
	
	echo "<tr>";		
	echo "<td width=\"15%\" bgcolor=\"#E6E6E6\">SMSC Address</td>";	
	echo "<td><table width=\"100%\">";
	{//show SMSC address
		echo "<tr>";
			echo "<td width=\"15%\">SMPP port:</td>";
			echo "<td colspan=\"3\" width=\"85%\">";
			if(isset($SMSC_port_edit))
			{
				echo "<input type = \"text\" name = \"SMSC_port\"	value = \"$SMSC_port\" size = \"6\" maxlength = \"5\"  onchange = checkInput(this,10,65535) class=\"text\">&nbsp;";
				echo "<input type=\"submit\" name=\"SMSC_port_save\" value=\"save\" onmouseover=\"this.className='style4'\" 	onmouseout=\"this.className='style3'\" class=\"style3\">";
			}
			else
			{
				echo "<input type=\"hidden\" name=\"SMSC_port\" value=\"$SMSC_port\">";
				if($SMSC_port ==='')
					$SMSC_port ='--';
				echo "<a href=javascript:linkTo('$backurl_un','SMSC_port_edit=1')>$SMSC_port</a>";		
			}
			echo "</td>";
		echo "</tr>";
		echo "<tr>";
			echo "<td width=\"15%\">SMSC0 IP:</td>";
			echo "<td width=\"35%\">";
			if(isset($SMSC0_ip_edit))
			{
				echo "<input type = \"text\" name = \"SMSC0_ip\"	value = \"$SMSC0_ip\" size = \"20\" maxlength = \"20\" class=\"text\" onchange=\"checkIP(this)\">&nbsp;";
				echo "<input type=\"submit\" name=\"SMSC0_ip_save\" value=\"save\" onmouseover=\"this.className='style4'\" 	onmouseout=\"this.className='style3'\" class=\"style3\">";
			}
			else
			{
				echo "<input type=\"hidden\" name=\"SMSC0_ip\" value=\"$SMSC0_ip\">";
				if($SMSC0_ip =='...')
					$SMSC0_ip ='--';
				echo "<a href=javascript:linkTo('$backurl_un','SMSC0_ip_edit=1')>$SMSC0_ip</a>";		
			}
			echo "</td>";
			
			echo "<td width=\"15%\">SMSC1 IP:</td>";
			echo "<td width=\"35%\">";
			if(isset($SMSC1_ip_edit))
			{
				echo "<input type = \"text\" name = \"SMSC1_ip\"	value = \"$SMSC1_ip\" size = \"20\" maxlength = \"20\" class=\"text\" onchange=\"checkIP(this)\">&nbsp;";
				echo "<input type=\"submit\" name=\"SMSC1_ip_save\" value=\"save\" onmouseover=\"this.className='style4'\" 	onmouseout=\"this.className='style3'\" class=\"style3\">";
			}
			else
			{
				echo "<input type=\"hidden\" name=\"SMSC1_ip\" value=\"$SMSC1_ip\">";
				if($SMSC1_ip =='...')
					$SMSC1_ip ='--';
				echo "<a href=javascript:linkTo('$backurl_un','SMSC1_ip_edit=1')>$SMSC1_ip</a>";		
			}
			echo "</td>";
		echo "</tr>";			
	}
	echo "</table></td>";	
	echo "</tr>";
	
	echo "<tr>";		
	echo "<td width=\"15%\" bgcolor=\"#E6E6E6\">PPS Address</td>";
	echo "<td><table width=\"100%\">";	
	{//show PPS address
		echo "<tr>";
		
		echo "<td width=\"15%\">PPS0 IP:</td>";
		echo "<td width=\"35%\">";
		
		if(isset($PPS0_ip_edit))
		{
			echo "<input type = \"text\" name = \"PPS0_ip\"	value = \"$PPS0_ip\" size = \"20\" maxlength = \"20\" class=\"text\" onchange=\"checkIP(this)\">&nbsp;";
			echo "<input type=\"submit\" name=\"PPS0_ip_save\" value=\"save\" onmouseover=\"this.className='style4'\" 	onmouseout=\"this.className='style3'\" class=\"style3\">";
		}
		else
		{
			echo "<input type=\"hidden\" name=\"PPS0_ip\" value=\"$PPS0_ip\">";
			if($PPS0_ip =='')
				$PPS0_ip ='--';
			echo "<a href=javascript:linkTo('$backurl_un','PPS0_ip_edit=1')>$PPS0_ip</a>";		
		}
		echo "</td>";
		
		echo "<td width=\"15%\">PPS1 IP:</td>";
		echo "<td width=\"35%\">";
		if(isset($PPS1_ip_edit))
		{
			echo "<input type = \"text\" name = \"PPS1_ip\"	value = \"$PPS1_ip\" size = \"20\" maxlength = \"20\" class=\"text\" onchange=\"checkIP(this)\">&nbsp;";
			echo "<input type=\"submit\" name=\"PPS1_ip_save\" value=\"save\" onmouseover=\"this.className='style4'\" 	onmouseout=\"this.className='style3'\" class=\"style3\">";
		}
		else
		{
			echo "<input type=\"hidden\" name=\"PPS1_ip\" value=\"$PPS1_ip\">";
			if($PPS1_ip =='')
				$PPS1_ip ='--';
			echo "<a href=javascript:linkTo('$backurl_un','PPS1_ip_edit=1')>$PPS1_ip</a>";		
		}
		echo "</td>";
		echo "</tr>";
	}
	echo "</table></td>";	
	echo "</tr>";	
	
	echo "<tr>";		
	echo "<td width=\"15%\" bgcolor=\"#E6E6E6\">Prefix</td>";
	echo "<td><table width=\"100%\">";	
	{//show Prefix
		echo "<tr>";
		echo "<td width=\"15%\">International:</td>";
		echo "<td width=\"35%\">";
		$sysId = "390_99_99";
		$oidStr = "2.2.1.5";
		$instanceNo=0;
		showParameter($sysId,$oidStr,1,1,$instanceNo);
		echo "</td>";
		echo "<td width=\"15%\">National:</td>";
		echo "<td width=\"35%\">";
		showParameter($sysId,$oidStr,2,1,$instanceNo);
		echo "</td>";
	}
	echo "</table></td>";
	echo "</tr>";
		
	echo "<tr>";		
	echo "<td width=\"15%\" bgcolor=\"#E6E6E6\">Number modification</td>";	
	echo "<td><table width=\"100%\">";		
	{//show Number modification
		echo "<tr>";
			echo "<td width=\"15%\">Greeting:</td>";
			echo "<td width=\"35%\">";
			$sysId = "390_99_99";
			$oidStr = "2.2.1.9";
			$instanceNo=0;
			showParameter($sysId,$oidStr,1,1,$instanceNo);
			echo "</td>";
			echo "<td width=\"15%\">Ringback Calling:</td>";
			echo "<td width=\"35%\">";
			$sysId = "390_99_99";
			$oidStr = "2.2.1.10";
			$instanceNo=0;
			showParameter($sysId,$oidStr,1,1,$instanceNo);
			echo "</td>";			
		echo "</tr>";	
		echo "<tr>";
			echo "<td width=\"15%\">SMS:</td>";
			echo "<td colspan=\"3\" width=\"85%\">";
			for($i=0; $i<32; $i++)
			{
				echo "<a href=\"vms_numModRemote.php?trunkgp=$trunkgp&infoNo=$infoNo&linkset=$linkset&inst=$i&sysNo=$TypeNo\">$i</a>";
				echo "&nbsp";
			}
			echo "</td>";
		echo "</tr>";

	}
	echo "</table></td>";
	echo "</tr>";
echo "</table>";	

echo "<br>";
}
if($setVMS)
{//Mailbox preferences
echo "<table border=\"1\" width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" bordercolor=\"#666666\" bordercolordark=\"#FFFFFF\"> ";
	echo "<tr><th colspan=\"2\"><b>Mailbox Preferences</b></th></tr>";
	echo "<tr>";
	echo "<td rowspan=\"1\" width=\"15%\" bgcolor=\"#E6E6E6\">Length</td>";	
	echo "<td><table width=\"100%\">";
	{//show Length
		$w1 = '20%';
		$w2 = '30%';
		echo "<tr>";
		echo "<td width=\"$w1\">Min. voicemail length:</td>";	
		echo "<td width=\"$w2\">";
		$sysId = "390_99_99";
		$oidStr = "2.2.2.1";
		$instanceNo=0;
		showParameter($sysId,$oidStr,1,1,$instanceNo);
		echo "</td>";
		echo "<td width=\"$w1\">Max. voicemail length:</td>";	
		echo "<td width=\"$w2\">";
		$sysId = "390_99_99";
		$oidStr = "2.2.2.2";
		$instanceNo=0;
		showParameter($sysId,$oidStr,1,1,$instanceNo);
		echo "</td>";
		echo "</tr>";
	}
	echo "</table></td>";	
	echo "</tr>";	
	
	echo "<tr>";
	echo "<td rowspan=\"1\" width=\"15%\" bgcolor=\"#E6E6E6\">Validity</td>";
	echo "<td><table width=\"100%\">";	
	{//show Validity
		echo "<tr>";
		echo "<td width=\"$w1\">New voicemail validity:</td>";	
		echo "<td width=\"$w2\">";
		$sysId = "390_99_99";
		$oidStr = "2.2.2.3";
		$instanceNo=0;
		showParameter($sysId,$oidStr,1,1,$instanceNo);
		echo "&nbsp;Days</td>";
		echo "<td width=\"$w1\">Old voicemail validity:</td>";	
		echo "<td width=\"$w2\"";
		showParameter($sysId,$oidStr,2,1,$instanceNo);
		echo "&nbsp;Days</td>";
		echo "</tr>";
	}
	echo "</table></td>";	
	echo "</tr>";	

	echo "<tr>";
	echo "<td rowspan=\"1\" width=\"15%\" bgcolor=\"#E6E6E6\">Digit Collection</td>";
	echo "<td><table width=\"100%\">";	
	{//show Digit collection
		echo "<td width=\"$w1\">Password retry times:</td>";	
		echo "<td width=\"$w2\">";
		$sysId = "390_99_99";
		$oidStr = "2.2.2.5";
		$instanceNo=0;
		showParameter($sysId,$oidStr,1,1,$instanceNo);
		echo "&nbsp;Times</td>";
		echo "<td width=\"$w1\">Key-press timeout:</td>";	
		echo "<td width=\"$w2\">";
		showParameter($sysId,$oidStr,2,1,$instanceNo);
		echo "&nbsp;Seconds</td>";	
	}	
	echo "</table></td>";	
	echo "</tr>";	
	
	echo "<tr>";
	echo "<td rowspan=\"1\" width=\"15%\" bgcolor=\"#E6E6E6\">Circuit</td>";
	echo "<td><table width=\"100%\">";
	{//show Circuit
		echo "<td width=\"$w1\">Circuit selection:</td>";	
		echo "<td width=\"$w2\">Clockwise";
		echo "</td>";
		
		echo "<td width=\"$w1\">Circuit delay:</td>";	
		echo "<td width=\"$w2\">";
		$sysId = "390_99_99";
		$oidStr = "2.2.2.7";
		$instanceNo=0;
		showParameter($sysId,$oidStr,1,1,$instanceNo);
		echo "</td>";
	}		
	echo "</table></td>";	
	echo "</tr>";
			
	echo "<tr>";
	echo "<td rowspan=\"1\" width=\"15%\" bgcolor=\"#E6E6E6\">Play Mode</td>";	
	{//show play mode
		echo "<td >&nbsp;";
		$sysId = "390_99_99";
		$oidStr = "2.2.2.4";
		$instanceNo=0;
		showParameter($sysId,$oidStr,1,1,$instanceNo);
		echo "</td>";
	}		
	echo "</tr>";		

echo "</table>";	
echo "<br>";
}
$languageArr=array("Language 0","Language 1","Language 2","Language 3","Language 4");
if($setVMS)
{//Short message notification
//$languageArr=array("English","French","Chinese","Russian","Spanish");
echo "<table border=\"1\" width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" bordercolor=\"#666666\" bordercolordark=\"#FFFFFF\"> ";
	echo "<tr><th colspan=\"4\"><b>Short Message Notification</b>";
	echo "&nbsp;(Laguage:";
			echo "<select name=\"slctLanguage\" onchange=\"selectLanguge(this)\" >";
				for($k=0;$k<5;$k++)
				{
					echo "<option value=\"$k\" ";
					if($k==$slctLanguage) echo "selected";
					echo ">$languageArr[$k]</option>";
				}
			echo "</select>)";
	echo "</th></tr>";
	echo "<tr>";
	echo "<td rowspan=\"1\" width=\"15%\" bgcolor=\"#E6E6E6\">&nbsp;</td>";
		echo "<td width=\"15%\"><b>Coding</b></td>";
		echo "<td width=\"35%\"><b>Short Message Contents</b></td>";
		echo "<td width=\"35%\"><b>Calling Number Prompt</b></td>";		
	echo "</tr>";
	
	echo "<tr>";
	echo "<td rowspan=\"1\" width=\"15%\" bgcolor=\"#E6E6E6\">New Message</td>";
	{//show New Message
		echo "<td>";
		$sysId = "390_99_99";
		$oidStr = "2.2.3.1";
		$instanceNo=$slctLanguage;
		showParameter($sysId,$oidStr,1,1,$instanceNo);
		echo "</td>";
		echo "<td>";
		showParameter($sysId,$oidStr,2,3,$instanceNo);
		echo "</td>";	
		echo "<td>";
		showParameter($sysId,$oidStr,3,3,$instanceNo);
		echo "</td>";	
	}
	echo "</tr>";
	
	echo "<tr>";
	echo "<td rowspan=\"1\" width=\"15%\" bgcolor=\"#E6E6E6\">Unanswered Call - CLI</td>";
	{//show Unanswered call - CLI
		echo "<td>";$sysId = "390_99_99";
		$oidStr = "2.2.3.2";
		$instanceNo=$slctLanguage;
		showParameter($sysId,$oidStr,1,1,$instanceNo);
		echo "</td>";
		echo "<td>";
		showParameter($sysId,$oidStr,2,3,$instanceNo);
		echo "</td>";	
		echo "<td>";
		showParameter($sysId,$oidStr,3,3,$instanceNo);
		echo "</td>";	
	}
	echo "</tr>";
	
	echo "<tr>";
	echo "<td rowspan=\"1\" width=\"15%\" bgcolor=\"#E6E6E6\">Full Mailbox</td>";
	{//show Full mailbox
		echo "<td>";$sysId = "390_99_99";
		$oidStr = "2.2.3.3";
		$instanceNo=$slctLanguage;
		showParameter($sysId,$oidStr,1,1,$instanceNo);
		echo "</td>";
		echo "<td>";
		showParameter($sysId,$oidStr,2,3,$instanceNo);
		echo "</td>";	
		echo "<td>";
		showParameter($sysId,$oidStr,3,3,$instanceNo);
		echo "</td>";	
	}	
	echo "</tr>";
	
	echo "<tr>";
	echo "<td rowspan=\"1\" width=\"15%\" bgcolor=\"#E6E6E6\">Unanswered call – no CLI</td>";
	{//show Unanswered call – no CLI
		echo "<td>";$sysId = "390_99_99";
		$oidStr = "2.2.3.4";
		$instanceNo=$slctLanguage;
		showParameter($sysId,$oidStr,1,1,$instanceNo);
		echo "</td>";
		echo "<td>";
		showParameter($sysId,$oidStr,2,3,$instanceNo);
		echo "</td>";	
		echo "<td>";
		echo "--";
		echo "</td>";	
	}
	echo "</tr>";
echo "</table>";	
echo "<br>";
}

{//Announcement play and update
if($setAAS)
{
	$tableName = 'aasAnnounce';
	$wName = 'AAS';
}
else
{
	$tableName = 'vmsAnnounce';
	$wName = 'VMS';
}
echo "<table border=\"1\" width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" bordercolor=\"#666666\" bordercolordark=\"#FFFFFF\"> ";
	//$languageArr=array("English","French","Chinese","Russian","Spanish");
	$selSql = " SELECT instance,languageNum,showfiled FROM $tableName where name ='$wName' and showfiled !='' order by instance";
	$Result = @mysqli_query($pubConn,$selSql);
	$announceNum=@mysqli_num_rows($Result);
	
	$selSql = " SELECT showfiled FROM $tableName where name ='languageNum'";
	$lan_re = @mysqli_query($pubConn,$selSql);
	$lan_row = @mysqli_fetch_array($lan_re);

	echo "<tr><th colspan=\"5\"><b>$wName Announcement</b>";		
		echo "&nbsp;(Laguage:";
			echo "<select name=\"slctLanguage1\" onchange=\"selectLanguge(this)\" >";
				for($k=0;$k< $lan_row[showfiled];$k++)
				{
					echo "<option value=\"$k\" ";
					if($k==$slctLanguage) echo "selected";
					echo ">$languageArr[$k]</option>";
				}
			echo "</select>)";
	echo "</th></tr>";
if($setAAS)
{

	echo "<tr>";	
	echo "<td width=\"15%\"bgcolor=\"#E6E6E6\">Repetition Counter</td>";
	echo "<td colspan=\"4\">&nbsp;";
	$sysId = "390_99_99";
	$oidStr = "2.4.2";
	showParameter($sysId,$oidStr,1,1);
	echo "</td>";
	echo "</tr>";
}
	echo "<tr >";
	//  
	if($setVMS==1)
		echo "<td rowspan=\"17\" width=\"15%\" bgcolor=\"#E6E6E6\" >Leave Message<br>Announcement</td>";		
	else
		echo "<td rowspan=\"17\" width=\"15%\" bgcolor=\"#E6E6E6\" >Call Unattainable<br>Announcement</td>";
	echo "</tr >";	
	echo "<tr>";
	echo "<td width=\"5%\"><b>No.</b></td>";
	echo "<td width=\"70%\"><b>Announcement</b></td>";
	echo "<td width=\"5%\"><b>Play</b></td>";
	echo "<td width=\"5%\"><b>Update</b></td>";	
	echo "</tr>";		
	for($num=0;$num< $announceNum;$num++)
	{
		echo "<tr>";		
			echo "<td>$num</td>";
			$Row = @mysqli_fetch_array($Result);
			$fileno = $Row[instance];
			$fileno = omc_keep_length($Row[instance],0,3);
			echo "<td width=\"19%\">$Row[showfiled]</td>";
			
			echo "<td>";
			$path = "language0".$slctLanguage."/";
			$fullpath =$path.$fileno;
			$tmpSysId='390_'.$sysNo.'_0';
			echo "<a href=\"./voiceplay.php?localpath=$tableName&voicefile=$fullpath&backurl=$backurl&sysId=$tmpSysId\">play</a>&nbsp;";
			echo "</td>";
			
			echo "<td>";		
			$path = "language0".$slctLanguage."/";
			$fullpath =$path.$fileno;
			echo "<a href=\"./uploadfile.php?vmsvoice=1&voicefile=$fullpath&backurl=$backurl&sysId=$sysId\">upload</a>&nbsp;";
			echo "</td>";				
		echo "</tr>";
	}
echo "</table>";	
}
echo "<div>";
	echo "<a href=\"./loaddata.php?infoNo=$infoNo&linkset=$linkset&trunkgp=$trunkgp&flag=$flag\">VSS -> MSS</a>";
	echo "</div>";
echo "<br>";

{//update vms param
	$otherWhereStr = "and subSysNo=$TypeNo";
	if($setAAS)
	{//add BB prefix for aas
		$tmp = omc_keep_length('BB','F',16,0);
		$tmp = strtoupper($tmp);
		$oidstr = "2.4.1";
		$objWhereStr = getLevelWhere($oidstr);
		$updflag = "UPDATE $paramTable SET initValue = '$tmp' 
	        			WHERE $objWhereStr
	        			";								
	  	if(0) echo "objDB,$objDB,$updflag<br>";
		mysqli_query($pubConn,$updflag);
		echo mysqli_error($pubConn);
		
		//aas0 添加prefix
		//====change the BB prefix callType to Emergency
		$callType = 1;
		if($TypeNo==0)
			updatePrefix('BB','BB',$callType,$trunkgp);
	}
	if($setAAS)
	{//SCF-- GTT table 		(arwean 060224)
		$sccp_objDB = 'OBJ_223';
		$tmpTable = 'param_8';
		$oidstr = '2.2';		
		$objWhereStr = getLevelWhere($oidstr);
		$getSql="SELECT initValue
				FROM $tmpTable 
				WHERE $objWhereStr $otherWhereStr AND instanceNo='0'
				";
		if($DEBUG) echo "<BR>getSql=$getSql";
		$result	=mysqli_query($pubConn,$getSql);		
		$rows	=mysqli_fetch_array($result);
		
		$niTypeArr = getNiType();
		if($niTypeArr[$NetID]==0)//ITU
		{
			$TT = '00';
			$NP = '01';
		}
		else
		{
			$TT = '0E';
			$NP = '00';
		}
		$rows[initValue] = setBitValue($rows[initValue],'0.0-0.7','01');//flag
		$rows[initValue] = setBitValue($rows[initValue],'01.0-01.7',$NP);
		$rows[initValue] = setBitValue($rows[initValue],'02.0-02.7',$TT);
		$tmp = omc_keep_length($SCF_num,'F',20,0);
		$rows[initValue] = setBitValue($rows[initValue],'03.0-12.7',$tmp);//SCF number 
		$rows[initValue] = setBitValue($rows[initValue],'13.0-22.7',$tmp);//SCF number
		$tmp = omc_keep_length($NetID,'0',2);
		$rows[initValue] = setBitValue($rows[initValue],'23.0-23.7',$tmp);//NI
		$tmp = omc_keep_length(dechex($WXC2OPC),'0',6);
		$rows[initValue] = setBitValue($rows[initValue],'24.0-26.7',$tmp);//DPC WXC2sp		
		$tmp = dechex(147);
		$rows[initValue] = setBitValue($rows[initValue],'27.0-27.7',$tmp);//SSN=147
		$rows[initValue] = setBitValue($rows[initValue],'29.0-29.7','07');//Address indicator
		$rows[initValue] = strtoupper($rows[initValue]);
		 
		$updflag = "UPDATE $tmpTable SET initValue = '$rows[initValue]' 
	        			WHERE $objWhereStr $otherWhereStr AND instanceNo='0'
	        			";								
	  if($DEBUG) echo "<br>updflag:: $updflag<br>";
		mysqli_query($pubConn,$updflag);
		echo mysqli_error($pubConn);					
	}	

	if(1)//修改VMS_mtp3 OPC DPC NI Route   		(arwean 060309)
	{
		$link_Db = 'OBJ_222';	
		$link_pub_Table  = 'param_99';
		$oidstr = '2.2';		
		$objWhereStr= '';
		$objWhereStr =getLevelWhere($oidstr);
				
		$paramSql = " SELECT initValue,readValue,instanceNo FROM $link_pub_Table
					WHERE $objWhereStr
					";
		$Result = mysqli_query($pubConn,$paramSql);
		$Row	= mysqli_fetch_array($Result);			
		
		$link_vms_Table  = 'param_8';						
		$updSql = "UPDATE $link_vms_Table SET initValue = '$Row[initValue]'   
								WHERE $objWhereStr $otherWhereStr AND instanceNo = '0'
								";
		mysqli_query($pubConn,$updSql);
								
		$NIoffset = array("0.0-0.0","0.1-0.1","0.2-0.2","0.3-0.3");		
		$NI_bit	= getBitValue($vms_Row[initValue],$NIoffset[$NetID]);
		$tmp = $NetID+1+$NI_bit*4;
		$oidstr = '2.3.'.$tmp;
		$objWhereStr= '';
		$objWhereStr =getLevelWhere($oidstr);
		$set_OPC = dechex($DPC);
		$set_OPC = omc_keep_length($set_OPC,0,6);
		$set_OPC = strtoupper($set_OPC);
		$updSql = "UPDATE $link_vms_Table SET initValue = '$set_OPC'
								WHERE $objWhereStr $otherWhereStr
								";
		if($DEBUG) echo "$updSql<br>";					
		mysqli_query($pubConn,$updSql);
		
		//VMS_8_pub--Linkset $TypeNo:		
		$oidstr = '2.4.1';		
		$objWhereStr = getLevelWhere($oidstr);
		$getSql="SELECT initValue
				FROM $link_vms_Table 
				WHERE $objWhereStr $otherWhereStr AND instanceNo='$TypeNo'
				";
		if($DEBUG) echo "<BR>getSql=$getSql";
		$result	=mysqli_query($pubConn,$getSql);		
		$rows	=mysqli_fetch_array($result);				

		$tmp = omc_keep_length(dechex($WXC2OPC),'0',6);
		$rows[initValue] = setBitValue($rows[initValue],'0.0-2.7',$tmp);//DPC

		$tmp = omc_keep_length(decbin($NetID),'0',2);
		$rows[initValue] = setBitValue($rows[initValue],'3.0-3.1',$tmp);//NI		

		$rows[initValue] = strtoupper($rows[initValue]);
		 	
		$updflag = "UPDATE $link_vms_Table SET initValue = '$rows[initValue]' 
	        			WHERE $objWhereStr $otherWhereStr AND instanceNo='$TypeNo'
	        			";								
	  	if($DEBUG) echo "$updflag<br>";
		mysqli_query($pubConn,$updflag);
		echo mysqli_error($pubConn);
		//VMS_8_pub--route
		$tmp=$NetID+1;
		$oidstr = '2.6.'.$tmp;		
		$objWhereStr = getLevelWhere($oidstr);
		$getSql="SELECT initValue
				FROM $link_vms_Table 
				WHERE $objWhereStr $otherWhereStr AND instanceNo='$TypeNo'
				";
		if($DEBUG) echo "<BR>getSql=$getSql";
		$result	=mysqli_query($pubConn,$getSql);		
		$rows	=mysqli_fetch_array($result);				

		$tmp = omc_keep_length(dechex($WXC2OPC),'0',6);
		$rows[initValue] = setBitValue($rows[initValue],'0.0-2.7',$tmp);   //DPC
		$rows[initValue] = setBitValue($rows[initValue],'3.0-3.7','00');   //Normal linkset 	
		$rows[initValue] = setBitValue($rows[initValue],'4.0-4.7','00');   //Alternative linkset 
		$rows[initValue] = strtoupper($rows[initValue]);	
		
		$updflag = "UPDATE $link_vms_Table SET initValue = '$rows[initValue]' 
	        			WHERE $objWhereStr $otherWhereStr AND instanceNo='$TypeNo'
	        			";								
	  if($DEBUG) echo "$updflag<br>";
		mysqli_query($pubConn,$updflag);	
	}
	if(1)//set vms NI DPC (arwean 060310)
	{
		$oidstr = "2.1.1"; //NI
		$objWhereStr = getLevelWhere($oidstr);
		$tmp = omc_keep_length(dechex($NetID),'0',2);
		$updflag = "UPDATE $paramTable SET initValue = '$tmp' 
	        			WHERE $objWhereStr and instanceNo='$TypeNo'
	        			";
		mysqli_query($pubConn,$updflag);
		echo mysqli_error($pubConn);
		
		$oidstr = "2.1.2"; //DPC
		$objWhereStr = getLevelWhere($oidstr);
		$tmp = omc_keep_length(dechex($WXC2OPC),'0',6);//DPC
		$tmp = strtoupper($tmp);
		$updflag = "UPDATE $paramTable SET initValue = '$tmp' 
	        			WHERE $objWhereStr and instanceNo='$TypeNo'
	        			";
	    if($DEBUG) echo "<br>updflag: $updflag";
		mysqli_query($pubConn,$updflag);
		echo mysqli_error($pubConn);
	}
}
?>

</form>
</body>
</html>
