<?php
/*********************************************************      
 程序说明：         
    功能说明：本程序实现对数据表中的参数的编辑，根据树状菜单的选择，
              每页显示该类参数的前$number_records_to_display个参数，。

    调用关系：调用: header.inc     
              被调用:paramConf_down_left.php      
 
    变量说明：
		输入变量：
			$objKeyId	:由左边树状菜单传来的值，用于确定参数类型
			$sysId		:由上面页面或左边树状菜单传来的值
			$languageType:语言种类

     返回值：无

 作者：      
      
修改注释：      
NO.1      
姓名：
时间：
修改说明：
*********************************************************/  
require("../../inc/header.inc");
?>
<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_noleft_frame("down");
adjust_title_head_frame("down");
adjust_title_tail_frame("down");

adjust_content_head_frame("down");	
echo "<br>";

$DEBUG = 0;
//echo "aliasValue_0=$aliasValue_0<br>";

//echo "strAlias=$strAlias, inputName=$inputName, setValue=$setValue<br>";
$nPubFlag = 99;
$nSubSysParam		= 0;
$nGlobalSubSysParam = 1;
$nGlobalSysParam	= 2;

if($DEBUG) echo"<br><font size=3 color=red>调试中...对各位带来不便，请原谅</font>";

$sysIdArr	= explode('_',$sysId);
$sysTypeNo	= $sysIdArr[0];
$sysNo		= $sysIdArr[1];
$subSysNo	= $sysIdArr[2];

$nGetComm = 0;
$nSetComm = 3;

$commTable	='OMC_PUB.parameterComm';
$maxLevelNum = 10;
$maxRecodeOfOnePage=16;

$nInteger = 2;
$nOctStr = 4;

//参数定义表，参数表名
$pubDb		= 'OMC_PUB';
$objDb		= 'OBJ_'.$sysTypeNo;
$confTable  = 'paramConf';
$paramTable = 'param_'.$sysNo;

//------------选择语言版本----------
if($language == 'eng'){
	$objNameField = 'name_2'; 
	$objDescField = 'desc_2';
	$objNoteField = 'note_2';
}else{
	$objNameField = 'name_1';
	$objDescField = 'desc_1';
	$objNoteField = 'note_1';
}

//在参数定义表寻找该类型参数的对应信息
if($objKeyId > 0){
	$paramConfSql = "SELECT * FROM $confTable 
			WHERE keyId ='$objKeyId'
			";
	if($DEBUG)	echo "paramConfSql=$paramConfSql<br>";
	$paramConfResult = mysqli_query($pubConn,$paramConfSql);
	$paramConfRows= mysqli_fetch_array($paramConfResult);
	echo mysqli_error($pubConn);
	
	$paramType	= $paramConfRows[paramType];
	$paramNum	= $paramConfRows[number]; 
	$length		= $paramConfRows[length];
	$initValue	= $paramConfRows[initValue];
	$minValue	= $paramConfRows[minValue];
	$maxValue	= $paramConfRows[maxValue];
	$objName	= $paramConfRows[$objNameField];
	$objDesc	= $paramConfRows[$objDescField];
    $isNeedNote = $paramConfRows[needNote];
	$noteMsg	= $paramConfRows[$objNoteField];
	$operType 	= $paramConfRows[operType];
	$valueType 	= $paramConfRows[valueType];
	$objIdStr	= '';
	$objWhereStr= '';
	$lastLevelNo = 0;
	for($i=1;$i<=$maxLevelNum;$i++){
		$levelId = 'level_'.$i;
		if($paramConfRows[$levelId] == 0){
			if($lastLevelNo <= 0){
				$lastLevelNo = $i-1;//最后一层编号
			}
		}else{
			${$levelId}=$paramConfRows[$levelId];
			$objIdStr .= $paramConfRows[$levelId].'.';//该类参数的对象编号
			$objWhereStr .= $levelId.'='.${$levelId}.' AND ';
		}
	}
	$objIdStr = substr($objIdStr,0,-1); //最后多了一个'.',将其去掉
	$objWhereStr = substr($objWhereStr,0,-5); //最后多了一个' AND ',将其去掉
	$maxlength = $length*2;
	if($DEBUG) echo "<br>objIdStr = $objIdStr ,lastLevelNo = $lastLevelNo";
	if($DEBUG) echo "<br>objWhereStr = $objWhereStr <br>";
 }//end if 

