<?php 
/*********************************************************      
AAS  configuration.

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

require("../../inc/header.inc");
$helpId = "1.1.1";
$DEBUG = 0;
 
//==========================================================
//变量定义
//==========================================================
$nShowsize = '40%';
$inputsize = 21;
$oidarr			=	array("2.1");

$pubDb	 = 'OMC_PUB';

$maxNum = 120;

$nGetComm	= 0;
$nSetComm	= 3;

$instanceNo	='0';

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


$oidarr			=	array("2.1.2","2.1.3","2.1.4","2.1.5","2.1.6","2.1.8","2.1.6","2.7.1","2.9");//与$sysId_list一一对应

$SaveArr=array(
	array('oidstr'=>'3.1',	'setvalue'=>'00'	,'sysid'=>'311_99_99'),
	array('oidstr'=>'3.2',	'setvalue'=>'B5'	,'sysid'=>'322_99_99'),
	array('oidstr'=>'3.7',	'setvalue'=>'02'	,'sysid'=>'222_99_99')		
);			


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


$SignalingArr=array(
	array('oid'=>'2.1.2',	'inputName'=>'NetID'	,'showName'=>'NetWork indicator'				,'length'=>'2' ,'value'=>''),
	array('oid'=>'2.1.3',	'inputName'=>'Wxc2PC'	,'showName'=>'WXC2 Point Code'					,'length'=>'6' ,'value'=>''), 
	array('oid'=>'2.1.8',	'inputName'=>'CIC'		,'showName'=>'CIC'											,'length'=>'10' ,'value0'=>'','value1'=>''),
	array('oid'=>'2.1.4',	'inputName'=>'CC'			,'showName'=>'Country code'							,'length'=>'4' ,'value'=>''), 
	array('oid'=>'2.1.5',	'inputName'=>'NDC'		,'showName'=>'National destination code','length'=>'4' ,'value'=>''),
	array('oid'=>'2.1.6',	'inputName'=>'MSISDN'	,'showName'=>'MSISDN'				,'length'=>'16','value'=>'')
);

$AASannounArr=array(
	array('oid'=>'2.3.1',	'inputName'=>'Prefix'			,'showName'=>'Prefix'							,'length'=>'16' ,'value'=>''),
	array('oid'=>'2.3.2',	'inputName'=>'playtimes'	,'showName'=>'Play times'					,'length'=>'3' ,'value'=>''), 
	array('oid'=>'2.3.3',	'inputName'=>''						,'showName'=>'Call unattainable announcement'	,'length'=>'1' ,'value'=>''),
);

$Causearr=array(
	array('name'=>'MAP', 'oid'=>'2.3.5',	'offset_vg'=>'02.0-03.7','offset_cv'=>'00.0-01.7'),
	array('name'=>'AIF', 'oid'=>'2.3.7',	'offset_vg'=>'02.0-03.7','offset_cv'=>'00.0-01.7'),
	array('name'=>'ISUP', 'oid'=>'2.3.8',	'offset_vg'=>'02.0-03.7','offset_cv'=>'00.0-01.7')
);
?>

<style type="text/css">
<!--
.style3 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 8pt;background: url(--.gif); border: 0px; width: 30px; height: 17px;color:blue}
.style4 {cursor:hand;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 8pt;background: url(--.gif); border: 0px 0; width: 30px; height: 17px;color:red; text-decoration: underline }
.style5 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 8pt;background: url(--.gif); border: 0px; width: 60px; height: 13px;color:blue}
.style6 {cursor:hand;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 8pt;background: url(--.gif); border: 0px 0; width: 60px; height: 13px;color:red; text-decoration: underline }
-->
</style> 
<body topmargin="0" leftmargin="12">
<?php



{
echo "<form method=\"POST\" name=\"setForm\" action=\"$PHP_SELF?linkset=$linkset&cause_edit=$cause_edit\">";
echo "<table border=\"0\" width=\"100%\">";
echo "<tr>";
echo "<td width=\"50%\">";
echo "Configuration > <a href=\"../overview/overview.php?scroll_y=1000\">Network</a> > <a href=\"#\">Cell overview</a>";
echo "</td>";
echo "<td width=\"50%\" align=\"right\" title=\"Help\">";
//showHelp($helpId);
echo "</td>";
echo "</tr>";
echo "</table>";
echo "<br>";

echo "<table width=\"100%\">";
echo "<tr><td width=\"20%\">";
echo "&nbsp;&nbsp;</td>";
echo "<td><p align=\"right\"><a href=\"../../element/overview/overview.php?scroll_y=1000\"><img align=absBottom border=0 src=\"../../images/left.gif\" width=\"14\" height=\"14\">$strBack</a>";
echo "</td></tr>";
echo "</table>";
}
?>

<?php
echo "<table border=\"1\" width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" bordercolor=\"#666666\" bordercolordark=\"#FFFFFF\">";
$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];

$objDb		= 'OBJ_'.$sysTypeNo;
$paramTable = 'param_'.$sysNo;

$oidEmergency = '2.2.7';
$objWhereStr =getLevelWhere($oidEmergency);

$defSql = " SELECT initValue FROM paramConf WHERE $objWhereStr";
$defRes = @mysqli_query($pubConn,$defSql);
$defRow = @mysqli_fetch_array($defRes);
$defValue = $defRow[initValue];
		
$Em_paramSql = " SELECT initValue,readValue,instanceNo FROM $paramTable  
			WHERE $objWhereStr AND initValue!='$defValue'
			";
if($DEBUG)echo "<br>Em_paramSql: $Em_paramSql";
$Em_Result = mysqli_query($pubConn,$Em_paramSql);
$num = 0;
while($Em_Row = mysqli_fetch_array($Em_Result))
{
	$Em_flag[$num] = hexdec(getBitValue($Em_Row[initValue],'00.0-00.7'));
	$Em_LAC[$num] = hexdec(getBitValue($Em_Row[initValue],'01.0-02.7'));
	$Em_CellNum[$num] = hexdec(getBitValue($Em_Row[initValue],'03.0-04.7'));
	$tempPrefix = getBitValue($Em_Row[initValue],'05.0-5.7');
	$Em_prefix[$num]		= str_replace('E','',$tempPrefix);
	$temprouted = getBitValue($Em_Row[initValue],'6.0-13.7');
	$Em_routed[$num] = str_replace('E','',$temprouted);
	$Em_ID[$num] = $Em_Row[instanceNo];
	{//Location management 			
		$oidstr_Loc = '2.2.6';
		$objWhereStr_loc =getLevelWhere($oidstr_Loc);

		$paramSql_Loc = " SELECT initValue,readValue,instanceNo FROM $paramTable  
					WHERE $objWhereStr_loc
					";
		if($DEBUG)echo "<br>paramSql_Loc: $paramSql_Loc";
		$Result_Loc = mysqli_query($pubConn,$paramSql_Loc);
		while($Row_Loc = mysqli_fetch_array($Result_Loc))
		{
			$LAC = hexdec(getBitValue($Row_Loc[initValue],'02.0-03.7'));
			$tempFlag = hexdec(getBitValue($Row_Loc[initValue],'0.0-0.7'));
			if($tempFlag&&($LAC==$Em_LAC[$num]))
			{
				$trunkgp_Loc[$num] = hexdec(getBitValue($Row_Loc[initValue],'01.0-01.7'));
				{
					$tmpDb = 'OBJ_322';
					$tmpTable = 'param_99';
					$tmpoid = '2.1.4';
					$objWhereStr = getLevelWhere($tmpoid);
					
					$paramSql = " SELECT initValue,readValue,instanceNo FROM $tmpTable  
								WHERE $objWhereStr AND instanceNo ='$trunkgp_Loc[$num]' 
								";
					//echo "$paramSql<br>";
					$Result = mysqli_query($pubConn,$paramSql);				
					$Row		= mysqli_fetch_array($Result);
					$DPC_TG 		= hexdec(getBitValue($Row[initValue],'0.0-3.7'));				
					$NetID_TG 	= hexdec(getBitValue($Row[initValue],'5.0-5.7'));				

					
					$tmpDb = 'OBJ_222';
					$tmpTable = 'param_99';
					$tmpoid = '2.4.1';
					$objWhereStr = getLevelWhere($tmpoid);
					$paramSql = " SELECT initValue,readValue,instanceNo FROM $tmpTable  
								WHERE $objWhereStr
								";
					//echo "$paramSql<br>";
					$Result_Link = mysqli_query($pubConn,$paramSql);
					while($Row_Link = mysqli_fetch_array($Result_Link))
					{
						$DPC_link	= hexdec(getBitValue($Row_Link[initValue],'0.0-2.7'));				
						$NetID_link	= bindec(getBitValue($Row_Link[initValue],'3.0-3.1'));				
						if(($DPC_link == $DPC_TG)&&($NetID_link == $NetID_TG))
						{
							$linkset[$num] = $Row_Link[instanceNo];
							$num++;
							break;
						}								
					}
				}
				break;
			}				
		}

	}//Location management	
}
//echo "$num";
$rowspan = $num +1;
echo "<tr bgcolor=\"#E6E6E6\">";
echo "<td ><b>No.</b></td>";	
echo "<td ><b>Emergency Call flag</b></td>";	
echo "<td ><b>LAC</b></td>";
echo "<td ><b>Cell ID</b></td>";
echo "<td ><b>Prefix Number</b></td>";
echo "<td ><b>Local emergency number</b></td>";
echo "</tr>";

for($i=0;$i< $num;$i++)
{
	echo "<tr >";
	echo "<td ><a href=\"../toElement/wxc2_sp.php?trunkgp=$trunkgp_Loc[$i]&linkset=$linkset[$i]\">$i</a></td>";	
	echo "<td >{$emFlagArr[$Em_flag[$i]]}&nbsp;</td>";
	echo "<td >$Em_LAC[$i]&nbsp;</td>";
	echo "<td >$Em_CellNum[$i]&nbsp;</td>";
	$temp=hexdec($Em_prefix[$i]);
	echo "<td >$temp&nbsp;</td>";
	echo "<td >$Em_routed[$i]&nbsp;</td>";
	echo "</tr>";		
}
echo "</table>&nbsp;";

?>

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



<script LANGUAGE="JavaScript"> 
function checkInput(term,flag,maxValue)
{
	term.value = term.value.toUpperCase();
    
    if (flag == 16)
    {
    	var checkOK = "0123456789ABCDEF";
    	var showmsg ="Parameter must be a hexadecimal value";
    }
    else 
    {
    	var checkOK = "0123456789";
    	var showmsg ="Parameter must be a decimal value";
    }

    var checkStr = term.value;
    var allValid = true;
    for (i = 0;  i < checkStr.length;  i++){
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++){
			if (ch == checkOK.charAt(j))
				break;
		}
		if (j == checkOK.length){
			allValid = false;
			break;
		}
	}
	
	if (!allValid){  
		alert(showmsg+"!");
		term.focus();
		term.value = 0;
		return (false);
	}
	if (maxValue != 0)
	{
		if (checkStr > maxValue)
		{
			showmsg = "Parameter must less then "+ maxValue;
			alert(showmsg+"!");
			term.value = 0;
			term.focus();
			return (false);
		}
	}
}
</script>
