<?php

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

$pubDb		 = 'OMC_PUB';



function delete_prefix($tg)
{
	global $nSetComm;
	//echo "database operation<br>";
	//========get the default value of Prefix Assignment,Prefix Attributes,Assign TG to Prefix
	$database="OBJ_322";
	$sql="select initValue from paramConf where level_1=2 and level_2=1 and level_3=1 ";
	$result=@mysqli_query($pubConn,$sql);
	$rows=@mysqli_fetch_array($result);
	$prefix_assignment_default_value=$rows[initValue];
	
	$database="OBJ_322";
	$sql="select initValue from paramConf where level_1=2 and level_2=1 and level_3=2 ";
	$result=@mysqli_query($pubConn,$sql);
	$rows=@mysqli_fetch_array($result);
	$prefix_attributes_default_value=$rows[initValue];
	
	$database="OBJ_322";
	$sql="select initValue from paramConf where level_1=2 and level_2=1 and level_3=3 ";
	$result=@mysqli_query($pubConn,$sql);
	$rows=@mysqli_fetch_array($result);
	$prefix_tg_default_value=$rows[initValue];
	
	//========get the prefix instanceNo by trunk group=======
	$database="OBJ_322";
	$sql="select instanceNo,initValue from param_99 where level_1=2 and level_2=1 and level_3=3 ";
	$result=@mysqli_query($pubConn,$sql);
	$rows=@mysqli_fetch_array($result);
	do{
		
		$prefix_tg_no=hexdec(getBitValue($rows[initValue],'0.0-0.7'))+0;
		if($prefix_tg_no==$tg)
		{
			$prefix_instance_no=$rows[instanceNo];
			//================delete the prefix in Prefix Assignment=========
			$database="OBJ_322";
			$update_sql="UPDATE param_99 SET 	
					initValue='$prefix_assignment_default_value'
					WHERE level_1=2 AND level_2=1 AND level_3=1 AND instanceNo='$prefix_instance_no'
					";
			//echo "<hr>$update_sql<hr>";	
			mysqli_query($pubConn,$update_sql);
			echo mysqli_error($pubConn);
			//================delete the prefix in Prefix Attributes=========
			$database="OBJ_322";
			$update_sql="UPDATE param_99 SET 	
					initValue='$prefix_attributes_default_value'
					WHERE level_1=2 AND level_2=1 AND level_3=2 AND instanceNo='$prefix_instance_no'
					";
			//echo "<hr>$update_sql<hr>";	
			mysqli_query($pubConn,$update_sql);
			echo mysqli_error($pubConn);
			//================delete the prefix in Assign TG to Prefix=========
			$database="OBJ_322";
			$update_sql="UPDATE param_99 SET 	
					initValue='$prefix_tg_default_value'
					WHERE level_1=2 AND level_2=1 AND level_3=3 AND instanceNo='$prefix_instance_no'
					";
			//echo "<hr>$update_sql<hr>";			
			mysqli_query($pubConn,$update_sql);
			echo mysqli_error($pubConn);
		}
		//echo "Flag=$Flag<br>";
	}while($rows=mysqli_fetch_array($result));
	
	
	
	
	
	//echo "oidSysCommSend<br>";
	$tmpSysId ='322_99_99';
	
	$tmpObjIdStr='2.1.1';
	$commIdStr	=oidSysCommSend($tmpSysId,$nSetComm,$tmpObjIdStr);
	$commArr = $commArr.$commIdStr;
	
	$tmpObjIdStr='2.1.2';	
	$commIdStr	=oidSysCommSend($tmpSysId,$nSetComm,$tmpObjIdStr);
	$commArr = $commArr.$commIdStr;
	
	$tmpObjIdStr='2.1.3';	
	$commIdStr	=oidSysCommSend($tmpSysId,$nSetComm,$tmpObjIdStr);
	$commArr = $commArr.$commIdStr;
	
	
	$SaveArrt=array(			
					array('oidstr'=>'3.2',	'setvalue'=>'B5'	,'sysid'=>'322_99_99','selectsysid'=>'-1'),//SCCP
			);
	//echo "SaveParam<br>";			
	SaveParam($SaveArrt);	
	
	if($DEBUG) echo "<BR>$commIdStr	=oidSysCommSend($tmpSysId,$nSetComm,$tmpObjIdStr)<br>";
	if($commIdStr=='-1'){
		DelComm($commArr);	
			
		echo "<br><br><b>Error while getting/setting parameters. Please check the device state!<br>";
		echo "oidSysCommSend($tmpSysId,$nSetComm,$tmpObjIdStr)<br>";
		echo "<p align=\"left\"><a href=\"JavaScript:history.go(-1)\"><img align=absBottom border=0 src=\"../../images/left.gif\" width=\"14\" height=\"14\">Back</a>";			
		exit();
	}
	

}




//===============This function use to delete a prefix manipulation when delete an ISDN=====

function delete_prefix_manipulation($tg)
{
	global $nSetComm;
	$tg=$tg+0;
	
	//===============get the defaule 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);
	$prefix_manipulation_default_value=$rows[initValue];
	
	//==============get the element title by tg==============
	$database="OBJ_225";
	$sql="select instanceNo,initValue from param_99 where level_1=2 and level_2=11 ";
	$result=@mysqli_query($pubConn,$sql);
	$rows=@mysqli_fetch_array($result);
	
	
	do
	{
		$tmp_tg_no=hexdec(getBitValue($rows[initValue],'3.0-3.7'))+0;
		if($tmp_tg_no==$tg)
		{
			
			$element_title=getBitValue($rows[initValue],'14.0-23.7');
			$temp="";
			for($num=0;$num<10;$num++)
			{
				$str=substr($element_title,$num*2,2);
				$str=hexdec($str);
				$str=chr($str);
				$temp.=$str;
			}
			$element_title=trim($temp);
			
			break;
		}
	}while($rows=mysqli_fetch_array($result));
	
	
	//=======delete the prefix manipulation from prefix manipulation table by element title============
	$database="OBJ_225";
	$sql="select instanceNo,initValue from param_99 where level_1=2 and level_2=8 ";
	$result=@mysqli_query($pubConn,$sql);
	$rows=@mysqli_fetch_array($result);
	do
	{
		$this_title=getBitValue($rows[initValue],'35.0-42.7');
		$temp="";
		for($num=0;$num<10;$num++)
		{
			$str=substr($this_title,$num*2,2);
			$str=hexdec($str);
			$str=chr($str);
			$temp.=$str;
		}
		$this_title=trim($temp);
		
		if(strcmp($this_title,$element_title)==0)
		{
			$gtt_instance_no=$rows[instanceNo];
			//=========delete in the prefix manipulation table=======================
			$database="OBJ_225";
			$update_sql="UPDATE param_99 SET 	
					initValue='$prefix_manipulation_default_value'
					WHERE level_1=2 AND level_2=8 AND instanceNo='$gtt_instance_no'
					";
			mysqli_query($pubConn,$update_sql);
			echo mysqli_error($pubConn);
			
		}
	}while($rows=mysqli_fetch_array($result));
	
	
	$tmpSysId ='225_99_99';
	
	$tmpObjIdStr='2.8';
	$commIdStr	=oidSysCommSend($tmpSysId,$nSetComm,$tmpObjIdStr);
	$commArr = $commArr.$commIdStr;
	
	$SaveArrt=array(			
					array('oidstr'=>'3.2',	'setvalue'=>'01'	,'sysid'=>'225_99_99','selectsysid'=>'-1'),//SCCP
			);
	//echo "SaveParam<br>";			
	SaveParam($SaveArrt);	
	
	if($DEBUG) echo "<BR>$commIdStr	=oidSysCommSend($tmpSysId,$nSetComm,$tmpObjIdStr)<br>";
	if($commIdStr=='-1'){
		DelComm($commArr);	
			
		echo "<br><br><b>Error while getting/setting parameters. Please check the device state!<br>";
		echo "oidSysCommSend($tmpSysId,$nSetComm,$tmpObjIdStr)<br>";
		echo "<p align=\"left\"><a href=\"JavaScript:history.go(-1)\"><img align=absBottom border=0 src=\"../../images/left.gif\" width=\"14\" height=\"14\">Back</a>";			
		exit();
	}
}