$needSaveInitValue = 0;
$needSendComm = 0;

//*********从设备读参数*************************** 
if($DEBUG) echo "<br>getFromSys =$getFromSys <br>";
if(isset($getFromSys)){
	$commType = $nGetComm;
	$needSendComm = 1;
}
//*********下载参数到设备*************************
if($DEBUG) echo "<br>setToSys =$setToSys <br>";
if(isset($setToSys)){ 
	if($DEBUG) echo "<br>setToSys =$setToSys <br>";
	if($isKnot > 0){
		$needSaveInitValue = 0;
	}else{
		$needSaveInitValue = 1;
	}
	$commType = $nSetComm;
	$needSendComm = 1;
}
//**********数据库各列间相互导入*******************
if(isset($read2init)){
	if($DEBUG) echo "<br>read2init=$read2init";
	$needSaveInitValue = 0;
	$needSendComm = 0;
	$moveType='read2init';
}	

if(isset($saveInitValue)){
	if($DEBUG) echo "<br>saveInitValue =$saveInitValue";
	$needSaveInitValue = 1;
	$needSendComm = 0;
}

//---------保存参数------------------------------
if($DEBUG) echo "<br>needSaveInitValue=$needSaveInitValue";
if($needSaveInitValue == 1){	
	if($DEBUG) echo "<br>bgnNo=$bgnNo / endNo=$endNo";
	if($isKnot==1) {
		$saveSql = "UPDATE $paramTable SET initValue = editValue
			WHERE subSysNo='$subSysNo' AND $objWhereStr";
		$saveResult = mysqli_query($pubConn,$saveSql);
	} else {
		for($i=$bgnNo;$i<=$endNo;$i++){
			$initValue=${'initValue_'.$i};
			$saveSql = "UPDATE $paramTable SET initValue = '$initValue' 
					WHERE subSysNo='$subSysNo' AND  $objWhereStr AND instanceNo='$i'
					";
			
			if($DEBUG) echo "<br>saveSql=$saveSql";
			$saveResult = mysqli_query($pubConn,$saveSql);
			echo mysqli_error($pubConn);
		}
	}
}

//---------导入各列的参数------------------------------
if(isset($moveType)){
	switch($moveType){
		case 'read2init':
			$moveSql = "UPDATE $paramTable SET initValue = readValue 
						WHERE subSysNo='$subSysNo' AND  $objWhereStr 
						AND (LENGTH(readValue) > 0) 
						AND readValue != 'Null' 
						AND readValue NOT LIKE 'Error%'
						";
			break;
		default:
				echo "Unknown moveType=$moveType!!";
				exit();
	}
	$moveResult=mysqli_query($pubConn,$moveSql);
	if($DEBUG) echo "<br>moveSql=$moveSql";
	echo mysqli_error($pubConn);
}

if($needSendComm == 1 &&$commType==$nSetComm){
	$clearSql = "UPDATE $paramTable SET readValue = ''
				WHERE subSysNo='$subSysNo' AND  $objWhereStr";
	$clearResult=mysqli_query($pubConn,$clearSql);
	if($DEBUG) echo "<br>clearSql=$clearSql";
	echo mysqli_error($pubConn);
}

//---------发送命令，跳转页面----------------------------
if($needSendComm == 1 && isset($commType)){
	$okURL	  = "$PHP_SELF?isKnot=$isKnot&sysId=$sysId&bgnNo=$bgnNo&objKeyId=$objKeyId&selectedSysId=$selectedSysId&selectedDPC=$selectedDPC";
	$failURL  = "$PHP_SELF?isKnot=$isKnot&sysId=$sysId&bgnNo=$bgnNo&objKeyId=$objKeyId&selectedSysId=$selectedSysId&selectedDPC=$selectedDPC";
	if($DEBUG) echo "<br>okURL =$okURL<br> ";	
	if($DEBUG) echo "<br>sysCommSend($sysId,$commType,$objIdStr,$selectedSysId,$selectedDPC)";
	if($DEBUG) echo "<br>selectedSysId=$selectedSysId";
	$commIdStr = sysCommSend($sysId,$commType,$objIdStr,$selectedSysId,$selectedDPC);
	if($DEBUG) echo "<br>commIdStr=$commIdStr";
	if(isset($commIdStr) && $commIdStr != -1){
		$failURL = urlencode($failURL);
		$okURL	 = urlencode($okURL);
		$scanURL ="commIdStr=$commIdStr&okURL=$okURL&failURL=$failURL";
		if($DEBUG) echo "<br>scanURL = $scanURL<BR>";
		if($DEBUG) exit();
		echo " <meta http-equiv=\"refresh\" content=\"0; url=./commScan.php?$scanURL\"> ";  
		exit();
	}else{
		echo "<br><font size=3 color=red>SEND GET COMMAND ERROR!<br></font>";
	}
}
?>

