<?php
/*********************************************************      
 文件说明:         
    功能说明:修改短消息费率

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

作者:崔体存    2004-04-13
NO.1      
姓名：         
时间：  
修改说明：
*********************************************************/ 
require("../../inc/header.inc");
?>
<body leftmargin="15" rightmargin="10" onload="javascript:adjust();" onresize="javascript:adjust();" style="overflow:hidden;overflow-x:hidden;overflow-y:hidden;">

<form name="editform" action="<?php echo"$PHP_SELF?record_id=".$_REQUEST['record_id']."&mode=".$_REQUEST['mode']; ?>" method="POST">


<?php
$DEBUG =0;
adjust_head();
adjust_title_head();
//==========================================================
//变量定义
//==========================================================
$ppsDb		='PPS_DB';

$id=$_REQUEST['id'];
$record_id=$_REQUEST['record_id'];
$tariffID=$_REQUEST['tariffID'];
$tariff_id=$_REQUEST['tariff_id'];
$mode=$_REQUEST['mode'];

$setSql="UPDATE $tableName
SET mms_type= '$mms_type',
	prefix= '$prefix',
	call_type= '$call_type',
	dest_name= '$dest_name',
	discount_id = '$discount_id', 
	charge_fee = '$charge_fee'  
 WHERE mms_send_id='$record_id' AND tariff_id='$tariffID'";

$mms_type=$_REQUEST['mms_type'];
$prefix=$_REQUEST['prefix'];
$call_type=$_REQUEST['call_type'];
$dest_name=$_REQUEST['dest_name'];
$discount_id=$_REQUEST['discount_id'];
$charge_fee=$_REQUEST['charge_fee'];

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

$tableName	='pre_vas_mms_send_tariff';
$listPageURL = "tariffBasic.php?keep_id=1&return_tariff_id=$tariffID";
$moneyPara	= getMoneyPara();			   //显示的货币单位是最小货币单位的倍数
$strPageTitle=$strTitleAdvanced.$strTitleSpace."PPS".$strTitleSpace."Tariff plan".$strTitleSpace."MMS Send";
$arr_mode=array("edit","add");
if($mode == "add"){
	$tableTitle = "Add MMS Send";
}
elseif($mode == "edit"){
	$tableTitle = "Edit MMS Send";
}

//==========================================================
//输入变量
//==========================================================
if($DEBUG) echo "<br>record_id=$record_id";

//==========================================================
//数据处理
//==========================================================
//保存修改的变量
if(strlen($_POST['set']) > 0){
	if ($mode == "edit"){
		/*if($record_id == 1 || $record_id == 2)
		{
			$prefix="--";
			$dest_name="default";
			$mms_type=$record_id;
		}*/
		$setSql="UPDATE $tableName
				  SET mms_type= '$mms_type',
				  	prefix= '$prefix',
					  call_type= '$call_type',
					  dest_name= '$dest_name',
					  discount_id = '$discount_id', 
					  charge_fee = '$charge_fee'  
				   WHERE mms_send_id='$record_id' AND tariff_id='$tariffID'";
		if($DEBUG)  echo "<br>$setSql";
		$result= @mysqli_query($srcDataConn,$setSql);
		echo mysqli_error($srcDataConn);
		if($DEBUG) exit();
		echo " <meta http-equiv=\"refresh\" content=\"0; url=$listPageURL\"> ";
	}
}

//==========================================================
//输出并显示数据
//==========================================================
$getEditSql="SELECT tariff_id,mms_send_id,mms_type,prefix,call_type,dest_name,discount_id,charge_fee,cap_flag 
		FROM $tableName
		WHERE mms_send_id='$record_id' AND tariff_id='$tariffID'";
if($DEBUG) 
echo "<br>$getEditSql";
$resultEdit= @mysqli_query($srcDataConn,$getEditSql);
$rows= @mysqli_fetch_array($resultEdit);
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>";

//echo "<pre>";
//print_r($rows);
//echo "</pre>";

?>

