<?php
/***********************************************************
WXC2 SP configuration.

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

require("../sub_inc/commfunc.php");
//*****
$url_temp=$_SERVER["REQUEST_URI"];
//echo "This page URL:$url_temp<br>";
?>

<head>
	<script language="Javascript">
	//=======This function called when click the more and hide button=========================
	//Parameter
	//where:specify which buttons group of more and hide to click
	//num:specify how many the elements for showing
	//oper:specify which button to click,more or hide
	function clickOnMoreHide(where,num,oper)
	{
		var cmd;
		//to change the more button to hide button or reverse
		if(oper=='show')
		{
			cmd="document.all.show"+where+".style.display='none'";
			eval(cmd);
			cmd="document.all.hide"+where+".style.display='block'";
			eval(cmd);		
			for(var i=4;i<num;i++)
			{
				cmd="document.all."+where+i+".style.display='block'";
				eval(cmd);
			}	
		}
		else
		{
			cmd="document.all.show"+where+".style.display='block'";
			eval(cmd);
			cmd="document.all.hide"+where+".style.display='none'";
			eval(cmd);
			
			for(var i=4;i<num;i++)
			{
				cmd="document.all."+where+i+".style.display='none'";
				eval(cmd);
			}		
		}
	}
	
	function openSetPrefix(trunkgp,instanceNo,objIdStr,sysId,webname,setname,backurl)
	{
		y = document.body.scrollTop;
		//backurl = backurl+'?scroll_y='+y;
		backurl=escape(backurl);
		//alert(backurl);
		URL="../mss/paramconf.php?instanceNo="+instanceNo+"&trunkgp="+trunkgp+"&objIdStr="+objIdStr+"&sysId="+sysId+"&webname="+webname+"&setname="+setname+"&backurl="+backurl+"&sub_page_top="+y+"&from_bss=1";	
		window.location.href=URL;
	}
	</script>	
</head>	
<?php
$DEBUG = 0; 


if(!isset($page_top))
	$page_top=0;
//echo "page_top:$page_top<br>";

//==========================delete the cell=====================
if($delete_cell==1)
{

	//=====get the default value of cell=================
	$database="OBJ_322";
	$sql="select initValue from paramConf where level_1=2 and level_2=2 and level_3=7 ";
	$result=@mysqli_query($pubConn,$sql);
	$rows=@mysqli_fetch_array($result);
	$cell_default_value=$rows[initValue];
	//===============delete	
	$updSql = "update param_99 set initValue='$cell_default_value' where level_1 =2 and level_2 =2 and level_3 =7 and instanceNo='$cell_instance_no_delete'";
	mysqli_query($pubConn,$updSql);
	echo mysqli_error($pubConn);
	unset($delete_cell);
}

//==========================================================
//变量定义
//==========================================================
$pubDb			= 'OMC_PUB';
$db				= "OBJ_322";
$paramTable		='OBJ_322.param_99';
$SP_show = 0;
$TG_show = 0;
$prefix_show = 0;
$E1_show = 0;
$BSC_show = 0;
$GTT_show = 0;
$nSetComm	= 3;
//$backurl用于页面跳转是回到正确的页面
$backurl =$PHP_SELF."?trunkgp=".$trunkgp."&gtt=".$gtt."&sysNo=".$sysNo."&infoNo=".$infoNo."&linkset=".$linkset."&gttSSN=".$gttSSN."&grpNo=".$grpNo."&appType=".$appType;

//echo "$backurl<br>";
//Spname
//取设备名,编号
getElementInfo($infoNo,$elementInfoArr);
$this_sysNo = $TypeNo = $elementInfoArr[sysNo];
$TypeIn = $elementInfoArr[typeValue];
$eleName = $elementInfoArr[eleName];
$devicename = $elementInfoArr[typeName];
$webname = $elementInfoArr[webName];

if($DEBUG) echo "<br>trunkgp: $trunkgp; webname: $webname";
{//initial params
	switch($devicename)
	{
		case 'BSC':
		{
			$SP_show = 1;
			$TG_show = 1;
			$prefix_show = 0;
			$E1_show = 1;
			$BSC_show = 1;
			$GTT_show = 0;
			$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'),//time 2,3s
				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.6',	'sysid'=>'322_99_99',	'selectsysid'=>'-1'),
				array('oid'=>'2.2.7',	'sysid'=>'322_99_99',	'selectsysid'=>'-1'),
			
				array('oid'=>'2.5.1',	'sysid'=>'222_99_99',	'selectsysid'=>'-1'),
			);
			$SaveArr=array(
				array('oidstr'=>'3.2',	'setvalue'=>'B5'	,'sysid'=>'322_99_99','selectsysid'=>'-1'),
				array('oidstr'=>'3.7',	'setvalue'=>'02'	,'sysid'=>'222_99_99','selectsysid'=>'-1')
			);			
			if($trunkgp=="")
			{
				$SP_show = 1;
				$TG_show = 0;
				$prefix_show = 0;
				$E1_show = 0;
				$BSC_show = 0;
				$GTT_show = 0;
			}
			break;
		}
		case 'Peripheral':
		{
			if($webname=='CNF')
			{
				$this_sysNo = 0;
				$this_subSysNo = $subSysNo;
				$TypeNo = 0;
			}
			if($webname=='VSS')
			{
				$vssPrefix_show=1;
			}
			if($webname=='PCR')
			{
				$pcrPrefix_show=1;
			}
			$SP_show = 1;
			$TG_show = 1;
			$prefix_show = 0;
			$E1_show = 1;
			$BSC_show = 0;
			$GTT_show = 0;			
			$aasMtp3_sysId = "222_11_".$TypeNo;				
			$vssMtp3_sysId = "222_8_".$TypeNo;	
			$vssSCCP_sysId = "223_8_".$TypeNo;
			$oidsysarr=array(
				array('oid'=>'2.1.4',	'sysid'=>'322_99_99',	'selectsysid'=>'-1'),
				array('oid'=>'2.4',		'sysid'=>'322_99_99',	'selectsysid'=>'-1'),
				array('oid'=>'2.5.1',	'sysid'=>'222_99_99',	'selectsysid'=>'-1'),
			);
			$oidAASarr=array(
				array('oid'=>'2.5.1',	'sysid'=> $aasMtp3_sysId,	'selectsysid'=>'-1' ),
			);
			$oidVSSarr=array(
				array('oid'=>'2.5.1',	'sysid'=> $vssMtp3_sysId,	'selectsysid'=> '-1'),
				array('oid'=>'2.1.8',	'sysid'=> $vssSCCP_sysId,	'selectsysid'=> '-1'),
				array('oid'=>'2.1.1',	'sysid'=>'322_99_99',	'selectsysid'=>'-1'),
				array('oid'=>'2.1.2',	'sysid'=>'322_99_99',	'selectsysid'=>'-1'),
				array('oid'=>'2.1.3',	'sysid'=>'322_99_99',	'selectsysid'=>'-1'),
				
				array('oid'=>'2.2',		'sysid'=>'223_99_99',	'selectsysid'=>'-1'),
			);
			$SaveArr=array(
				array('oidstr'=>'3.2',	'setvalue'=>'B5'	,'sysid'=>'322_99_99','selectsysid'=>'-1'),
				array('oidstr'=>'3.7',	'setvalue'=>'02'	,'sysid'=>'222_99_99','selectsysid'=>'-1'),
			);	
			if($webname=='AAS')
			{	
				$SaveArr=array(
					array('oidstr'=>'3.2',	'setvalue'=>'B5'	,'sysid'=>'322_99_99','selectsysid'=>'-1'),
					array('oidstr'=>'3.7',	'setvalue'=>'02'	,'sysid'=>'222_99_99','selectsysid'=>'-1'),
					array('oidstr'=>'3.7',	'setvalue'=>'02'	,'sysid'=> $aasMtp3_sysId,'selectsysid'=> '-1'),
				);	
			}
			if($webname=='VSS')
			{
				$SaveArr=array(
					array('oidstr'=>'3.2',	'setvalue'=>'B5'	,'sysid'=>'322_99_99','selectsysid'=>'-1'),
					array('oidstr'=>'3.7',	'setvalue'=>'02'	,'sysid'=>'222_99_99','selectsysid'=>'-1'),
					array('oidstr'=>'3.7',	'setvalue'=>'02'	,'sysid'=> $vssMtp3_sysId,'selectsysid'=> '-1'),
					array('oidstr'=>'3.2',	'setvalue'=>'02'	,'sysid'=>'223_99_99','selectsysid'=>'-1'),
					array('oidstr'=>'3.2',	'setvalue'=>'02'	,'sysid'=> $vssSCCP_sysId,'selectsysid'=> '-1'),
				);	
			}				
			if($trunkgp=="")
			{
				$SP_show = 1;
				$TG_show = 0;
				$prefix_show = 0;
				$E1_show = 0;
				$BSC_show = 0;
				$GTT_show = 0;
			}	
			break;
		}
		case 'Switch':
		{
			$SP_show = 1;
			$TG_show = 1;
			$prefix_show = 1;
			$E1_show = 1;
			$BSC_show = 0;
			$GTT_show = 0;			
			$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',		'sysid'=>'322_99_99',	'selectsysid'=>'-1'),
				array('oid'=>'2.5.1',	'sysid'=>'222_99_99',	'selectsysid'=>'-1'),
				array('oid'=>'2.8.0',	'sysid'=>'225_99_99',	'selectsysid'=>'-1'),						
			);
			$SaveArr=array(
				array('oidstr'=>'3.7',	'setvalue'=>'02'	,'sysid'=>'222_99_99','selectsysid'=>'-1'),
				array('oidstr'=>'3.2',	'setvalue'=>'B5'	,'sysid'=>'322_99_99','selectsysid'=>'-1'),
				array('oidstr'=>'3.2',	'setvalue'=>'01'	,'sysid'=>'225_99_99'),//XAPP
			);						
			
			if($trunkgp=="")
			{
				$SP_show = 1;
				$TG_show = 0;
				$prefix_show = 0;
				$E1_show = 0;
				$BSC_show = 0;
				$GTT_show = 0;
			}						
			break;
		}
		
		case $strGttObjects:
		{
			$SP_show = 1;
			$TG_show = 0;
			$prefix_show = 0;
			$E1_show = 0;
			$BSC_show = 0;
			$GTT_show = 1;
			$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')
			);
			$SaveArr=array(
				array('oidstr'=>'3.2',	'setvalue'=>'02'	,'sysid'=>'223_99_99','selectsysid'=>'-1'),
			);			
			break;
		}
		
		default:
		{
			$SP_show = 0;
			$TG_show = 0;
			$prefix_show = 0;
			$E1_show = 0;
			$BSC_show = 0;
			$GTT_show = 0;
			break;
		}
	}
}//end initial params

if($webname=='CNF')
	$Spname = $Spname;
if($webname=='PCR')
	$Spname = "$Spname-$this_sysNo-$this_subSysNo";
else
	$Spname = $Spname."$TypeNo";


$sysId		='322_99_99';

$NetIdConfArr=array('International','International-S','National','National-S');

//==========================================================
//数据处理
//==========================================================
?>


<script LANGUAGE="JavaScript"> 
function delFirm(No,deltype,trunkgp,linkset,delcheckbox){
	var delValue,x,y;
	x = document.body.scrollLeft;
	y = document.body.scrollTop;
    
	if(confirm('Do you want to delete the selected?')!=true)
	{
		/*window.location.href='<?php echo $PHP_SELF;?>'+"?trunkgp="+trunkgp+"&linkset="+linkset;*/
		delcheckbox.checked=false;
	}
	else
	{
		if(deltype == 'E1')
			window.location.href='<?php echo $PHP_SELF."?infoNo=$infoNo";?>&E1del=1&delValue='+No+"&trunkgp="+trunkgp+"&linkset="+linkset;
		if(deltype == 'prefix')
		{
			window.location.href='<?php echo $PHP_SELF."?infoNo=$infoNo";?>&prefixdel=1&delValue='+No+"&trunkgp="+trunkgp+"&linkset="+linkset;		
		}
		if(deltype == 'convPrefix')
		{
			window.location.href='<?php echo $PHP_SELF."?infoNo=$infoNo";?>&convPrefixDel=1&delValue='+No+"&trunkgp="+trunkgp+"&linkset="+linkset;		
		}
		if(deltype == 'BTS')	
			window.location.href='<?php echo $PHP_SELF."?infoNo=$infoNo";?>&BTSdel=1&delValue='+No+"&trunkgp="+trunkgp+"&linkset="+linkset;		
		if(deltype == 'GTT')
		{
			window.location.href='<?php echo $PHP_SELF."?infoNo=$infoNo&gttSSN=$gttSSN&grpNo=$grpNo&appType=$appType";?>&GTTdel=1&delValue='+No+"&trunkgp="+trunkgp+"&linkset="+linkset;	
		}	
		if(deltype == 'LAC')
			window.location.href='<?php echo $PHP_SELF."?infoNo=$infoNo";?>&lacdel=1&delValue='+No+"&trunkgp="+trunkgp+"&linkset="+linkset;
	}
}

function lockFirm(No,deltype,trunkgp,linkset,delcheckbox){
	var delValue,x,y;
	x = document.body.scrollLeft;
	y = document.body.scrollTop;
 
	if(deltype == 'E1lock')
	{
		if(confirm('Do you want to Lock the E1?')==true)
			window.location.href='<?php echo $PHP_SELF."?infoNo=$infoNo";?>&E1lock=1&delValue='+No+"&trunkgp="+trunkgp+"&linkset="+linkset;
	}
	if(deltype == 'E1unlock')
	{
		if(confirm('Do you want to Unlock the E1?')==true)
			window.location.href='<?php echo $PHP_SELF."?infoNo=$infoNo";?>&E1unlock=1&delValue='+No+"&trunkgp="+trunkgp+"&linkset="+linkset;
	}			

}

function openSetConv(instanceNo,objIdStr,sysId,webname,setname,backurl,infoNo,trunkgp)
{
	y = document.body.scrollTop;
	backurl = backurl+'?scroll_y='+y;
	backurl=escape(backurl);
	
	URL="../mss/paramconf.php?infoNo="+infoNo+"&instanceNo="+instanceNo+"&objIdStr="+objIdStr+"&sysId="+sysId+"&webname="+webname+"&setname="+setname+"&backurl="+backurl+"&trunkgp="+trunkgp;	
	window.location.href=URL;
}