<?php
 //***************************显示指定对象的参数**********************

if(!isset($objKeyId) ||$objKeyId == ''){ //没有选定参数对象
	echo "<font size=\"3\"><b>$strParametersOperations:</b></font>";
	echo "<br><br>$strParametersOperationsRemarks_1";
	echo "<br><br>$strParametersOperationsRemarks_2";
	echo "<br><br>$strParametersOperationsRemarks_3";
	
	//显示操作流程图
	echo "<br><br>";
	echo "<p align=\"center\">";
	if($language == 'eng'){
		echo "<img border=\"0\" src=\"../../images/flow_e.gif\">";
	}else{
		echo "<img border=\"0\" src=\"../../images/flow_c.gif\">";
	}
	echo "</p>";  
}else{
	//*********************大类的参数*********************
	if($isKnot > 0){
		echo "<form method=\"POST\" name=\"update\" action=\"$PHP_SELF\">";
		echo "<br>Object Id: $objIdStr";
		echo "<br><font size=3>You are going to operate All parameters included in <br> <b>$objName</b> </font>";
		echo "<br><br>";
		echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">";
		echo "<tr>";
		echo "<td width=\"70%\" >&nbsp;</td>  ";
		echo "<td width=\"15%\" >";
		echo "<input type=\"submit\" value=\"SET\" name=\"setToSys\" title=\"SET init buffer's parameters to system\" style=\"left: 3; top: 2; width: 50; height: 25; position: relative\">";
		echo "</td>  ";
		echo "<td width=\"15%\" >";
		echo "<input type=\"submit\" value=\"GET\" name=\"getFromSys\" title=\"GET parameters to read buffer\" style=\"left: 3; top: 2; width: 50; height: 25; position: relative\">";
		echo "</td>  ";
		echo "</tr>  ";
		echo "</table> ";
		echo "<br>";
		echo "<table border=\"1\" width=\"100%\" cellpadding=\"2\" cellspacing=\"0\"  bordercolor=\"#666666\" bordercolordark=\"#FFFFFF\" bgcolor=\"#FFFFFF\"> ";
		echo "<tr>";
		echo "<td width=\"5%\"  align=\"center\">No</td>  ";
		echo "<td width=\"45%\" align=\"center\">$strParameterdDescription</td>  ";
		echo "<td width=\"25%\" align=\"center\"><input type=\"submit\" value=\"Save\" name=\"saveInitValue\"></td>  ";
		echo "<td width=\"25%\" align=\"center\"><input type=\"submit\" value=\"Copy\" name=\"read2init\"></td>  ";
		echo "</tr>  ";
		echo "<tr>";
		echo "<td width=\"5%\"  align=\"center\">xx</td>  ";
		echo "<td width=\"45%\" align=\"center\">$objName</td>  ";
		echo "<td width=\"25%\" align=\"center\">ALL</td>  ";
		echo "<td width=\"25%\" align=\"center\">ALL</td>  ";
		echo "</tr>  ";
		echo "<tr>";
		echo "<td width=\"5%\"  align=\"center\">...</td>  ";
		echo "<td width=\"45%\" align=\"center\">.......</td>  ";
		echo "<td width=\"25%\" align=\"center\">...</td>  ";
		echo "<td width=\"25%\" align=\"center\">...</td>  ";
		echo "</tr>  ";
		echo "</table> ";
		//显示操作流程图
		echo "<br><br>";
		echo "<p align=\"center\">";
		if($language == 'eng'){
			echo "<img border=\"0\" src=\"../../images/flow_e.gif\">";
		}else{
			echo "<img border=\"0\" src=\"../../images/flow_c.gif\">";
		}
		echo "</p>";  
		echo "\n<input type=\"hidden\" name=\"isKnot\"			value=\"$isKnot\">";
		echo "\n<input type=\"hidden\" name=\"sysId\"			value=\"$sysId\">";
		echo "\n<input type=\"hidden\" name=\"objKeyId\"		value=\"$objKeyId\">";
		echo "\n<input type=\"hidden\" name=\"objIdStr\"		value=\"$objIdStr\">";
		echo "\n<input type=\"hidden\" name=\"selectedSysId\"	value=\"$selectedSysId\">";
		echo "\n<input type=\"hidden\" name=\"selectedDPC\"		value=\"$selectedDPC\">";
		exit();
		echo "</form>";
	}
	
	//*********************显示该对象参数说明*********************
	echo "<nobr>";
	echo "$strParameterDescription: <font color=008000>$objName</font>&nbsp;&nbsp;";
	echo "$strUnitLength:<font color=008000>$length</font>&nbspbyte&nbsp&nbsp";
	//echo "$strObjectID:<font color=008000> $objIdStr </font>&nbsp&nbsp$strRemark:";
	echo "</nobr><br><nobr>";
	$valueLen=strlen($initValue);
	//echo "<br>valueLen=$valueLen";
	if($valueLen<20)
	{
		echo "$strValueRange:<font color=008000>$minValue - $maxValue</font>&nbsp&nbsp";
		echo "$strDefaultValue:<font color=008000>$initValue</font>&nbsp&nbsp";
	}
	echo "$strTotalRecords:<font color=008000>$paramNum</font>";
	//$page_num=round($parameter_num / $number_records_to_display);
	//echo "$strTotalPages :<font color=008000>$page_num</font>";
	echo "</nobr>";
	//*********************显示参数**************************** 
	if(!isset($bgnNo)){
		$bgnNoSql = " SELECT snmpInstanceBgn FROM sysConf  
			WHERE sysTypeNo = '$sysTypeNo' 
			";
		if($DEBUG) echo"<br>bgnNoSql=$bgnNoSql";
		$result = mysqli_query($pubConn,$bgnNoSql);
		$rows	= mysqli_fetch_array($result);
		$bgnNo=$rows[0];
	}
	
	//------------查询参数表---------------------
	$paramSql = " SELECT initValue,readValue,instanceNo FROM $paramTable  
				WHERE subSysNo = '$subSysNo' AND  $objWhereStr AND instanceNo >='$bgnNo'
				ORDER BY instanceNo  LIMIT 0,$maxRecodeOfOnePage
				";
	if($DEBUG) echo"<br>ParamSql = $paramSql";
	$paramResult = mysqli_query($pubConn,$paramSql);	
 
	//已显示的参数个数  
	$endNo=$bgnNo + $maxRecodeOfOnePage - 1;
//*************************************************编辑参数时所用javascript*********************************
?>

<script LANGUAGE="JavaScript">         
			  
function changevalue(term){
	var change_num;
	term.style.color = "BLUE";
	term.value = term.value.toUpperCase();
     
	if(term.value.length != document.update.maxlength.value){  
		var LengthErrorWarning = "<?php echo $strLengthOfTheInputValueIsError; ?>";
		var CorrectItWarning = "<?php echo $strPleaseCorrectIt; ?>";
		alert(LengthErrorWarning + CorrectItWarning + "[= " + document.update.maxlength.value + "]");      
		term.focus();
		return (false);
	}
	change_num++;
    
    var checkOK = "-0123456789ABCDEF";
    var checkStr = term.value;
    var allValid = true;
    for (i = 0;  i < checkStr.length;  i++){
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++){
			if (ch == checkOK.charAt(j))
				break;
		}
		if (j == checkOK.length){
			allValid = false;
			break;
		}
	}

	if (!allValid){  
		var ParaHex="<?php echo $strParaMustBeAHexNumber; ?>";
		var Capital="<?php echo $strCapitalCharacter; ?>";
		alert(ParaHex+"，"+"("+Capital+")！");
		term.focus();
		return (false);
	}
}

