<?php
require("../sub_inc/commfunc.php");
$DEBUG = 0;
if($DEBUG) echo "<br>ÕýÔÚµ÷ÊÔÖÐ£¡£¡";

$sqltable = 'OBJ_360.param_99';

?>


<?php


if($_SERVER['REQUEST_METHOD'] == "POST")
{
	if($vss_InstanceNo==-1 || strlen($vss_InstanceNo)==0)
	{
		$PLMNServNo = $PSTNServNo = $LeaveMessNo = '';
	}	
	else
	{
		$vms_objDB 			= "OBJ_390";
		$vms_paramTable 	= 'param_99';
		$oidstr = "2.2.1.1";
		$objWhereStr = getLevelWhere($oidstr);
		$getsql = "select initValue from $vms_paramTable where $objWhereStr and instanceNo='$vss_InstanceNo'";
		$result = @mysqli_query($pubConn,$getsql);
		$row = @mysqli_fetch_array($result);
		/*
		$MSISDN = getBitValue($row[0],'00.0-07.7');
		$MSISDN = str_replace('F','',$MSISDN);			
		$CheckMessNo = getBitValue($row[0],'32.0-39.7');
		$CheckMessNo = str_replace('F','',$CheckMessNo);
		*/
		$PLMNServNo = getBitValue($row[0],'08.0-15.7');
		$PLMNServNo = str_replace('F','',$PLMNServNo);
		
		$PSTNServNo = getBitValue($row[0],'16.0-23.7');
		$PSTNServNo = str_replace('F','',$PSTNServNo);
		
		$LeaveMessNo = getBitValue($row[0],'24.0-31.7');
		$LeaveMessNo = str_replace('F','',$LeaveMessNo);
	}
	$objWhereStr = getLevelWhere('2.1.5.5');
	$getsql = "select initValue from $sqltable where $objWhereStr and instanceNo=$instanceNo";
	if(0) echo "<br> getsql: $getsql";
	$result = mysqli_query($pubConn,$getsql);
	echo mysqli_error($pubConn);
	$vmsSeg_row = mysqli_fetch_array($result);
	$vmsSeg_row = $vmsSeg_row[initValue];
	
	$tmpStartMSISDN = omc_keep_length(toHex($startMSISDN),'0',32,0);
	$tmpendMSISDN = omc_keep_length(toHex($endMSISDN),'0',32,0);
	
	$tmpPLMNServNo = omc_keep_length(toHex($PLMNServNo),'0',32,0);
	$tmpPSTNServNo = omc_keep_length(toHex($PSTNServNo),'0',32,0);
	$tmpLeaveMessNo = omc_keep_length(toHex($LeaveMessNo),'0',32,0);
	
	$setValue = setBitValue($vmsSeg_row, '00.0-15.7' ,$tmpStartMSISDN);
	$setValue = setBitValue($setValue, '16.0-31.7' ,$tmpendMSISDN);
	$setValue = setBitValue($setValue, '32.0-47.7' ,$tmpPLMNServNo);
	$setValue = setBitValue($setValue, '48.0-63.7' ,$tmpPSTNServNo);
	$setValue = setBitValue($setValue, '64.0-79.7' ,$tmpLeaveMessNo);
	
	$objWhereStr = getLevelWhere('2.1.5.5');
	$updSql = "update $sqltable set initvalue='$setValue' where $objWhereStr and instanceNo=$instanceNo";
	if(0) echo "<br> updSql: $updSql";
	$result = mysqli_query($pubConn,$updSql);
	echo mysqli_error($pubConn);


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

?>
<form method="POST" name="selectform" action="<?php echo "$PHP_SELF?"; ?>">
<?php
{
	echo "<table border=\"0\" width=\"100%\">";
	echo "<tr>";
	echo "<td width=\"50%\">";
	
	$backurl1 = str_replace("wxc2_sp_signaling","wxc2_sp",$backurl);
	echo "Configuration > <a href=\"../overview/overview.php\">Network</a> > ";
	echo "<a href=\"$backurl\">PPS</a> > ";
	echo "<a href=\"#\">Basic vmsSeg zone</a>";
	echo "</td>";
	echo "<td width=\"50%\" align=\"right\" title=\"Help\">";
	//showHelp($helpId);
	echo "</td>";
	echo "</tr>";
	echo "</table>";
	
	echo "<table width=\"100%\">";
	echo "<tr><td width=\"70%\">";
	
	echo "</td>";
	echo "<td width=\"20%\">";
	echo "<input type=\"submit\" name=\"set\" value=\"Save\" class=\"button\" style=\"left: 1; top: 2; width: 60; height: 25; position: relative\">";
	echo "&nbsp;&nbsp;&nbsp;";
	echo "<input type=\"reset\" name=\"Reset\" value=\"Reset\" class=\"button\" style=\"left: 1; top: 2; width: 60; height: 25; position: relative\">";
	echo "</td>";
	echo "<td width=\"10%\" align=\"right\">";
	
	echo "<a href=\"$backurl\"><img align=absBottom border=0 src=\"../../images/left.gif\" width=\"14\" height=\"14\">$strBack</a>";
	
	
	echo "<input type=\"hidden\" name=\"backurl\" value=\"$backurl\">";
	echo "<input type=\"hidden\" name=\"addflag\" value=\"$addflag\">";
	echo "<input type=\"hidden\" name=\"instanceNo\" value=\"$instanceNo\">";
	
	echo "</td></tr>";
	echo "</table>";
}

$objWhereStr = getLevelWhere('2.1.5.5');
$getsql = "select initValue from $sqltable where $objWhereStr and instanceNo=$instanceNo";
if(0) echo "<br> getsql: $getsql";
$result = mysqli_query($pubConn,$getsql);
echo mysqli_error($pubConn);
$vmsSeg_row = mysqli_fetch_array($result);
$vmsSeg_row = $vmsSeg_row[initValue];

$startMSISDN = trim(toAscii(getBitValue($vmsSeg_row,'00.0-15.7')));
$endMSISDN = trim(toAscii(getBitValue($vmsSeg_row,'16.0-31.7')));
$servNumPLMN = trim(toAscii(getBitValue($vmsSeg_row,'32.0-47.7')));
$servNumPSTN = trim(toAscii(getBitValue($vmsSeg_row,'48.0-63.7')));
$numberDeposit = trim(toAscii(getBitValue($vmsSeg_row,'64.0-79.7')));

//print_r($vssSegArr);
$vssIns = -1;
for($j=0; $j< sizeof($vssSegArr)-1; $j++)//vss serv number
{
	$vms_objDB 			= "OBJ_390";
	$vms_paramTable 	= 'param_99';
	$oidstr = "2.2.1.1";
	$objWhereStr = getLevelWhere($oidstr);
	$tmpInstNo = $vssSegArr[$j][sysNo];
	$getsql = "select initValue from $vms_paramTable where $objWhereStr and instanceNo='$tmpInstNo'";
	$result = @mysqli_query($pubConn,$getsql);
	$row = @mysqli_fetch_array($result);
	/*
	$MSISDN = getBitValue($row[0],'00.0-07.7');
	$MSISDN = str_replace('F','',$MSISDN);			
	$CheckMessNo = getBitValue($row[0],'32.0-39.7');
	$CheckMessNo = str_replace('F','',$CheckMessNo);
	*/
	$PLMNServNo = getBitValue($row[0],'08.0-15.7');
	$PLMNServNo = str_replace('F','',$PLMNServNo);
	
	$PSTNServNo = getBitValue($row[0],'16.0-23.7');
	$PSTNServNo = str_replace('F','',$PSTNServNo);
	
	$LeaveMessNo = getBitValue($row[0],'24.0-31.7');
	$LeaveMessNo = str_replace('F','',$LeaveMessNo);
	
	if(strcmp($PLMNServNo,$servNumPLMN)==0
		&&strcmp($PSTNServNo,$servNumPSTN)==0
		&&strcmp($LeaveMessNo,$numberDeposit)==0)
		
	{
		$vssIns = $vssSegArr[$j][sysNo];
		break;
	}
}//end vss serv number
echo "<table border=\"1\" width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" bordercolor=\"#666666\" bordercolordark=\"#FFFFFF\">";	
echo "<tr bgcolor=\"#E6E6E6\"><td width=\"50%\"><b>Parameters</b></td><td><b>Value</b></td></tr>";
echo "<tr>";
	echo "<td>Start MSISDN</td>";
	echo "<td><input type=\"text\" size=\"18\" maxlength=\"16\" name=\"startMSISDN\" value=\"$startMSISDN\"></td>";
echo "</tr>";

echo "<tr>";
	echo "<td>End MSISDN</td>";
	echo "<td><input type=\"text\" size=\"18\" maxlength=\"16\" name=\"endMSISDN\" value=\"$endMSISDN\"></td>";
echo "</tr>";

echo "<tr>";
	echo "<td>VSS Name</td>";
	echo "<td>";
		echo "<select name=\"vss_InstanceNo\">";
			for($i=0; $i< sizeof($vssSegArr); $i++)
			{
				echo "<option value=\"{$vssSegArr[$i][sysNo]}\" ";
				if($vssIns == $vssSegArr[$i][sysNo])
					echo "selected";
				echo ">{$vssSegArr[$i][name]}</option>";
			}
		echo "</select>";
	echo "</td>";
echo "</tr>";
?>