function openSetGTT(np,instanceNo,appType,bitFlag,ssn,linkset,grpNo,backurl)
{
	backurl=escape(backurl);
	url1 = '<?PHP echo "./gtt_edit.php?eleName=$eleName";?>';
	URL=url1 + "&instanceNo="+instanceNo+"&appType="+appType+"&NP="+np+"&bitFlag="+bitFlag+"&SSN="+ssn+"&linkset="+linkset+"&grpNo="+grpNo+"&backurl="+backurl;
	window.location.href=URL;
}
function openSet(objIdStr,instanceNo,setname,sysId,tg,linkset,webname,backurl,infoNo)
{
	setname=escape(setname);
	backurl=escape(backurl);
	if(setname == 'LAC')
		URL="./LACconf.php?infoNo="+infoNo+"&instanceNo="+instanceNo+"&pageType="+objIdStr+"&sysId="+sysId+"&setname="+setname+"&trunkgp="+tg+"&linkset="+linkset+"&backurl="+backurl;
	else if(setname == 'E1channel')
		URL="./E1channelEdit.php?infoNo="+infoNo+"&instanceNo="+instanceNo+"&Protocol="+sysId+"&trunkgp="+tg+"&linkset="+linkset+"&webname="+webname+"&backurl="+backurl;
	else if(setname == 'GTT')
		URL="./gtt_edit.php?infoNo="+infoNo+"&instanceNo="+instanceNo+"&NP="+objIdStr+"&bitFlag="+sysId+"&SSN="+tg+"&linkset="+linkset+"&grpNo="+webname+"&backurl="+backurl;
	else if(setname == 'E1')
		URL="./E1connectconf.php?infoNo="+infoNo+"&instanceNo="+instanceNo+"&cicflag="+objIdStr+"&ctrflag="+sysId+"&webname="+webname+"&trunkgp="+tg+"&linkset="+linkset+"&backurl="+backurl;
	else
		URL="./paramconf.php?infoNo="+infoNo+"&instanceNo="+instanceNo+"&objIdStr="+objIdStr+"&sysId="+sysId+"&setname="+setname+"&trunkgp="+tg+"&linkset="+linkset+"&webname="+webname+"&backurl="+backurl;	
	window.location.href=URL;
}

//===============delete the cell (add 2007-6-5)
function delete_cell(item,instanceNo,trunkgp,linkset)
{
	//No,deltype,trunkgp,linkset,delcheckbox
	var result;
	result=confirm("Do you want to delete the selected?");
	if(result==1)
	{
		window.location.href='<?php echo $PHP_SELF."?infoNo=$infoNo";?>&delete_cell=1&cell_instance_no_delete='+instanceNo+"&trunkgp="+trunkgp+"&linkset="+linkset;		
	}	
	else
	{
		item.checked=0;
		return	
	}
}

</script>

<?php
if($_SERVER['REQUEST_METHOD'] == "POST")
{
	if(isset($setSys) || isset($getSys))
	{
		if(isset($setSys))
		{
			echo "<br>Setting parameters<br>";
			//========set the parameter for 8kboard (2007-6-5)=====================================
			$database="OMC_PUB";
			$sql="select sysNo from sysInfo where sysNo=0 and sysTypeNo=111 ";
			$result=@mysqli_query($pubConn,$sql);
			$rows=@mysqli_fetch_array($result);
			if($rows[sysNo]==0)
				$OidArr_8ke1[]=array('oid'=>'2.8',	'sysid'=>'111_0_99',	'selectsysid'=> '-1');
			
			$database="OMC_PUB";
			$sql="select sysNo from sysInfo where sysNo=1 and sysTypeNo=111 ";
			$result=@mysqli_query($pubConn,$sql);
			$rows=@mysqli_fetch_array($result);
			if($rows[sysNo]==1)
				$OidArr_8ke1[]=array('oid'=>'2.8',	'sysid'=>'111_1_99',	'selectsysid'=> '-1');	
			SetParam($OidArr_8ke1);
			//===============================================================================
			
			
			if($TypeIn ==2)
			{
				SetParam($oidAASarr);
			}
			if($TypeIn ==3)
			{
				SetParam($oidVSSarr);
			}	
			
			if($devicename!=$strGttObjects) 
			{
				set_e1channel($trunkgp);
			}		
			
			SetParam($oidsysarr);

			SaveParam($SaveArr);
			
		}
		else
		{ 
			echo "<br>Getting parameters<br>";
			
			//========get the parameter for 8kboard (2007-6-5)=====================================
			$database="OMC_PUB";
			$sql="select sysNo from sysInfo where sysNo=0 and sysTypeNo=111 ";
			$result=@mysqli_query($pubConn,$sql);
			$rows=@mysqli_fetch_array($result);
			if($rows[sysNo]==0)
				$OidArr_8ke1[]=array('oid'=>'2.8',	'sysid'=>'111_0_99',	'selectsysid'=> '-1');
			
			$database="OMC_PUB";
			$sql="select sysNo from sysInfo where sysNo=1 and sysTypeNo=111 ";
			$result=@mysqli_query($pubConn,$sql);
			$rows=@mysqli_fetch_array($result);
			if($rows[sysNo]==1)
				$OidArr_8ke1[]=array('oid'=>'2.8',	'sysid'=>'111_1_99',	'selectsysid'=> '-1');	
			GetParam($OidArr_8ke1);
			//===============================================================================
			
			if($TypeIn ==2)
			{
				GetParam($oidAASarr);
			}	
			if($TypeIn ==3)
			{
				GetParam($oidVSSarr);
			}						
			if($devicename!=$strGttObjects) 
			{
				get_e1channel($trunkgp);
			}
			GetParam($oidsysarr);
			
		}
	}
}

if(1==$prefixdel)
{	
	if($thisUsedRa==''&&$otherUsedRa=='')//delete it
	{
		$sysId = '322_99_99';
		
		$sysIdArr	= explode('_',$sysId);
		$sysTypeNo	= $sysIdArr[0];
		$sysNo		= $sysIdArr[1];
		$subSysNo	= $sysIdArr[2];
	
		$objDb		= 'OBJ_'.$sysTypeNo;
		$paramTable = 'param_'.$sysNo;
				
		$oidstr = '2.1.2';
		$objWhereStr= '';
		$objWhereStr =getLevelWhere($oidstr);		
		
		$defSql = " SELECT initValue FROM paramConf WHERE $objWhereStr";
		$defRes = @mysqli_query($pubConn,$defSql);
		$row = @mysqli_fetch_array($defRes);
		
		$flagoffset = "10.7-10.7";			
		$row[initValue] = setBitValue($row[initValue],$flagoffset,0);
	
		$delSql = "UPDATE $paramTable SET initValue = '$row[initValue]' 
	            WHERE subSysNo = '$subSysNo' AND $objWhereStr AND instanceNo='$delValue'";
		if($DEBUG) echo "<br>delSql=$delSql";
		$delRes = @mysqli_query($pubConn,$delSql);
		echo mysqli_error($pubConn);
	
		$oidstr = '2.1.1';
		$objWhereStr= '';
		$objWhereStr =getLevelWhere($oidstr);		
		
		$defSql = " SELECT initValue FROM paramConf WHERE $objWhereStr";
		$defRes = @mysqli_query($pubConn,$defSql);
		$row = @mysqli_fetch_array($defRes);
		
		$delSql = "UPDATE $paramTable SET initValue = '$row[initValue]' 
	            WHERE subSysNo = '$subSysNo' AND $objWhereStr AND instanceNo='$delValue'";
		if($DEBUG) echo "<br>delSql=$delSql";
		$delRes = @mysqli_query($pubConn,$delSql);
		echo mysqli_error($pubConn);
		
		$oidstr = '2.1.3';
		$objWhereStr= '';
		$objWhereStr =getLevelWhere($oidstr);		
		
		$defSql = " SELECT initValue FROM paramConf WHERE $objWhereStr";
		$defRes = @mysqli_query($pubConn,$defSql);
		$row = @mysqli_fetch_array($defRes);
		
		$delSql = "UPDATE $paramTable SET initValue = '$row[initValue]' 
	            WHERE subSysNo = '$subSysNo' AND $objWhereStr AND instanceNo='$delValue'";
		if($DEBUG) echo "<br>delSql=$delSql";
		$delRes = @mysqli_query($pubConn,$delSql);
		echo mysqli_error($pubConn);				
	}
	if($thisUsedRa!='')//set used RA part to default value
	{		
		$thisUsedRaArr=explode(",", $thisUsedRa);
		for($i=0; $i<sizeof($thisUsedRaArr); $i++)
		{
			if($thisUsedRaArr[$i]=='Default')
				$thisUsedRaArr[$i] = 32;
		}
		{
		$sysId = '322_99_99';		
		$sysIdArr	= explode('_',$sysId);
		$sysTypeNo	= $sysIdArr[0];
		$sysNo		= $sysIdArr[1];
		$subSysNo	= $sysIdArr[2];	
		$objDb		= 'OBJ_'.$sysTypeNo;
		$paramTable = 'param_'.$sysNo;
		
		$oidstr = '2.1.3';
		$objWhereStr= '';
		$objWhereStr =getLevelWhere($oidstr);
		$paramSql = " SELECT initValue,readValue,instanceNo FROM $paramTable  
								WHERE $objWhereStr AND instanceNo ='$delValue'
								";
								
		$Result = mysqli_query($pubConn,$paramSql);				
		$Row		= mysqli_fetch_array($Result);
	
		$RAoffsetarr = array(
								"0.0-0.7","2.0-2.7","4.0-4.7","6.0-6.7",
								"8.0-8.7","10.0-10.7","12.0-12.7","14.0-14.7",
								"16.0-16.7","18.0-18.7","20.0-20.7","22.0-22.7",
								"24.0-24.7","26.0-26.7","28.0-28.7","30.0-30.7",
								"32.0-32.7","34.0-34.7","36.0-36.7","38.0-38.7",
								"40.0-40.7","42.0-42.7","44.0-44.7","46.0-46.7",
								"48.0-48.7","50.0-50.7","52.0-52.7","54.0-54.7",
								"56.0-56.7","58.0-58.7","60.0-60.7","62.0-62.7",
								"64.0-64.7");
		$CToffsetarr = array(
								"1.0-1.7","3.0-3.7","5.0-5.7","7.0-7.7",
								"9.0-9.7","11.0-11.7","13.0-13.7","15.0-15.7",
								"17.0-17.7","19.0-19.7","21.0-21.7","23.0-23.7",
								"25.0-25.7","27.0-27.7","29.0-29.7","31.0-31.7",
								"33.0-33.7","35.0-35.7","37.0-37.7","39.0-39.7",
								"41.0-41.7","43.0-43.7","45.0-45.7","47.0-47.7",
								"49.0-49.7","51.0-51.7","53.0-53.7","55.0-55.7",
								"57.0-57.7","59.0-59.7","61.0-61.7","63.0-63.7",
								"65.0-65.7");
								
		$hex_set_tg = 'EE';
		$hex_set_ct = '00';
		for($j=0; $j< sizeof($thisUsedRaArr); $j++)
		{
			for($i=0; $i<33; $i++)
			{
				if($i==$thisUsedRaArr[$j])
				{
					$Row[initValue] = setBitValue($Row[initValue],$RAoffsetarr[$i],$hex_set_tg);
					$Row[initValue] = setBitValue($Row[initValue],$CToffsetarr[$i],$hex_set_ct);
					break;
				}
			}
		}	
		
		$Row[initValue] = strtoupper($Row[initValue]);		
		$updSql = "UPDATE $paramTable SET initValue = '$Row[initValue]'   
					WHERE $objWhereStr AND instanceNo = '$delValue'";	
		//echo $updSql;									
		mysqli_query($pubConn,$updSql);		
		}
	}
	
	echo "<script LANGUAGE=\"JavaScript\">";
	echo "\n window.location.href=\"$backurl\";";
	echo "\n </script>";
	exit();		
}
if(1==$convPrefixDel)
{
	$pubDb = "OMC_PUB";
	//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 "conv_pre_def = $conv_pre_def<br>";
	
	$updSql = "update $net_paramTable set initValue='$conv_pre_def' where level_1 = '2' and level_2 = '8' and level_3 = '0' and instanceNo='$delValue'";
	mysqli_query($pubConn,$updSql);
}