function openSet(sysTypeNo,objKeyId,inputName,aliasName){
	var inputValue;
	var aliasValue;

	inputValue = eval("document.update."+inputName+".value");
	aliasValue = eval("document.update."+aliasName+".value");
	URL="./paramEdit.php?sysTypeNo="+sysTypeNo+"&keyId="+objKeyId+"&setValue="+inputValue+"&inputName="+inputName
		+"&alaisValue="+aliasValue+"&aliasName="+aliasName;
	//window.alert(URL);
	var msgWindow = open(URL, 'newWin', 'toolbar=no,directories=no,menubar=no,scrollbars=yes,resizable=yes,status=yes,width=400,height=350');
	msgWindow.focus();
}

function checkAllInput(theform){                    
	var bgnNo=document.update.bgnNo.value;
	var endNo=document.update.endNo.value;
	var i,j,p;                    
	var checkOK = "-0123456789ABCDEF";                     
	var initValue,readValue;                     
	var allValid = true;         
	var LengthErrorWarning="<?php echo "$strLengthOfTheInputValueIsError"; ?>";
	var CorrectItWarning="<?php echo "$strPleaseCorrectIt"; ?>";                    
	var ValueCannotEmpty="read buffer's value cannot be empty!";
	var ValueLengthError="read buffer's value length error!";

	var commdType = document.update.commdType.value;
	//alert(commdType);
	//window.alert("bgnNo="+bgnNo+",endNo="+endNo);
	for(p=bgnNo; p <= endNo; p++){
	    initValue = eval("document.update.initValue_"+p+".value.toUpperCase()");
		readValue = eval("document.update.readValue_"+p+".value.toUpperCase()");
		//window.alert(initValue);
		//window.alert(readValue);
		
		//当get buffer的值长度不足
	    if(commdType=='copy'){
		    <?php
			if($valueType == $nInteger){//整形
			?>
				if(readValue.length < 1 && document.update.readMoveToInit.value > 0){
					document.update.readMoveToInit.value=0;
					alert(ValueCannotEmpty);
					return (false);
				}
			<?php	
			}else{
			?>
				//window.alert("test test.");
				if(readValue.length < document.update.maxlength.value && document.update.readMoveToInit.value > 0){
					document.update.readMoveToInit.value=0;
					alert(ValueLengthError);
					return (false);
				}
			<?php
			}
			?>
		}//end if commdType==copy
		
		if(commdType=='save' || commdType=='set'){
		    <?php //当输入值的长度不足
			if($valueType == $nInteger){
			?>
		    if(initValue.length == 0){                     
				alert(LengthErrorWarning + CorrectItWarning ); 
				return (false);                     
	        }                                  
		    <?php 
			}else{
			?>
			if(initValue.length != document.update.maxlength.value){                     
				alert(LengthErrorWarning + CorrectItWarning + "[= " + document.update.maxlength.value + "]");  
				return (false);                     
	        }   
			<?php
			}
			?>
		
		
			//检测输入值是否为0-f的16进制字符
			for (i = 0;  i < initValue.length;  i++){                     
				ch = initValue.charAt(i);                     
				for (j = 0;  j < checkOK.length;  j++){                     
	                if (ch == checkOK.charAt(j))                     
	                break;
				}
	            if (j == checkOK.length){                     
					allValid = false;                     
					break;                     
				}                     
			}                     
			//当输入值的字符有非法字符        
			if (!allValid){
				var ParaHex="<?php echo $strParaMustBeAHexNumber; ?>";
				var Capital="<?php echo $strCapitalCharacter; ?>";
				alert(ParaHex+"，"+"("+Capital+")！");     
				return (false);
			}
		}//end if.
	}
    return (true);
}

