<?php
/*********************************************************      
 文件说明:         
    功能说明:修改Service基本费率

    调用关系:调用:header.inc  
             被调用:实现各个功能模块的页面        
    变量说明:

作者:
NO.1      
姓名：崔体存         
时间：2004-4-13  
修改说明：OMC 7.0 增加了可通过选择不同的tariff_id来修改不同
         tariff_id得费率
*********************************************************/ 
require("../../inc/header.inc");
?>
<body leftmargin="15" rightmargin="10" onload="javascript:adjust();" onresize="javascript:adjust();" style="overflow:hidden;overflow-x:hidden;overflow-y:hidden;">

<?php
$DEBUG=0;
adjust_head();
adjust_title_head();
//==========================================================
//参数定义
//==========================================================
$moneyPara = getMoneyPara();			   //显示的货币单位是最小货币单位的倍数
$ppsDb='PPS_DB';

$description=$_REQUEST['description'];
$arr_editfieldAmount=$_REQUEST['arr_editfieldAmount'];
$arr_editfieldUnit=$_REQUEST['arr_editfieldUnit'];
$tariffID=$_REQUEST['tariffID'];

$amount=$_REQUEST['amount'];
$unit=$_REQUEST['unit'];


global $OMC_server;
$srcDataConn = mysqli_connect($OMC_server[0]['host'],$OMC_server[0]['user'],$OMC_server[0]['password'], $ppsDb);

$tableName='pre_comm_tariff';
$listPageURL= "tariffBasic.php?keep_id=1&return_tariff_id=$tariffID";
if($DEBUG) echo "url=$listPageURL<br>";

$strPageTitle=$strTitleAdvanced.$strTitleSpace."PPS".$strTitleSpace.$strCurrentTariff.$strTitleSpace."Multiple services";

//==========================================================
//数据处理
//==========================================================
//保存修改的变量
if(strlen($_POST['set']) > 0){
	if (strlen($arr_editfieldUnit)>0){
		$strSqlUpdate = $arr_editfieldAmount."='$amount',".$arr_editfieldUnit."='$unit'";
	}
	else{
		$strSqlUpdate = $arr_editfieldAmount."='$amount'";
	}
	if ($DEBUG) echo "<br>strSqlUpdate:$strSqlUpdate";
	if ($DEBUG) echo "<br>arr_editfieldUnit:$arr_editfieldUnit";
	$where	=" WHERE tariff_id=$tariffID";
	$selSql	="Select count(*) FROM $tableName".$where;
	if($DEBUG) echo "<br>$selSql";
	$result	= @mysqli_query($srcDataConn,$selSql);
	$rows	=mysqli_fetch_array($result);
	$rowsNum=$rows[0];
	if($DEBUG) echo "<br>rowsNum=$rows[0]";
	if($rowsNum){
		$setSql="UPDATE $tableName
			  SET $strSqlUpdate $where";
	}else{
		$setSql="REPLACE $tableName
			  SET $strSqlUpdate $where";
	}
	if($DEBUG) echo "<br>setSql=$setSql<br>";
	$result= @mysqli_query($srcDataConn,$setSql);
	echo mysqli_error($srcDataConn);
	if(!$DEBUG){
		echo " <meta http-equiv=\"refresh\" content=\"0; url=$listPageURL\"> ";
	}
}

//==========================================================
//输出并显示数据
//==========================================================
$getSql="SELECT * FROM $tableName WHERE tariff_id='$tariffID'";
//echo $getSql;
$result=mysqli_query($srcDataConn,$getSql);
$rows=mysqli_fetch_array($result);
echo mysqli_error($srcDataConn);
?>


<?php
echo "<table id=\"table_up\" border=\"0\" width=\"100%\">";
	echo "<tr>";
		echo "<td width=\"50%\">";
		echo "$strPageTitle";
		echo "</td>";
		echo "<td width=\"50%\" align=\"right\">&nbsp;";

		echo "</td>";
	echo "</tr>";
echo "</table>";

adjust_title_tail();
adjust_content_head();
echo "<br>";

?>

<form name="editform" action="
<?php echo"$PHP_SELF?description=$description&arr_editfieldAmount=$arr_editfieldAmount&arr_editfieldUnit=$arr_editfieldUnit"; ?>
" method="POST">
<table border="1" width="400" cellpadding="2" cellspacing="0"  bordercolor="#666666" bordercolordark="#FFFFFF" bgcolor="#FFFFFF"  >
<?php
	echo "<tr>";
	echo "<td bgcolor=\"#E6E6E6\" colspan=\"2\">Edit services</td>";
	echo "</tr>";

	echo "<tr>";
	echo "<td width=\"40%\">$strDescription</td>";
	echo "<td width=\"60%\">$description</td>";
	$return_tariff_id = $rows[tariff_id]; //定义返回时的页面
	echo "</tr>";

	echo "<tr>";
	echo "<td>$strTariffRentChargeAmount</td>";
	echo "<td><input type=\"text\" name=\"amount\" size=\"5\" value=\"$rows[$arr_editfieldAmount]\" class=\"text\" style=\"text-align: right;\">&nbsp;&nbsp;$moneyPara</td>";
	echo "</tr>";

	echo "<tr>";
	echo "<td>$strUnitChargingTimeSecond</td>";
	if (strlen($arr_editfieldUnit)>0){
		echo "<td><input type=\"text\" name=\"unit\" size=\"5\" value=\"$rows[$arr_editfieldUnit]\" class=\"text\" style=\"text-align: right;\"></td>";
	}
	else{
		echo "<td>--</td>";
	}
	echo "</tr>";
?>
</table>
<table  width="400">     
    <tr>     
     <td> 
	      <input type="hidden" name="tariffID" value="<?php echo $tariffID;?>">
	      <input type="submit" name="set" value="Set" style="width:40" class="button">&nbsp; 
		  <input type="reset" name="reset" value="Reset" class="button">&nbsp;
		  <input type="button" name="return" value="Return" onclick=jacascript:location.href="./tariffBasic.php" class="button">
     </td>         
   </tr>           
</table>
<?php
adjust_content_tail();
?>
</body> 
</form>
</html>   