<?php

require("../../inc/header.inc");
require("../sub_inc/operWebFunc.inc");
require("param_comm.inc");
?>

<script language="Javascript">
	
document.write("<div id='EMS_TIP_WINDOW' style=\"z-index:1000;display:none;position:absolute;border-color:#000000;border-style:solid;border-width:1px;\" ></div>");
	
function getEvent()
{  
	if(document.all)   
		return window.event; 	
	func=getEvent.caller; 	

	while(func!=null){  
		var arg0=func.arguments[0];
		if(arg0)
		{
			if((arg0.constructor==Event || arg0.constructor ==MouseEvent) || (typeof(arg0)=="object" && arg0.preventDefault && arg0.stopPropagation)) 
				return arg0;
              
		}
		func=func.caller;
	}
	return null;
}

function showTipWindow(tip)
{
	if(tip.length == 0)
		return;
	var pos_x;
	var pos_y;
	var event=getEvent();
	if (navigator.appName=='Microsoft Internet Explorer') 
	{
		pos_x=event.x;
		pos_y=event.y+document.body.scrollTop;
	}
	else if (navigator.appName=='Netscape') 
	{
		pos_x=event.pageX;
		pos_y=event.pageY;
	}

	document.getElementById("EMS_TIP_WINDOW").style.top=pos_y;
	document.getElementById("EMS_TIP_WINDOW").style.left=pos_x+40;
	document.getElementById("EMS_TIP_WINDOW").style.backgroundColor='#eeeeee';
	document.getElementById("EMS_TIP_WINDOW").style.display='';
	document.getElementById("EMS_TIP_WINDOW").innerHTML=tip;
}

function hideTipWindow()
{
	document.getElementById("EMS_TIP_WINDOW").style.display='none';
}
	
function addObject(createMethod,createInstanceNo,sysId,tableOid,table_type)
{
	if(createMethod == 0)
		createIndex=document.myform.index_select.value;
	else
		createIndex=1;
		
	window.location.href="param_edit.php?create=1&createMethod="+createMethod+"&createIndex="+createIndex+"&createInstanceNo="+createInstanceNo+"&sysId="+sysId+"&tableOid="+tableOid+"&table_type="+table_type;
	
}

function openNITZ(sysId,tableOid,table_type,instanceNo,param_oid)
{
	URL="./mscNITZ.php?sysId="+sysId+"&tableOid="+tableOid+"&table_type="+table_type+"&instanceNo="+instanceNo+"&param_oid="+param_oid;
	var setWindow = open(URL, 'newWin', 'toolbar=no,directories=no,menubar=no,scrollbars=yes,resizable=yes,status=yes,width=400,height=350');
	//setWindow.focus();
}

</script>
<body leftmargin="15" rightmargin="10" onload="javascript:adjust_frame('down');" onresize="javascript:adjust_frame('down');" style="overflow:hidden;overflow-x:hidden;overflow-y:hidden;">

<?php
adjust_head_frame("down");
adjust_title_head_frame("down");
adjust_title_tail_frame("down");

adjust_content_head_frame("down");	
echo "<br>";
//*****
//$url_temp=$_SERVER["REQUEST_URI"];
//echo "This page URL:$url_temp<br>";


//echo "tableOid=$tableOid,sysId=$sysId,table_type=$table_type,instanceNo=$instanceNo<br>";

$sysIdArr=explode('_',$sysId);
$sysTypeNo=$sysIdArr[0];
$sysNo=$sysIdArr[1];
$subSysNo=$sysIdArr[2];
$objDb='OBJ_'.$sysTypeNo;
$paraConfTable=$objDb.'.paramConf';
$pubDb='OMC_PUB';

$sql="select sysTypeName from OMC_PUB.sysConf where sysTypeNo='$sysTypeNo' ";
$res=@mysqli_query($pubConn,$sql);
$row=@mysqli_fetch_array($res);
$module_name=$row[sysTypeName];

if(checkIndependSystem($sysTypeNo))//Plat
	$paraTable=$objDb.".param_".$sysNo;
else
	$paraTable=$objDb.".param_99";
	