function gotoPage(){
	var pageUrl,gotoNo,numberPerPage;
	var keepValue;

	pageNo=document.update.pageNo.value;
	maxRecodeOfOnePage='<?php echo "$maxRecodeOfOnePage";?>';
	gotoNo=maxRecodeOfOnePage*pageNo;
	keepValue = 
		'<?php echo "$PHP_SELF?objKeyId=$objKeyId&sysId=$sysId&selectedSysId=$selectedSysId&selectedDPC=$selectedDPC";?>';
	pageUrl=keepValue+"&bgnNo="+gotoNo;
	window.location.href=pageUrl;     
}      
</script>

<form method="POST" name="update" action="<?php echo"$PHP_SELF";?>" onsubmit="return checkAllInput(this)">
  <table border="0" cellpadding="0" cellspacing="0" width="100%">
    <tr>
	<?php
	//*********************显示翻页图标**********************
    echo "<td width=5%>";
    if($bgnNo >= $maxRecodeOfOnePage){//设定上一页开始序号
		$preNo = $bgnNo - $maxRecodeOfOnePage;
		$keepValue = "objKeyId=$objKeyId&sysId=$sysId&bgnNo=$preNo&selectedSysId=$selectedSysId&selectedDPC=$selectedDPC";
		echo"<a href=\"$PHP_SELF?$keepValue\"><img border=0 src=\"../../images/prePage.gif\" alt=\"previous page\"></a>";
	}
	echo"</td>"; 

	//select the page.
	echo "<td width=2% aligh=center>";
	if ( $paramNum > $maxRecodeOfOnePage ) {
		echo "<SELECT size=\"1\" name=\"pageNo\" onChange=\"javasript:gotoPage()\">"; 
		$totalPageNum = ceil ( $paramNum / $maxRecodeOfOnePage );
		$pageNo = ceil($bgnNo/$maxRecodeOfOnePage);
		for($i=0;$i<$totalPageNum;$i++){
			if($i== $pageNo){
				echo "<option  selected  value=\"$i\" >$i</option>";
			}else{
				echo "<option value=\"$i\">$i</option>";
			}
		}
		echo "</SELECT>";
	}
	echo "</td>";
	
	echo "<td width=5%>";
	if($paramNum > ($endNo+1)){//设定下一页开始序号
		$nextNo = $bgnNo + $maxRecodeOfOnePage;
		$keepValue = "objKeyId=$objKeyId&sysId=$sysId&bgnNo=$nextNo&selectedSysId=$selectedSysId&selectedDPC=$selectedDPC";
		echo"<a href=\"$PHP_SELF?$keepValue\"><img border=0 src=\"../../images/nextPage.gif\" alt=\"next page\"></a>";
	}
	echo"</td>";
	?>
	<td width="40%">No.
	<?php 
	echo "<font color=\"#008000\">$bgnNo</font>-";
	$endNo=($paramNum < $endNo)?($paramNum-1):$endNo;
	//当instanceNo从1开始时，需要将endNo加1
	if($bgnNo == 1){
		$endNo++;
	}
	echo "<font color=\"#008000\">$endNo</font>";
	?>
	</td>  
	<td width="15%" title="Set init buffer's parameters to system and write response into read buffer">
	<?php
	
	if($operType == 1){ //read only
		echo "<input type=\"submit\" value=\"SET\" name=\"setToSys\" DISABLED title=\"Read Only\" style=\"left: 3; top: 2; width: 50; height: 25; position: relative\">";
	}else{
		echo "<input type=\"submit\" value=\"SET\" name=\"setToSys\" style=\"left: 3; top: 2; width: 50; height: 25; position: relative\"
				 onclick=\"javascript:document.update.commdType.value='set';\">";
	}
	
	?>
	</td>  
	<td width="15%" title="Get parameters from system and write response into read buffer">
	<?php
	if($operType == 2){//write only
		echo "<input type=\"submit\" value=\"GET\" name=\"getFromSys\" DISABLED title=\"Write Only\" style=\"left: 3; top: 2; width: 50; height: 25; position: relative\">";
	}else{
		echo "<input type=\"submit\" value=\"GET\" name=\"getFromSys\" style=\"left: 3; top: 2; width: 50; height: 25; position: relative\"
				onclick=\"javascript:document.update.commdType.value='get';\">";
	}
	?>
	
	</td>  
  </tr>  