if(1==$E1del)//删除E1connect时需删除相同编号的E1 link
{
	$IdArr	= explode('_',$delValue);
	$delValue = $IdArr[0];
	$AAS_E1ID = $IdArr[1];
	
	$sysId = '322_99_99'; 
	
	$sysIdArr	= explode('_',$sysId);
	$sysTypeNo	= $sysIdArr[0];
	$sysNo		= $sysIdArr[1];
	$subSysNo	= $sysIdArr[2];

	$oidstr = '2.4.4';
	$objWhereStr= '';
	$objWhereStr =getLevelWhere($oidstr);		
			
	$objDb		= 'OBJ_'.$sysTypeNo;
	$paramTable = 'param_'.$sysNo;

	$defSql = " SELECT initValue FROM paramConf WHERE $objWhereStr";
	$defRes = @mysqli_query($pubConn,$defSql);
	$row = @mysqli_fetch_array($defRes);
	$delSql = "UPDATE $paramTable SET initValue = '$row[initValue]' 
            WHERE subSysNo = '$subSysNo' AND $objWhereStr AND instanceNo='$delValue'";
	$delRes = @mysqli_query($pubConn,$delSql);
	
	$oidstr = '2.4.3';
	$objWhereStr= '';
	$objWhereStr =getLevelWhere($oidstr);		
			
	$objDb		= 'OBJ_'.$sysTypeNo;
	$paramTable = 'param_'.$sysNo;

	$defSql = " SELECT initValue FROM paramConf WHERE $objWhereStr";
	$defRes = @mysqli_query($pubConn,$defSql);
	$row = @mysqli_fetch_array($defRes);
	$delSql = "UPDATE $paramTable SET initValue = '$row[initValue]' 
            WHERE subSysNo = '$subSysNo' AND $objWhereStr AND instanceNo='$delValue'";
	$delRes = @mysqli_query($pubConn,$delSql);
					
	$oidstr = '2.4.2';
	$objWhereStr= '';
	$objWhereStr =getLevelWhere($oidstr);		
			
	$objDb		= 'OBJ_'.$sysTypeNo;
	$paramTable = 'param_'.$sysNo;

	$defSql = " SELECT initValue FROM paramConf WHERE $objWhereStr";
	$defRes = @mysqli_query($pubConn,$defSql);
	$row = @mysqli_fetch_array($defRes);
	$delSql = "UPDATE $paramTable SET initValue = '$row[initValue]' 
            WHERE subSysNo = '$subSysNo' AND $objWhereStr AND instanceNo='$delValue'";
	$delRes = @mysqli_query($pubConn,$delSql);
	
	$oidstr = '2.4.1';
	$objWhereStr= '';
	$objWhereStr =getLevelWhere($oidstr);		
			
	$objDb		= 'OBJ_'.$sysTypeNo;
	$paramTable = 'param_'.$sysNo;

	$defSql = " SELECT initValue FROM paramConf WHERE $objWhereStr";
	$defRes = @mysqli_query($pubConn,$defSql);
	$row = @mysqli_fetch_array($defRes);
	$delSql = "UPDATE $paramTable SET initValue = '$row[initValue]' 
            WHERE subSysNo = '$subSysNo' AND $objWhereStr AND instanceNo='$delValue'";
	$delRes = @mysqli_query($pubConn,$delSql);	
				
	{//close 8ke1 enable, crc4flag
		open8ke1Enable($delValue,0);
		open8ke1CRC4Flag($delValue,0);
	}//end close

	$sysId = '222_99_99';		
	$sysIdArr	= explode('_',$sysId);
	$sysTypeNo	= $sysIdArr[0];
	$sysNo		= $sysIdArr[1];
	$subSysNo	= $sysIdArr[2];
	
	$E1link_oidstr = '2.5.1';
	$E1link_objWhereStr= '';	
	$E1link_objWhereStr =getLevelWhere($E1link_oidstr);
	
	
	$E1link_objDb	   = 'OBJ_'.$sysTypeNo;
	$E1link_paramTable = 'param_'.$sysNo;
	
	$defSql = " SELECT initValue FROM paramConf WHERE $E1link_objWhereStr";
	$defRes = @mysqli_query($pubConn,$defSql);
	$row = @mysqli_fetch_array($defRes);

	if($TypeIn == 3)//added by arwean 2006-03-30
	{
		$selSql = "select initValue from $paramTable where $E1link_objWhereStr and instanceNo='$delValue' ";
		$result = @mysqli_query($pubConn,$selSql);
		$rowFind = @mysqli_fetch_array($result);
		//MTP3_8_pub
		$VSS_MTP3Table	 = 'param_8';
		$selSql = "select initValue,instanceNo from $VSS_MTP3Table where $E1link_objWhereStr and initValue!='$row[initValue]'";
		$result = @mysqli_query($pubConn,$selSql);
		if(0)
	    {
	    	echo "<br>selSql: $selSql";
	    	echo mysqli_num_rows($result);
	    	exit;
	    }
		while($Row_1=@mysqli_fetch_array($result))
		{
			if($Row_1[initValue]==$rowFind[initValue])
			{
				$delSql = "UPDATE $VSS_MTP3Table SET initValue = '$row[initValue]' 
			            WHERE $E1link_objWhereStr AND instanceNo='$Row_1[instanceNo]'";
			    if(0)
			    {
			    	echo "<br>delSql: $delSql";
			    	exit;
			    }
				$delRes = @mysqli_query($pubConn,$delSql);
				echo mysqli_error($pubConn);	
				break;
			}
		}		
	}//end if
	
	$delSql = "UPDATE $paramTable SET initValue = '$row[initValue]' 
            WHERE $E1link_objWhereStr AND instanceNo='$delValue'";
//	echo "<br>delSql=$delSql";
	$delRes = @mysqli_query($pubConn,$delSql);
	echo mysqli_error($pubConn);
	
	if($TypeIn == 2)
	{
		//MTP3_11_pub
		$AAS_MTP3Table	 = 'param_11';
		$delSql = "UPDATE $AAS_MTP3Table SET initValue = '$row[initValue]' 
	            WHERE $E1link_objWhereStr AND instanceNo='$AAS_E1ID'";
//	echo "<br>delSql=$delSql";
		$delRes = @mysqli_query($pubConn,$delSql);
		echo mysqli_error($pubConn);			
	}

	echo "<script LANGUAGE=\"JavaScript\">";
	echo "\n window.location.href=\"$backurl\";";
	echo "\n </script>";
	exit();				
}

if(1==$BTSdel)
{
	$sysId = '322_99_99';
	
	$sysIdArr	= explode('_',$sysId);
	$sysTypeNo	= $sysIdArr[0];
	$sysNo		= $sysIdArr[1];
	$subSysNo	= $sysIdArr[2];
	
	$oidstr = '2.2.7';
	$objWhereStr= '';
	$objWhereStr =getLevelWhere($oidstr);		
	
	$objDb		= 'OBJ_'.$sysTypeNo;
	$paramTable = 'param_'.$sysNo;

	$paramSql = " SELECT initValue,instanceNo FROM $paramTable  
	WHERE $objWhereStr AND instanceNo ='$delValue'
	";
	$Result = mysqli_query($pubConn,$paramSql);				
	$Row	= mysqli_fetch_array($Result);
	$delPrefixNo = hexdec(getBitValue($Row[initValue],'5.0-5.7'));

	$defSql = " SELECT initValue FROM paramConf WHERE $objWhereStr";
	$defRes = @mysqli_query($pubConn,$defSql);
	$row = @mysqli_fetch_array($defRes);
	$defCellValue = $row[initValue];
	$delSql = "UPDATE $paramTable SET initValue = '$defCellValue' 
            WHERE subSysNo = '$subSysNo' AND $objWhereStr AND instanceNo='$delValue'";
	$delRes = @mysqli_query($pubConn,$delSql);
	echo mysqli_error($pubConn);
	
	{//delete the delPrefixNo if there is no other cells use it.
		$paramSql = " SELECT initValue FROM $paramTable  
					WHERE $objWhereStr and initValue!='$defCellValue' ";
		$result = mysqli_query($pubConn,$paramSql);
		$otherUsed=0;	
		while($row	= mysqli_fetch_array($result))
		{
			$prefixNo=hexdec(getBitValue($row[initValue],'5.0-5.7'));
			if($prefixNo==$delPrefixNo)
			{
				$otherUsed=1;
				break;
			}
		}
		if($otherUsed==0)//delete $delPrefixNo.
		{
			$tmpParamConfTable='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>";
									
			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);	
			}
//					exit;
		}					
	}
	echo "<script LANGUAGE=\"JavaScript\">";
	echo "\n window.location.href=\"$backurl\";";
	echo "\n </script>";
	exit();				
}

if(1==$GTTdel)
{
	$sysId = '223_99_99';
	
	$sysIdArr	= explode('_',$sysId);
	$sysTypeNo	= $sysIdArr[0];
	$sysNo		= $sysIdArr[1];
	$subSysNo	= $sysIdArr[2];
	
	$oidstr = '2.2';
	$objWhereStr= '';	
	$objWhereStr =getLevelWhere($oidstr);
	
	
	$objDb		= 'OBJ_'.$sysTypeNo;
	$paramTable = 'param_'.$sysNo;

	$defSql = " SELECT initValue FROM paramConf WHERE $objWhereStr";
	$defRes = @mysqli_query($pubConn,$defSql);
	$row = @mysqli_fetch_array($defRes);
	$flagoffset = "00.0-00.7";			
	$row[initValue] = setBitValue($row[initValue],$flagoffset,'00');
	$delSql = "UPDATE $paramTable SET initValue = '$row[initValue]' 
            WHERE subSysNo = '$subSysNo' AND $objWhereStr AND instanceNo='$delValue'";
	$delRes = @mysqli_query($pubConn,$delSql);
	echo mysqli_error($pubConn);
	echo "<script LANGUAGE=\"JavaScript\">";
	echo "\n window.location.href=\"$backurl\";";
	echo "\n </script>";
	exit();				
}

if(1==$lacdel)
{
	$objDb 		= 'OBJ_322';
	$objIdStr = '2.2.6';
	$objWhereStr =getLevelWhere($objIdStr);		
	$paramTable = 'param_99';
	$updSql = "UPDATE $paramTable SET initValue = '0000000000'   
		WHERE $objWhereStr AND instanceNo = '$delValue'
		";
	if($DEBUG) echo "$updSql<br>";										
	mysqli_query($pubConn,$updSql);
	echo "<script LANGUAGE=\"JavaScript\">";
	echo "\n window.location.href=\"$backurl\";";
	echo "\n </script>";
	exit();			
}

if((1==$E1lock)||(1==$E1unlock)){
		$IdArr	= explode('_',$delValue);
		$delValue = $IdArr[0];
		$AAS_E1ID = $IdArr[1];
		
		$sysId = '322_99_99';
		
		$sysIdArr	= explode('_',$sysId);
		$sysTypeNo	= $sysIdArr[0];
		$sysNo		= $sysIdArr[1];
		$subSysNo	= $sysIdArr[2];
		if(1==$E1lock) $set_value=0;
		if(1==$E1unlock)$set_value=1;
		open8ke1Enable($delValue,$set_value);

		$oidstr = '2.4.4';
		$objWhereStr= '';
		$objWhereStr =getLevelWhere($oidstr);		
				
		$objDb		= 'OBJ_'.$sysTypeNo;
		$paramTable = 'param_'.$sysNo;

		$defSql = " SELECT initValue FROM $paramTable WHERE $objWhereStr AND instanceNo='$delValue'";
		$defRes = @mysqli_query($pubConn,$defSql);
		$row = @mysqli_fetch_array($defRes);
		$flagoffset = "00.1-00.1";

		$row[initValue] = setBitValue($row[initValue],$flagoffset,$set_value);
		$delSql = "UPDATE $paramTable SET initValue = '$row[initValue]' 
	            WHERE subSysNo = '$subSysNo' AND $objWhereStr AND instanceNo='$delValue'";
		$delRes = @mysqli_query($pubConn,$delSql);
		echo mysqli_error($pubConn);
		$commIdStr	=oidSysCommSend($sysId,$nSetComm,$oidstr);
		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();
		}
		echo "<script LANGUAGE=\"JavaScript\">";
		echo " location='$PHP_SELF?trunkgp=$trunkgp&gtt=$gtt&sysNo=$sysNo&infoNo=$infoNo&linkset=$linkset&gttSSN=$gttSSN&grpNo=$grpNo&appType=$appType';";
		echo "</script>";
}

if(2==$E1unlock){
		$IdArr	= explode('_',$delValue);
		$delValue = $IdArr[0];
		$AAS_E1ID = $IdArr[1];
		
		$sysId = '322_99_99';
		
		$sysIdArr	= explode('_',$sysId);
		$sysTypeNo	= $sysIdArr[0];
		$sysNo		= $sysIdArr[1];
		$subSysNo	= $sysIdArr[2];
		
		open8ke1Enable($delValue,1);
		
		$oidstr = '2.4.4';
		$objWhereStr= '';
		$objWhereStr =getLevelWhere($oidstr);		
				
		$objDb		= 'OBJ_'.$sysTypeNo;
		$paramTable = 'param_'.$sysNo;

		$defSql = " SELECT initValue FROM $paramTable WHERE $objWhereStr AND instanceNo='$delValue'";		
		$defRes = @mysqli_query($pubConn,$defSql);
		$row = @mysqli_fetch_array($defRes);
		$flagoffset = "00.1-00.1";			
		$row[initValue] = setBitValue($row[initValue],$flagoffset,'1');
		$delSql = "UPDATE $paramTable SET initValue = '$row[initValue]' 
	            WHERE subSysNo = '$subSysNo' AND $objWhereStr AND instanceNo='$delValue'";
//	     echo       "$delSql<br>";
		$delRes = @mysqli_query($pubConn,$delSql);
		echo mysqli_error($pubConn);
		$commIdStr	=oidSysCommSend($sysId,$nSetComm,$oidstr);
		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();
		}
		echo "<script LANGUAGE=\"JavaScript\">";
		echo " location='$PHP_SELF?trunkgp=$trunkgp&gtt=$gtt&sysNo=$sysNo&infoNo=$infoNo&linkset=$linkset&gttSSN=$gttSSN&grpNo=$grpNo&appType=$appType';";
		echo "</script>";
}
if($setSys || $getSys  || $undoSet)
{
	echo "<br><br><h4><font color=\"#0000ff\">Finished!</font></h4>";
	if($DEBUG) exit();
	//sleep(1);
	echo "<script LANGUAGE=\"JavaScript\">";
	echo " location='$PHP_SELF?trunkgp=$trunkgp&gtt=$gtt&sysNo=$sysNo&infoNo=$infoNo&linkset=$linkset&gttSSN=$gttSSN&grpNo=$grpNo&appType=$appType';";
	echo "</script>";
	exit();
}

//==========================================================
//输出并显示数据
//==========================================================
?>

