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

*********************************************************/
session_start();

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

if(session_is_registered("vssArr"))
	session_unregister("vssArr");
	
if(session_is_registered("vssSegArr"))
	session_unregister("vssSegArr");
//==========================================================
//±äÁ¿¶¨Òå
//==========================================================
function getVssArr($flag,&$vssArr)
{
	global $pubDb;
	$sccp_objDB = 'OBJ_223';
	$tmpTable = 'param_8';
	$oidstr = '2.1.8';	
	$objWhereStr = getLevelWhere($oidstr);
	
	$ElementInfoObjId='2.11';
	$levelWhere = getLevelWhere($ElementInfoObjId);
	if($DEBUG) echo "<BR>levelWhere=$levelWhere";
	$ElementInfoParamTable='OBJ_225.param_99';
	$getSql="SELECT initValue,instanceNo FROM $ElementInfoParamTable 
				WHERE $levelWhere and initValue LIKE '01%' ";
	if($DEBUG) 
		echo "<BR>getSql=$getSql";
		//exit();
	$result	=mysqli_query($pubConn,$getSql);
	echo mysqli_error($pubConn);
	$typeOffset 	= '1.0-1.7';
	$sysNoOffset 	= '2.0-2.3';
	$subSysNoOffset = '2.4-2.7';
	$tgOffset 		= '3.0-3.7';
	$lsOffset 		= '4.0-4.7';
	$appTypeOffset 	= '5.0-5.7';
	$appGrpOffset 	= '6.0-6.7';
	$nameOffset 	= '14.0-23.7';
	$i=0;
	$j=0;
	while($rows=mysqli_fetch_array($result))
	{
		if($DEBUG)echo "<BR>initValue=$rows[initValue]";
		$typeValue=hexdec(getBitValue($rows[initValue],$typeOffset));
		$sysNo	= bindec(getBitValue($rows[initValue],$sysNoOffset));
		$subsysNo	= bindec(getBitValue($rows[initValue],$subSysNoOffset));
		$tmpSystemNo= $sysNo;
		$assignedTg = hexdec(getBitValue($rows[initValue],$tgOffset));
		$assignedls = hexdec(getBitValue($rows[initValue],$lsOffset));
		$appType = hexdec(getBitValue($rows[initValue],$appTypeOffset));
		$appGrp = hexdec(getBitValue($rows[initValue],$appGrpOffset));
		$name = trim(toAscii(getBitValue($rows[initValue],$nameOffset)));
		$eleInfoNo = $rows[instanceNo];
		if($typeValue==2)//aas
		{
		}
		if($typeValue==3)//VSS
		{
			$hbSel = "select detailStat from sysStat where sysTypeNo = 390 and sysNo=$sysNo";
			//echo "<br>hbSel:$hbSel";
			$hbResult = mysqli_query($pubConn,$hbSel);
			if($hbRow=mysqli_fetch_array($hbResult))
			{
				$hex_mes=$hbRow[detailStat];
				$licenseCtrl	= 	80;
				$license_ctrl=hexdec(substr($hex_mes,$licenseCtrl*2,2));
				//echo "<br>license_ctrl:$license_ctrl";
				if($flag=='srf')
				{
					if($license_ctrl==2 || $license_ctrl==3)
					{
						$otherWhereStr = "and subSysNo=$sysNo";
						$getsql_2 = "select initValue from $tmpTable where $objWhereStr $otherWhereStr";
						$result_2 = @mysqli_query($pubConn,$getsql_2);
						$row_2 = @mysqli_fetch_array($result_2);
						$SCCP_MSISDN_value = str_replace('F','',getBitValue($row_2[0],"01.0-10.7"));
						if(strlen($SCCP_MSISDN_value)>0)
						{
							$vssArr[$i][name]=$name;
							$vssArr[$i][srf] = $SCCP_MSISDN_value;
							$vssArr[$i][sysNo] = $sysNo;
							$i++;
						}
					}
				}
				else if($flag=='segment')
				{
					if($license_ctrl==1 || $license_ctrl==3)
					{
						$vssArr[$i][name]=$name;
						$vssArr[$i][srf] = '';
						$vssArr[$i][sysNo] = $sysNo;
						$i++;
					}
				}
				
			}
		}
	}
	$vssArr[$i][name] = "None";
	$vssArr[$i][srf] = '';
	$vssArr[$i][sysNo] = -1;
}//end getVssArr.

getVssArr('segment',$vssSegArr);
session_register("vssSegArr");

getVssArr('srf',$vssArr);
session_register("vssArr");

if($DEBUG) exit();
echo "<script LANGUAGE=\"JavaScript\">";
echo " location='./pps.php?load_flag=$load_flag&license=$license&users=$users&page_top=$page_top';";
echo "</script>";

exit();
?>