<table border="1" width="400" cellpadding="2" cellspacing="0"  bordercolor="#666666" bordercolordark="#FFFFFF" bgcolor="#FFFFFF"  >
  <tr bgcolor="#E6E6E6">
    <td colspan="2">
	  <?php echo $tableTitle; ?>
	</td>
  </tr>
  <?php
    if ($mode == "edit"){
		echo "<tr>";
		echo "<td width=\"40%\">ID</td>";
		echo "<td width=\"60%\">$record_id</td>";
		echo "<input type=\"hidden\" name=\"tariff_id\" value=\"$rows[tariff_id]\" size=\"25\">";
	  $return_tariff_id = $rows[tariff_id]; //定义返回时的页面
		echo "</tr>";

		//mms type
		
		$mms_type_value=$rows[mms_type]+0;
		$mms_type_label=array(1=>"To mobile",2=>"To email");
		echo "<tr>";
		echo "<td>MMS type</td>";
		echo "<td>";
		
		/*if($record_id == 1 || $record_id == 2)
			echo "<select disabled name=\"mms_type\" size=1>";
		else*/
			echo "<select name=\"mms_type\" size=1>";
		for($i=1;$i<=sizeof($mms_type_label);$i++)
		{
			if($mms_type_value==$i)
				echo "<option selected value=$i>{$mms_type_label[$i]}</option>";
			else
				echo "<option value=$i>{$mms_type_label[$i]}</option>";	
		}
		echo "</select>";
		
		echo "</td>";
		echo "</tr>";
		
		//prefix
		echo "<tr>";
		echo "<td>Prefix</td>";
		/*if($record_id == 1 || $record_id == 2)
			echo "<td><input type=\"text\" disabled name=\"prefix\" size=\"32\" value=\"$rows[prefix]\"></td>";
		else*/
			echo "<td><input type=\"text\" name=\"prefix\" size=\"32\" value=\"$rows[prefix]\"></td>";
		echo "</tr>";
		
		//call type
		$call_type_value=$rows[call_type]+0;
		$call_type_label=array(0=>"Local call out",1=>"NDD",2=>"IDD");
		echo "<tr>";
		echo "<td>Call type</td>";
		echo "<td>";
		echo "<select name=\"call_type\" size=1>";
		for($i=0;$i<sizeof($call_type_label);$i++)
		{
			if($call_type_value==$i)
				echo "<option selected value=$i>{$call_type_label[$i]}</option>";
			else
				echo "<option value=$i>{$call_type_label[$i]}</option>";	
		}
		echo "</select>";
		echo "</td>";
		echo "</tr>";
		
		//dest name
		echo "<tr>";
		echo "<td>Dest name</td>";
		/*if($record_id == 1 || $record_id == 2)
			echo "<td><input type=\"text\" disabled name=\"dest_name\" size=\"32\" value=\"$rows[dest_name]\"></td>";
		else*/
			echo "<td><input type=\"text\" name=\"dest_name\" size=\"32\" value=\"$rows[dest_name]\"></td>";
		echo "</tr>";
		
		//discount_id
		echo "<tr>";
		echo "<td>Discount ID</td>";
		echo "<td><input type=\"text\" name=\"discount_id\" size=\"10\" value=\"$rows[discount_id]\"></td>";
		echo "</tr>";
		
		//charge_fee
		echo "<tr>";
		echo "<td>Charge fee</td>";
		echo "<td><input type=\"text\" name=\"charge_fee\" size=\"10\" value=\"$rows[charge_fee]\"></td>";
		echo "</tr>";
		
		//cap flag
		$cap_flag_value=$rows[cap_flag]+0;
		$cap_flag_label=array(0=>"Disable",1=>"Enable");
		echo "<tr>";
		echo "<td>Cap flag</td>";
		echo "<td>{$cap_flag_label[$cap_flag_value]}&nbsp;</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">&nbsp;
        </td>         
   </tr>           
  </table>
</form>
<?php
adjust_content_tail();
?>
</body>   
</html>