<body topmargin="0" leftmargin="12">
<?php
if(!isset($linkset))
{
	if(!isset($linkset))
		echo "<font><b>ERROR!!:linkset == NULL</b></font><br>";	
	exit(0);
} 
echo "<form method=\"POST\" name=\"setForm\" action=\"$PHP_SELF?infoNo=$infoNo&trunkgp=$trunkgp&linkset=$linkset&gttSSN=$gttSSN&grpNo=$grpNo\">";
{
	echo "<table border=\"0\" width=\"100%\">";
	echo "<tr>";
	echo "<td width=\"50%\">";
	if($TypeIn==17)
		echo "Configuration > <a href=\"../overview/overview.php\">Network</a> > <a href=\"#\">$webname</a>";
	else
		echo "Configuration > <a href=\"../overview/overview.php\">Network</a> > <a href=\"#\">$devicename</a>";
	echo "</td>";
	echo "<td width=\"50%\" align=\"right\" title=\"Help\">";
	switch ($devicename)
	{
		case 'Switch':
		$helpId='2.32';
		break;
		case 'BSC':
		$helpId='2.31';
		break;
		case 'Peripheral':
		{
			switch($webname)
			{
				case 'PCR':
				$helpId='2.1.3.3';
				break;
				case 'AAS':
				$helpId='2.1.3.1';
				break;
				case 'VSS':
				$helpId='2.1.3.2';
				break;
				case 'CNF':
				$helpId='2.1.3.4';
				break;
				default:
				$helpId='2';
				break;
			}
			break;
		}
		default:
		$helpId='2';
		break;
	}
	if($devicename!=$strGttObjects)
		showHelp($helpId);
	echo "</td>";
	echo "</tr>";
	echo "</table>";
	echo "<br>";
	
	{
		echo "<table width=\"100%\">";
		echo "<tr>";
			echo "<td width=\"70%\">";
				echo "<b></b>";
			echo "</td>";
			echo "<td width=\"20%\" align=\"right\">";
					echo "<input type=\"submit\" title=\"$strTitleGet\" name=\"getSys\" value=\"$strGet\" class=\"button\" style=\"cursor:pointer; left: 1; top: 2; width: 60; height: 25; position: relative\">";
					echo "&nbsp;&nbsp;&nbsp;";
					echo "<input type=\"submit\" title=\"$strTitleSet\" name=\"setSys\" value=\"$strSet\" class=\"button\" style=\"cursor:pointer; left: 1; top: 2; width: 60; height: 25; position: relative\">";
				echo "</td>";
			echo "<td width=\"10%\">";
				echo "<p align=\"right\"><a href=\"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=\"sysNo\" value=\"$sysNo\">";
		echo "<input type=\"hidden\" name=\"grpNo\" value=\"$grpNo\">";
		echo "<input type=\"hidden\" name=\"appType\" value=\"$appType\">";
		echo "<input type=\"hidden\" name=\"infoNo\" value=\"$infoNo\">";

		echo "</table>";
		echo "<br>";
	}
}
echo "<table rules=rows border=\"1\" width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" bordercolor=\"#666666\" bordercolordark=\"#FFFFFF\">";

if($SP_show)
{
	if($TypeIn==17)//ISDN Switch
	{
		$oidstr = '2.11';
		
		$objWhereStr= '';
		$objWhereStr =getLevelWhere($oidstr);
		$paramSql = " SELECT initValue,instanceNo FROM param_99  
					WHERE $objWhereStr AND instanceNo ='$infoNo' 
					";	
		$Result = mysqli_query($pubConn,$paramSql);				
		$Row		 = mysqli_fetch_array($Result);
		$elementname		= trim(toAscii(getBitValue($Row[initValue],"14.0-23.7")));		
		echo "<tr>";
		echo "<td width=\"15%\" bgcolor=\"#E6E6E6\" style=\"border-right:1px solid\"><b>IUA Link</b></td>";
		echo "<td colspan=\"$colspans\">$elementname</td>";
		echo "</tr>";		
	}
	else
	{	
		$oidstr = '2.4.1';
		
		$objWhereStr= '';
		$objWhereStr =getLevelWhere($oidstr);
		$paramSql = " SELECT initValue,instanceNo FROM param_99  
					WHERE $objWhereStr AND instanceNo ='$linkset' 
					";	
		$Result = mysqli_query($pubConn,$paramSql);				
		$Row		 = mysqli_fetch_array($Result);
		$linksetname		= trim(toAscii(getBitValue($Row[initValue],"7.0-16.7")));
		if(strlen($linksetname)==0)
			$linksetname = '--';
		echo "<tr>";
		echo "<td width=\"15%\" bgcolor=\"#E6E6E6\" style=\"border-right:1px solid\"><b>SS7</b></td>";
		echo "<td ><a href=\"./wxc2_sp_signaling.php?trunkgp=$trunkgp&devicename=$devicename&sysNo=$sysNo&infoNo=$infoNo&linkset=$linkset&grpNo=$grpNo&appType=$appType\";>$linksetname</a></td>";
		echo "</tr>";
	}
}