//======================hide============================
function deletePrefix($tg)
{
	
	global $pubDb;
	$tmpObjIdStr='2.1.3';
	$levelWhere = getLevelWhere($tmpObjIdStr);
	$getSql="SELECT initValue,instanceNo FROM OBJ_322.param_99 
				WHERE $levelWhere";
	$result	=mysqli_query($pubConn,$getSql);
	echo mysqli_error($pubConn);
	while($rows=mysqli_fetch_array($result))
	{	
		$tmpTg = hexdec($rows[initValue]);		
		if($tmpTg == $tg)
		{
			if(!isset($tmpswInstanceNo))
			{
				$tmpswInstanceNo=$rows[instanceNo];
				$swprefixArr=$rows[instanceNo];
			}
			else
			{
				$swprefixArr=$swprefixArr.'.'.$rows[instanceNo];
			}
		}
	}				

	//delete prefix
	$tmpParamConfTable='OBJ_322.paramConf';
	$tmpObjIdStr='2.1';
	$levelWhere = getLevelWhere($tmpObjIdStr);
	if($DEBUG) echo "<BR>levelWhere=$levelWhere";

	$getSql="SELECT initValue,level_3 FROM $tmpParamConfTable 
				WHERE $levelWhere AND (level_3='1' OR level_3='2' OR level_3='3') ORDER BY level_3
			";
	if($DEBUG) echo "<BR>getSql=$getSql";
	$result	=mysqli_query($pubConn,$getSql);
	echo mysqli_error($pubConn);
	$i=0;
	unset($tmpDefaultValueArr);
	while($rows=mysqli_fetch_array($result)){
		if($DEBUG) 
		echo "<BR>initValue=$rows[initValue]"; 
		$tmpDefaultValueArr[$i][initValue]=$rows[initValue];
		//echo "<BR>level_3=$rows[level_3]";
		$tmpDefaultValueArr[$i][level_3]=$rows[level_3];
		$i++;
	}
	if($DEBUG) 	echo "<BR>$aasprefixArr<br>";
	if(!isset($tmpswInstanceNo)){
		$tmpInstanceNoArr=-1;
	}else{
		$tmpInstanceNoArr=explode(".",$swprefixArr);
	}
	
	for($i=0;$i<sizeof($tmpDefaultValueArr);$i++)
	{
		$updateSql="UPDATE OBJ_322.param_99 SET 	
					initValue='{$tmpDefaultValueArr[$i][initValue]}'
					WHERE $levelWhere AND level_3='{$tmpDefaultValueArr[$i][level_3]}' AND (instanceNo='$tmpInstanceNoArr[0]'";
		for($j=1;$j<sizeof($tmpInstanceNoArr);$j++){
			$updateSql=$updateSql." OR instanceNo='".$tmpInstanceNoArr[$j]."'";
		}
		$updateSql=$updateSql.")";
		if($DEBUG) echo "<BR>updateSql=$updateSql";
		mysqli_query($pubConn,$updateSql);
		echo mysqli_error($pubConn);			
		
		$tmpSysId ='322_99_99';
		$tmpObjIdStr='2.1.'.$tmpDefaultValueArr[$i][level_3];
		//****************************************************************
		$commIdStr	=oidSysCommSend($tmpSysId,$nSetComm,$tmpObjIdStr);
		
		$SaveArrt=array(
					array('oidstr'=>'3.2',	'setvalue'=>'02'	,'sysid'=>'322_99_99'),//SCCP
					array('oidstr'=>'3.7',	'setvalue'=>'02'	,'sysid'=>'222_99_99'),//mtp3
					array('oidstr'=>'3.2',	'setvalue'=>'01'	,'sysid'=>'225_99_99'),//xapp	
				);
		SaveParam($SaveArrt);	
		
		if($DEBUG) echo "<BR>$commIdStr	=oidSysCommSend($tmpSysId,$nSetComm,$tmpObjIdStr)<br>";
	if($commIdStr=='-1'){
		DelComm($commArr);	
			
		echo "<br><br><b>Error while getting/setting parameters. Please check the device state!<br>";
		echo "oidSysCommSend($tmpSysId,$nSetComm,$tmpObjIdStr)<br>";
		echo "<p align=\"left\"><a href=\"JavaScript:history.go(-1)\"><img align=absBottom border=0 src=\"../../images/left.gif\" width=\"14\" height=\"14\">Back</a>";			
		exit();
	}
	$commArr = $commArr.$commIdStr;
	//****************************************************************		
	}
}




$SaveArr=array(
					array('oidstr'=>'3.2',	'setvalue'=>'02'	,'sysid'=>'322_99_99'),//SCCP
					array('oidstr'=>'3.7',	'setvalue'=>'02'	,'sysid'=>'222_99_99'),//mtp3
					array('oidstr'=>'3.2',	'setvalue'=>'01'	,'sysid'=>'225_99_99'),//xapp	
				);
	//SaveParam($SaveArr);

$localElementArr=array(
	array('sysTypeName'=>'MSC',	'sysTypeNo'=>'320','sysTypeSSN'=>'8','GT'=>'--','existFlag'=>'0'),
	array('sysTypeName'=>'VLR',	'sysTypeNo'=>'325','sysTypeSSN'=>'7','GT'=>'--','existFlag'=>'0'),
	array('sysTypeName'=>'HLR',	'sysTypeNo'=>'330','sysTypeSSN'=>'6','GT'=>'--','existFlag'=>'0'),
	array('sysTypeName'=>'AC',	'sysTypeNo'=>'340','sysTypeSSN'=>'10','GT'=>'--','existFlag'=>'0'),
	array('sysTypeName'=>'SMSC','sysTypeNo'=>'350','sysTypeSSN'=>'11','GT'=>'--','existFlag'=>'0'),
	array('sysTypeName'=>'PPS',	'sysTypeNo'=>'360','sysTypeSSN'=>'147','GT'=>'--','existFlag'=>'0')
);





//==========================================================
//读取数据
//==========================================================
getElementInfo($infoNo,$elementInfoArr);
$this_sysNo = $TypeNo = $elementInfoArr[sysNo];
$eleName = $elementInfoArr[eleName];
$tg = $elementInfoArr[tg];

getExistElements($existElementArr);
if(@array_search('500', $existElementArr)==TRUE)//BSS
	$needBssIp = 1;
{//initial param
	//填充oid
	switch($systemNo)
	{
		case 1://bss
		{
			$devicename = 'BSC';
			$oidsysarr=array(
				array('oid'=>'2.2.6',	'sysid'=>'322_99_99',	'selectsysid'=>'-1'),
				array('oid'=>'2.2.7',	'sysid'=>'322_99_99',	'selectsysid'=>'-1'),
				array('oid'=>'2.1.4',	'sysid'=>'322_99_99',	'selectsysid'=>'-1'),
				array('oid'=>'2.1.3',	'sysid'=>'322_99_99',	'selectsysid'=>'-1'),
				array('oid'=>'2.1.2',	'sysid'=>'322_99_99',	'selectsysid'=>'-1'),
				array('oid'=>'2.1.1',	'sysid'=>'322_99_99',	'selectsysid'=>'-1'),
				array('oid'=>'2.4',		'sysid'=>'322_99_99',	'selectsysid'=>'-1'),
				//MTP3
				array('oid'=>'2.4.1',	'sysid'=>'222_99_99',	'selectsysid'=>'-1'),
				array('oid'=>'2.5.1',	'sysid'=>'222_99_99',	'selectsysid'=>'-1'),
				array('oid'=>'2.6.1',	'sysid'=>'222_99_99',	'selectsysid'=>'-1'),
				array('oid'=>'2.6.2',	'sysid'=>'222_99_99',	'selectsysid'=>'-1'),
				array('oid'=>'2.6.3',	'sysid'=>'222_99_99',	'selectsysid'=>'-1'),
				array('oid'=>'2.6.4',	'sysid'=>'222_99_99',	'selectsysid'=>'-1')
			);			
			break;
		}
		case 2://peripheral
		{
			$devicename = 'Peripheral';
			$oidsysarr=array(
				array('oid'=>'2.1.4',	'sysid'=>'322_99_99',	'selectsysid'=>'-1'),
				array('oid'=>'2.1.3',	'sysid'=>'322_99_99',	'selectsysid'=>'-1'),
				array('oid'=>'2.1.2',	'sysid'=>'322_99_99',	'selectsysid'=>'-1'),
				array('oid'=>'2.1.1',	'sysid'=>'322_99_99',	'selectsysid'=>'-1'),
				
				array('oid'=>'2.4.1',	'sysid'=>'322_99_99',	'selectsysid'=>'-1'),
				array('oid'=>'2.4.2',	'sysid'=>'322_99_99',	'selectsysid'=>'-1'),
				array('oid'=>'2.4.3',	'sysid'=>'322_99_99',	'selectsysid'=>'-1'),
				array('oid'=>'2.4.4',	'sysid'=>'322_99_99',	'selectsysid'=>'-1'),
				
				array('oid'=>'2.2',		'sysid'=>'223_99_99',	'selectsysid'=>'-1'),
				//MTP3
				array('oid'=>'2.4.1',	'sysid'=>'222_99_99',	'selectsysid'=>'-1'),
				array('oid'=>'2.5.1',	'sysid'=>'222_99_99',	'selectsysid'=>'-1'),
				array('oid'=>'2.6.1',	'sysid'=>'222_99_99',	'selectsysid'=>'-1'),
				array('oid'=>'2.6.2',	'sysid'=>'222_99_99',	'selectsysid'=>'-1'),
				array('oid'=>'2.6.3',	'sysid'=>'222_99_99',	'selectsysid'=>'-1'),
				array('oid'=>'2.6.4',	'sysid'=>'222_99_99',	'selectsysid'=>'-1')
			);
			break;
		}
		case 3://switch
		{
			$devicename = 'Switch';
			$oidsysarr=array(
				array('oid'=>'2.1.4',	'sysid'=>'322_99_99',	'selectsysid'=>'-1'),
				array('oid'=>'2.1.3',	'sysid'=>'322_99_99',	'selectsysid'=>'-1'),
				array('oid'=>'2.1.2',	'sysid'=>'322_99_99',	'selectsysid'=>'-1'),
				array('oid'=>'2.1.1',	'sysid'=>'322_99_99',	'selectsysid'=>'-1'),
				array('oid'=>'2.4.1',	'sysid'=>'322_99_99',	'selectsysid'=>'-1'),
				array('oid'=>'2.4.2',	'sysid'=>'322_99_99',	'selectsysid'=>'-1'),
				array('oid'=>'2.4.3',	'sysid'=>'322_99_99',	'selectsysid'=>'-1'),
				//MTP3
				array('oid'=>'2.4.1',	'sysid'=>'222_99_99',	'selectsysid'=>'-1'),
				array('oid'=>'2.5.1',	'sysid'=>'222_99_99',	'selectsysid'=>'-1'),
				array('oid'=>'2.6.1',	'sysid'=>'222_99_99',	'selectsysid'=>'-1'),
				array('oid'=>'2.6.2',	'sysid'=>'222_99_99',	'selectsysid'=>'-1'),
				array('oid'=>'2.6.3',	'sysid'=>'222_99_99',	'selectsysid'=>'-1'),
				array('oid'=>'2.6.4',	'sysid'=>'222_99_99',	'selectsysid'=>'-1')
			);
			break;
		}
		case 4://application
		{
			$devicename = $strGttObjects;
			$oidsysarr=array(
				array('oid'=>'2.2',		'sysid'=>'223_99_99',	'selectsysid'=>'-1'),
				array('oid'=>'2.4',		'sysid'=>'223_99_99',	'selectsysid'=>'-1'),
				array('oid'=>'2.1.12','sysid'=>'330_99_99',	'selectsysid'=>'-1'),
				//MTP3
				array('oid'=>'2.4.1',	'sysid'=>'222_99_99',	'selectsysid'=>'-1'),
				array('oid'=>'2.5.1',	'sysid'=>'222_99_99',	'selectsysid'=>'-1'),
				array('oid'=>'2.6.1',	'sysid'=>'222_99_99',	'selectsysid'=>'-1'),
				array('oid'=>'2.6.2',	'sysid'=>'222_99_99',	'selectsysid'=>'-1'),
				array('oid'=>'2.6.3',	'sysid'=>'222_99_99',	'selectsysid'=>'-1'),
				array('oid'=>'2.6.4',	'sysid'=>'222_99_99',	'selectsysid'=>'-1')
			);
			break;
		}
		default:
			break;
	}
	echo "<br>Deleting an element ...<br>";
	if($systemNo==1 && $needBssIp==1)//delete BSS sysinfo & OMCR_BSSTABLE
	{
		$sysInfoTable = "OMC_PUB.sysInfo";
		$tmpSysType = 500;
		$tmpSubSysNo = 0;
		$delSql = "DELETE FROM $sysInfoTable WHERE sysTypeNo='$tmpSysType' AND sysNo = '$sysNo'
					AND subSysNo = '$tmpSubSysNo'";
		if($DEBUG) echo "<br>delSql = $delSql";
		mysqli_query($pubConn,$delSql);
		
		/*
		//OMCR_BSSTABLE
		$bssTable = "BssOmcDb.OMCR_BSSTABLE";
		$updSql = "update $bssTable set ip='',name='' where bssid='$sysNo'";
		if(0) echo "<br>updSql:$updSql";
		mysqli_query($pubConn,$updSql);
		*/
		$bssTable = "BssOmcDb.OMCR_BSSTABLE";
		$selSql = "select ip from $bssTable where bssid='$sysNo'";
		$result = mysqli_query($pubConn,$selSql);
		if($row = mysqli_fetch_array($result))
		{
			$bssIP = $row[ip];		
			$bssid=$sysNo;
			if(strlen($bssIP)>0)
				sendBssCommand($bssid,$bssIP,'',0);
		}
	} //end delete BSS sysinfo & OMCR_BSSTABLE
	
	//get填充oid参数

	if($systemNo!=0){
		GetParam($oidsysarr);
		if($DEBUG) echo "<br>delete";
	}	
	
}

?>
<?php
if($DEBUG) echo "<br>systemNo=$systemNo;elementNo=$elementNo;sysNo=$sysNo;linkset=$linkset;otherVar_1=$otherVar_1;otherVar_2=$otherVar_2;";




//**********************************************************
//Set parameters
if($systemNo==0)//local element
{
	//local element
	//case (elementNo ){...   }

	$localElementObjIdStr='2.1';
	$levelWhere = getLevelWhere($localElementObjIdStr);
	if($DEBUG) echo "<BR>levelWhere=$levelWhere";
	$localElementParamConfTable='OBJ_223.paramConf';
	$getSql="SELECT initValue FROM $localElementParamConfTable 
				WHERE $levelWhere
			";
	if($DEBUG) echo "<BR>getSql=$getSql";
	$result	=mysqli_query($pubConn,$getSql);
	echo mysqli_error($pubConn);
	$rows=mysqli_fetch_array($result);
	if($DEBUG) echo "<BR>initValue=$rows[initValue]"; 
	$localElementDefaultValue=$rows[initValue];

	$updateSql="UPDATE OBJ_223.param_99 SET 	
				initValue='$localElementDefaultValue'
				WHERE $levelWhere AND level_3='{$localElementArr[$elementNo][sysTypeSSN]}'
				";
	if($DEBUG) 
	echo "<BR>updateSql=$updateSql";
	$result	=mysqli_query($pubConn,$updateSql);
	echo mysqli_error($pubConn);

	$tmpSysId ='223_99_99';
	$tmpObjIdStr='2.1';
	//****************************************************************
	$commIdStr	=oidSysCommSend($tmpSysId,$nSetComm,$tmpObjIdStr);
	//SetParam($oidsysarr);
	//SaveParam($SaveArr);
	if($commIdStr=='-1'){
		DelComm($commArr);
		
		echo "<br><br><b>Error while getting/setting parameters. Please check the device state!<br>";
		echo "oidSysCommSend($tmpSysId,$nSetComm,$tmpObjIdStr)<br>";
		echo "<p align=\"left\"><a href=\"JavaScript:history.go(-1)\"><img align=absBottom border=0 src=\"../../images/left.gif\" width=\"14\" height=\"14\">Back</a>";			
		exit();
	}
	$commArr = $commArr.$commIdStr;
	//****************************************************************				

}
else
{//others element
	//delete linkset
	{
		$othersElementObjIdStr='2.4.1';
		$levelWhere = getLevelWhere($othersElementObjIdStr);
		if($DEBUG) echo "<BR>levelWhere=$levelWhere";
		$getSql="SELECT initValue FROM OBJ_222.param_99 
					WHERE $levelWhere AND instanceNo='$linkset'
				";
		if($DEBUG) echo "<BR>getSql=$getSql";
		$result	=mysqli_query($pubConn,$getSql);
		echo mysqli_error($pubConn);
		$rows=mysqli_fetch_array($result);
		if($DEBUG) echo "<BR>initValue=$rows[initValue]";
		$tmpInitValue=$rows[initValue];
		$TypeIn	 = hexdec(getBitValue($tmpInitValue,'4.0-4.7'));
		$tmpDecValue=hexdec(getBitValue($tmpInitValue,'6.0-6.7'));//total elements in the linkset(when system type is 16)
		$tmpDecValueForRouting=$tmpDecValue;
		$DPC = hexdec(getBitValue($tmpInitValue,'0.0-2.7'));
		$NI = bindec(getBitValue($tmpInitValue,'3.0-3.1'));
		if($tmpDecValue<=1)
		{
			$othEleParConfTab='OBJ_222.paramConf';
			$getSql="SELECT initValue FROM $othEleParConfTab 
					WHERE $levelWhere
				";
			if($DEBUG) echo "<BR>getSql=$getSql";
			$result	=mysqli_query($pubConn,$getSql);
			echo mysqli_error($pubConn);
			$rows=mysqli_fetch_array($result);
			if($DEBUG) echo "<BR>initValue=$rows[initValue]"; 
			$othEleDefVal=$rows[initValue];	
			
			if($DEBUG) 
			echo "<BR>updateSql=$updateSql";
			if($TypeIn==5)//delete cnfcenter
			{
				$tmpSelSql = "select initValue,instanceNo from OBJ_222.param_99 where $levelWhere ";
				$tmpResult = @mysqli_query($pubConn,$tmpSelSql);
				while($tmpRows = mysqli_fetch_array($tmpResult))
				{
					$tmpTypeIn = hexdec(getBitValue($tmpRows[initValue],'4.0-4.7'));
					if($tmpTypeIn==6)//cnfcenter
					{
						$updateSql="UPDATE OBJ_222.param_99 SET 	
						initValue='$othEleDefVal'
						WHERE $levelWhere AND (instanceNo='$linkset' or instanceNo='$tmpRows[instanceNo]')
						"; 
						break;
					}
				}	
			}
			else
			{
				$updateSql="UPDATE OBJ_222.param_99 SET 	
						initValue='$othEleDefVal'
						WHERE $levelWhere AND instanceNo='$linkset'
						";
			}
		}
		else
		{
			$tmpDecValue=$tmpDecValue-1;
			$tmpHexValue=omc_keep_length(dechex($tmpDecValue),'0',2);
			$tmpInitValue=setBitValue($tmpInitValue,'6.0-6.7',$tmpHexValue);
			if($systemNo==3)//set isSwitch flag 0.
				$tmpInitValue=setBitValue($tmpInitValue,'17.0-17.0',0);
			$updateSql="UPDATE OBJ_222.param_99 SET 	
						initValue='$tmpInitValue'
						WHERE $levelWhere AND instanceNo='$linkset'
						";
			if($DEBUG) 
			echo "<BR>updateSql=$updateSql";
		}
		$result	=mysqli_query($pubConn,$updateSql);
		echo mysqli_error($pubConn);
	
		$tmpSysId ='222_99_99';
		$tmpObjIdStr='2.4.1';
		
		//****************************************************************
		$commIdStr	=oidSysCommSend($tmpSysId,$nSetComm,$tmpObjIdStr);
		//SetParam($oidsysarr);
		//SaveParam($SaveArr);
		if($commIdStr=='-1')
		{
			DelComm($commArr);
			
			echo "<br><br><b>Error while getting/setting parameters. Please check the device state!<br>";
			echo "oidSysCommSend($tmpSysId,$nSetComm,$tmpObjIdStr)<br>";
			echo "<p align=\"left\"><a href=\"JavaScript:history.go(-1)\"><img align=absBottom border=0 src=\"../../images/left.gif\" width=\"14\" height=\"14\">Back</a>";			
			exit();
		}
		$commArr = $commArr.$commIdStr;
		//****************************************************************
	}
	
	if($tmpDecValueForRouting<=1)
	{
		//delete Routing	
		{
		$tmpParamTable='OBJ_222.param_99';
		$tmpObjIdStr='2.6';
		$levelWhere = getLevelWhere($tmpObjIdStr);
		if($DEBUG) echo "<BR>levelWhere=$levelWhere";
	
		$getSql="SELECT initValue,instanceNo,level_3 FROM $tmpParamTable 
					WHERE $levelWhere
				";
		if($DEBUG) echo "<BR>getSql=$getSql";
		$result	=mysqli_query($pubConn,$getSql);
		echo mysqli_error($pubConn);
		$routeflag=0;
		while($rows=mysqli_fetch_array($result))
		{
			$unitValue=hexdec(getBitValue($rows[initValue],'3.0-3.7'));//normal linkset
			if($unitValue==$linkset)
			{
				$routeflag=1;
				break;
			}
		}
		if($routeflag)
		{
			//echo "<br>instanceNo=$rows[instanceNo]";
			$tmpInstanceNo=$rows[instanceNo];
			$tmpLevel_3=$rows[level_3];
	
			$updateSql="UPDATE $tmpParamTable SET initValue='0000008080'
							WHERE $levelWhere AND level_3='$tmpLevel_3' AND instanceNo='$tmpInstanceNo'
						";
			if($DEBUG) 
				echo "<BR>updateSql=$updateSql";
			mysqli_query($pubConn,$updateSql);
			echo mysqli_error($pubConn);
			$tmpSysId ='222_99_99';
			$tmpObjIdStr='2.6'.'.'.$tmpLevel_3;
			if($DEBUG) echo "<br>tmpObjIdStr=$tmpObjIdStr";
			//****************************************************************
			$commIdStr	=oidSysCommSend($tmpSysId,$nSetComm,$tmpObjIdStr);
			//SetParam($oidsysarr);
			//SaveParam($SaveArr);
			if($commIdStr=='-1'){
				DelComm($commArr);
				
				echo "<br><br><b>Error while getting/setting parameters. Please check the device state!<br>";
				echo "oidSysCommSend($tmpSysId,$nSetComm,$tmpObjIdStr)<br>";
				echo "<p align=\"left\"><a href=\"JavaScript:history.go(-1)\"><img align=absBottom border=0 src=\"../../images/left.gif\" width=\"14\" height=\"14\">Back</a>";			
				exit();
			}
			$commArr = $commArr.$commIdStr;
			//****************************************************************
		}
		}
		
		//delete link
		{
		$tmpObjIdStr='2.5.1';
		$levelWhere = getLevelWhere($tmpObjIdStr);
		if($DEBUG) echo "<BR>levelWhere=$levelWhere";
		$tmpParamConfTable='OBJ_222.paramConf';
		$getSql="SELECT initValue FROM $tmpParamConfTable 
					WHERE $levelWhere
				";
		if($DEBUG) echo "<BR>getSql=$getSql";
		$result	=mysqli_query($pubConn,$getSql);
		echo mysqli_error($pubConn);
		$rows=mysqli_fetch_array($result);
		if($DEBUG) echo "<BR>initValue=$rows[initValue]"; 
		$tmpDefaultValue=$rows[initValue];
	
		$tmpLinksetValue=strtoupper(omc_keep_length(dechex($linkset),0,2));
		$tmpWhere=initValue." LIKE "."'$tmpLinksetValue"."%'";
	
		$updateSql="UPDATE OBJ_222.param_99 SET 	
					initValue='$tmpDefaultValue',initValue='$tmpDefaultValue'
					WHERE $levelWhere AND $tmpWhere
					";
		if($DEBUG) 
		echo "<BR>updateSql=$updateSql";
		$result	=mysqli_query($pubConn,$updateSql);
		echo mysqli_error($pubConn);
	
		$tmpSysId ='222_99_99';
		$tmpObjIdStr='2.5.1';					
		//****************************************************************
		$commIdStr	=oidSysCommSend($tmpSysId,$nSetComm,$tmpObjIdStr);
		//SetParam($oidsysarr);
		//SaveParam($SaveArr);
		if($commIdStr=='-1')
		{
			DelComm($commArr);
			
			echo "<br><br><b>Error while getting/setting parameters. Please check the device state!<br>";
			echo "oidSysCommSend($tmpSysId,$nSetComm,$tmpObjIdStr)<br>";
			echo "<p align=\"left\"><a href=\"JavaScript:history.go(-1)\"><img align=absBottom border=0 src=\"../../images/left.gif\" width=\"14\" height=\"14\">Back</a>";			
			exit();
		}
		$commArr = $commArr.$commIdStr;
		//****************************************************************		
		}
	}
	
	if($systemNo<4)// delete tg and e1
	{
		//delete tg
		$tmpObjIdStr='2.1.4';
		$levelWhere = getLevelWhere($tmpObjIdStr);
		if($DEBUG) echo "<BR>levelWhere=$levelWhere";
		$tmpParamConfTable='OBJ_322.paramConf';
		$getSql="SELECT initValue FROM $tmpParamConfTable 
					WHERE $levelWhere
				";
		if($DEBUG) echo "<BR>getSql=$getSql";
		$result	=mysqli_query($pubConn,$getSql);
		echo mysqli_error($pubConn);
		$rows=mysqli_fetch_array($result);
		if($DEBUG) echo "<BR>initValue=$rows[initValue]"; 
		$tmpDefaultValue=$rows[initValue];
		
		$updateSql="UPDATE OBJ_322.param_99 SET 	
					initValue='$tmpDefaultValue'
					WHERE $levelWhere AND instanceNo='$otherVar_1'
					";
		if($elementNo==3)//cnf
		{
			//echo "<br>otherVar_1:------>$otherVar_1";
			$tmpArr = explode('.',$otherVar_1);
			if(sizeof($tmpArr)==3)//the last one CNF
			{
				$instNo1 = $tmpArr[0];
				$instNo2 = $tmpArr[1];
				$cnfcenterInfoNo = $tmpArr[2];
				$updateSql="UPDATE OBJ_322.param_99 SET 	
					initValue='$tmpDefaultValue'
					WHERE $levelWhere AND (instanceNo='$instNo1' or instanceNo='$instNo2')
					";
			}
		}
		if(0) 
		{
			echo "<BR>updateSql=$updateSql";
			exit;
		}
		$result	=mysqli_query($pubConn,$updateSql);
		echo mysqli_error($pubConn);

		$tmpSysId ='322_99_99';
		$tmpObjIdStr='2.1.4';
		//****************************************************************
		$commIdStr	=oidSysCommSend($tmpSysId,$nSetComm,$tmpObjIdStr);
		//SetParam($oidsysarr);
	  //SaveParam($SaveArr);
		if($commIdStr=='-1'){
		DelComm($commArr);	
		
		echo "<br><br><b>Error while getting/setting parameters. Please check the device state!<br>";
		echo "oidSysCommSend($tmpSysId,$nSetComm,$tmpObjIdStr)<br>";
		echo "<p align=\"left\"><a href=\"JavaScript:history.go(-1)\"><img align=absBottom border=0 src=\"../../images/left.gif\" width=\"14\" height=\"14\">Back</a>";			
		exit();
		}
		$commArr = $commArr.$commIdStr;
		//****************************************************************		


		//delete the e1 parameters
		{
			
			
			
			
		
			
			$tmpParamConfTable='OBJ_322.paramConf';
			$tmpObjIdStr='2.4';
			$levelWhere = getLevelWhere($tmpObjIdStr);
			if($DEBUG) echo "<BR>levelWhere=$levelWhere";
			
			$getSql="SELECT initValue FROM $tmpParamConfTable 
						WHERE $levelWhere AND (level_3='1' OR level_3='2' OR level_3='3' OR level_3='4') ORDER BY level_3
					";
			if($DEBUG) echo "<BR>getSql=$getSql";
			$result	=mysqli_query($pubConn,$getSql);
			echo mysqli_error($pubConn);
			$i=1;
			while($rows=mysqli_fetch_array($result))
			{
				if($DEBUG) echo "<BR>initValue=$rows[initValue]"; 
				$tmpDefaultValueArr[$i]=$rows[initValue];
				if($DEBUG)echo "<br>value=$tmpDefaultValueArr[$i]";
				$i++;
			}
			
			
	
			$tmpTgValue=strtoupper(omc_keep_length(dechex($otherVar_1),0,2));
			
			$getSql="SELECT instanceNo FROM OBJ_322.param_99 
						WHERE $levelWhere AND level_3='2' AND initValue='$tmpTgValue'
					";
			if($DEBUG) 
				echo "<BR>getSql=$getSql";
			$result	=mysqli_query($pubConn,$getSql);
			echo mysqli_error($pubConn);
			
			while($rows=mysqli_fetch_array($result))
			{
				if($DEBUG) echo "<BR>instanceNo=$rows[instanceNo]"; 
				for($i=1;$i<=4;$i++)
				{
					$updateSql="UPDATE OBJ_322.param_99 SET 	
								initValue='$tmpDefaultValueArr[$i]'
								WHERE $levelWhere AND level_3='$i' AND instanceNo='$rows[instanceNo]'
								";
					if($DEBUG)echo "<BR>updateSql=$updateSql";
					mysqli_query($pubConn,$updateSql);
					echo mysqli_error($pubConn);
				}
			}
			
	
			
			
			
			
			
			
			/*
			//=============get the default value===========================
			//=====port interface
			$database="OBJ_322";
			$sql="select initValue from paramConf where level_1=2 and level_2=4 and level_3=1 ";
			$result=@mysqli_query($pubConn,$sql);
			$rows=@mysqli_fetch_array($result);
			$port_interface_default_initValue=$rows[initValue];
			
			echo "<script language=\"JavaScript\">\n";
			echo "alert('interface---$port_interface_default_initValue');\n";
			echo "</script>\n";
			
			//=====Assign TG to port
			$database="OBJ_322";
			$sql="select initValue from paramConf where level_1=2 and level_2=4 and level_3=2 ";
			$result=@mysqli_query($pubConn,$sql);
			$rows=@mysqli_fetch_array($result);
			$tg_port_default_initValue=$rows[initValue];
			echo "<script language=\"JavaScript\">\n";
			echo "alert('assign tg to port---$tg_port_default_initValue');\n";
			echo "</script>\n";
			//=====CIC of port
			$database="OBJ_322";
			$sql="select initValue from paramConf where level_1=2 and level_2=4 and level_3=3 ";
			$result=@mysqli_query($pubConn,$sql);
			$rows=@mysqli_fetch_array($result);
			$cic_port_default_initValue=$rows[initValue];
			echo "<script language=\"JavaScript\">\n";
			echo "alert('cic---$cic_port_default_initValue');\n";
			echo "</script>\n";
			//======port flag
			$database="OBJ_322";
			$sql="select initValue from paramConf where level_1=2 and level_2=4 and level_3=4 ";
			$result=@mysqli_query($pubConn,$sql);
			$rows=@mysqli_fetch_array($result);
			$flag_port_default_initValue=$rows[initValue];
			echo "<script language=\"JavaScript\">\n";
			echo "alert('flag---$flag_port_default_initValue');\n";
			echo "</script>\n";
			
			//======find the ports by trunk group no($otherVar_1)============
			$this_trunk_no=$otherVar_1+0;
			$database="OBJ_322";
			$sql="select instanceNo,initValue from param_99 where level_1=2 and level_2=4 and level_3=3 ";
			$result=@mysqli_query($pubConn,$sql);
			$rows=@mysqli_fetch_array($result);

			do{
				//$initV=$rows[initValue];
				$tg_tmp=hexdec($rows[initValue])+0;
				
				//fint the ports of the trunk group
			  if($this_trunk_no==$tg_tmp)
			  {
			  	$port_instance_no=$rows[instanceNo];
			  	//=======delete the port interface to default value
			  	$database="OBJ_322";
			  	$update_sql="UPDATE param_99 SET 	
								initValue='$port_interface_default_initValue'
								WHERE level_1=2 AND level_2=4 AND level_3=1 AND instanceNo='$port_instance_no'
								";
					mysqli_query($pubConn,$update_sql);
					echo mysqli_error($pubConn);
					//=======delete the assign tg to port table
					$database="OBJ_322";
			  	$update_sql="UPDATE param_99 SET 	
								initValue='$tg_port_default_initValue'
								WHERE level_1=2 AND level_2=4 AND level_3=2 AND instanceNo='$port_instance_no'
								";
					mysqli_query($pubConn,$update_sql);
					echo mysqli_error($pubConn);
					//=======delete the cic of port
					$database="OBJ_322";
			  	$update_sql="UPDATE param_99 SET 	
								initValue='$cic_port_default_initValue'
								WHERE level_1=2 AND level_2=4 AND level_3=3 AND instanceNo='$port_instance_no'
								";
					mysqli_query($pubConn,$update_sql);
					echo mysqli_error($pubConn);
					//=======delete the port flag
					$database="OBJ_322";
			  	$update_sql="UPDATE param_99 SET 	
								initValue='$flag_port_default_initValue'
								WHERE level_1=2 AND level_2=4 AND level_3=4 AND instanceNo='$port_instance_no'
								";
					mysqli_query($pubConn,$update_sql);
					echo mysqli_error($pubConn);
			  }
				
			}while($rows=mysqli_fetch_array($result));
			*/
			
		}//end delete e1
		
		$tmpSysId ='322_99_99';
		$tmpObjIdStr='2.4';
		//****************************************************************
		$commIdStr	=oidSysCommSend($tmpSysId,$nSetComm,$tmpObjIdStr);
		//SetParam($oidsysarr);
		//SaveParam($SaveArr);
		if($commIdStr=='-1'){
		DelComm($commArr);
		
		echo "<br><br><b>Error while getting/setting parameters. Please check the device state!<br>";
		echo "oidSysCommSend($tmpSysId,$nSetComm,$tmpObjIdStr)<br>";
		echo "<p align=\"left\"><a href=\"JavaScript:history.go(-1)\"><img align=absBottom border=0 src=\"../../images/left.gif\" width=\"14\" height=\"14\">Back</a>";			
		exit();
		}
		$commArr = $commArr.$commIdStr;
	}
	switch($systemNo)
	{
		case 1://BSC
		{
			//find bts
			$tmpTgValue=strtoupper(omc_keep_length(dechex($otherVar_1),0,2));
			$tmpWhere=initValue." LIKE '01".$tmpTgValue."%'";
			$tmpObjIdStr='2.2.6';
			$levelWhere = getLevelWhere($tmpObjIdStr);
			//get default value.
			$getSql = "select initValue from OBJ_322.paramConf where $levelWhere ";
			$result = mysqli_query($pubConn,$getSql);
			echo mysqli_error($pubConn);
			$rows=mysqli_fetch_array($result);
			$defValue = $rows[initValue];
			
			$getSql="SELECT initValue,instanceNo FROM OBJ_322.param_99 
						WHERE $levelWhere AND $tmpWhere
					";
			if($DEBUG) 
			echo "<BR>getSql=$getSql";
			$result	=mysqli_query($pubConn,$getSql);
			echo mysqli_error($pubConn);
			while($rows=mysqli_fetch_array($result))//2006-04-14should be "while" -> "if", but when tg=0,lac=0, there will be very nums get.
			{
				$lacValue=hexdec(getBitValue($rows[initValue],'2.0-3.7'));
				if($lacValue==0) continue; //add by arwean , lac should not be zero.
				$updateSql="update OBJ_322.param_99 set initValue='$defValue' 
						WHERE $levelWhere AND instanceNo='$rows[instanceNo]'
					";				
				mysqli_query($pubConn,$updateSql);
				echo mysqli_error($pubConn);
				
				//delete cells through the same Lac.
				$tmpObjIdStr='2.2.7';
				$levelWhere = getLevelWhere($tmpObjIdStr);
				//get default value.
				$getSql = "select initValue from OBJ_322.paramConf where $levelWhere ";
				$result = mysqli_query($pubConn,$getSql);
				echo mysqli_error($pubConn);
				$rows=mysqli_fetch_array($result);
				$defCellValue = $rows[initValue];
				
				$getSql="SELECT initValue,instanceNo FROM OBJ_322.param_99 
							WHERE $levelWhere and initValue!='$defValue'
						";
				if($DEBUG) 
				echo "<BR>getSql=$getSql";
				$result	=mysqli_query($pubConn,$getSql);
				echo mysqli_error($pubConn);				
				while($rows=mysqli_fetch_array($result))
				{
					if($lacValue==hexdec(getBitValue($rows[initValue],'1.0-2.7')))
					{
						$delPrefixNo = hexdec(getBitValue($rows[initValue],'5.0-5.7'));
						
						$updateSql = "update OBJ_322.param_99 set initValue='$defCellValue' 
										where $levelWhere and instanceNo='$rows[instanceNo]' ";
						mysqli_query($pubConn,$updateSql);
					}
				}
			}//end while			
			{
				$tmpSysId ='322_99_99';
				$tmpObjIdStr='2.2';
				//****************************************************************
				$commIdStr	=oidSysCommSend($tmpSysId,$nSetComm,$tmpObjIdStr);
				//SetParam($oidsysarr);
				//SaveParam($SaveArr);
				if($commIdStr=='-1')
				{
					DelComm($commArr);	
					
					echo "<br><br><b>Error while getting/setting parameters. Please check the device state!<br>";
					echo "oidSysCommSend($tmpSysId,$nSetComm,$tmpObjIdStr)<br>";
					echo "<p align=\"left\"><a href=\"JavaScript:history.go(-1)\"><img align=absBottom border=0 src=\"../../images/left.gif\" width=\"14\" height=\"14\">Back</a>";			
					exit();
				}
				$commArr = $commArr.$commIdStr;
			}
			{//delete prefix not used by any BTS
			$oidstr = '2.1.2';
			$objWhereStr= '';
			$objWhereStr =getLevelWhere($oidstr);		
			
			$defSql = " SELECT initValue,instanceNo FROM OBJ_322.param_99 WHERE $objWhereStr ORDER BY instanceNo";
			if($DEBUG) echo "<br>$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";
			$offset_ton_in = "0.0-0.3";
			$offset_ton_out="0.4-0.7";

			while($row = @mysqli_fetch_array($defRes))
			{
				$prefix_enable=hexdec(getBitValue($row[initValue],$offset_enable));
				$prefix_calltype=hexdec(getBitValue($row[initValue],$offset_calltype));
				if($prefix_enable && $prefix_calltype==1)//enable,Emergency
				{
					$delPrefixNo=$row[instanceNo];
					
					$paramSql = " SELECT initValue FROM OBJ_322.param_99 
								WHERE $levelWhere and initValue!='$defCellValue'";
				if($DEBUG)echo "<br>paramSql:$paramSql";
					$delPreResult = mysqli_query($pubConn,$paramSql);
					$otherUsed=0;	
					while($delPreRow = mysqli_fetch_array($delPreResult))
					{
						$prefixNo=hexdec(getBitValue($delPreRow[initValue],'5.0-5.7'));
						if($prefixNo==$delPrefixNo)
						{
							$otherUsed=1;
							break;
						}
					}
					if($otherUsed==0)//delete $delPrefixNo.
					{
						$tmpParamConfTable='OBJ_322.paramConf';
						$tmpObjIdStr='2.1';
						$levelWhere = getLevelWhere($tmpObjIdStr);
						if($DEBUG) echo "<BR>levelWhere=$levelWhere";
					
						$getSql="SELECT initValue,level_3 FROM $tmpParamConfTable 
									WHERE $levelWhere AND (level_3='1' OR level_3='2' OR level_3='3') ORDER BY level_3
								";
						if($DEBUG) echo "<BR>getSql=$getSql";
						$delPreResult	=mysqli_query($pubConn,$getSql);
						echo mysqli_error($pubConn);
						$i=0;
						unset($tmpDefaultValueArr);
						while($rows=mysqli_fetch_array($delPreResult))
						{
							if($DEBUG) 
							echo "<BR>initValue=$rows[initValue]"; 
							$tmpDefaultValueArr[$i][initValue]=$rows[initValue];
							//echo "<BR>level_3=$rows[level_3]";
							$tmpDefaultValueArr[$i][level_3]=$rows[level_3];
							$i++;
						}
						if($DEBUG) 	echo "<BR>$aasprefixArr<br>";
												
						for($i=0;$i<sizeof($tmpDefaultValueArr);$i++)
						{
							$updateSql="UPDATE OBJ_322.param_99 SET 	
										initValue='{$tmpDefaultValueArr[$i][initValue]}'
										WHERE $levelWhere AND level_3='{$tmpDefaultValueArr[$i][level_3]}' AND (instanceNo='$delPrefixNo'";
							for($j=1;$j<sizeof($tmpInstanceNoArr);$j++){
								$updateSql=$updateSql." OR instanceNo='".$tmpInstanceNoArr[$j]."'";
							}
							$updateSql=$updateSql.")";
							if($DEBUG) echo "<BR>updateSql=$updateSql";
							mysqli_query($pubConn,$updateSql);
							echo mysqli_error($pubConn);	
							
							$tmpSysId ='322_99_99';
							$tmpObjIdStr='2.1.'.$tmpDefaultValueArr[$i][level_3];
							//****************************************************************
							$commIdStr	=oidSysCommSend($tmpSysId,$nSetComm,$tmpObjIdStr);
							//SetParam($oidsysarr);
							//SaveParam($SaveArr);
							if($DEBUG) echo "<BR>$commIdStr	=oidSysCommSend($tmpSysId,$nSetComm,$tmpObjIdStr)<br>";
							if($commIdStr=='-1'){
							DelComm($commArr);	
							
							echo "<br><br><b>Error while getting/setting parameters. Please check the device state!<br>";
							echo "oidSysCommSend($tmpSysId,$nSetComm,$tmpObjIdStr)<br>";
							echo "<p align=\"left\"><a href=\"JavaScript:history.go(-1)\"><img align=absBottom border=0 src=\"../../images/left.gif\" width=\"14\" height=\"14\">Back</a>";			
							exit();
							}
							$commArr = $commArr.$commIdStr;
						}
					}					
				}//end if enable,Emergency
			}//end while
			}//end delete prefix
			break;
		}
		case 2://peripheral
		{
			//VSS
			if($elementNo==1)//VSS
			{
				
				
				
				
				//InitialAAS($sysNo);
				//delete gtt table
				{
					$sccp_objDB = 'OBJ_223';
					$tmpTable = 'param_99';
					$tmpConf = 'paramConf';
					$oidstr = '2.2';		
					$objWhereStr = getLevelWhere($oidstr);
					
					$defSql = "select initValue from $tmpConf where $objWhereStr";
					$defResult = mysqli_query($pubConn,$defSql);
					$defRows = mysqli_fetch_array($defResult);
					$tmpDefValue = $defRows[initValue];
					
					$getSql="SELECT instanceNo,initValue FROM $tmpTable WHERE $objWhereStr AND initValue LIKE '01%' ";
					if(0) echo "<BR>getSql=$getSql";
					$result	=mysqli_query($pubConn,$getSql);
					while($rows	=mysqli_fetch_array($result))
					{
						$tmpDpc = hexdec(getBitValue($rows[initValue],'24.0-26.7'));
						$tmpSSN = hexdec(getBitValue($rows[initValue],'27.0-27.7'));
						$tmpNi = hexdec(getBitValue($rows[initValue],'23.0-23.7'));
						if( $tmpDpc==$DPC && $tmpNi == $NI)
						{
							//echo "<br>$tmpStartMSISDN<br>$MSISDN_old";
							$tmpInstanceNo = $rows[instanceNo];
							//echo "<br>tmpInstanceNo: $tmpInstanceNo";
							$updSql = "update $tmpTable set initValue='$tmpDefValue' 
							where $objWhereStr and instanceNo='$tmpInstanceNo'";
							if(0) echo "<br>updSql:$updSql";
							mysqli_query($pubConn,$updSql);
							//break;
						}
						//echo "<br>$tmpStartMSISDN<br>$MSISDN_old<br>";
					}
				}//end delete gtt table
			}
			if($elementNo==2)//pcr
				;
			if($elementNo==3)//cnf
				;
			//find prefix
			$tmpObjIdStr='2.1.3';
			$levelWhere = getLevelWhere($tmpObjIdStr);
			$getSql="SELECT initValue,instanceNo FROM OBJ_322.param_99 
						WHERE $levelWhere
					";
			if($DEBUG) echo "<BR>getSql=$getSql";
			$result	=mysqli_query($pubConn,$getSql);
			echo mysqli_error($pubConn);
			while($rows=mysqli_fetch_array($result))
			{
				$tmpValue=hexdec($rows[initValue]);		
				//echo "<br>tmpValue=$tmpValue";
				if($tmpValue==$otherVar_1)
				{
					//echo "<br>instance=$rows[instanceNo]";
					//echo "<br>initValue=$rows[initValue]";
					if(!isset($tmpaasInstanceNo))
					{
						$tmpaasInstanceNo=$rows[instanceNo];
						$aasprefixArr=$rows[instanceNo];
					}
					else
					{
						$aasprefixArr=$aasprefixArr.'.'.$rows[instanceNo];
					}
				}
			}			
			
			//delete prefix
			$tmpParamConfTable='OBJ_322.paramConf';
			$tmpObjIdStr='2.1';
			$levelWhere = getLevelWhere($tmpObjIdStr);
			if($DEBUG) echo "<BR>levelWhere=$levelWhere";
		
			$getSql="SELECT initValue,level_3 FROM $tmpParamConfTable 
						WHERE $levelWhere AND (level_3='1' OR level_3='2' OR level_3='3') ORDER BY level_3
					";
			if($DEBUG) echo "<BR>getSql=$getSql";
			$result	=mysqli_query($pubConn,$getSql);
			echo mysqli_error($pubConn);
			$i=0;
			unset($tmpDefaultValueArr);
			while($rows=mysqli_fetch_array($result))
			{
				if($DEBUG) 
				echo "<BR>initValue=$rows[initValue]"; 
				$tmpDefaultValueArr[$i][initValue]=$rows[initValue];
				//echo "<BR>level_3=$rows[level_3]";
				$tmpDefaultValueArr[$i][level_3]=$rows[level_3];
				$i++;
			}
			if($DEBUG) 	echo "<BR>$aasprefixArr<br>";
			if(!isset($tmpaasInstanceNo))
			{
				$tmpInstanceNoArr[0]=-1;
			}
			else
			{
				$tmpInstanceNoArr=explode(".",$aasprefixArr);
			}
			for($i=0;$i<sizeof($tmpDefaultValueArr);$i++)
			{
				$updateSql="UPDATE OBJ_322.param_99 SET 	
							initValue='{$tmpDefaultValueArr[$i][initValue]}'
							WHERE $levelWhere AND level_3='{$tmpDefaultValueArr[$i][level_3]}' AND (instanceNo='$tmpInstanceNoArr[0]'";
				for($j=1;$j<sizeof($tmpInstanceNoArr);$j++)
				{
					$updateSql=$updateSql." OR instanceNo='".$tmpInstanceNoArr[$j]."'";
				}
				$updateSql=$updateSql.")";
				if($DEBUG) echo "<BR>updateSql=$updateSql";
				mysqli_query($pubConn,$updateSql);
				echo mysqli_error($pubConn);			
				
				$tmpSysId ='322_99_99';
				$tmpObjIdStr='2.1.'.$tmpDefaultValueArr[$i][level_3];
				//****************************************************************
				$commIdStr	=oidSysCommSend($tmpSysId,$nSetComm,$tmpObjIdStr);
				//SetParam($oidsysarr);
				//SaveParam($SaveArr);
				if($DEBUG) echo "<BR>$commIdStr	=oidSysCommSend($tmpSysId,$nSetComm,$tmpObjIdStr)<br>";
				if($commIdStr=='-1'){
				DelComm($commArr);	
				
				echo "<br><br><b>Error while getting/setting parameters. Please check the device state!<br>";
				echo "oidSysCommSend($tmpSysId,$nSetComm,$tmpObjIdStr)<br>";
				echo "<p align=\"left\"><a href=\"JavaScript:history.go(-1)\"><img align=absBottom border=0 src=\"../../images/left.gif\" width=\"14\" height=\"14\">Back</a>";			
				exit();
				}
				$commArr = $commArr.$commIdStr;
				//****************************************************************		
			}
			//end delete prefix
			break;
		}
		case 3://switch
		{
			{//delete conv prefix
				//get default value of local prefix(conv prefix)
				$net_paramConf		='OBJ_225.paramConf';
				$net_paramTable		="OBJ_225.param_99";
				$getsql = "select initValue from $net_paramConf where level_1 = '2' and level_2 = '8' and level_3 = '0'";  
				$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 "<br>conv_pre_def = $conv_pre_def<br>";
				
				$getsql = "select instanceNo,initValue from $net_paramTable where level_1 = '2' and level_2 = '8' and level_3 = '0' and initValue!='$conv_pre_def'";
				if($DEBUG) echo "<br>getsql:$getsql";
				$xappResult = mysqli_query($pubConn,$getsql);
				while($xappRow = mysqli_fetch_array($xappResult))
				{
					$tmpName = toAscii(getBitValue($xappRow[initValue],'35.0-42.7'));
					$cmpName = "Info".$infoNo;
					if(strcmp($tmpName,$cmpName)==0)
					{
						$instNo = $xappRow[instanceNo];
						$updSql = "update $net_paramTable set initValue='$conv_pre_def' where level_1 = '2' and level_2 = '8' and level_3 = '0' and instanceNo='$instNo'";
						mysqli_query($pubConn,$updSql);
					}
				}
				$tmpSysId ='225_99_99';
        		$tmpObjIdStr='2.8';
        		//****************************************************************
        		$commIdStr	=oidSysCommSend($tmpSysId,$nSetComm,$tmpObjIdStr);
        		//SetParam($oidsysarr);
            //SaveParam($SaveArr);
        		if($commIdStr=='-1'){
            		DelComm($commArr);
            		
            		echo "<br><br><b>Error while getting/setting parameters. Please check the device state!<br>";
            		echo "oidSysCommSend($tmpSysId,$nSetComm,$tmpObjIdStr)<br>";
            		echo "<p align=\"left\"><a href=\"JavaScript:history.go(-1)\"><img align=absBottom border=0 src=\"../../images/left.gif\" width=\"14\" height=\"14\">Back</a>";			
            		exit();
        		}
		        $commArr = $commArr.$commIdStr;	
			}//end delete conv prefix
			//delete prefix 
			if($otherVar_1!=-1)
			{
				//deletePrefix($otherVar_1);
				//echo "delete_prefix<br>";
				delete_prefix($otherVar_1);
				delete_prefix_manipulation($otherVar_1);
			}
			break;	
		}
		case 4://application
		{
			
			$tmpParamConfTable='OBJ_223.paramConf';
			$tmpObjIdStr='2.2';
			$levelWhere = getLevelWhere($tmpObjIdStr);
			if($DEBUG) echo "<BR>levelWhere=$levelWhere";
		
			$getSql="SELECT initValue FROM $tmpParamConfTable 
						WHERE $levelWhere 
					";
			if($DEBUG) 
			echo "<BR>getSql=$getSql";
			$result	=mysqli_query($pubConn,$getSql);
			echo mysqli_error($pubConn);
			$rows=mysqli_fetch_array($result);
			if($DEBUG) 
				echo "<BR>initValue=$rows[initValue]"; 
			$tmpDefaultValue=$rows[initValue];
			
			$tmpObjIdStr='2.4';
			$levelWhere1 = getLevelWhere($tmpObjIdStr);
			if($DEBUG) echo "<BR>levelWhere1=$levelWhere1";
		
			$getSql="SELECT initValue FROM $tmpParamConfTable 
						WHERE $levelWhere1 
					";
			if($DEBUG) 
			echo "<BR>getSql=$getSql";
			$result	=mysqli_query($pubConn,$getSql);
			echo mysqli_error($pubConn);
			$rows=mysqli_fetch_array($result);
			if($DEBUG) 
				echo "<BR>initValue=$rows[initValue]"; 
			$tmpDefaultValue1=$rows[initValue];
			
			$selSql = "select initValue,instanceNo from OBJ_223.param_99 where $levelWhere and initValue like '01%' ";
			$result = mysqli_query($pubConn,$selSql);
			
			$offsetAppType='00.0-00.7';
			$offsetGrpNo = '01.0-01.7';
			
			$i=0;
			$GTTWhere="(0";
			while($rows=mysqli_fetch_array($result))
			{
				$tmpDpc = hexdec(getBitValue($rows[initValue],'24.0-26.7'));
				$tmpNi =  hexdec(getBitValue($rows[initValue],'23.0-23.7'));
				$SSN  = hexdec(getBitValue($rows[initValue],'27.0-27.7'));
				if($tmpDpc==$DPC && $tmpNi==$NI )
				{
					{//get gtt attribution form 2.4
						$selSql = "select initValue from OBJ_223.param_99 where level_1='2' and level_2='4' and instanceNo='$rows[instanceNo]'";
						$tmpResult = mysqli_query($pubConn,$selSql);
						$tmpRow = mysqli_fetch_array($tmpResult);
						$tmpGrpNo = hexdec(getBitValue($tmpRow[initValue],$offsetGrpNo));
						$tmpAppType = hexdec(getBitValue($tmpRow[initValue],$offsetAppType));
					}//end get gtt attribution
//					echo "<br>$selSql<br>$tmpRow[initValue]";		
//					echo "<br>($tmpGrpNo==$otherVar_2 && $tmpAppType==$otherVar_1)";
					if($tmpGrpNo==$otherVar_2 && $tmpAppType==$otherVar_1)
					{
//	    				echo "<br>1: dpc=$tmpDpc, ni=$tmpNi, grpNo=$tmpGrpNo, ssn=$SSN, instanceNo={$rows[instanceNo]}";
//						echo "<br>2: dpc=$DPC, ni=$NI, grpNo=$otherVar_2, ssn=$otherVar_1";
						if($i==0)
							$GTTWhere="(instanceNo='{$rows[instanceNo]}'";
						else
							$GTTWhere=$GTTWhere." OR instanceNo='{$rows[instanceNo]}'";
						$i++;
					}
				}
			}
			$GTTWhere=$GTTWhere.")";
			
			$getSql="SELECT initValue FROM OBJ_223.param_99 
						WHERE $levelWhere AND $GTTWhere
					";
			if(0) 
			{
				echo "<br>levelWhere=$levelWhere";
				echo "<br>GTTWhere=$GTTWhere";
				echo "<BR>getSql=$getSql";
				exit;
			}
			$result	=mysqli_query($pubConn,$getSql);
			echo mysqli_error($pubConn);
			$rows=mysqli_fetch_array($result);
			if($DEBUG) 
				echo "<BR>initValue=$rows[initValue]"; 
			$GTT_start	= getBitValue($rows[initValue],'3.0-12.7');	
			$GTT_start	= str_replace('F','',$GTT_start);//for delete xapp(vlr)
			
			$updateSql="UPDATE OBJ_223.param_99 SET 	
					initValue='$tmpDefaultValue'
					WHERE $levelWhere AND $GTTWhere";
			if($DEBUG)
				echo "<BR>updateSql=$updateSql";
			mysqli_query($pubConn,$updateSql);
			echo mysqli_error($pubConn);
			
			$updateSql="UPDATE OBJ_223.param_99 SET 	
					initValue='$tmpDefaultValue1'
					WHERE $levelWhere1 AND $GTTWhere";
			if($DEBUG)
				echo "<BR>updateSql=$updateSql";
			mysqli_query($pubConn,$updateSql);
			echo mysqli_error($pubConn);
			
			$tmpSysId ='223_99_99';
			$tmpObjIdStr='2.2';
			//****************************************************************
			$commIdStr	=oidSysCommSend($tmpSysId,$nSetComm,$tmpObjIdStr);
			//SetParam($oidsysarr);
			//SaveParam($SaveArr);
			if($commIdStr=='-1'){
			DelComm($commArr);	
			
			echo "<br><br><b>Error while getting/setting parameters. Please check the device state!<br>";
			echo "oidSysCommSend($tmpSysId,$nSetComm,$tmpObjIdStr)<br>";
			echo "<p align=\"left\"><a href=\"JavaScript:history.go(-1)\"><img align=absBottom border=0 src=\"../../images/left.gif\" width=\"14\" height=\"14\">Back</a>";			
			exit();
			}
			$commArr = $commArr.$commIdStr;
			
			$tmpSysId ='223_99_99';
			$tmpObjIdStr='2.4';
			//****************************************************************
			$commIdStr	=oidSysCommSend($tmpSysId,$nSetComm,$tmpObjIdStr);
			//SetParam($oidsysarr);
			//SaveParam($SaveArr);
			if($commIdStr=='-1'){
			DelComm($commArr);	
			
			echo "<br><br><b>Error while getting/setting parameters. Please check the device state!<br>";
			echo "oidSysCommSend($tmpSysId,$nSetComm,$tmpObjIdStr)<br>";
			echo "<p align=\"left\"><a href=\"JavaScript:history.go(-1)\"><img align=absBottom border=0 src=\"../../images/left.gif\" width=\"14\" height=\"14\">Back</a>";			
			exit();
			}
			$commArr = $commArr.$commIdStr;
			
			//****************************************************************			
			if($elementNo==2){
				//(VLR)delete VPLMNs add by yizane
				$tmpParamConfTable='OBJ_330.paramConf';
				$tmpObjIdStr='2.1.12';
				$levelWhere = getLevelWhere($tmpObjIdStr);
				if($DEBUG) echo "<BR>levelWhere=$levelWhere";
			
				$getSql="SELECT initValue FROM $tmpParamConfTable 
							WHERE $levelWhere 
						";
				if($DEBUG) echo "<BR>getSql=$getSql";
				$result	=mysqli_query($pubConn,$getSql);
				echo mysqli_error($pubConn);
				$rows=mysqli_fetch_array($result);
				if($DEBUG) 
					echo "<BR>initValue=$rows[initValue]"; 
				$tmpDefaultValue=$rows[initValue];					
				$updateSql="UPDATE OBJ_330.param_99 SET 	
						initValue='$tmpDefaultValue'
						WHERE $levelWhere AND instanceNo='$otherVar_2'";
				if($DEBUG)
					echo "<BR>updateSql=$updateSql";
				mysqli_query($pubConn,$updateSql);
				echo mysqli_error($pubConn);
				
				$tmpSysId ='330_99_99';
				$tmpObjIdStr='2.1.12';
				//****************************************************************
				$commIdStr	=oidSysCommSend($tmpSysId,$nSetComm,$tmpObjIdStr);
				//SetParam($oidsysarr);
				//SaveParam($SaveArr);
				if($commIdStr=='-1'){
				DelComm($commArr);	
				
				echo "<br><br><b>Error while getting/setting parameters. Please check the device state!<br>";
				echo "oidSysCommSend($tmpSysId,$nSetComm,$tmpObjIdStr)<br>";
				echo "<p align=\"left\"><a href=\"JavaScript:history.go(-1)\"><img align=absBottom border=0 src=\"../../images/left.gif\" width=\"14\" height=\"14\">Back</a>";			
				exit();
				}
				$commArr = $commArr.$commIdStr;
				//****************************************************************									
			}			
			break;		
		}	
		default:
			break;			
	}
	if(1)//delete element info
	{
		$tmpObjIdStr='2.11';
		$levelWhere = getLevelWhere($tmpObjIdStr);
		if($DEBUG) echo "<BR>levelWhere=$levelWhere";
		$tmpParamConfTable='OBJ_225.paramConf';
		$getSql="SELECT initValue FROM $tmpParamConfTable 
					WHERE $levelWhere
				";			
		if($DEBUG) echo "<BR>getSql=$getSql";
		$result	=mysqli_query($pubConn,$getSql);
		echo mysqli_error($pubConn);
		$rows=mysqli_fetch_array($result);
		if($DEBUG) echo "<BR>initValue=$rows[initValue]"; 
		$tmpDefaultValue=$rows[initValue];
		$instanceNoWhere = "(instanceNo='$infoNo')";
		if(isset($cnfcenterInfoNo))
			$instanceNoWhere = "(instanceNo='$infoNo' or instanceNo='$cnfcenterInfoNo')";
		$updateSql="UPDATE OBJ_225.param_99 SET initValue='$tmpDefaultValue'
					WHERE $levelWhere  AND $instanceNoWhere";
		if($DEBUG) 
		echo "<BR>updateSql=$updateSql";
		$result	=mysqli_query($pubConn,$updateSql);
		echo mysqli_error($pubConn);		
		
		$tmpSysId ='225_99_99';
		$tmpObjIdStr='2.11';
		//****************************************************************
		$commIdStr	=oidSysCommSend($tmpSysId,$nSetComm,$tmpObjIdStr);
		//SetParam($oidsysarr);
		//SaveParam($SaveArr);
		if($commIdStr=='-1'){
		DelComm($commArr);
		
		echo "<br><br><b>Error while getting/setting parameters. Please check the device state!<br>";
		echo "oidSysCommSend($tmpSysId,$nSetComm,$tmpObjIdStr)<br>";
		echo "<p align=\"left\"><a href=\"JavaScript:history.go(-1)\"><img align=absBottom border=0 src=\"../../images/left.gif\" width=\"14\" height=\"14\">Back</a>";			
		exit();
		}
		$commArr = $commArr.$commIdStr;			
	}	//end delete element info
}//end other element
CheckState($commArr);

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





//Save parameters
if($systemNo==0)
{
	//save parameters
	$tmpInitValue='02';
	$tmpObjIdStr='3.2';
	$levelWhere = getLevelWhere($tmpObjIdStr);
	if($DEBUG) echo "<BR>levelWhere=$levelWhere";
	$tmpParamTable='OBJ_223.param_99';
	$updateSql="UPDATE $tmpParamTable SET initValue='$tmpInitValue'
				WHERE $levelWhere
				";
	if($DEBUG) 
		echo "<BR>updateSql=$updateSql";
	mysqli_query($pubConn,$updateSql);
	echo mysqli_error($pubConn);
	$tmpSysId ='223_99_99';	
	//****************************************************************
	$commIdStr	=oidSysCommSend($tmpSysId,$nSetComm,$tmpObjIdStr);
	//SetParam($oidsysarr);
	//SaveParam($SaveArr);
	if($commIdStr=='-1'){
		DelComm($SavecommArr);
		
		echo "<br><br><b>Error while getting/setting parameters. Please check the device state!<br>";
		echo "oidSysCommSend($tmpSysId,$nSetComm,$tmpObjIdStr)<br>";
		echo "<p align=\"left\"><a href=\"JavaScript:history.go(-1)\"><img align=absBottom border=0 src=\"../../images/left.gif\" width=\"14\" height=\"14\">Back</a>";			
		exit();
	}
	$SavecommArr = $SavecommArr.$commIdStr;
	//****************************************************************	
}
else//others element
{	
	$tmpInitValue='02';
	$tmpObjIdStr='3.7';
	$levelWhere = getLevelWhere($tmpObjIdStr);
	if($DEBUG) echo "<BR>levelWhere=$levelWhere";
	$tmpParamTable='OBJ_222.param_99';
	$updateSql="UPDATE $tmpParamTable SET initValue='$tmpInitValue'
				WHERE $levelWhere
							";
	if($DEBUG) 
			echo "<BR>updateSql=$updateSql";
	mysqli_query($pubConn,$updateSql);
	echo mysqli_error($pubConn);
	$tmpSysId ='222_99_99';
	//****************************************************************
	$commIdStr	=oidSysCommSend($tmpSysId,$nSetComm,$tmpObjIdStr);
	//SetParam($oidsysarr);
	//SaveParam($SaveArr);
	if($commIdStr=='-1'){
		DelComm($SavecommArr);
		
		echo "<br><br><b>Error while getting/setting parameters. Please check the device state!<br>";
		echo "oidSysCommSend($tmpSysId,$nSetComm,$tmpObjIdStr)<br>";
		echo "<p align=\"left\"><a href=\"JavaScript:history.go(-1)\"><img align=absBottom border=0 src=\"../../images/left.gif\" width=\"14\" height=\"14\">Back</a>";			
		exit();
	}
	$SavecommArr = $SavecommArr.$commIdStr;
	//****************************************************************
	if($systemNo<4)
	{
		//save parameters
		$tmpInitValue='B5';
		$tmpObjIdStr='3.2';
		$levelWhere = getLevelWhere($tmpObjIdStr);
		if($DEBUG) echo "<BR>levelWhere=$levelWhere";
		$tmpParamTable='OBJ_322.param_99';
		$updateSql="UPDATE $tmpParamTable SET initValue='$tmpInitValue'
					WHERE $levelWhere
						";
		if($DEBUG) 
				echo "<BR>updateSql=$updateSql";
		mysqli_query($pubConn,$updateSql);
		echo mysqli_error($pubConn);
		$tmpSysId ='322_99_99';
		//****************************************************************
		$commIdStr	=oidSysCommSend($tmpSysId,$nSetComm,$tmpObjIdStr);
		//SetParam($oidsysarr);
		//SaveParam($SaveArr);
		if($commIdStr=='-1'){
		DelComm($SavecommArr);	
		
		echo "<br><br><b>Error while getting/setting parameters. Please check the device state!<br>";
		echo "oidSysCommSend($tmpSysId,$nSetComm,$tmpObjIdStr)<br>";
		echo "<p align=\"left\"><a href=\"JavaScript:history.go(-1)\"><img align=absBottom border=0 src=\"../../images/left.gif\" width=\"14\" height=\"14\">Back</a>";			
		exit();
		}
		$SavecommArr = $SavecommArr.$commIdStr;
		//****************************************************************
	}
	else
	{
		//save parameters
		$tmpInitValue='02';
		$tmpObjIdStr='3.2';
		$levelWhere = getLevelWhere($tmpObjIdStr);
		if($DEBUG) echo "<BR>levelWhere=$levelWhere";
		$tmpParamTable='OBJ_223.param_99';
		$updateSql="UPDATE $tmpParamTable SET initValue='$tmpInitValue'
					WHERE $levelWhere
					";
		if($DEBUG) 
			echo "<BR>updateSql=$updateSql";
		mysqli_query($pubConn,$updateSql);
		echo mysqli_error($pubConn);
		$tmpSysId ='223_99_99';
		//****************************************************************
		$commIdStr	=oidSysCommSend($tmpSysId,$nSetComm,$tmpObjIdStr);
		//SetParam($oidsysarr);
		//SaveParam($SaveArr);
		if($commIdStr=='-1'){
		DelComm($SavecommArr);	
		
		echo "<br><br><b>Error while getting/setting parameters. Please check the device state!<br>";
		echo "oidSysCommSend($tmpSysId,$nSetComm,$tmpObjIdStr)<br>";
		echo "<p align=\"left\"><a href=\"JavaScript:history.go(-1)\"><img align=absBottom border=0 src=\"../../images/left.gif\" width=\"14\" height=\"14\">Back</a>";			
		exit();
		}
		$SavecommArr = $SavecommArr.$commIdStr;
		//****************************************************************
	}
	{
		$tmpInitValue='01';
		$tmpObjIdStr='3.2';
		$levelWhere = getLevelWhere($tmpObjIdStr);
		if($DEBUG) echo "<BR>levelWhere=$levelWhere";
		$tmpParamTable='OBJ_225.param_99';
		$updateSql="UPDATE $tmpParamTable SET initValue='$tmpInitValue'
					WHERE $levelWhere
					";
		if($DEBUG) 
			echo "<BR>updateSql=$updateSql";
		mysqli_query($pubConn,$updateSql);
		echo mysqli_error($pubConn);
		$tmpSysId ='225_99_99';
		//****************************************************************
		$commIdStr	=oidSysCommSend($tmpSysId,$nSetComm,$tmpObjIdStr);
		//SetParam($oidsysarr);
		//SaveParam($SaveArr);
		if($commIdStr=='-1'){
		DelComm($SavecommArr);	
		
		echo "<br><br><b>Error while getting/setting parameters. Please check the device state!<br>";
		echo "oidSysCommSend($tmpSysId,$nSetComm,$tmpObjIdStr)<br>";
		echo "<p align=\"left\"><a href=\"JavaScript:history.go(-1)\"><img align=absBottom border=0 src=\"../../images/left.gif\" width=\"14\" height=\"14\">Back</a>";			
		exit();
		}
		$SavecommArr = $SavecommArr.$commIdStr;
		//****************************************************************					
	}
}

CheckState($SavecommArr);

//==============save the mtp3 sccp parameter in server==========================
$SaveArrt=array(
					array('oidstr'=>'3.2',	'setvalue'=>'02'	,'sysid'=>'322_99_99'),//SCCP
					array('oidstr'=>'3.7',	'setvalue'=>'02'	,'sysid'=>'222_99_99'),//mtp3
					array('oidstr'=>'3.2',	'setvalue'=>'01'	,'sysid'=>'225_99_99'),//xapp	
				);
		SaveParam($SaveArrt);	
//**********************************************************
echo "<br><br><h4><font color=\"#0000ff\">Finished!</font></h4>";
if($DEBUG) exit();
echo "<br>";
//echo "<p align=\"left\"><a href=\"./overview.php?\" target=\"contents\"><img align=absBottom border=0 src=\"../../images/left.gif\" width=\"14\" height=\"14\">$strBack</a>";
echo "<script LANGUAGE=\"JavaScript\">";
echo "\n window.location.href=\"./overview.php\";";
echo "\n </script>";		
exit();
?>
</HTML>