//Get all
if($_SERVER['REQUEST_METHOD'] == "POST")
{
	
	if($get)
	{
		//scalar table
		if($table_type == 0)
		{
			getParam($commInfoArr);
		}
		//column table
		else
		{
			//Get the timeslot parameter from the plat(trunk group id)
			$timeslot_table_oid=GetOIDByName(SYSTYPENO_MSC,"timeSlotEntry");
			if($sysTypeNo == SYSTYPENO_MSC && $tableOid == $timeslot_table_oid)
			{
				$tmps=explode(".",$instanceNo);
				$grounp_id=GetTrunkGroupID($tmps[0]+0,$tmps[1]+0);
				if($grounp_id == 1)
					$tmpSysId="320_1_0";
				else
					$tmpSysId="320_0_0";

				if(!GetSystemStatus(SYSTYPENO_MSC,$grounp_id))
					$tmpSysId="320_99_99";
					
				$commIdStr=oidSysCommSend($tmpSysId,0,$tableOid,$selectedSysId=-1,$instanceNo);
				checkState($commIdStr,"./param_edit.php?sysId=$sysId&tableOid=$tableOid&table_type=$table_type&instanceNo=$instanceNo");
			}
			else
			{
				$commIdStr=oidSysCommSend($sysId,0,$tableOid,$selectedSysId=-1,$instanceNo);
				echo "oidSysCommSend($sysId,0,$tableOid,$selectedSysId=-1,$instanceNo);<br>";
				checkState($commIdStr,"./param_edit.php?sysId=$sysId&tableOid=$tableOid&table_type=$table_type&instanceNo=$instanceNo");
			}
		}
		
	}
	else if($set)
	{
		//scalar table
		if($table_type == 0)
		{		
			$len=sizeof($setCommInfoArr);
			$commIdStr="";
			for($i=0;$i<$len;$i++)
			{
				$tmpCommIdStr = oidSysCommSend($setCommInfoArr[$i][sysId],3,$setCommInfoArr[$i][oid],-1);		
				$commIdStr=$commIdStr.$tmpCommIdStr;
			}
			if($len>0)
				checkState($commIdStr,"./param_edit.php?sysId=$sysId&tableOid=$tableOid&table_type=$table_type&instanceNo=$instanceNo");
		}
		//column table
		else
		{
			$commIdStr=oidSysCommSend($sysId,3,$tableOid,$selectedSysId=-1,$instanceNo);	
			checkState($commIdStr,"./param_edit.php?sysId=$sysId&tableOid=$tableOid&table_type=$table_type&instanceNo=$instanceNo");
		}
		
	}
	else if($lock || $unlock)
	{
		$tmpWhere=getLevelWhere($adminStatOid);
		if($lock)
			$initValue=0;
		else
			$initValue=1;
				
		$updateSql="UPDATE $paraTable SET initValue=$initValue WHERE $tmpWhere AND instanceNo=$instanceNo ";		
		
		if($sysTypeNo == 260 && $sysNo != 99 && $subSysNo != 99)
			$updateSql.="and subSysNo='$subSysNo' ";
		
		mysqli_query($pubConn,$updateSql);
		$commIdStr=oidSysCommSend($sysId,3,$adminStatOid,$selectedSysId=-1,$instanceNo);
		checkState($commIdStr,"./param_edit.php?sysId=$sysId&tableOid=$tableOid&table_type=$table_type&instanceNo=$instanceNo");
	}
	else if($podUpdateToPod)
	{
		 $tmpWhere=getLevelWhere($podUpdateToPodOid);
                //if($lock)
                        $initValue=1;
               // else
                 //       $initValue=1;

                $updateSql="UPDATE $paraTable SET initValue=$initValue WHERE $tmpWhere AND instanceNo=$instanceNo ";

                if($sysTypeNo == 260 && $sysNo != 99 && $subSysNo != 99)
                        $updateSql.="and subSysNo='$subSysNo' ";

                mysqli_query($pubConn,$updateSql);
                $commIdStr=oidSysCommSend($sysId,3,$podUpdateToPodOid,$selectedSysId=-1,$instanceNo);
                checkState($commIdStr,"./param_edit.php?sysId=$sysId&tableOid=$tableOid&table_type=$table_type&instanceNo=$instanceNo");
	}
}

