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

$listPageUrl = "AASconf.php?linkset=$linkset&trunkgp=$trunkgp&inst=$inst&sysNo=$sysNo"; 

$objDB = 'OBJ_311';
$paramTable = 'param_'.$sysNo;
?>

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

<?php

if($_SERVER['REQUEST_METHOD'] == "POST")
{
	$oidstr = "2.3.3";
	$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];

	for($i=0; $i< 32; $i++)
	{
		$l=$i*2;
		$h=$l+1;
		$setbits = "$l.0-$h.7";
		$tmp = omc_keep_length(${"unit$i"},'0',4,1);
		$tmp = strtoupper($tmp);
		$setValue = setBitValue($setValue, $setbits, $tmp);
	}

	$updflag = "UPDATE $paramTable SET initValue = '$setValue' 
        			WHERE $objWhereStr  and instanceNo='$TypeNo'
        			";								
	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.3.3";
$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);
for($i=0; $i< 32; $i++)
{
	${"unit$i"} = substr($row[initValue],$i*4,4);
}

		
$selfPage = "$PHP_SELF?linkset=$linkset&trunkgp=$trunkgp&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 > Network > Element > AAS > Voice Group";
	echo "<td width=\"20%\" align=\"right\" title=\"Help\">";
	showHelp($helpId);
	echo "</td>";
	echo "</tr>";
	echo "</table>";
	echo "<br>";
	
	echo "<table width=\"80%\">";
	echo "<tr><td>";
	echo "<b>Number - $inst:&nbsp;&nbsp;</b>";
	echo "$subChannelName";
	echo "<input type=\"submit\" value=$strSave class=\"button\" name=\"setSys\" style=\"left: 1; top: 2; width: 60; height: 25; position: relative\">";	
	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=\"80%\" cellpadding=\"1\" cellspacing=\"0\" bordercolor=\"#666666\" bordercolordark=\"#FFFFFF\">";
		echo "<td width=\"40%\">";
			echo "<table border=\"1\" width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" bordercolor=\"#666666\" bordercolordark=\"#FFFFFF\">";
				for($i=0; $i< 16; $i++)
				{
				$value=${"unit$i"};
				echo "<tr>";
					echo "<td width=\"40%\">voice unit #$i</td>";
					echo "<td><input type=\"text\" name=\"unit$i\" value=\"$value\" size=\"5\" maxlength=\"4\"></td>";
				echo "</tr>";
				}
			echo "</table>";
		echo "</td>";
		
		echo "<td width=\"40%\">";
			echo "<table border=\"1\" width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" bordercolor=\"#666666\" bordercolordark=\"#FFFFFF\">";
				for($i=16; $i< 32; $i++)
				{
				$value=${"unit$i"};	
				echo "<tr>";
					echo "<td width=\"40%\">voice unit #$i</td>";
					echo "<td><input type=\"text\" name=\"unit$i\" value=\"$value\" size=\"5\" maxlength=\"4\"></td>";
				echo "</tr>";
				}
			echo "</table>";
		echo "</td>";
echo "</table>";

?>