</table> 

<br>  
<table border="1" width="100%" cellpadding="2" cellspacing="0"  bordercolor="#666666" bordercolordark="#FFFFFF" bgcolor="#FFFFFF">   
  <tr>
    <td width="4%" align="center" >No.</td>  
    <td width="50%" align="center" ><?php echo"$strParameterdDescription";?></td>  
    <td width="23%" align="center" title="save this init buffer's parameters to database">
	<input type="submit" value="Save" name="saveInitValue" onclick="javascript:document.update.commdType.value='save';">
	</td>  
    <td width="23%" align="center" title="copy this read buffer's parameters to init buffer">
	<input type="submit" value="Copy" name="read2init" onclick="javascript:document.update.readMoveToInit.value='1';javascript:document.update.commdType.value='copy';" >&nbsp;
	<?php 
	//echo"System";
	?>
	<input type="hidden" name="readMoveToInit" >
	<input type="hidden" name="commdType">
	</td>  
  </tr>  
<?php
//************************顺序显示该页每条参数************************
if($maxlength > 8){
	$inputSize = $maxlength;
}else{
	$inputSize = 8;
}
$objDescArr = explode('+',$objDesc);
$objDescArrSize= sizeof($objDescArr);
while($paramRows = @mysqli_fetch_array($paramResult)){       
	$initName='initValue_'.$paramRows[instanceNo];
	$aliasName = "aliasValue_".$paramRows[instanceNo];
	$readName='readValue_'.$paramRows[instanceNo]; 
	echo "\n <tr>";
	echo "<td width=\"4%\" > $paramRows[instanceNo] </td> ";
	if($objDescArrSize == 4){
		$objDescNo	=0;
		$objDescNo	= $objDescArr[1]+$objDescArr[2]*$paramRows[instanceNo];
		$objDescTmp	='';
		$objDescTmp	= $objDescArr[0].$objDescNo.$objDescArr[3];
	}else{
		$objDescTmp = $objDesc;
	}
	//echo "aliasName=$aliasName<br>";
	echo "<input type=\"hidden\" name=\"$aliasName\" maxlength=\"$maxlength\" size=\"$inputSize\" value=\"$strAlias\">";
	if(TRUE == isset($strAlias)){
		echo "<td width=\"50%\" >$objDescTmp($strAlias)</td>";
	}else{
		echo "<td width=\"50%\" >$objDescTmp</td>";
	}
	echo "<td width=\"23%\" >";
	$rows=ceil($inputSize/20);
	//echo "<br>rows=$rows";
	if($inputSize > 20){
		$cols=20;
		echo "<textarea rows=\"$rows\" name=\"$initName\" cols=\"$cols\" size=\"$inputSize\" onchange = changevalue(this)>$paramRows[initValue]</textarea>";
		echo "<a href=javascript:openSet('$sysTypeNo','$objKeyId','$initName','$aliasName')>set..</a>"; 
		echo "</td>";
		echo "<td width=\"23%\"><textarea rows=\"$rows\" name=\"$readName\" cols=\"$cols\" size=\"$inputSize\">$paramRows[readValue]</textarea></td>";
	}else{
		echo "<input type=\"text\" name=\"$initName\" maxlength=\"$maxlength\" size=\"$inputSize\" value=\"$paramRows[initValue]\" onchange = changevalue(this)>";
		echo "<a href=javascript:openSet('$sysTypeNo','$objKeyId','$initName','$aliasName')>set..</a>"; 
		echo "</td>";
		echo "<td width=\"23%\">&nbsp;$paramRows[readValue] <input type=\"hidden\" name=\"$readName\" value=\"$paramRows[readValue]\"></td>";
	}
	echo "</tr>";
}
?>
</table>
<?php

}//end of if

//*****************************************隐藏输入框,用于传递值****************************************
echo "\n<input type=\"hidden\" name=\"maxlength\"		value=\"$maxlength\">";
echo "\n<input type=\"hidden\" name=\"isKnot\"			value=\"$isKnot\">";
echo "\n<input type=\"hidden\" name=\"sysId\"			value=\"$sysId\">";
echo "\n<input type=\"hidden\" name=\"objKeyId\"		value=\"$objKeyId\">";
echo "\n<input type=\"hidden\" name=\"bgnNo\"			value=\"$bgnNo\">";
echo "\n<input type=\"hidden\" name=\"endNo\"			value=\"$endNo\">";
echo "\n<input type=\"hidden\" name=\"objIdStr\"		value=\"$objIdStr\">";
echo "\n<input type=\"hidden\" name=\"selectedSysId\"	value=\"$selectedSysId\">";
echo "\n<input type=\"hidden\" name=\"selectedDPC\"		value=\"$selectedDPC\">";

adjust_content_tail("down");
?>
</form> 
</body>
</html>