//create
if($create == 1)
{
	//echo "createIndex=$createIndex,createInstanceNo=$createInstanceNo,createOid=$createOid,sysId=$sysId,tableOid=$tableOid,table_type=$table_type<br>";	
	$level=getTableLevel($tableOid,$sysTypeNo);
	$tmpwhere=getLevelWhere($tableOid);
	$newInstanceNo=omc_keep_length($createIndex,'0',4);
	if($createMethod == AUTO_CREATE)
		$createIndex=1;
		
	$sql="replace into $paraTable set initValue='$createIndex',instanceNo='$createInstanceNo'";
	
	if($sysTypeNo == 260 && $sysNo != 99 && $subSysNo != 99)
		$sql.=",subSysNo='$subSysNo' ";
	
	//nest table
	if($level > 1)
	{
		$createTableName=getTableNameByOid($sysId,$tableOid);
		$createTableName=str_replace("Entry","",$createTableName);
		$createOid=findRelationOid($createTableName,TABLE_CREATE,$sysTypeNo);
		$entriesOid=findRelationOid($createTableName,TABLE_ENTRIES,$sysTypeNo);
		//PrintInfo("createOid=".$createOid);
		//PrintInfo("entriesOid=".$entriesOid);
	}
	else
	{
		$orderBy="order by level_1 desc,level_2 desc,level_3 desc,level_4 desc,level_5 desc,level_6 desc,level_7 desc,level_8 desc,level_9 desc,level_10 desc";
		$sql1="select * from $paraConfTable where $tmpwhere and name_1 like '%Index' $orderBy";
		$res=@mysqli_query($pubConn,$sql1);
		$row=@mysqli_fetch_array($res);
		$createOid="";
		for($i=1;$i<=10;$i++)
		{
			if($row["level_".$i] == '0')
				break;
			$createOid.=$row["level_".$i].".";
		}
		$createOid=substr($createOid,0,strlen($createOid)-1);
		//echo "createOid=$createOid<br>";
	}
	
	$indexOidArr=explode(".",$createOid);
	for($i=0;$i<sizeof($indexOidArr);$i++)
		$sql=$sql.",level_".($i+1)."=".$indexOidArr[$i];
	//echo "$sql<br>";
	mysqli_query($pubConn,$sql);
	
  //nest table
	if($level > 1)
	{
		$commIdStr=oidSysCommSend($sysId,9,$createOid,$selectedSysId=-1,$createInstanceNo);
		checkState($commIdStr,"./param_edit.php?sysId=$sysId&tableOid=$tableOid&table_type=$table_type&instanceNo=$instanceNo");
		
		if($createMethod == AUTO_CREATE)
		{
			$indexLevelWhere=getLevelWhere($createOid);
			$indexSql="select * from $paraTable where $indexLevelWhere and instanceNo='$createInstanceNo' ";
			
			if($sysTypeNo == 260 && $sysNo != 99 && $subSysNo != 99)
				$indexSql.="and subSysNo='$subSysNo' ";
			
			$indexres=@mysqli_query($pubConn,$indexSql);
			$indexrow=@mysqli_fetch_array($indexres);
			$newIndex=$indexrow[readValue]+0;
		}
		
		
		$tmpwhere=getLevelWhere($tableOid);
		$sql="delete from $paraTable WHERE $tmpwhere ";
		
		if($sysTypeNo == 260 && $sysNo != 99 && $subSysNo != 99)
			$sql.="and subSysNo='$subSysNo' ";
		
		if($DEBUG)echo "<br>clearSql=$clearSql";
		mysqli_query($pubConn,$sql);
		
		$commIdStr=oidSysCommSend($sysId,5,$tableOid,$selectedSysId=-1,"");
		checkState($commIdStr,"./param_edit.php?sysId=$sysId&tableOid=$tableOid&table_type=$table_type&instanceNo=$instanceNo");
		
		$commIdStr=oidSysCommSend($sysId,0,$entriesOid,$selectedSysId=-1,$createInstanceNo);
		//echo "oidSysCommSend($sysId,0,$entriesOid,$selectedSysId=-1,$createInstanceNo);<br>";
		checkState($commIdStr,"./param_edit.php?sysId=$sysId&tableOid=$tableOid&table_type=$table_type&instanceNo=$instanceNo&createpage=$createpage");
		
		if($createMethod == AUTO_CREATE)
			$newInstanceNo=omc_keep_length($newIndex,'0',4);
		
		$instanceNo=$createInstanceNo.".".$newInstanceNo;
	}
	else
	{
		$commIdStr=oidSysCommSend($sysId,9,$createOid,$selectedSysId=-1,$createInstanceNo);
		checkState($commIdStr,"./param_edit.php?sysId=$sysId&tableOid=$tableOid&table_type=$table_type&instanceNo=$instanceNo");
		
		//some table create instance auto
		if($createMethod == AUTO_CREATE)
		{
			$wheretest=getLevelWhere($createOid);
			$sqltest="select * from $paraTable where $wheretest and instanceNo='0000' ";
			
			if($sysTypeNo == 260 && $sysNo != 99 && $subSysNo != 99)
				$sqltest.="and subSysNo='$subSysNo' ";
			
			$restest=@mysqli_query($pubConn,$sqltest);
			$numtest=mysqli_num_rows($restest);
			$rowtest=@mysqli_fetch_array($restest);
			$thisnew=$rowtest[readValue];
			$thisnew=omc_keep_length($thisnew,'0',4);			
		}
		
		$sql="delete from $paraTable WHERE $tmpwhere ";
		
		if($sysTypeNo == 260 && $sysNo != 99 && $subSysNo != 99)
				$sqltest.="and subSysNo='$subSysNo' ";
		
		if($DEBUG)echo "<br>clearSql=$clearSql";
		mysqli_query($pubConn,$sql);
		

		$commIdStr=oidSysCommSend($sysId,5,$tableOid,$selectedSysId=-1,"");
		checkState($commIdStr,"./param_edit.php?sysId=$sysId&tableOid=$tableOid&table_type=$table_type&instanceNo=$instanceNo");
		
		$instanceNo=$newInstanceNo;
		if($createMethod == AUTO_CREATE)
			$instanceNo=$thisnew;
		
	}
}