if($TG_show)
{
	{//Trunk group strat
	echo "<tr>";
	echo "<td width=\"15%\" bgcolor=\"#E6E6E6\" style=\"border-right:1px solid\"><b>Trunk group</b></td>";
	echo "<td><table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\">";
		echo "<tr bgcolor=\"#E6E6E6\">";
		echo "<td width=\"15%\">No.</td>";
		echo "<td width=\"15%\">Category</td>";
		if($webname=='IUA')
		{
			echo "<td width=\"15%\">&nbsp</td>";
			echo "<td width=\"55%\">&nbsp</td>";
		}
		else
		{
			echo "<td width=\"15%\">NI</td>";
			echo "<td width=\"55%\">DPC</td>";
		}
		echo "</tr>";
	
	//------------查询TrunkGroup参数表---------------------
	
	$sysId = '322_99_99';
	
	$sysIdArr	= explode('_',$sysId);
	$sysTypeNo	= $sysIdArr[0];
	$sysNo		= $sysIdArr[1];
	$subSysNo	= $sysIdArr[2];
	
	$oidstr = '2.1.4';
	$objWhereStr= '';
	$objWhereStr = getLevelWhere($oidstr);
	$objDb		= 'OBJ_'.$sysTypeNo;
	$paramTable = 'param_'.$sysNo;
	
	
	$paramSql = " SELECT initValue,readValue,instanceNo FROM $paramTable  
				WHERE subSysNo = '$subSysNo' AND  $objWhereStr AND instanceNo ='$trunkgp' 
				";
	
	$Result = mysqli_query($pubConn,$paramSql);				
	$Row		 = mysqli_fetch_array($Result);
	//------------读TrunkGroup参数表---------------------
	//echo "<br>paramSql: $paramSql";
	
//	$RAC 			= hexdec(getBitValue($Row[initValue],'10.0-10.7'));
	$Flag 			=	getBitValue($Row[initValue],'4.0-4.0');
	$Category 		= getBitValue($Row[initValue],'4.3-4.5');
	$NetID 			= hexdec(getBitValue($Row[initValue],'5.0-5.7'));
	$DPC 			= hexdec(getBitValue($Row[initValue],'0.0-3.7'));
	$Alternative 	=	hexdec( getBitValue($Row[initValue],'7.0-7.7'));	
	
	$CDR			= getBitValue($Row[initValue],'4.1-4.1');
	$Flag			= (BinDec($Flag)) ? ("Enable") : ("Disable");
	$CDR			= (BinDec($CDR)) ? ("on") : ("off");
	switch(BinDec($Category))
	{
		case 0:
		$Category = "PSTN";
		break;
		case 1:
		$Category = "HPLMN";
		break;
		case 2:
		$Category = "VPLMN";
		break;
		case 3:
		$Category = "SUB";
		break;
		case 4:
		$Category = "IP";
		break;
		case 5:
		$Category = "Intercept";
		break;
		default:
		$Category = "N/A";
	}
	//echo "$Row[initValue]";
	//------------显示TrunkGroup参数表---------------------
	echo "<tr>";
	if(isset($trunkgp))
	{
		$setobjIdstr = "2.1.4-2.1.4";
		$setname = 'Trunk Group';
		if($TypeIn==17)
			echo "<td ><a href=\"javascript:openSet('$setobjIdstr','$trunkgp-$RAC','$setname','$sysId','$trunkgp','$linkset','$webname','$backurl','$infoNo');\">$trunkgp&nbsp</a></td>";
		else
			echo "<td ><a href=\"javascript:openSet('$setobjIdstr','$trunkgp-$RAC','$setname','$sysId','$trunkgp','$linkset','$webname','$backurl','$infoNo');\">$trunkgp&nbsp</a></td>";
		echo "<td >$Category&nbsp</td>";
		if($webname=='IUA')
		{
			echo "<td >&nbsp</td>";
			echo "<td >&nbsp</td>";
		}
		else
		{
			echo "<td >$NetIdConfArr[$NetID]&nbsp</td>";
			echo "<td >$DPC&nbsp</td>";
		}
	}
	else
	{
		echo "<td >--</td>";
		echo "<td >--</td>";
		echo "<td >--</td>";
		echo "<td colspan=\"4\">--</td>";
	}
	echo "</tr>";
	echo "</table></td>";
	echo "</tr>";
	}//Trunk group end
}
if($E1_show)
{
	{//E1 strat
	//------------查询E1参数表---------------
	$sysId = '322_99_99';
	
	$oidstr = '2.4.2';
	$objWhereStr= '';	
	$objWhereStr =getLevelWhere($oidstr);
	
	$objDb		= 'OBJ_'.$sysTypeNo;
	$paramTable = 'param_'.$sysNo;
	
	$HEXtrunkgp	= omc_keep_length(dechex($trunkgp),"0","2");
	$HEXtrunkgp = strtoupper($HEXtrunkgp);
	$paramSql = " SELECT initValue,readValue,instanceNo FROM $paramTable  
				WHERE subSysNo = '$subSysNo' AND  $objWhereStr AND initValue = '$HEXtrunkgp' 
				ORDER BY instanceNo";
	//echo "$paramSql";
	$Result = mysqli_query($pubConn,$paramSql);
	
	
	//------------读E1参数表---------------------
	$tmpWhere='(0';
	$E1connarr="";
	
	$out_time=date("Y-m-d H:i:s",mktime(date("H"),date("i"),date("s")-30,date("m"),date("d"),date("Y")));
	$el2_bgn	=   25; //e1 layer2
	while($Row = mysqli_fetch_array($Result))
	{		
		if($tmpWhere=='(0')
			$tmpWhere="(instanceNo='$Row[instanceNo]'";
		else
			$tmpWhere=$tmpWhere." OR instanceNo='$Row[instanceNo]'";	
	}
	$tmpWhere=$tmpWhere.")";
	
	{
		$oidstr = '2.4.4';
		$objWhereStr= '';	
		$objWhereStr =getLevelWhere($oidstr);
		
		$paramSql = " SELECT initValue,readValue,instanceNo FROM $paramTable  
					WHERE subSysNo = '$subSysNo' AND  $objWhereStr AND $tmpWhere ORDER BY instanceNo 
					";
		$Result_3 = mysqli_query($pubConn,$paramSql);				
		//echo $paramSql;
		$tmpWhere='(0';
		$n = 0;
		while($Row_3 = mysqli_fetch_array($Result_3))
		{
			$oflag = getBitValue($Row_3[initValue],'0.0-0.0');
			if($oflag)
			{
				if($tmpWhere=='(0')
					$tmpWhere="(instanceNo='$Row_3[instanceNo]'";
				else
					$tmpWhere=$tmpWhere." OR instanceNo='$Row_3[instanceNo]'";
				
				{//E1 state
					$tempnum = $Row_3[instanceNo]/8;
					$cardno = Floor($tempnum);
					$sysNo = $cardno > 15 ? 1 : 0;
					$slot = $cardno % 16;
					$port = $Row_3[instanceNo] - $cardno*8;	
					
					$e1selSql = "SELECT sysTypeNo,sysNo,subSysNo,detailStat,updateTime 
									FROM sysStat WHERE sysTypeNo='111' AND sysNo='$sysNo' and subSysNo='$slot' ";
					$e1Result = @mysqli_query($pubConn,$e1selSql);
					if($e1Row = @mysqli_fetch_array($e1Result))
					{
						$hex_mes = $e1Row[detailStat];
						$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;
						}
		
						//e1 layer2
						$bin_inl=substr($bin_mes,$el2_bgn*8+7-$port,1);//0:'N'; 1:'Y'; 2:'--'
						$E1state[$n] = bindec($bin_inl);
					}
				}//end E1 state
				
				$mscLocflag[$n]	= getBitValue($Row_3[initValue],"00.1-00.1");
				
				$n++;
			}
		}
		$tmpWhere=$tmpWhere.")";
	}
	
	{//Protocol
		$oidstr = '2.4.1';
		$objWhereStr= '';
		$objWhereStr = getLevelWhere($oidstr);

		$paramSql = " SELECT initValue,readValue,instanceNo FROM $paramTable  
					WHERE subSysNo = '$subSysNo' AND  $objWhereStr AND $tmpWhere ORDER BY instanceNo 
					";
		//echo "$paramSql";
		$Result_1 = mysqli_query($pubConn,$paramSql);				
		$n=0;
		while($Row_1 = mysqli_fetch_array($Result_1))
		{
			$instNo[$n] = $Row_1[instanceNo];
			$is8ke1En = is8ke1Enable($Row_1[instanceNo]);
			$Lockflag[$n] = $mscLocflag[$n] && 	$is8ke1En;			
			if($n==0)
			{
				$E1connarr = $instNo[$n];
			}
			else
			{
				$E1connarr = $E1connarr."_".$instNo[$n];		
			}				
			$E1Protocol[$n] = $Row_1;								
			$n++;
		}
	}			
	{//CIC
		$oidstr = '2.4.3';
		$objWhereStr= '';					
		$objWhereStr = getLevelWhere($oidstr);

		$paramSql = " SELECT initValue,readValue,instanceNo FROM $paramTable  
					WHERE subSysNo = '$subSysNo' AND  $objWhereStr AND $tmpWhere ORDER BY instanceNo 
					";
		//echo "$paramSql";
		$Result_2 = mysqli_query($pubConn,$paramSql);				
		$n=0;
		while($Row_2 = mysqli_fetch_array($Result_2))
		{		
			$E1cic[$n] = $Row_2;
			$n++;
		}
	}
	
	echo "<input type=\"hidden\" name=\"E1connarr\" value=\"$E1connarr\">";	
	if($DEBUG) echo "E1connarr=$E1connarr<br>";
	//------------显示E1参数表---------------------	
	$rowspan = $n +1;
	if($n ==0)
	{
		$tmpcic = 255;
		$rowspan =2;
	}
	else
	{
		$tmpcic = hexdec($E1cic[0][initValue]);
	}
	
echo "<tr>";
	echo "<td style=\"border-right:1px solid\" bgcolor=\"#E6E6E6\">";
	echo "<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" ><tr>";
	echo "<td align=\"left\" ><b>E1/T1 connection</b></td>";
	if($TypeIn ==2 && $n > 1)//AAS最多加2条E1connect
	{
		echo "<td align=\"right\"><a href=\"javascript:newError('E1')\"><font size=4>+</font></a></td>";			
	}
	elseif($TypeIn ==2)
	{	
		echo "<td align=\"right\"><a href=\"javascript:openSet('$tmpcic','new','E1','$n','$trunkgp','$linkset','$webname','$backurl','$infoNo')\"><font size=4>+</font></a></td>";	
	}
	elseif($TypeIn !=2&& $n > 31)//最多加32条E1connect
	{	
		echo "<td align=\"right\"><a href=\"javascript:newError('E1')\"><font size=4>+</font></a></td>";			
	}
	else
	{
		echo "<td align=\"right\"><a href=\"javascript:openSet('$tmpcic','new','E1','$n','$trunkgp','$linkset','$webname','$backurl','$infoNo')\"><font size=4>+</font></a></td>";
	}
	echo "</tr></table>";
	echo "</td>";
	
	echo "<td>";
	echo "<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" >";	
	echo "<tr bgcolor=\"#E6E6E6\"  >";
		echo "<td width=\"15%\">No.</td>";
		echo "<td width=\"15%\">Protocol</td>";
		if($webname=="IUA")
			echo "<td width=\"15%\">Interface ID</td>";
		else	
			echo "<td width=\"15%\">Circuit ID</td>";
		echo "<td width=\"15%\">E1/T1 channel</td>";
		echo "<td width=\"15%\">Status</td>";
		echo "<td width=\"15%\">Admin State</td>";
		echo "<td width=\"10%\"align=\"right\">Delete</td>";
	echo "</tr>";
	if($n==0)	
	{
		echo "<tr><td colspan=\"7\">--</td></tr>";			
	}
	$Protocol = array("TUP","ISUP","AIF","ISDN NT","ISDN LT","CI-CNF","CI-loopback");
	for($i=0;$i < $n;$i++)
	{
		$tempnum = $instNo[$i]/8;
		$cardno = Floor($tempnum);
		$cardE1no = $instNo[$i] - $cardno*8;
		$cscNo = Floor($cardno/16);
		$subCardNo = $cardno%16;
		$cardname = "CSC$cscNo"."&nbsp;"."Card-$subCardNo-$cardE1no";
		
		$cic =	hexdec(getBitValue($E1cic[$i][initValue],'0.0-0.7'));
		if($i>3)
			echo "<tr id='e1t1$i' style=\"display:none\" onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";
		else
			echo "<tr id='e1t1$i' onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";
		//echo "<tr onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";		
		echo "<td ><a href=\"javascript:openSet('$cic','$instNo[$i]','E1','$sysId','$trunkgp','$linkset','$webname','$backurl','$infoNo')\">$cardname</a></td>";
		$p	 =	hexdec(getBitValue($E1Protocol[$i][initValue],'0.0-0.7'));
		echo "<td >$Protocol[$p]&nbsp;</td>";	
		
		echo "<td >$cic&nbsp;</td>";
			
	 	echo "<td><a href=\"javascript:openSet('11','$instNo[$i]','E1channel','$Protocol[$p]','$trunkgp','$linkset','$webname','$backurl','$infoNo')\">";
		
		$tempnum = $instNo[$i]/8;
		$cardno = Floor($tempnum);
		$cardname = "cardno"."_$cardno";
		$tempno = $cardno+1;
		$oidCard = "2.5."."$tempno";
//		$objWhereStr =getLevelWhere($oidCard);
		$objWhereStr =" level_1 = '2' and level_2 = '5' and level_3 = '$tempno'";
		$cardE1no = $instNo[$i] - $cardno*8;
		$timeslotno = $cardE1no*32;	
		$enabletime = 0;

		$tmp = $timeslotno+32;
		$selSql = "SELECT  initValue    
				 FROM $paramTable 
				 WHERE $objWhereStr AND instanceNo>='$timeslotno' AND instanceNo<='$tmp'
				";
		//echo "<br>E1 Enable Sql: $selSql";
		$result=mysqli_query($pubConn,$selSql);
		echo mysqli_error($pubConn);				
		for($j=0; $j< 32;$j++)
		{
			$rows  =mysqli_fetch_array($result);
			$orgValue=$rows[0];
			echo mysqli_error($pubConn);
					
			$getval	=	bindec(getBitValue($orgValue,'00.0-00.0'));	
			if($getval)
				$enabletime++;
			$timeslotno++;
		}

		echo "<input type=\"hidden\" name=\"$cardname\" value=\"$oidCard\">";
		echo "$enabletime enable</a></td>";

		if($cic == 0)
		{
			$delE1ID = 0;
		}
		else
		{
			$delE1ID = 1;
		}
		$delID = $instNo[$i]."_".$delE1ID;
		if($DEBUG) echo "$delID<br>";		
		if(isset($E1state[$i]) && $E1state[$i]==1)//$E1state[$i]也可能没有赋值
			echo "<td>OK</td>";
		else
			echo "<td>Down</td>";

		if($Lockflag[$i])
			echo "<td><a href=\"javascript:lockFirm('$delID','E1lock','$trunkgp','$linkset',this)\" title=\"to lock this E1\">Unlocked</a>";
		else
			echo "<td><a href=\"javascript:lockFirm('$delID','E1unlock','$trunkgp','$linkset',this)\" title=\"to unlock this E1\">Locked</a>";

		echo "</td>";				
	
		echo "<td align=\"right\" colspan=\"1\"><input type=\"checkbox\" name=\"C$instanceNo\" value=\"ON\" onClick=\"javascript:delFirm('$delID','E1','$trunkgp','$linkset',this)\" ></td>";
		echo "</tr>";	
	}
	if($n>4)
	{	
		echo "<tr id='showe1t1' style=\"display:block\"><td><a href=\"javascript:clickOnMoreHide('e1t1',$n,'show')\">More >></a></td></tr>"; 
		echo "<tr id='hidee1t1' style=\"display:none\"><td><a href=\"javascript:clickOnMoreHide('e1t1',$n,'hide')\">Hide >></a></td></tr>"; 
	}
	echo "</table>";
	echo "</td>";
	echo "</tr>";
	}//E1 end
}
if($vssPrefix_show || $prefix_show || $pcrPrefix_show)//SHOW VSS PREFIX or switch prefix
{
	
	$sysId = '322_99_99';
	
	$sysIdArr	= explode('_',$sysId);
	$sysTypeNo	= $sysIdArr[0];
	$sysNo		= $sysIdArr[1];
	$subSysNo	= $sysIdArr[2];
	
	$objDb		= 'OBJ_'.$sysTypeNo;
	$paramTable = 'param_'.$sysNo;
	
	{//get all valid prefix No
	$oidstr = '2.1.2';
	$objWhereStr= '';
	$objWhereStr =getLevelWhere($oidstr);		
	
	$defSql = " SELECT initValue,instanceNo FROM $paramTable 
				WHERE $objWhereStr and instanceNo<252
				ORDER BY instanceNo";
	//echo $defSql;
	$defRes = @mysqli_query($pubConn,$defSql);
	echo mysqli_error($pubConn);
	$offset_enable = "10.7-10.7";
	$offset_Properties = "10.2-10.3";	
	$offset_calltype = "10.4-10.6";
	$prefix_num=0;	
	while($row = @mysqli_fetch_array($defRes))
	{
		$prefix_enable=hexdec(getBitValue($row[initValue],$offset_enable));
		$prefix_property=hexdec(getBitValue($row[initValue],$offset_Properties));
		$prefix_calltype=hexdec(getBitValue($row[initValue],$offset_calltype));
		
		if($vssPrefix_show||$pcrPrefix_show) 
			$flag = $prefix_enable;
		if($prefix_show) 
			//$flag = ($prefix_enable && ($prefix_property==0) && ($prefix_calltype==0));//enable,trunk,normalcall
			$flag = $prefix_enable;
		if($flag)
		{
			$enablePrefix[$prefix_num][inst_no]=$row[instanceNo];
			$enablePrefix[$prefix_num][init_value]=$row[initValue];
			//echo "<br>enablePrefix[$prefix_num][init_value]:{$enablePrefix[$prefix_num][init_value]}";
			$prefix_num++;
		}
	}	
	}//end get valid prefix No
	{
	$oidstr = '2.1.3';
	$objWhereStr= '';
	$objWhereStr =getLevelWhere($oidstr);	
	
	$paramSql = " SELECT initValue,readValue,instanceNo FROM $paramTable  
				WHERE subSysNo = '$subSysNo' AND  $objWhereStr  and instanceNo<252
				ORDER BY instanceNo 
				";
	//echo "<br>paramSql: $paramSql";
	$Result_1 = mysqli_query($pubConn,$paramSql);	
	$prefix_no=0;
	$valid_num=0;	
	while($Row_1 = mysqli_fetch_array($Result_1))
	{
		if($Row_1[instanceNo]==$enablePrefix[$prefix_no][inst_no])
		{
			$tmpTg=hexdec($Row_1[initValue]);
			//echo "<br>tmpTg: $tmpTg";
			if($tmpTg == $trunkgp)
			{
				$validPrefix[$valid_num][inst_no] = $enablePrefix[$prefix_no][inst_no];
				$validPrefix[$valid_num][init_value] = $enablePrefix[$prefix_no][init_value];
				$valid_num++;
			}
			$prefix_no++;
		}
		if($prefix_no >= $prefix_num)
			break;		
	}
	}
	{//get prefix value
	$oidstr = '2.1.1';
	$objWhereStr= '';
	$objWhereStr =getLevelWhere($oidstr);	
	
	$paramSql = " SELECT initValue,readValue,instanceNo FROM $paramTable  
				WHERE subSysNo = '$subSysNo' AND  $objWhereStr  and instanceNo<252
				ORDER BY instanceNo 
				";
//				echo "$paramSql";
	$Result_1 = mysqli_query($pubConn,$paramSql);	
	$prefix_no=0;			
	while($Row_1 = mysqli_fetch_array($Result_1))
	{
		if($Row_1[instanceNo]==$validPrefix[$prefix_no][inst_no])
		{
			$tempprefix=strtoupper($Row_1[initValue]);
			$prefix = explode('E',$tempprefix);
			if($prefix[0] =="")
				$prefix[0]="--";
			$validPrefix[$prefix_no][prefix]=$prefix[0];
			//echo "<br>validPrefix[$prefix_no][prefix]:{$validPrefix[$prefix_no][prefix]}";
			$prefix_no++;
		}
		if($prefix_no >= $valid_num)
			break;		
	}
	}//end get prefix value
		
	//------------显示prefix参数表---------------------	
	$n=$prefix_no;
	$rowspan = $prefix_no +1;
	if($prefix_no==0) $rowspan=2;
	
	$setobjIdstr = "2.1.2-2.1.1-2.1.2";
	$backurlprefix=$backurl;
	
	echo "<tr>";
	echo "<td bgcolor=\"#E6E6E6\" style=\"border-right:1px solid\">";	
	echo "<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" ><tr>";
	echo "<td align=\"left\" ><b>Prefix</b></td>";
	echo "<td align=\"right\"><a href=\"javascript:openSet('$setobjIdstr','new','Prefix','$sysId','$trunkgp','$linkset','$webname','$backurlprefix','$infoNo')\"><font size=4>+</font></a></td>";
	echo "</tr></table>";
	echo "</td>";
	echo "<td>";
	
	echo "<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\">";
		echo "<tr bgcolor=\"#E6E6E6\" >";
			echo "<td width=\"15%\">No.</td>";
			echo "<td width=\"15%\">Prefix</td>";
			echo "<td width=\"15%\">TON-in</td>";
			echo "<td width=\"15%\">TON-out</td>";
			echo "<td width=\"15%\">Properties</td>";
			echo "<td width=\"15%\">Call Type</td>";
			//echo "<td >CDR</td>";
			echo "<td width=\"10%\"align=\"right\">Delete</td>";
		echo "</tr>";
	
	$TON_in 	= array('Spare','MSISDN','Unkown','NDD','IDD','Spare');
	$TON_out 	= array('Spare','MSISDN','Unkown','NDD','IDD','Spare');
	$Properties = array('Trunk','MSISDN','MSRN','MSC');	
	$callTypeArr= array('Normal Call','Emergency','MCT','VMS','IN');
	if($n==0){
		echo "<tr><td colspan=\"7\">--</td></tr>";	
	}
	for($i=0;$i < $n;$i++)
	{
		$tmpInitValue = $validPrefix[$i][init_value];
		$tmpInst	= $validPrefix[$i][inst_no];
		if($i>3)
			echo "<tr id='prefix$i' style=\"display:none\" onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";
		else
			echo "<tr id='prefix$i' onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";	
		//echo "<tr onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";
		echo "<td ><a href=\"javascript:openSet('$setobjIdstr','$tmpInst','Prefix','$sysId','$trunkgp','$linkset','$webname','$backurlprefix','$infoNo');\">$i&nbsp;</a></td>";
		$oTON_in		= BinDec(getBitValue($tmpInitValue,'0.0-0.3'));
		$oTON_out 		= BinDec(getBitValue($tmpInitValue,'0.4-0.7'));
		$oProperties 	= BinDec(getBitValue($tmpInitValue,'10.2-10.3'));
		$oCallType      = BinDec(getBitValue($tmpInitValue,'10.4-10.6'));
		$oCDR			= BinDec(getBitValue($tmpInitValue,'10.0-10.0'));
		$oCDR			= ($oCDR) ? ("ON") : ("OFF");
		$oRano			= $validPrefix[$i][prefix];
		echo "<td >$oRano&nbsp</td>";
		echo "<td >$TON_in[$oTON_in]&nbsp;</td>";
		echo "<td >$TON_out[$oTON_out]&nbsp;</td>";
		echo "<td >$Properties[$oProperties]&nbsp;</td>";
		echo "<td >$callTypeArr[$oCallType]&nbsp;</td>";
		echo "<td align=\"right\"><input type=\"checkbox\" name=\"C$instanceNo\" value=\"ON\" onClick=\"javascript:delFirm($tmpInst,'prefix','$trunkgp','$linkset',this)\" ></td>";
		echo "</tr>";			
	}
	//==============the more and hide button===================		
	if($n>4)
	{		
		echo "<tr id='showprefix' style=\"display:block\"><td><a href=\"javascript:clickOnMoreHide('prefix',$n,'show')\">More >></a></td></tr>"; 
		echo "<tr id='hideprefix' style=\"display:none\"><td><a href=\"javascript:clickOnMoreHide('prefix',$n,'hide')\">Hide >></a></td></tr>"; 
	}
	echo "</table>";
	echo "</td>";
	echo "</tr>";
}

