<?php
/*********************************************************      
 文件说明:         
    功能说明:prepaid parameter configuration

    调用关系:
    变量说明:

作者:
NO.1      
姓名：         
时间：  
修改说明：
*********************************************************/ 
require("../../inc/header.inc");
$DEBUG=1;

//=====================================
//变量定义
//=====================================
$db='OMC_PUB';
$tableName='omcPubVarConf';
$editVarArr=array('pssCardMinCount');

function getPubVar($pubVarName)
{
	$db='OMC_PUB';
	$tableName='omcPubVarConf';
	$sql = " SELECT pubVarValue,remark
			   FROM $tableName
			   WHERE pubVarName='$pubVarName'
			 ";
	//echo "<br>sql=$sql";
	$res = @mysqli_query($pubConn,$sql);
	
	if(mysqli_num_rows($res) > 0){
		$row = @mysqli_fetch_array($res);
		//$varInfoArr=array(name,value,remark);
		$varInfoArr[name]=$pubVarName;
		$varInfoArr[value]=$row[pubVarValue];
		$varInfoArr[remark]=$row[remark];
		return($varInfoArr);
	}else{
		return(-1);
	}
}

//=====================================
//输入变量
//=====================================
//保存修改的参数
if(strlen($actMode) > 1){
	for($i=0;$i<sizeof($editVarArr);$i++){
		$name	= $editVarArr[$i];
		$value	= ${$editVarArr[$i]};
		$remark	= $name.'_remark';
		$remark	= ${$remark};
		if($DEBUG) echo "<br>=====================";
		if($DEBUG) echo "<br>name=$name";
		if($DEBUG) echo "<br>value=$value";
		if($DEBUG) echo "<br>remark=$remark";
		$sql = " UPDATE $tableName SET
				pubVarValue='$value',
				remark='$remark'
				WHERE pubVarName='$name'
			 ";
		if($DEBUG) echo "<br>sql=$sql";
		$res = @mysqli_query($pubConn,$sql);
	}
}

?>
<body>
<form name="listForm" method="POST" action="<?php echo"$PHP_SELF";?>">
<table border="1" width="100%" cellpadding="2" cellspacing="0"  bordercolor="#666666" bordercolordark="#FFFFFF" bgcolor="#FFFFFF"  >
<?php
echo "<tr><td width=\"100%\" colspan=\"12\" align=\"center\" bgcolor=\"#E6E6E6\">";
echo "Public Var Define";
echo "</td></tr>";

for($i=0;$i<sizeof($editVarArr);$i++){
	$varInfoArr=getPubVar($editVarArr[$i]);
	echo "<tr>";		
	echo "<td width=\"30%\">&nbsp;{$varInfoArr[name]}</td>";	
	echo "<td width=\"20%\">&nbsp;";	
	echo "<input type=text name=\"{$varInfoArr[name]}\" value=\"{$varInfoArr[value]}\" size=8>";
	echo "</td>";	
	echo "<td width=\"50%\">&nbsp;";
	echo "<input type=text name=\"{$varInfoArr[name]}_remark\" value=\"{$varInfoArr[remark]}\" size=50></td>";	
	echo "</tr>";	
}
?>
</table>
<br>&nbsp;&nbsp;&nbsp;&nbsp;
<input type="submit" value="Save" name="actMode">
&nbsp;&nbsp;&nbsp;&nbsp;
<input type="submit" value="Delete" name="actMode">
</form>
</body>
</html>