echo "<form name=\"myform\" method=\"POST\" action=\"$PHP_SELF\">";

if($table_type == 1)
{
	if($createpage == 1)
	{
		showTitle("show",$tableOid,$instanceNo,$sysId,$sysTypeNo,$module_name);
	}
	else
	{		
		showTitle("edit",$tableOid,$instanceNo,$sysId,$sysTypeNo,$module_name);
	}
}
else
{
	echo "<p><a href=\"param_show_down.php?tableOid=2&sysId=$sysId&instanceNo=0000&table_type=0\">";
	echo "<b>$module_name</b></a> > ";
}

//create page
if($createpage == 1)
{
	//echo "sysId=$sysId,tableOid=$tableOid,instanceNo=$instanceNo<br>";
	//get the kind of creation, auto or manual
	//get the table level
	$level=getTableLevel($tableOid,$sysTypeNo);
	
	//nest table
	if($level > 1)
	{
		$createTableName=getTableNameByOid($sysId,$tableOid);
		$createTableName=str_replace("Entry","",$createTableName);
		$createEntryOid=findRelationOid($createTableName,TABLE_CREATE,$sysTypeNo);
		$checkWhere=getLevelWhere($createEntryOid);
		$checksql="select * from $paraConfTable where $checkWhere ";
		$checkres=@mysqli_query($pubConn,$checksql);
		$num=mysqli_num_rows($checkres);
		if($num != 1)
			echo "The table not include create entry column<br>";
		else
		{
			$checkrow=@mysqli_fetch_array($checkres);
			if($checkrow[setTemplate_2] == "create=1")
				$create_method=AUTO_CREATE;
			else
				$create_method=MANUAL_CREATE;
		}
		//PrintInfo("createTableName=".$createTableName.",createEntryOid=".$createEntryOid.",createMethod=".$create_method);
	}
	else
	{
		$checkWhere=getLevelWhere($tableOid);
		$checksql="select * from $paraConfTable where $checkWhere and name_1 like '%Index' ";
		//echo "$checksql<br>";
		$checkres=@mysqli_query($pubConn,$checksql);
		$num=mysqli_num_rows($checkres);
		if($num != 1)
			echo "The table not include Index column<br>";
		else
		{
			$checkrow=@mysqli_fetch_array($checkres);
			if($checkrow[setTemplate_2] == "create=1")
				$create_method=AUTO_CREATE;
			else
				$create_method=MANUAL_CREATE;
			$createEntryOid="";
			for($i=1;$i<=10;$i++)
			{
				if($checkrow["level_".$i] == '0')
					break;
				$createEntryOid.=$checkrow["level_".$i].".";
			}
			$createEntryOid=substr($createEntryOid,0,strlen($createEntryOid)-1);
		}
		//PrintInfo("createEntryOid=".$createEntryOid.",createMethod=".$create_method);
	}
	

	if($create_method == AUTO_CREATE)
	{
		echo "<p><table border=\"1\" cellpadding=\"2\" cellspacing=\"0\"  bordercolor=\"#666666\" bordercolordark=\"#FFFFFF\" bgcolor=\"#FFFFFF\">";
		echo "<tr><td>Index is assigned by $module_name</td>";
		echo "<td>";
		echo "<input DISABLED type=\"text\" class=\"text\" size=\"3\" maxLength=\"3\">";

		echo "</td></tr>";
		echo "</table>";
		
		echo "<input id=\"add_id\" type=\"button\" onClick=\"javascript:addObject('$create_method','$instanceNo','$sysId','$tableOid','1');\" name=\"add\" value=\"$strAdd\" class=\"button\" style=\"$buttonStyle\">";	
	}
	else if($create_method == MANUAL_CREATE)
	{
		
		//first level
		//if($last_table_level == 0)
		$tmpwhere=getLevelWhere($tableOid);
		$orderBy="order by level_1 desc,level_2 desc,level_3 desc,level_4 desc,level_5 desc,level_6 desc,level_7 desc,level_8 desc,level_9 desc,level_10 desc";
		$sql="select * from $paraConfTable where $tmpwhere and name_1 like '%Index' $orderBy";
		//echo "$sql<br>";
		$res=@mysqli_query($pubConn,$sql);
		$row=@mysqli_fetch_array($res);
		$minIndex=$row[minValue]+0;
		$maxIndex=$row[maxValue]+0;
		
		$createIndexOid="";
		for($i=1;$i<=10;$i++)
		{
			if($row["level_".$i] == '0')
				break;
			$createIndexOid.=$row["level_".$i].".";
		}
		$createIndexOid=substr($createIndexOid,0,strlen($createIndexOid)-1);
		//echo "createIndexOid=$createIndexOid,minIndex=$minIndex,maxIndex=$maxIndex<br>";
		
		$tmpwhere=getLevelWhere($createIndexOid);
		if($instanceNo != "0000")
			$sql="select initValue from $paraTable where $tmpwhere and instanceNo like '$instanceNo.%' ";
		else
			$sql="select initValue from $paraTable where $tmpwhere ";
			
		if($sysTypeNo == 260 && $sysNo != 99 && $subSysNo != 99)
			$sql.="and subSysNo='$subSysNo' ";
			
		//echo "$sql,instanceNo=$instanceNo<br>";
		$res=@mysqli_query($pubConn,$sql);
		while($row=@mysqli_fetch_array($res))
			$index_use_flags[$row[initValue]+0]=1;
		
		
		echo "<p><table border=\"1\" cellpadding=\"2\" cellspacing=\"0\"  bordercolor=\"#666666\" bordercolordark=\"#FFFFFF\" bgcolor=\"#FFFFFF\">";
		echo "<tr><td>Please input the index No.</td>";
		echo "<td>";
		$no_use_count=0;
		//auto
		//if($sysTypeNo == 260 && $tableOid == "2.2.1.1")
		//	echo "<select name=\"index_select\" disabled>";
		//else
			echo "<select name=\"index_select\">";
		for($index=$minIndex;$index<=$maxIndex;$index++)
		{
			if($index_use_flags[$index] != 1)
			{
				echo "<option value=$index>$index</option>";
				$no_use_count++;
			}
		}
		echo "</select>";
		echo "</td></tr>";
		echo "</table>";
		
		//table is full
		if($no_use_count == 0)
		{
			echo "<input disabled id=\"add_id\" type=\"submit\" name=\"add\" value=\"$strAdd\" class=\"button\" style=\"$buttonStyle\">";
			echo "<p><table border=\"1\" cellpadding=\"2\" cellspacing=\"0\"  bordercolor=\"#666666\" bordercolordark=\"#cecece\" bgcolor=\"#cecece\">";
			echo "<tr><td>";
			echo "Note: The table is full";
			echo "</td></tr></table>";
		}
		else
		{
			//echo "instanceNo=$instanceNo,table_type=$table_type<br>";
			echo "<input id=\"add_id\" type=\"button\" onClick=\"javascript:addObject('$create_method','$instanceNo','$sysId','$tableOid','1');\" name=\"add\" value=\"$strAdd\" class=\"button\" style=\"$buttonStyle\">";
		}
		

	}
	

	echo "</form>";
	exit();
}