if($prefix_show )//show conv prefix in switch
{
	$pubDb = "OMC_PUB";
	
	
	//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 "conv_pre_def = $conv_pre_def<br>";

	$objIdStr='no-2.8';
	$sysId = '225_99_99';
	$setname="Prefix manipulation";
	
	$oidStr = '2.8.0';
	$levelWhere = getLevelWhere($oidStr);
	
	$getsql = "select initValue,instanceNo from $net_paramTable where $levelWhere and initValue!='$conv_pre_def'";  
	$result = @mysqli_query($pubConn,$getsql);
	echo mysqli_error($pubConn);
	$convNo=0;
	$cmpName = "Info".$infoNo;
	
	//===================get the ISDN name
	$databases="OBJ_225";
	$sqll="select instanceNo,initValue from param_99 where level_1=2 and level_2=11 ";
	$resultt=@mysqli_query($pubConn,$sqll);
	$rowss=@mysqli_fetch_array($resultt);
	do
	{
		//======assign tg
		$trunk_tmp=hexdec(getBitValue($rowss[initValue],'3.0-3.7'))+0;
		if($trunk_tmp==$trunkgp)
		{
			//=======title
			$title=getBitValue($rowss[initValue],'14.0-23.7');
			$temp="";
			for($num=0;$num<10;$num++)
			{
				$str=substr($title,$num*2,2);
				$str=hexdec($str);
				$str=chr($str);
				$temp.=$str;
			}
			$title=$temp;
			$ISDN_Name=$title;
			break;
		}					
	}while($rowss=mysqli_fetch_array($resultt));
	$ISDN_Name=trim($ISDN_Name);
	

	
	
	while($pre_row = @mysqli_fetch_array($result))
	{
		$nameFlag = trim(toAscii(getBitValue($pre_row[initValue],'35.0-42.7')));
		if(strcmp($nameFlag,$ISDN_Name)==0)
		{
			$convPrefix[$convNo][initValue]=$pre_row[initValue];
			$convPrefix[$convNo][inst_no] = $pre_row[instanceNo];
			$prefix = getBitValue($pre_row[initValue],'00.0-15.7');
			if($convPrefix != 0)
				$prefix = toAscii($prefix);
			else
				$prefix = '--';
			$addDigs = getBitValue($pre_row[initValue],'18.0-33.7');
			if($addDigs != 0)
				$addDigs = toAscii($addDigs);
			else
				$addDigs = '--';
			$convPrefix[$convNo][prefix] = $prefix;
			$convPrefix[$convNo][delLen] = hexdec(getBitValue($pre_row[initValue],'16.0-16.7'));
			$convPrefix[$convNo][addLen] = hexdec(getBitValue($pre_row[initValue],'17.0-17.7'));
			$convPrefix[$convNo][addDigs] = $addDigs;
			$convPrefix[$convNo][valiLen] = hexdec(getBitValue($pre_row[initValue],'34.0-34.7'));
			//echo "<br>convPrefix[$convNo][prefix]:{$convPrefix[$convNo][initValue]}";
			$convNo++;
		}
	}//end while
	$getsql = "select initValue,instanceNo from $net_paramTable where $levelWhere and initValue='$conv_pre_def'";  
	//echo "<br>getsql: $getsql;";
	$result = @mysqli_query($pubConn,$getsql);
	$Row = @mysqli_fetch_array($result);
	$newConvInst=$Row[instanceNo];
	$conv_nrow = $convNo + 1;
	
	echo "<tr>";
	echo "<td bgcolor=\"#E6E6E6\" style=\"border-right:1px solid\">";	
	echo "<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" ><tr>";
	echo "<td align=\"left\" ><b>Prefix manipulation</b></td>";
	echo "<td align=\"right\"><a href=\"javascript:openSetConv('$newConvInst','$objIdStr','$sysId','$webname','$setname','$backurl','$infoNo','$trunkgp')\"><font size=4>+</font></a></td>";
	echo "</tr></table>";
	echo "</td>";
	
	echo "<td>";
		echo "<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" >";
		echo "<tr bgcolor=\"#E6E6E6\">";
			echo "<td width=\"15%\">No.</td>";
			echo "<td width=\"15%\">Prefix</td>";
			echo "<td width=\"15%\">Delete length</td>";
			echo "<td width=\"15%\">Add length</td>";
			echo "<td width=\"15%\">Add digits</td>";
			echo "<td width=\"15%\">Valid length</td>";
			echo "<td width=\"10%\"align=\"right\">Delete</td>";
		echo "</tr>";
	if($convNo==0){
		echo "<tr><td colspan=\"7\">--</td></tr>";	
	}
	for($i=0; $i< $convNo; $i++)
	{
		if($i>3)
			echo "<tr id='Prefixmanipulation$i' style=\"display:none\" onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";
		else
			echo "<tr id='Prefixmanipulation$i' onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";
		//echo "<tr onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";
		echo "<td width=\"15%\"><a href=\"javascript:openSetConv('{$convPrefix[$i][inst_no]}','$objIdStr','$sysId','$webname','$setname','$backurl','$infoNo','$trunkgp')\">$i</a></td>";

		echo "<td width=\"15%\">{$convPrefix[$i][prefix]}&nbsp</td>";
		echo "<td width=\"15%\">{$convPrefix[$i][delLen]}&nbsp;</td>";
		echo "<td width=\"15%\">{$convPrefix[$i][addLen]}&nbsp;</td>";
		echo "<td width=\"15%\">{$convPrefix[$i][addDigs]}&nbsp;</td>";
		echo "<td width=\"15%\">{$convPrefix[$i][valiLen]}&nbsp;</td>";
		
		echo "<td width=\"10%\"align=\"right\"><input type=\"checkbox\" name=\"C$instanceNo\" value=\"ON\" onClick=\"javascript:delFirm('{$convPrefix[$i][inst_no]}','convPrefix','$trunkgp','$linkset',this)\" ></td>";
		echo "</tr>";	
	}
	//===============more button==============
	if($convNo>4)
	{
		echo "<tr id='showPrefixmanipulation' style=\"display:block\"><td><a href=\"javascript:clickOnMoreHide('Prefixmanipulation',$convNo,'show')\">More >></a></td></tr>"; 
		echo "<tr id='hidePrefixmanipulation' style=\"display:none\"><td><a href=\"javascript:clickOnMoreHide('Prefixmanipulation',$convNo,'hide')\">Hide >></a></td></tr>"; 
	}
	echo "</table>";
	echo "</td>";
	echo "</tr>";
}




