<?php
/*********************************************************      
 程序说明：         
    功能说明：列表显示基本计费信息
    调用关系：调用: header.inc   
              被调用:        
     变量说明
作者:
      
修改注释：      
NO.1      
姓名：崔体存         
时间: 2004-4-13    
修改说明： OMC 7.0 把Mo tariff、Rent、SMS、Servives tariff放
          进一个页面，都可以通过选择tariff_id来查看相应的费率情况
*********************************************************/
require("../../inc/header.inc");
?>
<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="selectform" action="<?php echo "$PHP_SELF";?>">
<?php
adjust_head();
adjust_title_head();
$helpId = "2.2.3.1"; 
global $OMC_server,$pubConn;
$tariff_id=$_REQUEST['tariff_id'];
$where=$_REQUEST['where'];
$sort_field=$_REQUEST['sort_field'];
$return_tariff_id=$_REQUEST['return_tariff_id'];
$keep_id=$_REQUEST['keep_id'];


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

$table_name='pre_mo_tariff';
$strThisPage=$strTitleAdvanced.$strTitleSpace.$strTariffPlan.$strTitleSpace.$strBasicTariff;
$arr_mode=array("edit","add");
$DEBUG = 0;

if(!$sort_field){
	$sort_field        = 'bill_id';        //排序所依赖的字段名
}
$sort_direction            = 'ASC ';       //排序顺序
$moneyPara = getMoneyPara();			   //显示的货币单位是最小货币单位的倍数
$call_cap_flag_label=array(0=>"Disable",1=>"Home PLMN Call",2=>"Other Network Call");
$sm_cap_flag_label=array(0=>"Disable",1=>"Home PLMN SM",2=>"Other Network SM");
//echo "<br>moneyPara = $moneyPara";

if($add_area){
	echo " <meta http-equiv=\"refresh\" content=\"0; url=./rate_modify.php?add_area=1\"> ";
	exit();
}

//编辑后保持对应tariff_id的页面
if ($keep_id != 1){
	$tariff_id=isset($tariff_id)?$tariff_id:'00';
}
else {$tariff_id=$return_tariff_id;}
if($DEBUG) {echo "<br>keep_id=$keep_id<br>tariff_id=$return_tariff_id<br>";}
//
 

$where=" WHERE tariff_id=$tariff_id ";
//echo "<br>where=$where";
$str_sql ="SELECT  count(*) FROM $table_name ".$where;
//echo "<br>str_sql=$str_sql";

$result=mysqli_query($srcDataConn,$str_sql);
$record = mysqli_fetch_array($result);
$number_of_records = $record[0];