$keyId=0;
showTable($tableOid);

for($i=0;$i<$keyId;$i++)
{
	if(!$objects[$i]['type'] == LEAF_TYPE && !strstr($objects[$i]['name_1'],"Entry") && !strstr($objects[$i]['name_1'],"Table"))
	{
		$objects[$i]['table_type']=SCALAR_TABLE_TYPE;
	}
	if($objects[$i]['type'] == UNKNOWN_TYPE)
	{
		$objects[$i]['type']=SCALAR_TABLE_TYPE;
	}
}

//=============================================
//SCALAR_TABLE_TYPE
if($table_type == 0)
{
	$commInfoArrNo=0;
	$setCommInfoArrNo=0;
	$table_level=0;
	for($index=0;$index<$keyId;$index++)
	{
		if($objects[$index]['type'] == COLUMN_TABLE_TYPE)
		{
			echo "</table>";
			break;
		}
		else if($objects[$index]['type'] == SCALAR_TABLE_TYPE)
		{
			$table_name=getShowNameOfTable($objects[$index]['name_1'],$index);
			echo "<b>{$table_name}</b><p>";
			echo "<table border=\"1\" cellpadding=\"2\" cellspacing=\"0\"  bordercolor=\"#666666\" bordercolordark=\"#FFFFFF\" bgcolor=\"#FFFFFF\">";
		}
		else if($objects[$index]['type'] == LEAF_TYPE)
		{
			//not accessable
			if($objects[$index]['maxAccess'] == ACCESS_ENTRY)
				continue;
			if(strstr($objects[$index]['desc_1'],"Hidden Parameter"))
				continue;
			if(stristr($objects[$index]['name_1'],"Command"))
				continue;
			$showName=getShowNameOfTable($objects[$index]['name_1'],$index);
			echo "<tr>";
			//title=\"{$objects[$index]['note_1']}\"
			echo "<td onMouseOver=\"javascript:showTipWindow('{$objects[$index]['note_1']}');\" onMouseOut=\"javascript:hideTipWindow();\">{$showName}</td>";
			echo "<td>";
			if($objects[$index]['valueType'] == VALUE_OPAQUE)
				showParameter($sysId,$objects[$index]['oid'],$instanceNo);
			else	
				showParameterAdv($sysId,$objects[$index]['oid'],$instanceNo);
			echo "</td>";
			echo "</tr>";
			
			echo "<input type=\"hidden\" name=\"commInfoArr[$commInfoArrNo][sysId]\" value=\"$sysId\">";
			echo "<input type=\"hidden\" name=\"commInfoArr[$commInfoArrNo][oid]\" value=\"{$objects[$index]['oid']}\">";
			echo "<input type=\"hidden\" name=\"commInfoArr[$commInfoArrNo][instanceNo]\" value=\"\">";
			$commInfoArrNo++;
		
			if($objects[$index]['maxAccess'] == ACCESS_READ_WRITE)
			{
				echo "<input type=\"hidden\" name=\"setCommInfoArr[$setCommInfoArrNo][sysId]\" value=\"$sysId\">";
				echo "<input type=\"hidden\" name=\"setCommInfoArr[$setCommInfoArrNo][oid]\" value=\"{$objects[$index]['oid']}\">";
				echo "<input type=\"hidden\" name=\"setCommInfoArr[$setCommInfoArrNo][instanceNo]\" value=\"\">";
				$setCommInfoArrNo++;
			}
		}
	}
	if($index == $keyId)
		echo "</table>";

}
//COLUMN_TABLE_TYPE
else if($table_type == 1)
{
	$table_level=0;
	$this_page_title_object="";
	for($index=0;$index<$keyId;$index++)
	{
		if($objects[$index]['type'] == ENTRY_TYPE)
		{
			$this_page_title_object=$objects[$index]['name_1'];

			echo "<br><table border=\"1\" cellpadding=\"2\" cellspacing=\"0\"  bordercolor=\"#666666\" bordercolordark=\"#FFFFFF\" bgcolor=\"#FFFFFF\">";
		}
		else if($objects[$index]['type'] == LEAF_TYPE)
		{
			//not accessable
			if($objects[$index]['maxAccess'] == ACCESS_ENTRY)
				continue;
			//row status
			if(strstr($objects[$index]['name_1'],"RowStatus"))
				continue;
			echo "<tr>";
			
			//whether have lock and unlock button
			if(strstr($objects[$index]['name_1'],"AdminState"))
			{
				$lock_unlock_flag=1;
				$lock_unlock_oid=$objects[$index]['oid'];
			}
			// echo "name_1:$objects[$index]['name_1']<br>";
			if(strstr($objects[$index]['name_1'],"podUpdateToPod"))
                        {
                                $podUpdateToPod_flag=1;
                                $podUpdateToPod_oid=$objects[$index]['oid'];
                        }
		
	
			if(strstr($objects[$index]['name_1'],"CreateEntry"))
			{
				continue;
			}
			if(strstr($objects[$index]['name_1'],"Entries"))
			{
				$showName=getShowNameOfField($objects[$index]['name_1'],$index);
				echo "<td>{$showName}</td>";
				
				//get the entry value
				//get the table name
				$tb=$objects[$index][name_1];
				$tlen=strlen($tb);
				$fg=0;
				$tb1="";
				for($ti=0;$ti<$tlen;$ti++)
				{
					if($tb[$ti] >= 'A' && $tb[$ti] <= 'Z')
						$fg=1;
					if($fg==1)
						$tb1.=$tb[$ti];
				}
				$tb2=explode("Entries",$tb1);
				$tb3=$tb2[0];
				$entriesOid=findRelationOid($tb3,TABLE_ENTRY,$sysTypeNo);
				//PrintInfo($entriesOid);
							
				echo "<td>";
				$value=getParamValue($sysId,$objects[$index]['oid'],$instanceNo);
				
				echo "<a href=\"param_show_table.php?tableOid=$entriesOid&instanceNo=$instanceNo&sysId=$sysId\">$value</a>";
				echo "</td>";
				//$nextTableOid=
				
			}
			else
			{
				$showName=getShowNameOfField($objects[$index]['name_1'],$index);
				//title=\"{$objects[$index]['note_1']}\"
				echo "<td onMouseOver=\"javascript:showTipWindow('{$objects[$index]['note_1']}');\" onMouseOut=\"javascript:hideTipWindow();\">{$showName}</td>";
				echo "<td>";
				if($objects[$index]['valueType'] == VALUE_OPAQUE)
				{
					if(stristr($objects[$index]['name_1'],"NITZ"))
					{
						$mscTable="OBJ_320.param_99";
						$levels=getLevelWhere($objects[$index]['oid']);
						$sql="SELECT * FROM $mscTable WHERE $levels AND instanceNo=$instanceNo";
						$res=mysqli_query($pubConn,$sql);
						$rows=@mysqli_fetch_array($res);
						$initValue=$rows[initValue];
						$readValue=$rows[readValue];
						if($initValue == '')
							$initValue="--";
						echo "<a href=# onClick=\"javascript:openNITZ('$sysId','$tableOid','$table_type','$instanceNo','{$objects[$index][oid]}');\" >";
						if(strlen($initValue)>8)
							$showValue=substr($initValue,0,8);
						if($initValue == $readValue)
							echo "<font class=text color=#0000ff>$showValue</font>";		
						else
							echo "<font class=text color=#008000>$showValue</font>";		
						echo "</a>";
					}
					else
					{
						showParameter($sysId,$objects[$index]['oid'],$instanceNo);
					}
				}
				else if(strstr($objects[$index]['name_1'],"Index"))
				{
					$value=getParamValue($sysId,$objects[$index]['oid'],$instanceNo);
					echo "$value";
				}
				else if(strstr($objects[$index]['desc_1'],"RelationPoint"))
				{
					$tmp1=strstr($objects[$index]['desc_1'],"RelationPoint:");
					$tmp2=explode(";",$tmp1);
					$tmp3=explode("RelationPoint:",$tmp2[0]);
					$rTableOid=$tmp3[1];
					
					$showvalue=getParamValue($sysId,$objects[$index]['oid'],$instanceNo);
					
					if(trim($showvalue) == "--" || trim($showvalue)=="")
					{
						echo "--";
					}
					else
					{
						$tmp1=explode(" ",$showvalue);
						$tmp2=$tmp1[1];
						$tmp3=explode("-",$tmp2);
						$tmp4=omc_keep_length($tmp3[0],'0',4);
						$tmp5=omc_keep_length($tmp3[1],'0',4);
						$rInstanceNo=$tmp4.".".$tmp5;
						$rWhere=getLevelWhere($rTableOid);
						$rsql="select * from $paraTable where instanceNo='$rInstanceNo' and $rWhere ";
						$rres=mysqli_query($pubConn,$rsql);
						$num=mysqli_num_rows($rres);
						//echo "$rsql";
						if($num == 0)
							echo "--";
						else
							echo "<a href=\"./param_edit.php?tableOid=$rTableOid&instanceNo=$rInstanceNo&sysId=$sysId&table_type=$table_type\">$showvalue</a>";
					}
				}
				else
					showParameterAdv($sysId,$objects[$index]['oid'],$instanceNo);
				echo "</td>";
			}
			echo "</tr>";
		}
	}
	echo "</table>";
	
	echo "<input type=\"hidden\" name=\"commInfoArr[0][sysId]\" value=\"$sysId\">";
	echo "<input type=\"hidden\" name=\"commInfoArr[0][oid]\" value=\"$tableOid\">";
	echo "<input type=\"hidden\" name=\"commInfoArr[0][instanceNo]\" value=\"$instanceNo\">";

}