if($BSC_show)
{
	{//LAC
		$sysId = '322_99_99';
		$sysIdArr	= explode('_',$sysId);
		$sysTypeNo	= $sysIdArr[0];
		$sysNo		= $sysIdArr[1];
		$subSysNo	= $sysIdArr[2];
		$oidstr = '2.2.6';
		$objWhereStr =getLevelWhere($oidstr);
		
		$objDb		= 'OBJ_'.$sysTypeNo;
		$paramTable = 'param_'.$sysNo;
		
		$paramSql = " SELECT initValue,readValue,instanceNo FROM $paramTable  
					WHERE subSysNo = '$subSysNo' AND  $objWhereStr
					";
		$Result = mysqli_query($pubConn,$paramSql);
		$n=0;
		while($Row = mysqli_fetch_array($Result))
		{
			$tempGp = hexdec(getBitValue($Row[initValue],'01.0-01.7'));
			$tempFlag = hexdec(getBitValue($Row[initValue],'0.0-0.7'));
			
			if( $tempFlag == 1 && $trunkgp == $tempGp)
			{
				$LAC_value[$n] = hexdec(getBitValue($Row[initValue],'02.0-03.7'));
				$LAC_inst[$n] = $Row[instanceNo];
				$LAC_pageType[$n] = hexdec(getBitValue($Row[initValue],'4.0-4.7'));
				$n++;
			}
		}
		
		$setobjIdstr = '2.2.6';
		echo "<tr>";
		echo "<td bgcolor=\"#E6E6E6\" style=\"border-right:1px solid\">";
		echo "<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" ><tr>";
		echo "<td align=\"left\" ><b>LAC</b></td>";
		echo "<td align=\"right\"><a href=\"javascript:openSet('6','new-0','LAC','$sysId','$trunkgp','$linkset','$webname','$backurl','$infoNo')\"><font size=4>+</font></a></td>";
		echo "</tr></table></td>";
		
		echo "<td>";
		echo "<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\">";
			echo "<tr bgcolor=\"#E6E6E6\">";
				echo "<td width=\"15%\" >No.</td>";
				echo "<td width=\"15%\" >LAC</td>";
				echo "<td width=\"15%\" >Page Mode</td>";
				echo "<td width=\"55%\" align=\"right\">Delete</td>";
			echo "</tr>";
		
		if($n==0)	
		{
			echo "<tr bgcolor=\"#E6E6E6\"><td colspan=\"7\">--</td></tr>";			
		}	
		for($i=0;$i < $n;$i++)
		{
			if($i>3)
				echo "<tr id='LAC$i' style=\"display:none\" onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";
			else
				echo "<tr id='LAC$i' onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";	
			//echo "<tr onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";
			if($LAC_pageType[$i]==5) $pageTypeStr='By LAC';
			else if($LAC_pageType[$i]==6) $pageTypeStr='In All Cell';
			else $pageTypeStr='--';
			$lac_inst = $LAC_inst[$i];
			$lac_value = $LAC_value[$i];
			echo "<td width=\"15%\"><a href=\"javascript:openSet('{$LAC_pageType[$i]}','$lac_inst-$lac_value','LAC','$sysId','$trunkgp','$linkset','$webname','$backurl','$infoNo')\">$i&nbsp;</a></td>";
			echo "<td width=\"15%\">{$LAC_value[$i]}</td>";
			echo "<td width=\"15%\">$pageTypeStr</td>";
			echo "<td width=\"55%\" align=\"right\"><input type=\"checkbox\" name=\"\" value=\"ON\" onClick=\"javascript:delFirm('$lac_inst','LAC','$trunkgp','$linkset',this)\" ></td>";
			echo "</tr>";
		}
		//===============more button==============
		if($n>4)
		{
			echo "<tr id='showLAC' style=\"display:block\"><td><a href=\"javascript:clickOnMoreHide('LAC',$n,'show')\">More >></a></td></tr>"; 
			echo "<tr id='hideLAC' style=\"display:none\"><td><a href=\"javascript:clickOnMoreHide('LAC',$n,'hide')\">Hide >></a></td></tr>"; 
		}
		echo "</table>";
		echo "</td>";
		echo "</tr>";	
	}//LAC end

	{//BTS	
		$emFlagArr = array(
			'Disable',
			'By Cell',
			'By LAC',
			'By MSC'
		);

		$sysId = '322_99_99';
		$sysIdArr	= explode('_',$sysId);
		$sysTypeNo	= $sysIdArr[0];
		$sysNo		= $sysIdArr[1];
		$subSysNo	= $sysIdArr[2];
		$oidstr = '2.2.7';
		$objWhereStr =getLevelWhere($oidstr);
		
		$objDb		= 'OBJ_'.$sysTypeNo;
		$paramTable = 'param_'.$sysNo;
	
		//************get default value*************
		$defSql = " SELECT initValue FROM paramConf WHERE $objWhereStr";
		$defRes = @mysqli_query($pubConn,$defSql);
		$defRow = @mysqli_fetch_array($defRes);
		$BTS_DefValue = $defRow[initValue];
		if($DEBUG) echo "BTS_DefValue] = $BTS_DefValue";
		//查找一个未用的Cell parameter，供新加bts时使用
		$paramSql = " SELECT initValue,readValue,instanceNo FROM $paramTable  
					WHERE subSysNo = '$subSysNo' AND  $objWhereStr AND initValue='$BTS_DefValue'
					";
		$Result = mysqli_query($pubConn,$paramSql);
		$Row = mysqli_fetch_array($Result);
		$newID = $Row[instanceNo];
		
		$paramSql = " SELECT initValue,readValue,instanceNo FROM $paramTable  
					WHERE subSysNo = '$subSysNo' AND  $objWhereStr
					";
		$Result = mysqli_query($pubConn,$paramSql);
		$num = 0;
		while($Row = mysqli_fetch_array($Result))
		{
			$lacValue = hexdec(getBitValue($Row[initValue],'1.0-2.7'));
			
			if($lacValue!=0)// $lacValue!=0 ?
			{
				for($j=0; $j<sizeof($LAC_value);$j++)
				{
					if($lacValue==$LAC_value[$j])
					{
						$CellID[$num] = $Row[instanceNo];
						$Em_flag[$num] = hexdec(getBitValue($Row[initValue],'00.0-00.7'));
						$Em_prefix[$num]= hexdec(getBitValue($Row[initValue],'05.0-5.7'));
						$CellNum[$num] = hexdec(getBitValue($Row[initValue],'03.0-04.7'));
						$tmpLocEme = getBitValue($Row[initValue],'06.0-13.7');
						$Em_routed[$num] = str_replace('E','',$tmpLocEme);
						$Em_lac[$num] = $lacValue;
						$num++;
						break;
					}
				}
			}			
		}
	
		$setobjIdstr = '2.2.7-2.2.7';
		$newobjIdstr = 'new-2.2.7';
		/*  the Emergency call parameter (old hide 2007-6-5)
		echo "<tr>";
			echo "<td bgcolor=\"#E6E6E6\" width=\"15%\" style=\"border-right:1px solid\">";
				echo "<table border=\"0\" width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" ><tr>";
				echo "<td align=\"left\" title=\"Emergency call.\"><b>Emergency call</b></td>";
				if(!isset($newID))
				{
					echo "<td align=\"right\"><a href=\"javascript:newError('BTS')\"><font size=4>+</font></a></td>";
				}
				elseif(sizeof($LAC_value)==0)
				{
					echo "<td align=\"right\"><a href=\"javascript:newError('LAC')\"><font size=4>+</font></a></td>";
				}
				else
				{	
					echo "<td align=\"right\"><a href=\"javascript:openSet('$newobjIdstr','$newID-$LAC_value[0]','BTS','$sysId','$trunkgp','$linkset','$webname','$backurl','$infoNo')\"><font size=4>+</font></a></td>";
				}
				echo "</tr></table>";
			echo "</td>";
			echo "<td>";
			echo "<table border=\"0\" width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" >";
				echo "<tr bgcolor=\"#E6E6E6\">";
					echo "<td width=\"15%\">No</td>";
					echo "<td width=\"15%\">Prefix</td>";
					echo "<td width=\"15%\">LAC</td>";
					echo "<td width=\"15%\">Cell</td>";
					echo "<td width=\"15%\">Em Number</td>";
					echo "<td width=\"15%\">Em Flag</td>";
					echo "<td width=\"10%\" align=\"right\">Delete</td>";
				echo "</tr>";
		
		//显示CELL
		if($num==0)
		{
			echo "<tr><td colspan=\"6\">--</td></tr>";				
		}
		for($i=0;$i < $num;$i++)
		{
			$tmpInst=$Em_prefix[$i];
			//get Prefix
			{
				$sysId = '322_99_99';
				$sysIdArr	= explode('_',$sysId);
				$sysTypeNo	= $sysIdArr[0];
				$sysNo		= $sysIdArr[1];
				$subSysNo	= $sysIdArr[2];
				$oidstr = '2.1.1';
				$objWhereStr =getLevelWhere($oidstr);
				
				$objDb		= 'OBJ_'.$sysTypeNo;
				$paramTable = 'param_'.$sysNo;
				
				$paramSql = " SELECT initValue,readValue,instanceNo FROM $paramTable  
							WHERE subSysNo = '$subSysNo' AND  $objWhereStr and instanceNo='$tmpInst'
							";
				$result = @mysqli_query($pubConn,$paramSql);
				$Row = @mysqli_fetch_array($result);
				$tmpPrefix = str_replace('E','',$Row[initValue]);
				if(strlen($tmpPrefix)==0)
					$tmpPrefix='--';
			}
			if($i>3)
				echo "<tr id='EmergencyCall$i' style=\"display:none\" onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";
			else
				echo "<tr id='EmergencyCall$i' onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";
			//echo "<tr onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";
			echo "<td ><a href=\"javascript:openSet('$setobjIdstr','$CellID[$i]-$Em_lac[$i]','BTS','$sysId','$trunkgp','$linkset','$webname','$backurl','$infoNo')\">{$CellID[$i]}&nbsp;</a></td>";
			echo "<td ><a href=\"javascript:openSet('2.1.2-2.1.1-2.1.2-2.1.3','$tmpInst','Prefix','$sysId','$trunkgp','$linkset','$webname','$backurl','$infoNo')\">$tmpPrefix&nbsp;</a></td>";
			echo "<td >$Em_lac[$i]</td>";
			echo "<td >$CellNum[$i]</td>";
			echo "<td >{$Em_routed[$i]}</td>";
			echo "<td >{$emFlagArr[$Em_flag[$i]]}</td>";
			echo "<td align=\"right\"><input type=\"checkbox\" name=\"C$instanceNo\" value=\"ON\" onClick=\"javascript:delFirm($CellID[$i],'BTS','$trunkgp','$linkset',this)\" ></td>";
			echo "</tr>";		
		}
		//===============more button==============
		if($num>4)
		{
			echo "<tr id='showEmergencyCall' style=\"display:block\"><td><a href=\"javascript:clickOnMoreHide('EmergencyCall',$num,'show')\">More >></a></td></tr>"; 
			echo "<tr id='hideEmergencyCall' style=\"display:none\"><td><a href=\"javascript:clickOnMoreHide('EmergencyCall',$num,'hide')\">Hide >></a></td></tr>"; 
		}
		
		echo "</table>";
		echo "</td>";
		*/
		
		
		//================Emergency call parameter (add 2007-6-5)==================
		{
			//=====get the default value of cell=================
			$database="OBJ_322";
			$sql="select initValue from paramConf where level_1=2 and level_2=2 and level_3=7 ";
			$result=@mysqli_query($pubConn,$sql);
			$rows=@mysqli_fetch_array($result);
			$cell_default_value=$rows[initValue];
			
			//=====get the count of cell================
			$database="OBJ_322";
			$sql="select initValue,instanceNo from param_99 where level_1=2 and level_2=2 and level_3=7 ";
			$result=@mysqli_query($pubConn,$sql);
			$rows=@mysqli_fetch_array($result);
			$cell_count=0;
			do
			{
				if($rows[initValue]==$cell_default_value)
					continue;
				else
				{
					//============store the parameter
					$cell_instance_no[$cell_count]=$rows[instanceNo];
					$cell_emergency_call_flag[$cell_count]=hexdec(getBitValue($rows[initValue],'0.0-0.7'))+0;
					$cell_lac[$cell_count]=hexdec(getBitValue($rows[initValue],'1.0-2.7'))+0;
					$cell_id[$cell_count]=hexdec(getBitValue($rows[initValue],'3.0-4.7'))+0;
					$cell_prefix_index_number[$cell_count]=hexdec(getBitValue($rows[initValue],'5.0-5.7'))+0;
					$prefix_instance_no_tmp=$cell_prefix_index_number[$cell_count];
					{
						$databasee="OBJ_322";
						$sqll="select initValue,instanceNo from param_99 where level_1=2 and level_2=1 and level_3=1 and instanceNo=$prefix_instance_no_tmp ";
						$resultt=@mysqli_query($pubConn,$sqll);
						$rowss=@mysqli_fetch_array($resultt);
						
						$cell_prefix_prefix[$cell_count]=str_replace("E","",$rowss[initValue]);
						if($cell_prefix_prefix[$cell_count]=="")
							$cell_prefix_prefix[$cell_count]="--";
					}
					$cell_local_emergency_number[$cell_count]=getBitValue($rows[initValue],'6.0-13.7');
					$cell_regional_zone_flag[$cell_count]=hexdec(getBitValue($rows[initValue],'14.0-14.7'))+0;
					$cell_zone_code[$cell_count]=hexdec(getBitValue($rows[initValue],'15.0-16.7'))+0;
					
					//test
					/*
					{
					echo "<hr>";
					echo "{$cell_instance_no[$cell_count]}<br>";
					echo "----{$cell_emergency_call_flag[$cell_count]}<br>";
					echo "----{$cell_lac[$cell_count]}<br>";
					echo "----{$cell_id[$cell_count]}<br>";
					echo "----{$cell_prefix_index_number[$cell_count]}<br>";
					echo "----{$cell_local_emergency_number[$cell_count]}<br>";
					echo "----{$cell_regional_zone_flag[$cell_count]}<br>";
					echo "----{$cell_zone_code[$cell_count]}<br>";
					}
					*/
					$cell_count++;
				}	
			}while($rows=@mysqli_fetch_array($result));
			
			//========get the unuse cell instanceNo======================
			$database="OBJ_322";
			$sql="select initValue,instanceNo from param_99 where level_1=2 and level_2=2 and level_3=7 ";
			$result=@mysqli_query($pubConn,$sql);
			$rows=@mysqli_fetch_array($result);
			
			do
			{
				if($rows[initValue]==$cell_default_value)
				{
					$cell_unuse_instanceNo=$rows[instanceNo];
					break;
				}
			}while($rows=@mysqli_fetch_array($result));
			
			//=======================show====================
			$u_t=$url_temp;
			$url_temp=urlencode($url_temp);
			echo "<tr>";
			echo "<td bgcolor=\"#E6E6E6\" width=\"15%\" style=\"border-right:1px solid\">";
			$oper="new";
				echo "<b>Emergency Call</b><a href=\"./cell_edit.php?instanceNo=$cell_unuse_instanceNo&trunkgp=$trunkgp&linkset=$linkset&infoNo=$infoNo&operation=$oper&backurl=$url_temp\"><font color=blue size=4>+</font></a>";
			echo "</td>";
			echo "<td>";
				echo "<table border=0 width=100% cellspacing=0>";
					echo "<tr bgcolor=\"#E6E6E6\">";
						echo "<td width=10%>No.</td>";
						echo "<td width=14%>Prefix</td>";
						echo "<td width=12%>LAC</td>";
						echo "<td width=12%>Cell ID</td>";
						echo "<td width=20%>Emergency Number</td>";
						echo "<td width=12%>Emergency Flag</td>";
						echo "<td width=4%>Delete</td>";
					echo "</tr>";
					if($cell_count==0)
					{
						echo "<tr>";
							echo "<td width=12%>--</td>";
						echo "</tr>";
					}	
					else
					{
						
						for($i=0;$i<$cell_count;$i++)
						{
							
							if($i>3)
								echo "<tr id='EmergencyCall$i' style=\"display:none\" onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";
							else
								echo "<tr id='EmergencyCall$i' onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";
											
								$no_tmp=$cell_instance_no[$i];
								
								$prefix_tmp_no=$cell_prefix_index_number[$i];
								$oper="edit";
								echo "<td><a href=\"./cell_edit.php?instanceNo=$no_tmp&trunkgp=$trunkgp&linkset=$linkset&infoNo=$infoNo&operation=$oper&backurl=$url_temp\">{$cell_instance_no[$i]}</a></td>";
								echo "<td><a href=# onClick=\"javascript:openSetPrefix('$trunkgp','$prefix_tmp_no','no-2.1.1-2.1.2','322_99_99','MSC','Prefix','$u_t')\">{$cell_prefix_prefix[$i]}</a></td>";
								echo "<td>{$cell_lac[$i]}</td>";
								echo "<td>{$cell_id[$i]}</td>";
								$tmp=str_replace("E","",$cell_local_emergency_number[$i]);
								echo "<td>$tmp</td>";
								echo "<td>{$cell_emergency_call_flag[$i]}</td>";
								//=======delete button==================
								echo "<td align=right><input type=checkbox onClick=\"javascript:delete_cell(this,'$no_tmp','$trunkgp','$linkset')\"></td>";
							echo "</tr>";
							
							
					
						}
						//===============more button==============
						if($cell_count>4)
						{
							echo "<tr id='showEmergencyCall' style=\"display:block\"><td><a href=\"javascript:clickOnMoreHide('EmergencyCall',$cell_count,'show')\">More >></a></td></tr>"; 
							echo "<tr id='hideEmergencyCall' style=\"display:none\"><td><a href=\"javascript:clickOnMoreHide('EmergencyCall',$cell_count,'hide')\">Hide >></a></td></tr>"; 
						}
					}
				echo "</table>";
			echo "</td>";
			echo "</tr>";
		}	
	}
	
	
	
	
}