$order  = " ORDER BY $sort_field   $sort_direction ";
$sel_sql ="SELECT * FROM $table_name ".$where.$order;
//echo "<br>sel_sql=$sel_sql";
$result = @mysqli_query($srcDataConn,$sel_sql);
$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%\" align=\"left\">";
	echo "$strThisPage";
	echo "</td>";
	echo "<td width=\"50%\" align=\"right\" title=\"Help\">";
	showHelp($helpId);
	echo "</td>";
	echo "</tr>";
	echo "<tr>";
	echo "<td align=\"left\">&nbsp;";

	echo "</td>";
	echo "<td align=\"right\">";
	
	 echo "$strResideZone:&nbsp;";
   $maxCosSql = " SELECT pubVarValue FROM OMC_PUB.omcPubVarConf WHERE pubVarName = 'maxCOSNumber' ";
   $maxCosRes = @mysqli_query($pubConn,$maxCosSql);
   $maxCosRow = @mysqli_fetch_array($maxCosRes);
   $maxCosNum = $maxCosRow[pubVarValue];
   echo "<select size=\"1\" name=\"tariff_id\" onChange=\"javascript:selectTitle()\">";       
   for($i=0;$i<$maxCosNum;$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>";
   
	echo "</td>";
	echo "</tr>";
	echo "</table>";
adjust_title_tail();
adjust_content_head();
echo "<br>";
?>
<script LANGUAGE="JavaScript">  
function selectTitle(){      
	var base_url,url_add,url; 
	base_url='<?php echo "$PHP_SELF?tariff_id=";?>';
	url_add=document.selectform.tariff_id.options[document.selectform.tariff_id.selectedIndex].value;      
	url=base_url+url_add;
	window.location=url;
}     
</script>


<?php 
  echo "<b>MO basic tariff</b>";
?>
<table border="0" width="40%" cellpadding="1" cellspacing="2" bordercolor="#666666" bordercolordark="#FFFFFF">
<tr>
  <td width="3%">
   <a href="./tariffBasic.php" target="_self"><img align=absBottom border="0" src="../../images/list.gif" width="16" height="16"><?php echo "$strList"; ?></a></td> 
  <td width="30%">
  <?php
	   $maxMoPrefixNumCosSql = " SELECT pubVarValue FROM OMC_PUB.omcPubVarConf WHERE pubVarName = 'maxMoPrefixNumPerCOS' ";
	   $maxMoPrefixNumCosRes = @mysqli_query($pubConn,$maxMoPrefixNumCosSql);
	   $maxMoPrefixNumCosRow = @mysqli_fetch_array($maxMoPrefixNumCosRes);
	   $maxMoPrefixNumCosNum = $maxMoPrefixNumCosRow[pubVarValue];
	   echo "Total records:$number_of_records Max records:$maxMoPrefixNumCosNum";
	   //modify on 2008-4-30
	   //echo "Total records:$number_of_records&nbsp&nbsp&nbsp&nbspMax records:300";
  ?>	
  </td>
  <td width="12%">
  <?php
	  echo "<a href=\"tariffBasicEdit.php?mode=$arr_mode[1]&number_of_records=$number_of_records&tariff_id=$tariff_id\" target=\"_self\">";
  ?>
  <img align="absBottom" border="0" src="../../images/add.gif" width="16" height="16"><?php echo "$strAdd"; ?></a></td> 
  </td>  
</tr>
</table>
<p></p>
<?php
//没有纪录时，显示无记录提示
  if(!$rows){
	echo "$strTariffNoRecords $tariff_id"."!";
  }
?>

<?php
 if($rows){
	echo "<table border=\"1\" width=\"100%\"  cellpadding=\"1\"  cellspacing=\"0\"  bordercolor=\"#666666\" bordercolordark=\"#FFFFFF\">";
	echo "<tr bgcolor=\"#E6E6E6\" valign=\"top\">";
	echo "<td><a href=\"$PHP_SELF?tariff_id=$tariff_id&where=$where&sort_field=bill_id\"  target=\"_self\">$strChargingPrefix</a></td>";
	echo "<td><a href=\"$PHP_SELF?tariff_id=$tariff_id&where=$where&sort_field=area\" target=\"_self\">$strCountryDistrict</a></td>";
	echo "<td >$strCallType</td>";
	echo "<td >$strDiscountID</td>";
	echo "<td >$strUnitChargingTimeSecond</td>";
	echo "<td >$strFreeChargeUnit</td>";
	echo "<td >$strMinimumChargingUnit</td>";
	//echo "<td >$strBasicFee($moneyPara)</td>";
	//echo "<td >$strBasicLongDistance($moneyPara)</td>";
	echo "<td >$strBasicInitial($moneyPara)</td>";
	echo "<td >$strTariffRentCapFlag</td>";
	echo "<td >Tier Level</td>";
	
	echo "<td >Tier0 Unit</td>";
  echo "<td >$strBasicFee</td>";
  echo "<td >$strBasicLongDistance</td>";
  echo "<td >Tier1 Unit</td>";
  echo "<td >$strBasicFee</td>";
  echo "<td >$strBasicLongDistance</td>";
  echo "<td >Tier2 Unit</td>";
  echo "<td >$strBasicFee</td>";
  echo "<td >$strBasicLongDistance</td>";
  
	
	echo "</tr>";    
 
	do{
		echo "<tr>";
		echo "<td><a href=\"./tariffBasicEdit.php?id=$rows[bill_id]&tariffID=$rows[tariff_id]&mode=$arr_mode[0]\">$rows[bill_id]</a></td>";
		echo "<td>$rows[area]&nbsp</td>";
		if($rows[call_type]==0)
			echo "<td>Local call out</td>";
		elseif($rows[call_type]==1)
			echo "<td>NDD</td>";
		elseif($rows[call_type]==2)
			echo "<td>IDD</td>";
		else
			echo "<td align=\"right\">---</td>";
			
		echo "<td align=\"right\">$rows[discount_id]</td>";
		echo "<td align=\"right\">$rows[unit_time]</td>";
		echo "<td align=\"right\">$rows[free_time]</td>";
		echo "<td align=\"right\">$rows[mini_time]</td>";
		//echo "<td align=\"right\">$rows[base_fee]</td>";
		//echo "<td align=\"right\">$rows[long_distance_fee]</td>";
		echo "<td align=\"right\">$rows[adjustment]</td>";
		echo "<td align=\"right\">{$call_cap_flag_label[$rows[cap_flag]]}</td>";
		echo "<td align=\"right\">$rows[tier_level]</td>";
		
		echo "<td align=\"right\">$rows[tier_unit_0]</td>";
		echo "<td align=\"right\">$rows[base_fee_0]</td>";
		echo "<td align=\"right\">$rows[long_distance_fee_0]</td>";
		echo "<td align=\"right\">$rows[tier_unit_1]</td>";
		echo "<td align=\"right\">$rows[base_fee_1]</td>";
		echo "<td align=\"right\">$rows[long_distance_fee_1]</td>";
		echo "<td align=\"right\">$rows[tier_unit_2]</td>";
		echo "<td align=\"right\">$rows[base_fee_2]</td>";
		echo "<td align=\"right\">$rows[long_distance_fee_2]</td>";
		
     /*   $base_fee=$rows[base_fee]/$moneyPara;
	    if($moneyPara < 10){
			printf("<td align=\"right\">%5.0f</td>",$base_fee); 
		}
	    elseif($moneyPara < 100){
			printf("<td align=\"right\">%5.1f</td>",$base_fee); 
		}
	    else{
			printf("<td align=\"right\">%5.2f</td>",$base_fee); 
		}
    
	    $long_distance_fee=$rows[long_distance_fee]/$moneyPara;
 	    if($moneyPara < 10){
			printf("<td align=\"right\">%5.0f</td>", $long_distance_fee);
		}
	    elseif($moneyPara < 100){
			printf("<td align=\"right\">%5.1f</td>", $long_distance_fee);
		}
	    else{
			printf("<td align=\"right\">%5.2f</td>", $long_distance_fee);
		}
	    
		$adjustment_fee=$rows[adjustment]/$moneyPara;
 	    if($moneyPara < 10){
			printf("<td align=\"right\">%5.0f</td>", $adjustment_fee);
		}
	    elseif($moneyPara < 100){
			printf("<td align=\"right\">%5.1f</td>", $adjustment_fee);
		}
	    else{
			printf("<td align=\"right\">%5.2f</td>", $adjustment_fee);
		}*/
	    echo "</tr>";	
	}while($rows = mysqli_fetch_array($result));
}
?>  
</table>
</form>

<!--  Rent -->
<?php
$moneyPara = getMoneyPara();			   //显示的货币单位是最小货币单位的倍数
$db='PPS_DB';
$table_name='pre_rent';
$arr_mode=array("edit","add");

//编辑后保持对应tariff_id的页面
if ($keep_id != 1){
	$tariff_id=isset($tariff_id)?$tariff_id:'00';
}
else {
	$tariff_id=$return_tariff_id;
}
if($DEBUG) echo "<br>keep_id=$keep_id<br>tariff_id=$return_tariff_id<br>";
 
$sql="SELECT  id,description,rent_type,charge_date,rent_amount
	FROM $table_name
	WHERE tariff_id=$tariff_id
 	ORDER by id";
//echo $sql,$bill_db;
$result=@mysqli_query($srcDataConn,$sql);
$rows=@mysqli_fetch_array($result);
echo mysqli_error($srcDataConn);

echo "<table border=\"0\" width=\"100%\">";
echo "<tr>";
echo "<td>";
echo "<b>Rent</b>";
echo "</td>";
echo "</tr>";
echo "</table>";
echo "<p></p>";
?>

<table border="1" width="100%" cellpadding="2" cellspacing="0"  bordercolor="#666666" bordercolordark="#FFFFFF" bgcolor="#FFFFFF"  >
  <tr bgcolor="#E6E6E6">
   <?php
	echo "<td align=\"center\">$strTariffRentID</td>";
    echo "<td align=\"center\">$strDescription</td>";
	echo "<td align=\"center\">$strTariffRentChargeType</td>"; 
    echo "<td align=\"center\">$strTariffRentChargeDate</td>";  
    echo "<td align=\"center\">$strTariffRentChargeAmount($moneyPara)</td>";
   ?>
  </tr>
  <?php
   $i=0;
   if($rows && $result){
	   do{
		   $i++;
		   $showi=$i;
		   if ($rows[description] == ''){
			   echo "<tr>";
			   echo "<td align=\"center\"><a href=\"./tariffRentEdit.php?id=$showi&mode=$arr_mode[0]&tariffID=$tariff_id\">$showi</a></td>";
		       echo "<td align=\"center\">--</td>";
		       echo "<td align=\"center\">--</td>";
		       echo "<td align=\"center\">--</td>";
		       echo "<td align=\"right\">--</td>";
		       echo "</tr>";
		   }
		   else{
			   echo "<tr>";
			   echo "<td align=\"center\"><a href=\"./tariffRentEdit.php?id=$showi&mode=$arr_mode[0]&tariffID=$tariff_id\">$showi</a></td>";
		       echo "<td align=\"center\">$rows[description]</td>";
			   echo "<td align=\"center\">";
			   if($rows[rent_type]=='00'){
				   echo "$strTariffRentAccordingToDate";
			   }else{
				   echo "$strTariffRentAccordingToPeriod";
			   }
			   echo "</td>"; 
			   echo "<td align=\"center\">";
			   if($rows[rent_type]=='01'){
				   echo "$rows[charge_date]";
			   }else{
				   echo "--";
			   }
			   echo "</td>"; 
			   echo "<td align=\"right\">$rows[rent_amount]";
			   echo "</td>";
			   /*$rows[rent_amount] = $rows[rent_amount]/$moneyPara;
			   if($moneyPara < 10){
				   printf("<td align=\"right\">%5.0f</td>", $rows[rent_amount]);
			   }
			   elseif($moneyPara < 100){
				   printf("<td align=\"right\">%5.1f</td>", $rows[rent_amount]);
			   }
		       else{
				   printf("<td align=\"right\">%5.2f</td>", $rows[rent_amount]);
			   }*/
			   echo "</tr>"; 
		   }
	   }while($rows=mysqli_fetch_array($result));
   }
   ?>
  </table> 


<!-- SMS -->
<?php
$moneyPara = getMoneyPara();			   //显示的货币单位是最小货币单位的倍数
$db='PPS_DB';
$table_name='pre_bill_sms';
$arr_mode=array("edit","add");

//编辑后保持对应tariff_id的页面
if ($keep_id != 1){
	$tariff_id=isset($tariff_id)?$tariff_id:'00';
}
else {$tariff_id=$return_tariff_id;}
if($DEBUG) {echo "<br>keep_id=$keep_id<br>tariff_id=$return_tariff_id<br>";}
 
$sql="SELECT  id,prefix,call_type,area,discount_id,charge_amount,cap_flag 
	FROM $table_name
	WHERE tariff_id=$tariff_id
 	ORDER by id";
//echo $sql,$bill_db;
$result=@mysqli_query($srcDataConn,$sql);
$rows=@mysqli_fetch_array($result);
echo mysqli_error($srcDataConn);
?>
<p></p>
<?php
	echo "<table border=\"0\" width=\"100%\">";
    echo "<tr>";
    echo "<td>";
    echo "<b>SMS</b>";
    echo "</td>";
    echo "</tr>";	echo "</table>";
	echo "<p></p>";

?>

<table border="1" width="100%" cellpadding="2" cellspacing="0"  bordercolor="#666666" bordercolordark="#FFFFFF" bgcolor="#FFFFFF"  >
  <tr bgcolor="#E6E6E6">
   <?php
	echo "<td align=\"center\">$strTariffRentID</td>";
    echo "<td align=\"center\">$strChargingPrefix</td>";
    echo "<td align=\"center\">Call type</td>";
	echo "<td align=\"center\">$strCountryDistrict</td>"; 
    echo "<td align=\"center\">$strDiscountID</td>";  
    echo "<td align=\"center\">$strTariffRentChargeAmount($moneyPara)</td>";
    echo "<td align=\"center\">$strTariffRentCapFlag</td>";
   ?>
  </tr>
    <?php
    $i=0;
    
	if($rows && $result){
		do{
			$i++;
			echo "<tr>";
			echo "<td align=\"center\"><a href=\"./tariffSmsEdit.php?id=$i&mode=$arr_mode[0]&tariffID=$tariff_id\">$i</a></td>";
			if("" == $rows[prefix]){
				$rows[prefix]="--";
		    }
			echo "<td align=\"center\">&nbsp;$rows[prefix]</td>";
			
			if($rows[call_type]==0)
				echo "<td align=\"center\">Local call out</td>";
			elseif($rows[call_type]==1)
				echo "<td align=\"center\">NDD</td>";
			elseif($rows[call_type]==2)
				echo "<td align=\"center\">IDD</td>";
			else
				echo "<td align=\"right\">---</td>";
			
			if ($rows[area] == ''){
				$rows[area]='--';
			}
			echo "<td align=\"center\">&nbsp;$rows[area]</td>";
		    echo "<td align=\"center\">$rows[discount_id]</td>";
		    echo "</td>"; 
			echo "<td align=\"center\">$rows[charge_amount]</td>";
			echo "<td align=\"center\">{$sm_cap_flag_label[$rows[cap_flag]]}</td>";
			/*$rows[charge_amount ] = $rows[charge_amount ]/$moneyPara;
			if($moneyPara < 10){
				printf("<td align=\"right\">%5.0f</td>", $rows[charge_amount]);
			}
			elseif($moneyPara < 100){
				printf("<td align=\"right\">%5.1f</td>", $rows[charge_amount]);
			}
			else{
				printf("<td align=\"right\">%5.2f</td>", $rows[charge_amount]);
			}*/
			echo "</tr>"; 
		}while($rows=mysqli_fetch_array($result));
	}
    ?>
  </table> 
  



<!-- GPRS -->
<?php
$moneyPara = getMoneyPara();			   //显示的货币单位是最小货币单位的倍数
$db='PPS_DB';
$table_name='pre_gprs_tariff';
$arr_mode=array("edit","add");

//编辑后保持对应tariff_id的页面
if ($keep_id != 1){
	$tariff_id=isset($tariff_id)?$tariff_id:'00';
}
else {$tariff_id=$return_tariff_id;}
if($DEBUG) {echo "<br>keep_id=$keep_id<br>tariff_id=$return_tariff_id<br>";}
  
$sql="SELECT  record_id,dest_ip,charge_unit,basic_fee,min_charge_unit,initial_adjustment,cap_flag,discount_id
	FROM $table_name
	WHERE tariff_id=$tariff_id
 	ORDER by record_id";
//echo $sql,$bill_db;
$result=@mysqli_query($srcDataConn,$sql);
$rows=@mysqli_fetch_array($result);
echo mysqli_error($srcDataConn);
?>
<p></p>
<?php
	echo "<table border=\"0\" width=\"100%\">";
    echo "<tr>";
    echo "<td>";
    echo "<b>GPRS</b>";
    echo "</td>";
    echo "</tr>";	echo "</table>";
	echo "<p></p>";

?>

<table border="1" width="100%" cellpadding="2" cellspacing="0"  bordercolor="#666666" bordercolordark="#FFFFFF" bgcolor="#FFFFFF"  >
  <tr bgcolor="#E6E6E6">
   <?php
	echo "<td align=\"center\">ID</td>";
    echo "<td align=\"center\">Dest IP</td>";
    echo "<td align=\"center\">Charge unit(KB)</td>";
	echo "<td align=\"center\">Basic fee</td>"; 
    echo "<td align=\"center\">Minimun charge unit</td>";  
    echo "<td align=\"center\">Initial adjustment</td>";
    echo "<td align=\"center\">Cap Flag</td>";
    echo "<td align=\"center\">Discount ID</td>";
   ?>
  </tr>
    <?php
    $i=0;
$gprs_cap_flag_label=array(0=>"Disable",1=>"Enable");
	if($rows && $result){
		do{
			$i++;
			echo "<tr>";
			echo "<td align=\"center\"><a href=\"./gprsEdit.php?record_id={$rows[record_id]}&mode=$arr_mode[0]&tariffID=$tariff_id\">{$rows[record_id]}</a></td>";
			
			echo "<td align=\"center\">{$rows[dest_ip]}&nbsp;</td>";
			
			echo "<td align=\"center\">{$rows[charge_unit]}&nbsp;</td>";
			echo "<td align=\"center\">{$rows[basic_fee]}&nbsp;</td>";
			echo "<td align=\"center\">{$rows[min_charge_unit]}&nbsp;</td>";
			echo "<td align=\"center\">{$rows[initial_adjustment]}&nbsp;</td>";
			echo "<td align=\"center\">{$gprs_cap_flag_label[$rows[cap_flag]]}&nbsp;</td>";
			echo "<td align=\"center\">{$rows[discount_id]}&nbsp;</td>";
			echo "</tr>"; 
		}while($rows=mysqli_fetch_array($result));
	}
    ?>
  </table> 







<!-- MMS Send -->
<?php

$moneyPara = getMoneyPara();			   //显示的货币单位是最小货币单位的倍数
$db='PPS_DB';
$table_name='pre_vas_mms_send_tariff';
$arr_mode=array("edit","add");

//编辑后保持对应tariff_id的页面
if ($keep_id != 1){
	$tariff_id=isset($tariff_id)?$tariff_id:'00';
}
else {$tariff_id=$return_tariff_id;}
if($DEBUG) {echo "<br>keep_id=$keep_id<br>tariff_id=$return_tariff_id<br>";}
  
$sql="SELECT  mms_send_id,mms_type,prefix,call_type,dest_name,discount_id,charge_fee,cap_flag 
	FROM $table_name
	WHERE tariff_id=$tariff_id
 	ORDER by mms_send_id";
//echo $sql,$bill_db;
$result=@mysqli_query($srcDataConn,$sql);
$rows=@mysqli_fetch_array($result);
echo mysqli_error($srcDataConn);
?>
<p></p>
<?php
	echo "<table border=\"0\" width=\"100%\">";
    echo "<tr>";
    echo "<td>";
    echo "<b>MMS Send</b>";
    echo "</td>";
    echo "</tr>";	echo "</table>";
	echo "<p></p>";

?>

<table border="1" width="100%" cellpadding="2" cellspacing="0"  bordercolor="#666666" bordercolordark="#FFFFFF" bgcolor="#FFFFFF"  >
  <tr bgcolor="#E6E6E6">
   <?php
		echo "<td align=\"center\">ID</td>";
    echo "<td align=\"center\">MMS type</td>";
    echo "<td align=\"center\">Prefix</td>";
		echo "<td align=\"center\">Call type</td>"; 
    echo "<td align=\"center\">Dest name</td>";  
    echo "<td align=\"center\">Discount ID</td>";
    echo "<td align=\"center\">Charge fee</td>";
    echo "<td align=\"center\">Cap flag</td>";
   ?>
  </tr>
    <?php
    $i=0;
$mms_send_cap_flag_label=array(0=>"Disable",1=>"Enable");
$mms_type_label=array(1=>"To mobile",2=>"To email");
	if($rows && $result){
		do{
			$i++;
			echo "<tr>";
			echo "<td align=\"center\"><a href=\"./mmsSendEdit.php?record_id={$rows[mms_send_id]}&mode=$arr_mode[0]&tariffID=$tariff_id\">{$rows[mms_send_id]}</a></td>";
			
			echo "<td align=\"center\">{$mms_type_label[$rows[mms_type]]}&nbsp;</td>";
			if(trim($rows[prefix])=="")
				echo "<td align=\"center\">--</td>";
			else
				echo "<td align=\"center\">{$rows[prefix]}&nbsp;</td>";
			
			if($rows[call_type]==0)
				echo "<td align=\"center\">Local call out</td>";
			elseif($rows[call_type]==1)
				echo "<td align=\"center\">NDD</td>";
			elseif($rows[call_type]==2)
				echo "<td align=\"center\">IDD</td>";
			else
				echo "<td align=\"right\">---</td>";
			
			if(trim($rows[dest_name])=="")
				echo "<td align=\"center\">--</td>";
			else
				echo "<td align=\"center\">{$rows[dest_name]}&nbsp;</td>";
			echo "<td align=\"center\">{$rows[discount_id]}&nbsp;</td>";
			echo "<td align=\"center\">{$rows[charge_fee]}&nbsp;</td>";
			echo "<td align=\"center\">{$mms_send_cap_flag_label[$rows[cap_flag]]}&nbsp;</td>";
						
			echo "</tr>"; 
		}while($rows=mysqli_fetch_array($result));
	}
	echo "</table>";
  
  ?>
  




  
  
  
  
  

<!--  Service tariff -->

<?php
$moneyPara = getMoneyPara();			   //显示的货币单位是最小货币单位的倍数
$db='PPS_DB';
$tableName='pre_comm_tariff';


//编辑后保持对应tariff_id的页面
if ($keep_id != 1){
	$tariff_id=isset($tariff_id)?$tariff_id:'00';
}
else {$tariff_id=$return_tariff_id;}
if($DEBUG) {echo "<br>keep_id=$keep_id<br>tariff_id=$return_tariff_id<br>";}
//
 

$where=" WHERE tariff_id=$tariff_id ";
$sql="SELECT * FROM $tableName".$where;
//echo $sql,$bill_db;
$result=@mysqli_query($srcDataConn,$sql);
$rows=@mysqli_fetch_array($result);
echo mysqli_error($srcDataConn);
?>

<?php
//没有纪录时，显示无记录提示
if(!$rows){
	$setSql="INSERT INTO $tableName
				(tariff_id,cf_charge_unit,cf_charge_amount,roaming_charge_unit,roaming_charge_amount,cc_charge_unit,cc_charge_amount,cug_charge_unit,cug_charge_amount,fav_change_charge,fav_charge_unit,fav_charge_amount )
				 VALUES
				('$tariff_id','','','','','','','','','','','')";
	if($DEBUG) echo "<br>setSql=$setSql";
	mysqli_query($srcDataConn,$setSql);
}
echo "<table border=\"0\" width=\"100%\">";
echo "<tr>";
echo "<td>";
echo "<b><br>Supplementary tariff</b>";
echo "</td>";
echo "</tr>";
echo "</table>";
echo "<p></p>";
?>

<table border="1" width="100%" cellpadding="2" cellspacing="0"  bordercolor="#666666" bordercolordark="#FFFFFF" bgcolor="#FFFFFF"  >
<?php
	echo "<tr bgcolor=\"#E6E6E6\">";
	echo "<td width=\"40%\">$strDescription</td>";
	echo "<td align =\"right\" width=\"30%\">$strTariffRentChargeAmount($moneyPara)</td>";
	echo "<td align =\"right\" width=\"30%\">$strUnitChargingTimeSecond</td>";
	echo "</tr>";

	/*    
	$arr_editfieldAmount = array("cf_charge_amount","roaming_charge_amount","cc_charge_amount","cug_charge_amount","fav_charge_amount","fav_change_charge","cf_cug_charge_amount","cf_fav_charge_amount","cug_fav_charge_amount","cf_cug_fav_charge_amount");
	$arr_editfieldUnit = array("cf_charge_unit","roaming_charge_unit","cc_charge_unit","cug_charge_unit","fav_charge_unit","","cf_cug_charge_unit","cf_fav_charge_unit","cug_fav_charge_unit","cf_cug_fav_charge_unit");
	$arr_description = array($strCallForwrd,$strRoaming,$strConferenceCall,$strCloseUserGroup,$strFav_call,$strFav_listedtion,$strCf_Cug_call,$strCf_Fav_call,$strCug_Fav_call,$strCf_Cug_Fav_call);
	$arr_amount = array($rows[cf_charge_amount],$rows[roaming_charge_amount],$rows[cc_charge_amount],$rows[cug_charge_amount],$rows[fav_charge_amount],$rows[fav_change_charge],$rows[cf_cug_charge_amount],$rows[cf_fav_charge_amount],$rows[cug_fav_charge_amount],$rows[cf_cug_fav_charge_amount]);
	$arr_unit = array($rows[cf_charge_unit],$rows[roaming_charge_unit],$rows[cc_charge_unit],$rows[cug_charge_unit],$rows[fav_charge_unit],"----",$rows[cf_cug_charge_unit],$rows[cf_fav_charge_unit],$rows[cug_fav_charge_unit],$rows[cf_cug_fav_charge_unit]);
	*/
	
	$arr_editfieldAmount = array("cf_charge_amount","roaming_charge_amount","cc_charge_amount","cug_charge_amount","fav_charge_amount","fav_change_charge","cf_cug_charge_amount","cf_fav_charge_amount","cug_fav_charge_amount","cf_cug_fav_charge_amount","pool_account_change_charge","pool_call_amount","act_free_sms_charge","deact_free_sms_charge");
	$arr_editfieldUnit = array("cf_charge_unit","roaming_charge_unit","cc_charge_unit","cug_charge_unit","fav_charge_unit","","cf_cug_charge_unit","cf_fav_charge_unit","cug_fav_charge_unit","cf_cug_fav_charge_unit","","pool_call_unit","","");
	$arr_description = array($strCallForwrd,$strRoaming,$strConferenceCall,$strCloseUserGroup,$strFav_call,"Friends and family number change fee",$strCf_Cug_call,$strCf_Fav_call,$strCug_Fav_call,$strCf_Cug_Fav_call,"Pool account change fee","Pool call","Active free SMS charge","Deactive free SMS charge");
	$arr_amount = array($rows[cf_charge_amount],$rows[roaming_charge_amount],$rows[cc_charge_amount],$rows[cug_charge_amount],$rows[fav_charge_amount],$rows[fav_change_charge],$rows[cf_cug_charge_amount],$rows[cf_fav_charge_amount],$rows[cug_fav_charge_amount],$rows[cf_cug_fav_charge_amount],$rows[pool_account_change_charge],$rows[pool_call_amount],$rows[act_free_sms_charge],$rows[deact_free_sms_charge]);
	$arr_unit = array($rows[cf_charge_unit],$rows[roaming_charge_unit],$rows[cc_charge_unit],$rows[cug_charge_unit],$rows[fav_charge_unit],"----",$rows[cf_cug_charge_unit],$rows[cf_fav_charge_unit],$rows[cug_fav_charge_unit],$rows[cf_cug_fav_charge_unit],"----",$rows[pool_call_unit],"----","----");
	

	for ($i=0;$i<14;$i++){
		echo "<tr>";
		echo "<td><a href=\"./tariffServicesEdit.php?description=$arr_description[$i]&arr_editfieldAmount=$arr_editfieldAmount[$i]&arr_editfieldUnit=$arr_editfieldUnit[$i]&tariffID=$tariff_id\" target=\"_self\">$arr_description[$i]</a></td>";
		echo "<td align=\"right\">$arr_amount[$i]</td>";
		/*if($moneyPara < 10){
			printf("<td align=\"right\">%5.0f</td>", $arr_amount[$i]/$moneyPara);
		}
		elseif($moneyPara < 100){
			printf("<td align=\"right\">%5.1f</td>", $arr_amount[$i]/$moneyPara);
		}
		else{
			printf("<td align=\"right\">%5.2f</td>", $arr_amount[$i]/$moneyPara);
		}*/
		echo "<td align =\"right\">&nbsp;$arr_unit[$i]</td>";
		echo "</tr>";
		echo $tariffID;
	}
?>
</table> 
<?php
adjust_content_tail();
?>
 </body>  
</html>   