//=======================================
$DEBUG=0;
if($DEBUG)
{
	echo "<p>============================test========================<br>";
	echo "keyId=$keyId<br>";
	$test_oid_flag=1;
	$test_name_flag=1;
	$test_nest_flag=1;
	$test_type_flag=1;
	
	for($i=0;$i<$keyId;$i++)
	{
		//if($objects[$i]['type'] != LEAF_TYPE && $objects[$i]['type'] != ENTRY_TYPE)
		{
			echo "$i-";
			if($test_oid_flag)
				echo "oid-{$objects[$i]['oid']}, ";
			if($test_name_flag)
			 	echo "name-{$objects[$i]['name_1']}, ";
			if($test_nest_flag)
				echo "nestNum-{$objects[$i]['nest_num']},  ";
			if($test_type_flag)
				echo "type-{$type_label[$objects[$i]['type']]}, ";
				
			echo "<br>";
		}
	}
}

//lock and unlock
if($lock_unlock_flag == 1)
{
	echo "<input type=\"submit\" name=\"lock\" value=\"$strLock\" class=\"button\" style=\"$buttonStyle\">";
	echo "&nbsp;";
	echo "<input type=\"submit\" name=\"unlock\" value=\"$strUnlock\" class=\"button\" style=\"$buttonStyle\">";	
	echo "&nbsp;";
	echo "<input type=\"hidden\" name=\"adminStatOid\" value=\"$lock_unlock_oid\">";		
}
if($podUpdateToPod_flag == 1)
{
	echo "<input type=\"submit\" name=\"podUpdateToPod\" value=\"podUpdateToPod\" class=\"button\" style=\"$buttonStyle\">";
        echo "&nbsp;";
	echo "<input type=\"hidden\" name=\"podUpdateToPodOid\" value=\"$podUpdateToPod_oid\">";
}
				

//get all
echo "<input type=\"submit\" name=\"get\" value=\"$strGet\" class=\"button\" style=\"$buttonStyle\">";
echo "&nbsp;";
echo "<input type=\"submit\" name=\"set\" value=\"$strSet\" class=\"button\" style=\"$buttonStyle\">";	
echo "&nbsp;";

echo "<input type=\"hidden\" name=\"tableOid\" value=\"$tableOid\">";
echo "<input type=\"hidden\" name=\"sysId\" value=\"$sysId\">";
echo "<input type=\"hidden\" name=\"table_type\" value=\"$table_type\">";
echo "<input type=\"hidden\" name=\"instanceNo\" value=\"$instanceNo\">";
echo "</form>";
adjust_content_tail("down");
?>
