<?php
require("../sub_inc/commfunc.php");

$listPageUrl = "VSSconf.php?linkset=$linkset&trunkgp=$trunkgp&infoNo=$infoNo&inst=$inst&sysNo=$sysNo&setVMS=1"; 

$objDB = 'OBJ_390';
$paramTable = 'param_99';
?>

<body topmargin="0" leftmargin="12">

<?php

if($_SERVER['REQUEST_METHOD'] == "POST")
{
	$oidstr = "2.2.1.8";
	$objWhereStr = getLevelWhere($oidstr);
	$getsql = "select initValue from $paramTable 
						where $objWhereStr and instanceNo='$inst'
						";
	$result = @mysqli_query($pubConn,$getsql);
	$row = @mysqli_fetch_array($result);
	$setValue = $row[0];

	$tmp = omc_keep_length($Prefix,'F',16,0);
	$tmp = strtoupper($tmp);
	$setValue = setBitValue($setValue,'00.0-07.7',$tmp);

	$tmp = dechex($OriNAI);
	$tmp = omc_keep_length($tmp,'0',2);
	$setValue = setBitValue($setValue,'08.0-08.7',$tmp);
	
	$tmp = dechex($Del_digit);
	$tmp = omc_keep_length($tmp,'0',2);
	$setValue = setBitValue($setValue,'09.0-09.7',$tmp);
	
	$tmp = omc_keep_length($Ins_digit,'F',16,0);
	$tmp = strtoupper($tmp);
	$setValue = setBitValue($setValue,'10.0-17.7',$tmp);
	
	$tmp = dechex($ModiNAI);
	$tmp = omc_keep_length($tmp,'0',2);
	$setValue = setBitValue($setValue,'18.0-18.7',$tmp);

	$updflag = "UPDATE $paramTable SET initValue = '$setValue' 
        			WHERE $objWhereStr  and instanceNo='$inst'
        			";								
	if($DEBUG) echo "$updflag<br>";
	mysqli_query($pubConn,$updflag);
	echo mysqli_error($pubConn);
	
	echo "<script LANGUAGE=\"JavaScript\">";
	if(!$DEBUG)
	{
		echo "\n window.location.href=\"$listPageUrl\";";
	} 	
	echo "\n </script>";
}

$oidstr = "2.2.1.8";
$objWhereStr = getLevelWhere($oidstr);
$getsql = "select initValue from $paramTable 
					where $objWhereStr and instanceNo='$inst'
					";
if($DEBUG)echo "<br>getsql: $getsql";
$result = @mysqli_query($pubConn,$getsql);
$row = @mysqli_fetch_array($result);

$Prefix = getBitValue($row[0],'0.0-7.7');
$Prefix = str_replace('F','',$Prefix);

$OriNAI = getBitValue($row[0],'08.0-08.7');
$OriNAI = hexdec($OriNAI);

$Del_digit = hexdec(getBitValue($row[0],'09.0-09.7'));

$Ins_digit = getBitValue($row[0],'10.0-17.7');
$Ins_digit = str_replace('F','',$Ins_digit);

$ModiNAI = getBitValue($row[0],'18.0-18.7');
$ModiNAI = hexdec($ModiNAI);
		
$NAIArr = array("","Subscriber","Unknown","National","International");
		
$selfPage = "$PHP_SELF?linkset=$linkset&trunkgp=$trunkgp&infoNo=$infoNo&inst=$inst&sysNo=$sysNo";

echo "<form method=\"POST\" name=\"Set\" action=\"$selfPage\">";
{
	echo "<table border=\"0\" width=\"80%\">";
	echo "<tr>";
	echo "<td width=\"60%\">";
	echo "Configuration > <a href=\"../overview/overview.php\">Network</a> > <a href=\"$listPageUrl\">VSS</a> > Number modification remote";
	echo "<td width=\"20%\" align=\"right\" title=\"Help\">";
	showHelp($helpId);
	echo "</td>";
	echo "</tr>";
	echo "</table>";
	echo "<br>";
	
	echo "<table width=\"100%\">";
	echo "<tr><td width=\"70%\">";
	echo "<b>Number - $inst:&nbsp;&nbsp;</b>";
	echo "$subChannelName";
	echo "</td>";
	echo "<td width=\"20%\">";
	echo "<input type=\"submit\" value=$strSave class=\"button\" name=\"setSys\" style=\"left: 1; top: 2; width: 60; height: 25; position: relative\">";	
	echo "&nbsp;&nbsp;&nbsp;";
	echo "<input type=\"reset\" value=$strReset  class=\"button\" name=\"Reset\" style=\"left: 1; top: 2; width: 60; height: 25; position: relative\">";
	echo "</td>";
	echo "<td>";
	echo "<p align=\"right\"><a href=\"$listPageUrl\"><img align=absBottom border=0 src=\"../../images/left.gif\" width=\"14\" height=\"14\">$strBack</a>";
	echo "</td></tr>"; 
	echo "</table>";
}

echo "<table border=\"1\" width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" bordercolor=\"#666666\" bordercolordark=\"#FFFFFF\">";
	echo "<tr>";
		echo "<td width=\"50%\">Prefix</td>";
		echo "<td>";
			echo "<input type = \"text\" name = \"Prefix\"	value = \"$Prefix\" size = \"18\" maxlength = \"16\" class=\"text\" onchange = checkInput(this,16,0)>&nbsp;";
		echo "</td>";
	echo "</tr>";
	 
	echo "<tr>";
		echo "<td>Delete digit</td>";
		echo "<td>";
		echo "<input type = \"text\" name = \"Del_digit\"	value = \"$Del_digit\" size = \"4\" maxlength = \"3\" class=\"text\" onchange = checkInput(this,10,255)>&nbsp;";
		echo "</td>";
	echo "</tr>";
	
	echo "<tr>";
		echo "<td>Insert digit</td>";
		echo "<td>";
		echo "<input type = \"text\" name = \"Ins_digit\"	value = \"$Ins_digit\" size = \"18\" maxlength = \"16\" class=\"text\" onchange = checkInput(this,16,0)>&nbsp;";
		echo "</td>";
	echo "</tr>";
	
	echo "<tr>";
		echo "<td>Original NAI</td>";
		echo "<td>";
		echo "<select size=\"1\" value=\"$OriNAI\" name=\"OriNAI\">";
			for($i=1; $i<sizeof($NAIArr); $i++)
			{
				echo "<option value=\"$i\" ";
				if($i == $OriNAI)
					echo "selected";
				echo ">{$NAIArr[$i]}</option>";
			}
		echo "</td>";
	echo "</tr>";
	
	echo "<tr>";
		echo "<td>Modified NAI</td>";
		echo "<td>";
		echo "<select size=\"1\" value=\"$ModiNAI\" name=\"ModiNAI\">";
			for($i=1; $i<sizeof($NAIArr); $i++)
			{
				echo "<option value=\"$i\" ";
				if($i == $ModiNAI)
					echo "selected";
				echo ">{$NAIArr[$i]}</option>";
			}
		echo "</td>";
	echo "</tr>";
echo "</table>";

?>