if($GTT_show)
{	
	$sysId = '222_99_99';
	
	$sysIdArr	= explode('_',$sysId);
	$sysTypeNo	= $sysIdArr[0];
	$sysNo		= $sysIdArr[1];
	$subSysNo	= $sysIdArr[2];	
	$oidstr = '2.4.1';
	$objWhereStr= '';	
	
	$objWhereStr =getLevelWhere($oidstr);			
	$objDb		= 'OBJ_'.$sysTypeNo;
	$paramTable = 'param_'.$sysNo;
	
	$selSql = "select initValue from $paramTable where $objWhereStr and instanceNo='$linkset' ";
	$result = mysqli_query($pubConn,$selSql);
	$row = mysqli_fetch_array($result);
	
	$DPC = hexdec(getBitValue($row[initValue],'0.0-2.7'));
	$NI = bindec(getBitValue($row[initValue],'3.0-3.1'));
	//echo "$DPC,$NI";
	
	{//GTT
		$NetIdConfArr=array(
		"0"=>"International",
		"1"=>"International spare",
		"2"=>"National",
		"3"=>"National spare"
		);
		
		$numPlanArr = array(
		"7" => "GT",
		"6"=> "IMSI",
		"1"=> "MSISDN",
		"0"=> "0"
		);
			
		$sysId = '223_99_99';		
		$sysIdArr	= explode('_',$sysId);
		$sysTypeNo	= $sysIdArr[0];
		$sysNo		= $sysIdArr[1];
		$subSysNo	= $sysIdArr[2];		
		$oidstr = '2.2';
		$objWhereStr= '';	
		
		$objWhereStr =getLevelWhere($oidstr);				
		$objDb		= 'OBJ_'.$sysTypeNo;
		$paramTable = 'param_'.$sysNo;
		
		$selSql = "select initValue,instanceNo from $paramTable where $objWhereStr and initValue like '01%' ";
		$result = mysqli_query($pubConn,$selSql);
		
		$offsetAppType='00.0-00.7';
		$offsetGrpNo = '01.0-01.7';
		$offsetBitFlag = '02.0-02.7';//if '1', global title.
		
		$niTypeArr = getNiType();

		$n=0;
		$m=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'));
			$TT = hexdec(getBitValue($rows[initValue],'2.0-2.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]'";
					if(0)echo "<br>selSql:$selSql";
					$tmpResult = mysqli_query($pubConn,$selSql);
					$tmpRow = mysqli_fetch_array($tmpResult);
					$tmpGrpNo = hexdec(getBitValue($tmpRow[initValue],$offsetGrpNo));
					$tmpAppType = hexdec(getBitValue($tmpRow[initValue],$offsetAppType));
					$bitFlag = hexdec(getBitValue($tmpRow[initValue],$offsetBitFlag));	
				}//end get gtt attribution		
				if($grpNo==$tmpGrpNo && $tmpAppType==$appType)
				{
					if(0)echo "<br>1: dpc=$tmpDpc, ni=$tmpNi, grpNo=$tmpGrpNo, ssn=$SSN,instanceNo={$rows[instanceNo]}";
					$NP	  = hexdec(getBitValue($rows[initValue],'01.0-01.7'));
					$tmpStart 	= getBitValue($rows[initValue],'3.0-12.7');	
					$tmpEnd 	= getBitValue($rows[initValue],'13.0-22.7');	
					$startGT = str_replace('F','',$tmpStart);
					$endGT = str_replace('F','',$tmpEnd);
					if(strlen($startGT)==0) $startGT='--';
					if(strlen($endGT)==0) $endGT='--';
					if($niTypeArr[$NI]==0)//ITU
					{
						$msisdnFlag = ($NP==1);
						$imsiFlag = ($NP==6 || $NP==7);
					}
					else//ansi
					{
						$msisdnFlag = ($TT==14 || $TT==10);
						$imsiFlag = ($TT==9);
					}
					if(0)echo "<br>np:$NP, tt:$TT, msisdnFlag:$msisdnFlag, imsiFlag:$imsiFlag";
					switch($appType)
					{
						case  '1'://hlr
						{
							if($bitFlag)
							{
								$globalTitle = $startGT;
								$instNo = $rows[instanceNo];
								$np = $NP;
								$tt = $TT;
							}
							else
							{
								if($msisdnFlag)
								{
									$msisdnGTTArr[$n][np]=$NP;
									$msisdnGTTArr[$n][tt]=$TT;
									$msisdnGTTArr[$n][instanceNo] = $rows[instanceNo];
									$msisdnGTTArr[$n][start] = $startGT;
									$msisdnGTTArr[$n][end] 	= $endGT;
									$n++;
								}
								if($imsiFlag)
								{
									$imsiGTTArr[$m][np] 	= $NP;
									$imsiGTTArr[$m][tt] 	= $TT;
									$imsiGTTArr[$m][instanceNo] = $rows[instanceNo];
									$imsiGTTArr[$m][start] = $startGT;
									$imsiGTTArr[$m][end] 	= $endGT;
									$m++;
								}
							}
							break;
						}
						case  '5'://new Element
						{
							if($msisdnFlag)
							{
								$msisdnGTTArr[$n][np]=$NP;
								$msisdnGTTArr[$n][tt]=$TT;
								$msisdnGTTArr[$n][instanceNo] = $rows[instanceNo];
								$msisdnGTTArr[$n][start] = $startGT;
								$msisdnGTTArr[$n][end] 	= $endGT;
								$n++;
							}
							if($imsiFlag)
							{
								$imsiGTTArr[$m][np] 	= $NP;
								$imsiGTTArr[$m][tt] 	= $TT;
								$imsiGTTArr[$m][instanceNo] = $rows[instanceNo];
								$imsiGTTArr[$m][start] = $startGT;
								$imsiGTTArr[$m][end] 	= $endGT;
								$m++;
							}
							break;
						}
						
						case  '2'://vlr
						case  '0'://msc
						case  '4'://sgsn
						{
							$globalTitle = $startGT;
							$instNo = $rows[instanceNo];
							$np = $NP;
							$tt = $TT;
							break;
						}
						
						case  '3'://smsc
						{
							if($bitFlag)
							{
								$globalTitle = $startGT;
								$instNo = $rows[instanceNo];
								$np = $NP;
							}
							else
							{
								if($msisdnFlag)
								{
									$msisdnGTTArr[$n][np] 	= $NP;
									$msisdnGTTArr[$n][tt] 	= $TT;
									$msisdnGTTArr[$n][instanceNo] = $rows[instanceNo];
									$msisdnGTTArr[$n][start] = $startGT;
									$msisdnGTTArr[$n][end] 	= $endGT;
									$n++;
								}
							}
							break;
						}
					}
				}
			}
		}
//		echo "<br>gttSSN=$gttSSN, n=$n, m=$m";
		{//show GTT
			$setobjIdstr = "2.2-2.2";
			if($appType != 5)
			{
				echo "<tr>";
				echo "<td bgcolor=\"#E6E6E6\" width=\"15%\" style=\"border-right:1px solid\"><b>$strE164Number</b></td>";
				echo "<td>";
				echo "<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" >";
					echo "<tr bgcolor=\"#E6E6E6\">";
						echo "<td width=\"15%\">No.</td>";
						if($niTypeArr[$NI]==0)//ITU
							echo "<td width=\"15%\">NP</td>";	
						else
							echo "<td width=\"15%\">TT</td>";
						echo "<td width=\"15%\">$strE164Number</td>";
						echo "<td width=\"15%\">&nbsp;</td>";
						echo "<td width=\"15%\">NI</td>";		
						echo "<td width=\"15%\">DPC</td>";		
						echo "<td width=\"10%\">&nbsp;</td>";
					echo "</tr>";
				
					echo "<tr>";
						echo "<td width=\"15%\"><a href=\"javascript:openSetGTT('$np','$instNo','$appType','1','$gttSSN','$linkset','$grpNo','$backurl')\">0</a></td>";
						if($niTypeArr[$NI]==0)//ITU
							echo "<td width=\"15%\"><a href=\"javascript:openSetGTT('$np','$instNo','$appType','1','$gttSSN','$linkset','$grpNo','$backurl')\">MSISDN</a></td>";		
						else
							echo "<td width=\"15%\"><a href=\"javascript:openSetGTT('$np','$instNo','$appType','1','$gttSSN','$linkset','$grpNo','$backurl')\">$tt</a></td>";		
						echo "<td width=\"15%\"><a href=\"javascript:openSetGTT('$np','$instNo','$appType','1','$gttSSN','$linkset','$grpNo','$backurl')\">$globalTitle</a></td>";
						echo "<td width=\"15%\"></td>";
						echo "<td width=\"15%\"><a href=\"javascript:openSetGTT('$np','$instNo','$appType','1','$gttSSN','$linkset','$grpNo','$backurl')\">{$NetIdConfArr[$NI]}</a></td>";
						echo "<td width=\"15%\"><a href=\"javascript:openSetGTT('$np','$instNo','$appType','1','$gttSSN','$linkset','$grpNo','$backurl')\">$DPC</a></td>";
						echo "<td width=\"15%\">&nbsp;</td>";
					echo "</tr>";
				echo "</table>";
				echo "</td>";
				echo "</tr>";
			}
			//if($gttSSN==6 || $gttSSN==11)
			if($appType==1 || $appType==3 || $appType==5)
			{
				$rowspan = $n+1;
				echo "<tr>";
				echo "<td bgcolor=\"#E6E6E6\" style=\"border-right:1px solid\">";
				echo "<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" ><tr>";
				echo "<td align=\"left\" ><b>MSISDN</b></td>";
				echo "<td align=\"right\"><a href=\"javascript:openSetGTT('1','new','$appType','0','$gttSSN','$linkset','$grpNo','$backurl')\"><font size=4>+</font></a></td>";
				echo "</tr></table></td>";
				
				echo "<td>";
				echo "<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" >";
				echo "<tr bgcolor=\"#E6E6E6\">";
				echo "<td width=\"15%\">No.</td>";
				if($niTypeArr[$NI]==0)//ITU
					echo "<td width=\"15%\">NP</td>";	
				else
					echo "<td width=\"15%\">TT</td>";	
				echo "<td width=\"15%\">start GT</td>";
				echo "<td width=\"15%\">end GT</td>";
				echo "<td width=\"15%\">NI</td>";		
				echo "<td width=\"15%\">DPC</td>";
				echo "<td width=\"10%\" align=\"right\">Delete</td>";
				echo "</tr>";
				if($n==0)	
					echo "<tr><td colspan=\"7\">--</td></tr>";			
 				for($i=0; $i< $n; $i++)
				{
					if($i>3)
						echo "<tr id='MSISDN$i' style=\"display:none\" onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";
					else
						echo "<tr id='MSISDN$i' onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";
					//echo "<tr onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";
					echo "<td ><a href=\"javascript:openSetGTT('1','{$msisdnGTTArr[$i][instanceNo]}','$appType','0','$gttSSN','$linkset','$grpNo','$backurl')\">$i</a></td>";
					if($niTypeArr[$NI]==0)//ITU
						echo "<td>MSISDN</td>";
					else
						echo "<td>{$msisdnGTTArr[$i][tt]}</td>";	
					echo "<td>{$msisdnGTTArr[$i][start]}</td>";		
					echo "<td>{$msisdnGTTArr[$i][end]}</td>";	
					echo "<td>{$NetIdConfArr[$NI]}</td>";
					echo "<td>$DPC</td>";
					echo "<td align=\"right\"><input type=\"checkbox\" name=\"Checbox$n\" value=\"ON\" onClick=\"javascript:delFirm('{$msisdnGTTArr[$i][instanceNo]}','GTT','$trunkgp','$linkset',this)\" ></td>";
					echo "</tr>";
				}
				if($n>4)
				{
					echo "<tr id='showMSISDN' style=\"display:block\"><td><a href=\"javascript:clickOnMoreHide('MSISDN',$n,'show')\">More >></a></td></tr>"; 
					echo "<tr id='hideMSISDN' style=\"display:none\"><td><a href=\"javascript:clickOnMoreHide('MSISDN',$n,'hide')\">Hide >></a></td></tr>"; 
				}
				echo "</table>";
				echo "</td>";
				echo "</tr>";
				//if($gttSSN==6) 
				if($appType==1 || $appType == 5)
				{
					$rowspan = $m+1;
					
					echo "<tr>";
					echo "<td bgcolor=\"#E6E6E6\" style=\"border-right:1px solid\">";
					echo "<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" ><tr>";
					echo "<td align=\"left\" ><b>IMSI</b></td>";
					echo "<td align=\"right\"><a href=\"javascript:openSetGTT('6','new','$appType','0','$gttSSN','$linkset','$grpNo','$backurl')\"><font size=4>+</font></a></td>";
					echo "</tr></table></td>";
					
					echo "<td>";
					echo "<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\">";
					echo "<tr bgcolor=\"#E6E6E6\">";
					echo "<td width=\"15%\">No.</td>";
					
					if($niTypeArr[$NI]==0)//ITU
						echo "<td width=\"15%\">NP</td>";	
					else
						echo "<td width=\"15%\">TT</td>";	
							
					echo "<td width=\"15%\">start GT</td>";
					echo "<td width=\"15%\">end GT</td>";
					echo "<td width=\"15%\">NI</td>";		
					echo "<td width=\"15%\">DPC</td>";
					echo "<td width=\"10%\" align=\"right\">Delete</td>";
					echo "</tr>";
					if($m==0)	
						echo "<tr><td colspan=\"7\">--</td></tr>";	
					for($i=0; $i< $m; $i++)
					{
						if($i>3)
							echo "<tr id='IMSI$i' style=\"display:none\" onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";
						else
							echo "<tr id='IMSI$i' onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";
						//echo "<tr onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";
						echo "<td ><a href=\"javascript:openSetGTT('6','{$imsiGTTArr[$i][instanceNo]}','$appType','0','$gttSSN','$linkset','$grpNo','$backurl')\">$i</a></td>";
						if($niTypeArr[$NI]==0)//ITU
						{
							if($imsiGTTArr[$i][np]==6)
								echo "<td>IMSI</td>";
							else if($imsiGTTArr[$i][np]==7)	
								echo "<td>GT</td>";
						}
						else
						{
							echo "<td>{$imsiGTTArr[$i][tt]}</td>";	
						}
						echo "<td>{$imsiGTTArr[$i][start]}</td>";		
						echo "<td>{$imsiGTTArr[$i][end]}</td>";	
						echo "<td>{$NetIdConfArr[$NI]}</td>";
						echo "<td>$DPC</td>";
						echo "<td align=\"right\"><input type=\"checkbox\" name=\"Checbox$n\" value=\"ON\" onClick=\"javascript:delFirm('{$imsiGTTArr[$i][instanceNo]}','GTT','$trunkgp','$linkset',this)\" ></td>";
						echo "</tr>";
					}
					
					//===============more button==============
					if($m>4)
					{
						echo "<tr id='showIMSI' style=\"display:block\"><td><a href=\"javascript:clickOnMoreHide('IMSI',$m,'show')\">More >></a></td></tr>"; 
						echo "<tr id='hideIMSI' style=\"display:none\"><td><a href=\"javascript:clickOnMoreHide('IMSI',$m,'hide')\">Hide >></a></td></tr>"; 
					}
					echo "</table>";
					echo "</td>";
					echo "</tr>";
				}
			}
		}//end show GTT
	}//GTT
}

echo "</table>&nbsp;";

if($devicename=='Peripheral')
{
	$lowerWebname = strtolower($webname);
	$loadfile = "load$lowerWebname.php";
	echo "<div>";
	echo "<a href=\"./$loadfile?infoNo=$infoNo&linkset=$linkset&trunkgp=$trunkgp&flag=$flag\"><b>MSS -> $webname<b></a>";
	echo "</div>";
}
{//get all exist elements from elementExistConf
	getExistElements($existElementArr);
	
	if(@array_search('500', $existElementArr)==TRUE)//BSS
		$BssExist = 1;
}//end get all exisit elements
if($BssExist==1)
if($devicename=='BSC')
{
	echo "<div>";
	echo "<a href=\"../bssSpecific/bssSpecific.php?bssid=$this_sysNo&infoNo=$infoNo&linkset=$linkset&trunkgp=$trunkgp&flag=$flag\"><b>MSS -> $webname<b></a>";
	echo "</div>";
}

/*{
	echo "<table width=\"100%\">";
	echo "<tr>";
		echo "<td width=\"70%\">";
			echo "&nbsp;&nbsp;";
		echo "</td>";
		echo "<td width=\"20%\" align=\"right\">";
				echo "<input type=\"submit\" title=\"$strTitleGet\" name=\"getSys\" value=\"$strGet\" class=\"button\" style=\"cursor:pointer; left: 1; top: 2; width: 60; height: 25; position: relative\">";
				echo "&nbsp;&nbsp;&nbsp;";
				echo "<input type=\"submit\" title=\"$strTitleSet\" name=\"setSys\" value=\"$strSet\" class=\"button\" style=\"cursor:pointer; left: 1; top: 2; width: 60; height: 25; position: relative\">";
			echo "</td>";
		echo "<td width=\"10%\">";
			echo "<p align=\"right\"><a href=\"javascript:backpage(0,'../overview/overview.php')\"><img align=absBottom border=0 src=\"../../images/left.gif\" width=\"14\" height=\"14\">$strBack</a>";
		echo "</td>";
	echo "</tr>";
	echo "</table>";
}*/
?>
</form>
<?php
if($E1_show == 1)
{
?>
<font color=#808080>
Notes:<br>
1. Add E1/T1 Connection first.
<br>
2. Link to  SS7 webpage, add Signalling link.
</font>
</body>
</html>
<?php
}
?>
