Files
web.ems/wxc2_omc/account/tariffPlan/mttariffEdit.php
2024-11-21 11:14:38 +08:00

572 lines
19 KiB
PHP
Executable File

<?php
/*********************************************************
程序说明:
功能说明:编辑被叫显示计费号码信息
调用关系:调用: header.inc
被调用:
变量说明
作者:崔体存 2004-04-13
修改注释:
NO.1
姓名:
时间:
修改说明:
*********************************************************/
require("../../inc/header.inc");
$id=$_REQUEST['id'];
$mode=$_REQUEST['mode'];
$tariffID=$_REQUEST['tariffID'];
?>
<base>
<body leftmargin="15" rightmargin="10" onload="javascript:adjust();" onresize="javascript:adjust();" style="overflow:hidden;overflow-x:hidden;overflow-y:hidden;">
<form method="POST" name="editform" action="<?php echo"$PHP_SELF?id=$id&tariffID=$tariffID&mode=$mode"; ?>">
<?php
adjust_head();
adjust_title_head();
$ppsDb='PPS_DB';
$tableName='pre_mt_tariff';
global $pubConn,$OMC_server;
$srcDataConn = mysqli_connect($OMC_server[0]['host'],$OMC_server[0]['user'],$OMC_server[0]['password'], $ppsDb);
$tariff_id=$_REQUEST['tariff_id'];//必填
$number_of_records=$_REQUEST['number_of_records'];
$call_cap_flag_label=array(0=>"Disable",1=>"Enable");
//添加修改所需的参数
$DistrictID=$_REQUEST['DistrictID'];//必填
$District=$_REQUEST['District'];//必填
$call_type=isset($_REQUEST['call_type']) ?$_REQUEST['call_type']:'DEFAULT';
$discount_id=$_REQUEST['discount_id']?$_REQUEST['discount_id']:'DEFAULT';
$Unit_time=$_REQUEST['Unit_time']?$_REQUEST['Unit_time']:'DEFAULT';
$Free_time=$_REQUEST['Free_time']?$_REQUEST['Free_time']:'DEFAULT';
$Min_unit=$_REQUEST['Min_unit']?$_REQUEST['Min_unit']:'DEFAULT';
$adjustment=$_REQUEST['adjustment']?$_REQUEST['adjustment']:'DEFAULT';
$tier_level=$_REQUEST['tier_level']?$_REQUEST['tier_level']:'DEFAULT';
$tier_unit_0=$_REQUEST['tier_unit_0']?$_REQUEST['tier_unit_0']:'DEFAULT';
$base_fee_0=$_REQUEST['base_fee_0']?$_REQUEST['base_fee_0']:'DEFAULT';
$long_distance_fee_0=$_REQUEST['long_distance_fee_0']?$_REQUEST['long_distance_fee_0']:'DEFAULT';
$tier_unit_1=$_REQUEST['tier_unit_1']?$_REQUEST['tier_unit_1']:'DEFAULT';
$base_fee_1=$_REQUEST['base_fee_1']?$_REQUEST['base_fee_1']:'DEFAULT';
$long_distance_fee_1=$_REQUEST['long_distance_fee_1']?$_REQUEST['long_distance_fee_1']:'DEFAULT';
$tier_unit_2=$_REQUEST['tier_unit_2']?$_REQUEST['tier_unit_2']:'DEFAULT';
$base_fee_2=$_REQUEST['base_fee_2']?$_REQUEST['base_fee_2']:'DEFAULT';
$long_distance_fee_2=$_REQUEST['long_distance_fee_2']?$_REQUEST['long_distance_fee_2']:'DEFAULT';
$long_distance_fee_2=$_REQUEST['long_distance_fee_2']?$_REQUEST['long_distance_fee_2']:'DEFAULT';
$cap_flag=isset($_REQUEST['cap_flag']) ?$_REQUEST['cap_flag']:'DEFAULT';
$DEBUG = 0;
$listPageURL = 'mttariff.php?keep_id=1&return_tariff_id='.$tariff_id;
$strThisPage=$strTitleAdvanced.$strTitleSpace."Tariff plan".$strTitleSpace."MT tariff";
$arr_mode=array("edit","add");
if($mode == "add"){
if($number_of_records>=300){
echo "<SCRIPT LANGUAGE=\"JavaScript\">";
echo "alert(\"The number of MT tariff is full. \")";
echo "</SCRIPT>";
echo " <meta http-equiv=\"refresh\" content=\"0; url=tariffBasic.php?tariff_id=$tariff_id&mode=$mode\"> ";
exit();
}
}
if($mode == "add"){
$tableTitle = "Add MT tariff";
}
elseif($mode == "edit"){
$tableTitle = "Edit MT tariff";
}
if(!$sort_field){
$sort_field = 'bill_id'; //排序所依赖的字段名
}
$sort_direction = 'ASC '; //排序顺序
$moneyPara = getMoneyPara(); //显示的货币单位是最小货币单位的倍数
//==========================================================
//输入变量
//==========================================================
if($DEBUG) echo "<br>";
//==========================================================
//数据处理
//==========================================================
//保存修改的变量
//echo "<br>REQUEST=".$_REQUEST['set'];
if(strlen($_REQUEST['set']) > 0){
if($mode=="edit"){
$setSql="UPDATE $tableName
SET area = '$District',
call_type='$call_type',
discount_id = $discount_id,
unit_time = $Unit_time,
free_time = $Free_time,
mini_time = $Min_unit,
adjustment = $adjustment,
tier_level = $tier_level,
tier_unit_0 = $tier_unit_0,
base_fee_0 = $base_fee_0,
long_distance_fee_0 = $long_distance_fee_0,
tier_unit_1 = $tier_unit_1,
base_fee_1 = $base_fee_1,
long_distance_fee_1 = $long_distance_fee_1,
tier_unit_2 = $tier_unit_2,
base_fee_2 = $base_fee_2,
long_distance_fee_2 = $long_distance_fee_2,
cap_flag=$cap_flag
WHERE bill_id='$id' AND tariff_id='$tariffID'";
if(0) echo "<br>$setSql";
$result= @mysqli_query($srcDataConn,$setSql);
echo mysqli_error($srcDataConn);
if($DEBUG) echo"<br>$listPageURL";
if(0 == $DEBUG) echo " <meta http-equiv=\"refresh\" content=\"0; url=$listPageURL\"> ";
}
if($mode=="add"){
//检查区号和地区名是否输入
if (strlen($DistrictID) < 1){
echo "<SCRIPT LANGUAGE=\"JavaScript\">";
echo "alert(\"Please input prefix\")";
echo "</SCRIPT>";
echo " <meta http-equiv=\"refresh\" content=\"0; url=mttariffEdit.php?tariff_id=$tariff_id&mode=$mode\"> ";
exit();
}
if (!$District){
echo "<SCRIPT LANGUAGE=\"JavaScript\">";
echo "alert(\"Please input Country/District\")";
echo "</SCRIPT>";
echo " <meta http-equiv=\"refresh\" content=\"0; url=mttariffEdit.php?tariff_id=$tariff_id&mode=$mode\"> ";
exit();
}
for($count=0;$count<strlen($DistrictID);$count++){
if($DistrictID[$count]<'0'||$DistrictID[$count]>'9'){
if($DistrictID[$count]!='B'&&$DistrictID[$count]!='b'&&$DistrictID[$count]!='C'&&$DistrictID[$count]!='c'){
echo "<SCRIPT LANGUAGE=\"JavaScript\">";
echo "alert(\"The prefix is error\")";
echo "</SCRIPT>";
echo " <meta http-equiv=\"refresh\" content=\"0; url=mttariffEdit.php?tariff_id=$tariff_id&mode=$mode\"> ";
exit();
}
}
}
$setSql="INSERT INTO $tableName
(bill_id,tariff_id,area,call_type,discount_id,unit_time,free_time,mini_time,adjustment,tier_level,tier_unit_0,base_fee_0,long_distance_fee_0,tier_unit_1,base_fee_1,long_distance_fee_1,tier_unit_2,base_fee_2,long_distance_fee_2,cap_flag)
VALUES
('$DistrictID','$tariff_id','$District','$call_type',$discount_id,$Unit_time,$Free_time,$Min_unit,$adjustment,$tier_level,$tier_unit_0,$base_fee_0,$long_distance_fee_0,$tier_unit_1,$base_fee_1,$long_distance_fee_1,$tier_unit_2,$base_fee_2,$long_distance_fee_2,'$cap_flag')";
if(0) echo "<br>setSql=$setSql";
$result= @mysqli_query($srcDataConn,$setSql);
echo mysqli_error($srcDataConn);
echo " <meta http-equiv=\"refresh\" content=\"0; url=$listPageURL\"> ";
}
}
if(strlen($_REQUEST['delete']) > 0){
$deleteSql="DELETE FROM $tableName
WHERE bill_id='$id' AND tariff_id='$tariffID'";
if(0) echo "<br>$deleteSql";
$result= @mysqli_query($srcDataConn,$deleteSql);
echo mysqli_error($srcDataConn);
echo " <meta http-equiv=\"refresh\" content=\"0; url=$listPageURL\"> ";
}
//==========================================================
//输出并显示数据
//==========================================================
$sel_sql ="SELECT *
FROM $tableName
WHERE bill_id='$id' AND tariff_id='$tariffID'";
//echo "<br>sel_sql=$sel_sql";
$result = @mysqli_query($srcDataConn,$sel_sql);
$rows = @mysqli_fetch_array($result);
echo mysqli_error($srcDataConn);
?>
<script LANGUAGE="JavaScript">
function selectType(){
var base_url,url_add,url;
base_url='<?php echo "$PHP_SELF?edit=1&id=$id&tariffID=$tariffID&mode=$mode&call_type=";?>';
url_add=document.editform.call_type.options[document.editform.call_type.selectedIndex].value;
url=base_url+url_add;
window.location=url;
}
</script>
<?php
echo "<table id=\"table_up\" border=\"0\" width=\"100%\">";
echo "<tr>";
echo "<td width=\"50%\">";
echo "$strThisPage";
echo "</td>";
echo "<td width=\"50%\" align=\"right\">&nbsp;";
echo "</td>";
echo "</tr>";
echo "<tr>";
echo "<td align=\"left\">";
echo "<br>";
?>
<a href="./mttariff.php" target="_self"><img align=absBottom border="0" src="../../images/list.gif" width="16" height="16">List</a>
<?php
echo "</td>";
echo "<td width=\"50%\" align=\"right\">&nbsp;";
echo "</td>";
echo "</tr>";
echo "</table>";
adjust_title_tail();
adjust_content_head();
echo "<br>";
?>
<form method="POST" name="editform" action="<?php echo"$PHP_SELF?id=$id&tariffID=$tariffID&mode=$mode"; ?>">
<table border="1" width="400" cellpadding="1" cellspacing="0" bordercolor="#666666" bordercolordark="#FFFFFF">
<tr>
<td colspan="2" bgcolor="#E6E6E6">
<?php echo $tableTitle; ?>
</td>
</tr>
<?php
if ($mode == "edit"){
echo "<tr>";
echo "<td width=\"40%\">$strResideZone</td>";
echo "<td>$rows[tariff_id]<input type=\"hidden\" name=\"tariff_id\" value=\"$rows[tariff_id]\" size=\"25\"></td>";
$return_tariff_id = $rows[tariff_id]; //定义返回时的页面
echo "</tr>";
if('Default' == $rows[area]){
echo "<tr>";
echo "<td>$strChargingPrefix</td>";
echo "<td>&nbsp</td>";
echo "</tr>";
echo "<tr>";
echo "<td>$strCountryDistrict</td>";
echo "<td><input disabled type=\"text\" name=\"District\" value=\"$rows[area]\" size=\"25\" class=\"text\"></td>";
echo "<td><input type=\"hidden\" name=\"District\" value=\"$rows[area]\" size=\"25\" class=\"text\"></td>";
echo "</tr>";
}else{
echo "<tr>";
echo "<td>$strChargingPrefix</td>";
echo "<td>$rows[bill_id] </td>";
echo "</tr>";
echo "<tr>";
echo "<td>$strCountryDistrict</td>";
echo "<td><input type=\"text\" name=\"District\" value=\"$rows[area]\" size=\"25\" class=\"text\"></td>";
echo "</tr>";
}
echo "<tr>";
echo "<td>$strCallType</td>";
$arr_CallType = array("Local call in","Trunk call in");
$length = sizeof($arr_CallType);
echo "<td>";
echo "<select onChange=\"javascript:selectType();\" name=\"call_type\">";
//检查是否处于编辑状态
if($edit != 1){
$call_type = $rows[call_type];
}
else {
$call_type=$call_type;
}
for ($i=4;$i<4+$length;$i++)
{
echo "<option value=\"$i\" ";
if ($i == $call_type)
{
echo "selected";
}
$tmpI=$i-4;
echo ">$arr_CallType[$tmpI]</option>";
}
echo "</select>";
echo "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>$strDiscountID</td>";
echo "<td><input type=\"text\" name=\"discount_id\" value=\"$rows[discount_id]\" size=\"25\" class=\"text\"></td>";
echo "</tr>";
echo "<tr>";
echo "<td>$strUnitChargingTimeSecond</td>";
echo "<td><input type=\"text\" name=\"Unit_time\" value=\"$rows[unit_time]\" size=\"25\" class=\"text\"></td>";
echo "</tr>";
echo "<tr>";
echo "<td>$strFreeChargeUnit</td>";
echo "<td><input type=\"text\" name=\"Free_time\" value=\"$rows[free_time]\" size=\"25\" class=\"text\"></td>";
echo "</tr>";
echo "<tr>";
echo "<td>$strMinimumChargingUnit</td>";
echo "<td><input type=\"text\" name=\"Min_unit\" value=\"$rows[mini_time]\" size=\"25\" class=\"text\"></td>";
echo "</tr>";
echo "<tr>";
echo "<td>$strBasicInitial</td>";
echo "<td><input type=\"text\" name=\"adjustment\" value=\"$rows[adjustment]\" size=\"25\" class=\"text\">&nbsp;&nbsp;$moneyPara</td>";
echo "</tr>";
echo "<tr>";
echo "<td>$strTariffRentCapFlag</td>";
echo "<td>";
echo "<select name=\"cap_flag\">";
for ($i=0;$i<sizeof($call_cap_flag_label);$i++)
{
echo "<option value=\"$i\" ";
if ($i == $rows[cap_flag])
{
echo "selected";
}
echo ">$call_cap_flag_label[$i]</option>";
}
echo "</select>";
echo "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>Tier Level</td>";
echo "<td><input type=\"text\" name=\"tier_level\" value=\"$rows[tier_level]\" size=\"25\" class=\"text\">(0-2)</td>";
echo "</tr>";
echo "<tr>";
echo "<td>Tier0 Unit</td>";
echo "<td><input type=\"text\" name=\"tier_unit_0\" value=\"$rows[tier_unit_0]\" size=\"25\" class=\"text\"></td>";
echo "</tr>";
echo "<tr>";
echo "<td>$strBasicFee</td>";
echo "<td><input type=\"text\" name=\"base_fee_0\" value=\"$rows[base_fee_0]\" size=\"25\" class=\"text\">&nbsp;&nbsp;$moneyPara</td>";
echo "</tr>";
echo "<tr>";
echo "<td>$strBasicLongDistance</td>";
echo "<td><input type=\"text\" name=\"long_distance_fee_0\" value=\"$rows[long_distance_fee_0]\" size=\"25\" class=\"text\">&nbsp;&nbsp;$moneyPara</td>";
echo "</tr>";
echo "<tr>";
echo "<td>Tier1 Unit</td>";
echo "<td><input type=\"text\" name=\"tier_unit_1\" value=\"$rows[tier_unit_1]\" size=\"25\" class=\"text\"></td>";
echo "</tr>";
echo "<tr>";
echo "<td>$strBasicFee</td>";
echo "<td><input type=\"text\" name=\"base_fee_1\" value=\"$rows[base_fee_1]\" size=\"25\" class=\"text\">&nbsp;&nbsp;$moneyPara</td>";
echo "</tr>";
echo "<tr>";
echo "<td>$strBasicLongDistance</td>";
echo "<td><input type=\"text\" name=\"long_distance_fee_1\" value=\"$rows[long_distance_fee_1]\" size=\"25\" class=\"text\">&nbsp;&nbsp;$moneyPara</td>";
echo "</tr>";
echo "<tr>";
echo "<td>Tier2 Unit</td>";
echo "<td><input type=\"text\" name=\"tier_unit_2\" value=\"$rows[tier_unit_2]\" size=\"25\" class=\"text\"></td>";
echo "</tr>";
echo "<tr>";
echo "<td>$strBasicFee</td>";
echo "<td><input type=\"text\" name=\"base_fee_2\" value=\"$rows[base_fee_2]\" size=\"25\" class=\"text\">&nbsp;&nbsp;$moneyPara</td>";
echo "</tr>";
echo "<tr>";
echo "<td>$strBasicLongDistance</td>";
echo "<td><input type=\"text\" name=\"long_distance_fee_2\" value=\"$rows[long_distance_fee_2]\" size=\"25\" class=\"text\">&nbsp;&nbsp;$moneyPara</td>";
echo "</tr>";
}
elseif ($mode == "add"){
echo "<tr>";
echo "<td width=\"40%\">$strResideZone</td>";
echo "<td>$tariff_id";
/*
echo "<select size=\"1\" name=\"tariff_id\">";
for($i=0;$i<16;$i++){
$m=($i<10?"0":"").$i;
if($m != $tariff_id){
echo "<option value=\"$m\">$m</option>";
}else{
echo "<option value=\"$m\" selected>$m</option>";
}
}
echo "</select>";
*/
$return_tariff_id = $tariff_id; //定义返回时的页面
echo "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>$strChargingPrefix</td>";
echo "<td><input type=\"text\" name=\"DistrictID\" value=\"\" size=\"25\" class=\"text\"></td>";
echo "</tr>";
echo "<tr>";
echo "<td>$strCountryDistrict</td>";
echo "<td><input type=\"text\" name=\"District\" value=\"\" size=\"25\" class=\"text\"></td>";
echo "</tr>";
echo "<tr>";
echo "<td>$strCallType</td>";
$arr_CallType = array("Local call in","Trunk call in");
$length = sizeof($arr_CallType);
echo "<td>";
echo "<select size=\"1\" name=\"call_type\">";
for ($i=4;$i<4+$length;$i++){
$tmpI=$i-4;
if($i != $call_type){
echo "<option value=\"$i\">$arr_CallType[$tmpI]</option>";
}else{
echo "<option value=\"$i\" selected>$arr_CallType[$tmpI]</option>";
}
}
echo "</select>";
$call_type = $call_type;
echo "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>$strDiscountID</td>";
echo "<td><input type=\"text\" name=\"discount_id\" value=\"\" size=\"25\" class=\"text\"></td>";
echo "</tr>";
echo "<tr>";
echo "<td>$strUnitChargingTimeSecond</td>";
echo "<td><input type=\"text\" name=\"Unit_time\" value=\"\" size=\"25\" class=\"text\"></td>";
echo "</tr>";
echo "<tr>";
echo "<td>$strFreeChargeUnit</td>";
echo "<td><input type=\"text\" name=\"Free_time\" value=\"\" size=\"25\" class=\"text\"></td>";
echo "</tr>";
echo "<tr>";
echo "<td>$strMinimumChargingUnit</td>";
echo "<td><input type=\"text\" name=\"Min_unit\" value=\"\" size=\"25\" class=\"text\"></td>";
echo "</tr>";
echo "<tr>";
echo "<td>$strBasicInitial</td>";
echo "<td><input type=\"text\" name=\"adjustment\" value=\"\" size=\"25\" class=\"text\">&nbsp;&nbsp;$moneyPara</td>";
echo "</tr>";
echo "<tr>";
echo "<td>$strTariffRentCapFlag</td>";
echo "<td>";
echo "<select name=\"cap_flag\">";
for ($i=0;$i<sizeof($call_cap_flag_label);$i++)
{
echo "<option value=\"$i\" ";
if ($i == $rows[cap_flag])
{
echo "selected";
}
echo ">$call_cap_flag_label[$i]</option>";
}
echo "</select>";
echo "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>Tier Level</td>";
echo "<td><input type=\"text\" name=\"tier_level\" value=\"\" size=\"25\" class=\"text\">&nbsp;&nbsp;(0-2)</td>";
echo "</tr>";
echo "<tr>";
echo "<td>Tier0 Unit</td>";
echo "<td><input type=\"text\" name=\"tier_unit_0\" value=\"\" size=\"25\" class=\"text\"></td>";
echo "</tr>";
echo "<tr>";
echo "<td>$strBasicFee</td>";
echo "<td><input type=\"text\" name=\"base_fee_0\" value=\"\" size=\"25\" class=\"text\">&nbsp;&nbsp;$moneyPara</td>";
echo "</tr>";
echo "<tr>";
echo "<td>$strBasicLongDistance</td>";
echo "<td><input type=\"text\" name=\"long_distance_fee_0\" value=\"\" size=\"25\" class=\"text\">&nbsp;&nbsp;$moneyPara</td>";
echo "</tr>";
echo "<tr>";
echo "<td>Tier1 Unit</td>";
echo "<td><input type=\"text\" name=\"tier_unit_1\" value=\"\" size=\"25\" class=\"text\"></td>";
echo "</tr>";
echo "<tr>";
echo "<td>$strBasicFee</td>";
echo "<td><input type=\"text\" name=\"base_fee_1\" value=\"\" size=\"25\" class=\"text\">&nbsp;&nbsp;$moneyPara</td>";
echo "</tr>";
echo "<tr>";
echo "<td>$strBasicLongDistance</td>";
echo "<td><input type=\"text\" name=\"long_distance_fee_1\" value=\"\" size=\"25\" class=\"text\">&nbsp;&nbsp;$moneyPara</td>";
echo "</tr>";
echo "<tr>";
echo "<td>Tier2 Unit</td>";
echo "<td><input type=\"text\" name=\"tier_unit_2\" value=\"\" size=\"25\" class=\"text\"></td>";
echo "</tr>";
echo "<tr>";
echo "<td>$strBasicFee</td>";
echo "<td><input type=\"text\" name=\"base_fee_2\" value=\"\" size=\"25\" class=\"text\">&nbsp;&nbsp;$moneyPara</td>";
echo "</tr>";
echo "<tr>";
echo "<td>$strBasicLongDistance</td>";
echo "<td><input type=\"text\" name=\"long_distance_fee_2\" value=\"\" size=\"25\" class=\"text\">&nbsp;&nbsp;$moneyPara</td>";
echo "</tr>";
}
else {
exit();
}
?>
</table>
<table width="400">
<tr>
<td>
<input type="submit" name="set" value="Set" style="width:40" class="button">&nbsp;
<input type="reset" name="reset" value="Reset" class="button">&nbsp;
<?php
echo "<input type=\"button\" name=\"return\" value=\"Return\" onclick=jacascript:location.href=\"./mttariff.php?keep_id=1&return_tariff_id=$return_tariff_id\" class=\"button\">&nbsp;";
?>
<?php
if ($mode == "edit"){
if($rows[area]!='Default'){
echo "<input type=\"submit\" name=\"delete\" value=\"Delete\" class=\"button\">";
echo "<input type=\"hidden\" name=\"tariffID\" value=\"$tariffID\">";
}
else
{
echo "<input type=\"hidden\" name=\"tariffID\" value=\"$tariffID\">";
}
}else
echo "<input type=\"hidden\" name=\"tariff_id\" value=\"$tariff_id\">";
?>
</td>
</tr>
</table>
</form>
<?php
adjust_content_tail();
?>
</body>
</html>