<?php
/*************************************************
File name:  cos.php
Author:     Cui Ticun
Version:    8.02.00
Date:       2007-11-9
Description:Set PPS's COS Parameters
Calls:		header.inc,operwebfunc.inc
Called:

History:
No.1:
Author:
Date:
Version:
Description:
*************************************************/
$DEBUG = 0;
require("../../inc/header.inc");
require("../sub_inc/operwebfunc.inc");

//---------------------------------------------------------
//Variable definitions
//---------------------------------------------------------
	
$objDb='OBJ_360';
$table_name='param_99';
$sysId	='360_99_99';
$nProcFail	= 0;//failure
$nWaitProc	= 1;//wait
$nInProc	= 2;
$nOutProc	= 3;
$maxNum		= 30;
$nGetComm	= 0;
$nSetComm	= 3;
$objIdStr	='2.1.4';
$currentCosObjIdstr=$objIdStr.'.'.($cos_id+1);
$objIdWhere=getLevelWhere($objIdStr);

$strThisPage=$strTitleAccount.$strTitleSpace."COS";
//$strThisPage=$strConfiguration.$strTitleSpace."PPS".$strTitleSpace."COS";
?>

<base>
<body leftmargin="15" rightmargin="10" onload="javascript:adjust();" onresize="javascript:adjust();" style="overflow:hidden;overflow-x:hidden;overflow-y:hidden;">

<script LANGUAGE="JavaScript">  
function selectTitle(){      
	var base_url,url_add,url; 
	base_url='<?php echo "$PHP_SELF?cos_id=";?>';
	url_add=document.selectform.cos_id.options[document.selectform.cos_id.selectedIndex].value;      
	url=base_url+url_add;
	window.location=url;
}
</script>

<?php
adjust_head();
adjust_title_head();
if($_SERVER['REQUEST_METHOD'] == "POST"){
	echo "<br><br><br><br><br>";
	if(isset($setSys)){			
		//send set command
		$commIdStr	= sysCommSend($sysId,$nSetComm,$currentCosObjIdstr);	
		$showType="Set";
	}elseif(isset($getSys)){
		$commIdStr	= sysCommSend($sysId,$nGetComm,$currentCosObjIdstr);
		$showType="Get";
	}elseif(isset($saveSys)){
		$updSql = " UPDATE $table_name SET initValue = '01' 
		               WHERE  level_1 = '2' AND level_2 = '1' AND level_3 = '6' AND level_4 = '2'
					   ";
		$updRes = @mysqli_query($pubConn,$updSql);
		echo mysqli_error($pubConn);
		$commIdStr=sysCommSend($sysId,$nSetComm,'2.1.6.2');
		$showType="Save parameter to system";
	}/*elseif(isset($resetSys)){
		$updSql = " UPDATE $table_name SET initValue = '01' 
		               WHERE  level_1 = '2' AND level_2 = '1' AND level_3 = '6' AND level_4 = '2'
					   ";
		$updRes = @mysqli_query($pubConn,$updSql);
		echo mysqli_error($pubConn);
		$commIdStr=sysCommSend($sysId,$nSetComm,'2.1.6.2');   
	}*/
	
	if($DEBUG) echo "<BR>commIdStr  =$commIdStr";
	$i = 0;
	while(1)
	{
		//echo "<br>i=$i";
		if($i == 0)
			echo "<br>$showType";
		if($i > $maxNum){
			echo "<br><font size=\"2\" color=\"#FF0000\">Timeout</font>";
			break;
		}
		echo "<img border=\"0\" src=\"../../images/arrow.gif\" width=\"10\" height=\"10\">";
		flush();	
		$sysId = "360_99_99";
		$chkType = "0";
		$chRes=ChComm($sysId,$chkType);
		//echo "<br>chRes=$chRes";
		if($chRes == $nOutProc || $chRes == $nProcFail){
			if($chRes == $nProcFail)
				echo "<br><font size=\"2\" color=\"#FF0000\">$remark</font><br>";
			elseif($remark == 'response timeout')
				echo "<br><font size=\"2\" color=\"#FF0000\">$remark</font><br>";
			else
				echo "<br><font size=\"2\" color=\"#0000FF\">$remark</font><br>";
			break;
		}

		sleep(1);
		$i++;
	}
	
	if(isset($getSys)){
		$moveSql = "UPDATE $table_name SET initValue = readValue   
				WHERE $objIdWhere
				";
		if($DEBUG) echo "<BR>moveSql=$moveSql";
		mysqli_query($pubConn,$moveSql);
		echo mysqli_error($pubConn);
	}
}

if($setSys || $getSys || $saveSys ||$resetSys){
	echo "<br>";
	echo "<p align=\"left\"><a href=\"$PHP_SELF?cos_id=$cos_id\" target=\"contents\"><img align=absBottom border=0 src=\"../../images/left.gif\" width=\"14\" height=\"14\">$strBack</a>";
	exit();
}
?>

<?php
function ChComm($sysId,$chkType)
{     
	global $remark,$nProcFail,$nWaitProc,$nInProc,$nOutProc;

	$commTable = "parameterComm";
	
	$sysIdArr = explode('_',$sysId);
	$sysTypeNo	= $sysIdArr[0];
	$sysNo		= $sysIdArr[1];
	$subSysNo	= $sysIdArr[2];
	
	if($chkType==0)
		$selComm = " SELECT commState,remark FROM $commTable WHERE sysTypeNo = '$sysTypeNo' ";
	else
		$selComm = " SELECT commState,remark FROM $commTable WHERE sysTypeNo = '$sysTypeNo' AND sysNo = '$sysNo' ";
	
	$selRes  = @mysqli_query($pubConn,$selComm);
	$selRow  = @mysqli_fetch_array($selRes);
	echo mysqli_error($pubConn);
	$outProcCount=0;
	do
	{
		$temCommState = $selRow[commState];
		if(isset($selRow[remark])){
			$remark = $selRow[remark];
			if($DEBUG)echo "<br>remark=$remark";
		}
		if($DEBUG)echo "<br>temCommState=$temCommState";
		if($temCommState == $nWaitProc){
			return($nWaitProc);
		}elseif($temCommState == $nInProc){
			return($nInProc);
		}elseif($temCommState == $nOutProc){
			$commState = $nOutProc;
			$outProcCount++;
		}else{
			$commState = $nProcFail;
		}
	}while($selRow  = @mysqli_fetch_array($selRes));
	if($outProcCount > 0){
		return($nOutProc);
	}else{
		return($nProcFail);
	}
}
?>


<form method="POST" name="selectform" action="<?php echo "$PHP_SELF";?>">
<?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\" title=\"Help\">";
$helpId="2.2.4";
showHelp($helpId);
echo "</td>";
echo "</tr>";
echo "<tr>";
echo "<td align=\"left\">";

echo "<b>System:</b>&nbsp;&nbsp;";
echo "<input type=\"submit\" name=\"getSys\" value=\"$strGet\" class=\"button\" style=\"left: 1; top: 2; width: 60; height: 20; position: relative\">";
echo "<input type=\"submit\" name=\"setSys\" value=\"$strSet\" class=\"button\" style=\"left: 1; top: 2; width: 50; height: 20; position: relative\">";
echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Command:</b>&nbsp;&nbsp;";
echo "<input type=\"submit\" name=\"saveSys\" value=\"$strSave\" class=\"button\" style=\"left: 1; top: 2; width: 60; height: 20; position: relative\">";

echo "</td>";
echo "<td align=\"right\">";

echo "<b>COS ID</b>";
echo "&nbsp;&nbsp;&nbsp;&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=\"cos_id\" onChange=\"javascript:selectTitle()\">";       
for($i=0;$i< $maxCosNum;$i++){
  $m=($i<10?"0":"").$i;       
    if($m != $cos_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>";

//echo "<input type=\"submit\" name=\"resetSys\" value=\"$strReset\" class=\"button\" style=\"left: 1; top: 2; width: 60; height: 20; position: relative\">";
//echo "</table>";     
?>



<?php
//COS ID
$cos_id=$cos_id+1;

//Tariff表格
$tableHeader		="<table border=\"1\" width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" 
						bordercolor=\"#666666\" bordercolordark=\"#FFFFFF\">";
$tableHeaderNoBorder="<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" 
						bordercolor=\"#666666\" bordercolordark=\"#FFFFFF\">";


?>


<?php
//Tariff title
echo "<br>";
echo "\n $tableHeader";    

echo "\n <tr bgcolor=\"#F3F3F3\">";	
echo "<td width=\"180\"><b>Title</b></td>";
echo "<td>";
$titleId=$objIdStr.'.'.$cos_id.'.10';
showParameter($sysId,$titleId,1,3);
//echo "($sysId,$titleId,1,1)";
echo "</td>";
echo "</tr>";
echo "</table>";   
?>
<!--
<?php
echo "\n $tableHeader";
echo "\n <tr bgcolor=\"#F3F3F3\">";	
echo "<td width=\"180\"><b>COS Title</td>";
echo "<td>";
echo "<input type=\"text\" name=\"minbalance\" size=\"16\" value=\"Service Plan XX\" style=\"font-family: Verdana; font-size: 10px\" maxLength=\"16\">";
echo "</td>";
echo "</tr>";  
echo "</table>";
?>
-->

<?php
//Tariff表格
echo "<br>";
echo "\n $tableHeader";    

echo "\n <tr bgcolor=\"#F3F3F3\">";	
echo "<td colspan=2><b>Tariff</b></td>";
echo "</tr>";
    
echo "<tr>";
echo "<td width=\"180\">";
echo "MO Tariff ID";
echo "</td>";
echo "<td>";
$moTariffId=$objIdStr.'.'.$cos_id.'.2.1';
showParameter($sysId,$moTariffId,1,1);
//echo "($sysId,$moTariffId,1,1)";
echo "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>";
echo "MT Tariff ID";
echo "</td>";
echo "<td>";
$moTariffId=$objIdStr.'.'.$cos_id.'.2.2';
showParameter($sysId,$moTariffId,1,1);
//echo "($sysId,$moTariffId,1,1)";
echo "</td>";
echo "</tr>"; 
echo "</table>";   
?>


<?php
//Tariff subscription表格
echo "<br><br>";
echo "\n $tableHeader";

echo "\n <tr bgcolor=\"#F3F3F3\">";	
echo "<td colspan=2><b>Tariff Subscription</b></td>";
echo "</tr>";

echo "<tr>";
echo "<td width=\"180\">";
echo "Charge By";
echo "</td>";
echo "<td>";
$tariffSubId=$objIdStr.'.'.$cos_id.'.2.3';
showParameter($sysId,$tariffSubId,1,1);
//echo "($sysId,$tariffSubId,1,1)";
echo "</td>";
echo "</tr>";
echo "</table>";
?> 

<?php
//service control表格
echo "<br><br>";
echo "\n $tableHeader";

echo "\n <tr bgcolor=\"#F3F3F3\">";	
echo "<td colspan=2><b>Service Control</b></td></tr>";
//MO Call
echo "<tr>";
echo "<td width=\"180\">MO Call</td>";
echo "<td>";
	echo "$tableHeaderNoBorder";
	echo "<tr>";
	echo "<td width=\"180\">Set Threshold for MO Call</td>";
	echo "<td>";
	$minbalanceId=$objIdStr.'.'.$cos_id.'.3.1';
	showParameter($sysId,$minbalanceId,1,1);
	//echo "($sysId,$minbalanceId,1,1)";
	echo "</td>";
	echo "</tr>";
			
	echo "<tr>";
	echo "<td width=\"180\">Minimum Balance for MO</td>";
	echo "<td>";
	$minbalanceId=$objIdStr.'.'.$cos_id.'.3.1';
	showParameter($sysId,$minbalanceId,2,1);
	//echo "($sysId,$minbalanceId,2,1)";
	echo "&nbsp;&nbsp;(currency unit)";
	echo "</td>";
	echo "</tr>";
	echo "</table>";
echo "</td>";
echo "<tr>";

//MT Call
echo "<tr>";
echo "<td width=\"180\">MT Call</td>";
echo "<td>";
	echo "$tableHeaderNoBorder";
	echo "<tr>";
	echo "<td width=\"180\">Charged Flag</td>";
	echo "<td>";
		$mtChargeId=$objIdStr.'.'.$cos_id.'.4.1';
		showParameter($sysId,$mtChargeId,1,1);
		//echo "($sysId,$mtChargeId,1,1)";
	echo "</td>";
	echo "</tr>";
	
	echo "<tr>";
	echo "<td width=\"180\">Balance Control</td>";
	echo "<td>";
	$mtZeroId=$objIdStr.'.'.$cos_id.'.4.2';
	showParameter($sysId,$mtZeroId,1,1);
	//echo "($sysId,$mtZeroId,1,1)";
	echo "</td>";
	echo "</tr>";
	
	echo "<tr>";
	echo "<td width=\"180\">Balance Threshold</td>";
	echo "<td>";
	$mtZeroId=$objIdStr.'.'.$cos_id.'.4.3';
	showParameter($sysId,$mtZeroId,1,1);
	//echo "($sysId,$mtZeroId,1,1)";
	echo "</td>";
	echo "</tr>";
	echo "</table>";
echo "</td>";

//F&&F Number
echo "<tr>";
echo "<td>Friends & Family Number</td>";
echo "<td>";
	echo "$tableHeaderNoBorder";
	
	echo "<tr>";
	echo "<td width=\"180\">Flag</td>";      
	echo "<td>";
	$ffNumberId=$objIdStr.'.'.$cos_id.'.5.5';   
	showParameter($sysId,$ffNumberId,2,1);
	//echo "($sysId,$ffNumberId,2,1)";
	echo "</td>";
	echo "</tr>";
	
	echo "<tr>";
	echo "<td width=\"180\">Charge Flag</td>";
	echo "<td>";
	showParameter($sysId,$ffNumberId,3,1);
	//echo "($sysId,$ffNumberId,3,1)";
	echo "</td>";
	echo "</tr>";
	
	echo "<tr>";
	echo "<td>Free Changes</td>";
	echo "<td>";
	showParameter($sysId,$ffNumberId,5,1);
	//echo "($sysId,$ffNumberId,5,1)";
	echo "&nbsp;&nbsp;(times)";
	echo "</td>";
	echo "</tr>";
	echo "</table>";
echo "</td>";
	
echo "<tr>";
echo "<td>Others</td>";
echo "<td>";
	echo "$tableHeaderNoBorder";
	
	echo "<tr>";
	echo "<td width=\"180\">Close User Group Service";
	echo "<td>";
	showParameter($sysId,$ffNumberId,1,1);
	//echo "($sysId,$ffNumberId,1,1)";
	echo "</td>";
	echo "</tr>";
	
	echo "<tr>";
	echo "<td width=\"180\">Recharge via Credit Card</td>";
	echo "<td>";
	$rechargeViaCardId=$objIdStr.'.'.$cos_id.'.5.6';
	showParameter($sysId,$rechargeViaCardId,1,1);
	//echo "($sysId,$rechargeViaCardId,1,1)";
	echo "</td>";
	echo "</tr>";
	
	echo "<tr>";
	echo "<td width=\"180\">Credit Vault</td>";
	echo "<td>";
	$creditVaultServiceId=$objIdStr.'.'.$cos_id.'.5.7';
	showParameter($sysId,$creditVaultServiceId,1,1);
	//echo "($sysId,$creditVaultServiceId,1,1)";
	echo "</td>";
	echo "</tr>";

	echo "<tr>";
	echo "<td width=\"180\">Credit Vault Amount</td>";
	echo "<td>";
	showParameter($sysId,$creditVaultServiceId,2,1);
	//echo "($sysId,$creditVaultServiceId,2,1)";
	echo "</td>";
	echo "</tr>";
	echo "</table>";
echo "</td>";
echo "</tr>";
echo "</table>";
 ?>

<?php
//Account validity表格
echo "<br><br>";
echo "\n $tableHeader";

echo "\n <tr bgcolor=\"#F3F3F3\">";	
echo "<td colspan=2><b>Account Validity</b></td>";
echo "<tr>";
echo "<td width=\"180\">Account Expiration</td>";
echo "<td>";
	echo "$tableHeaderNoBorder";
	echo "<td width=\"180\">Maximum account validity is</td>";
	echo "<td width=\"80\">";
	$maxvalidityId=$objIdStr.'.'.$cos_id.'.3.2';
	showParameter($sysId,$maxvalidityId,1,1);
	//echo "($sysId,$maxvalidityId,1,1)";
	echo "&nbsp;&nbsp;(days).";
	echo "</td>";
	echo "<td width=\"180\">When account expires</td>";
	echo "<td><nobr>";
	$clearBalanceId=$objIdStr.'.'.$cos_id.'.5.1';
	showParameter($sysId,$clearBalanceId,1,1);
	//echo "($sysId,$clearBalanceId,1,1)";
	echo "</td>";
	
	//--
	echo "<td width=\"30\"><nobr>Expired when</td>";
	echo "<td>";
	showParameter($sysId,$clearBalanceId,3,1);
	//echo "($sysId,$clearBalanceId,1,1)";
	echo "</td>";
	//--
	
	echo "</tr>";
	
	echo "<tr>";
	echo "<td width=\"180\">Keep an expired account for";
	echo "<td width=\"80\">";
	$keepExpireDayId=$objIdStr.'.'.$cos_id.'.3.3';
	showParameter($sysId,$keepExpireDayId,1,1);
	//echo "($sysId,$keepExpireDayId,1,1)";
	echo "&nbsp;&nbsp;(days).";
	echo "</td>";
	echo "<td width=\"180\">After that";
	echo "<td>";
	showParameter($sysId,$clearBalanceId,2,1);
	//echo "($sysId,$clearBalanceId,2,1)";
	echo "</td>";
	
	//--
	echo "</td>";
	echo "<td width=\"180\">SMS Notification</td>";
	echo "<td>";
	showParameter($sysId,$clearBalanceId,4,1);
	echo "</td>";
	//--
	
	echo "</tr>";
	echo "</table>";
echo "</td>";
echo "</tr>";

echo "<tr>";
echo "<td>Validity Adjustment</td>";
echo "<td>"	;
	echo "$tableHeaderNoBorder";
	echo "<tr>";
	echo "<td width=\"180\">After recharge, account validity</td>";
	echo "<td>";
	$balanceAfRechargeId=$objIdStr.'.'.$cos_id.'.5.2';
	showParameter($sysId,$balanceAfRechargeId,1,1);
	//echo "($sysId,$balanceAfRechargeId,1,1)";
	echo "</td>";
	echo "</tr>";
	
	echo "<tr>";
	echo "<td width=\"180\">When balance is depleted, change account validity</td>";
	echo "<td width=\"80\">";
	$validityBalanceId=$objIdStr.'.'.$cos_id.'.5.3';
	showParameter($sysId,$validityBalanceId,1,1);
	//echo "($sysId,$validityBalanceId,1,1)";
	echo "</td>";
	echo "<td width=\"180\">Change validity to</td>";
	echo "<td>";
	showParameter($sysId,$validityBalanceId,2,1);
	//echo "($sysId,$validityBalanceId,2,1)";
	echo "&nbsp;&nbsp(days)";
	echo "</td>";
	echo "</tr>";
	
	echo "<tr>";
	echo "<td width=\"180\">Activation by inquiring is</td>";
	echo "<td width=\"80\">";
	$activatedAccountValidityId=$objIdStr.'.'.$cos_id.'.5.4';
	showParameter($sysId,$activatedAccountValidityId,1,1);
	//echo "($sysId,$activatedAccountValidityId,1,1)";
	echo "</td>";
	echo "<td width=\"180\">Validity of activated account with zero balance </td>";
	echo "<td>";
	showParameter($sysId,$activatedAccountValidityId,2,1);
	//echo "($sysId,$activatedAccountValidityId,2,1)";
	echo "</td>";
	echo "</tr>";
	echo "</table>";
echo "</td>";
echo "</tr>";
echo "</table>";
?>


<?php
//SMS notification表格
echo "<br><br>";

echo "\n $tableHeader";
echo "\n <tr bgcolor=\"#F3F3F3\">";	
echo "<td colspan=2><b>Short Message Notification & Inquiry</b></td>";
echo "<tr>";
echo "<td width=\"180\">Short Message Notification</td>";
echo "<td>";
	echo "$tableHeaderNoBorder";
	echo "<tr>";
	echo "<td width=\"180\">Successful Recharge";
	echo "<td>";
	$feedbackSMId=$objIdStr.'.'.$cos_id.'.6.1';
	showParameter($sysId,$feedbackSMId,1,1);
	//echo "($sysId,$feedbackSMId,1,1)";
	echo "</td>";
	
	echo "<td width=\"180\">CAP Plan about to change";
	echo "<td>";
	showParameter($sysId,$feedbackSMId,3,1);
	//echo "($sysId,$feedbackSMId,1,1)";
	echo "</td>";
	
	echo "</tr>";

	echo "<tr>";
	echo "<td width=\"180\">Account Inquiry</td>";
	echo "<td>";
	showParameter($sysId,$feedbackSMId,2,1);
	//echo "($sysId,$feedbackSMId,2,1)";
	echo "</td>";
	echo "</tr>";

	echo "<tr>";
	echo "<td width=\"180\">Expiration</td>";
	echo "<td width=\"80\">";
	$SMExpiryId=$objIdStr.'.'.$cos_id.'.6.3';
	showParameter($sysId,$SMExpiryId,1,1);
	//echo "($sysId,$SMExpiryId,1,1)";
	echo "<td width=\"180\">";
	showParameter($sysId,$SMExpiryId,2,1);
	//echo "($sysId,$SMExpiryId,2,1)";
	echo "&nbsp;&nbsp(days) before expiration";
	echo "</td>";
	echo "</tr>";
	
	echo "<tr>";
	echo "<td width=\"180\">Insufficient Balance";
	echo "<td width=\"80\">";
	$SMLowBalanceId=$objIdStr.'.'.$cos_id.'.6.4';
	showParameter($sysId,$SMLowBalanceId,1,1);
	//echo "($sysId,$SMLowBalanceId,1,1)";
	echo "<td width=\"180\">";
	echo "When balance reaches&nbsp;&nbsp;&nbsp;&nbsp";
	echo "</td>";
	echo "<td>";
	showParameter($sysId,$SMLowBalanceId,2,1);
	//echo "($sysId,$SMLowBalanceId,2,1)";
	echo "&nbsp;&nbsp(currency unit)";
	echo "</td>";
	echo "</tr>";
	echo "</table>";
echo "</td>";
echo "</tr>";
	
echo "<tr>";
echo "<td width=\"180\">Inquiry by Short Message</td>";
echo "<td>";
echo "$tableHeaderNoBorder";
	echo "<tr>";
	echo "<td width=\"180\">Charge</td>";
	echo "<td>";
	$InquirySMId=$objIdStr.'.'.$cos_id.'.6.2';
	showParameter($sysId,$InquirySMId,1,1);
	//echo "($sysId,$InquirySMId,1,1)";
	echo "</td>";
	echo "</tr>";
	echo "<tr>";
	
	echo "<td width=\"180\">Free Inquiry per Day</td>";
	echo "<td>";
	showParameter($sysId,$InquirySMId,2,1);
	//echo "($sysId,$InquirySMId,2,1)";
	echo "&nbsp;&nbsp(times)";
	echo "</td>";
	echo "</tr>";
	echo "</table>";
echo "</td>";
echo "</tr>";
echo "</table>";
?>

<?php
//Recharge card validity表格
echo "<br><br>";

echo "\n $tableHeader";
echo "\n <tr bgcolor=\"#F3F3F3\">";	
echo "<td colspan=2><b>Recharge Card Validity</b></td></tr>";
$rechargeCardValidityId=$objIdStr.'.'.$cos_id.'.2.4';    
for($instanceNo=0;$instanceNo<4;$instanceNo++){
	echo "<tr>";
	echo "<td width=\"180\">Recharge Card Type $instanceNo</td>";
	echo "<td>";
	echo "$tableHeaderNoBorder";
		echo "<tr>";
		echo "<td width=\"80\">Card Credit</td>";
		echo "<td width=\"100\">";
		showParameter($sysId,$rechargeCardValidityId,1,1,$instanceNo);
		//echo "($sysId,$rechargeCardValidityId,1,1,$instanceNo)";
		echo "</td>";
		echo "<td width=\"80\">MO Validity</td>";
		echo "<td width=\"100\">";
		showParameter($sysId,$rechargeCardValidityId,2,1,$instanceNo);
		//echo "($sysId,$rechargeCardValidityId,2,1,$instanceNo)";
		echo "</td>";
		echo "<td width=\"80\">MT Validity</td>";
		echo "<td>";
		showParameter($sysId,$rechargeCardValidityId,3,1,$instanceNo);
		//echo "($sysId,$rechargeCardValidityId,3,1,$instanceNo)";
		echo "</td>";
		echo "</tr>";
	echo "</table>";
	echo "</td>";
	echo "</tr>";
}
echo "</table>";
?>

<?php
//Recharge promotion表格
echo "<br><br>";
echo "\n $tableHeader";

echo "\n <tr bgcolor=\"#F3F3F3\">";	
echo "<td colspan=2><b>Recharge Promotion</b></td></tr>";
echo "<tr>";   
echo "<td colspan=2>";
echo "$tableHeaderNoBorder";
	echo "<tr>";
	$startDateId=$objIdStr.'.'.$cos_id.'.1.1'; 
	echo "<td width=\"180\">Start Date:20";
	showParameter($sysId, $startDateId,1,1);
	//echo "($sysId, $startDateId,1,1)";
	echo "/";
	showParameter($sysId, $startDateId,2,1);
	//echo "($sysId, $startDateId,2,1)";
	echo "/";
	showParameter($sysId, $startDateId,3,1);
	//echo "($sysId, $startDateId,3,1)";
	echo "</td>";
	
	$endDateId=$objIdStr.'.'.$cos_id.'.1.2'; 
	echo "<td>End Date:20";
	showParameter($sysId, $endDateId,1,1);
	//echo "($sysId, $endDateId,1,1)";
	echo "/";
	showParameter($sysId, $endDateId,2,1);
	//echo "($sysId, $endDateId,2,1)";
	echo "/";
	showParameter($sysId, $endDateId,3,1);
	//echo "($sysId, $endDateId,3,1)";
	echo "</td>";
	echo "</tr>";   
	echo "</table>"  ; 
echo "</td>";
echo "</tr>";

$promotionBonusId= $objIdStr.'.'.$cos_id.'.1.3'; 
for($instanceNo=0;$instanceNo<4;$instanceNo++){
	echo "<tr>";
	echo "<td width=\"180\">Promotion $instanceNo</td>";
	echo "<td>";
		echo "$tableHeaderNoBorder";
		echo "<tr>";
		echo "<td width=\"140\">Recharge Card Credit</td>";  
		echo "<td width=\"40\">";
		showParameter($sysId,$promotionBonusId,1,1,$instanceNo); 
		//echo "($sysId,$promotionBonusId,1,1,$instanceNo)";
		echo "</td>";        
		echo "<td width=\"105\">Promotion Bonus</td>";
		echo "<td width=\"75\">";		
		showParameter($sysId,$promotionBonusId,2,1,$instanceNo); 
		//echo "($sysId,$promotionBonusId,2,1,$instanceNo)";
		echo "<td width=\"90\">Bonus Validity</td>";
		echo "<td>";	
		showParameter($sysId,$promotionBonusId,3,1,$instanceNo); 
		//echo "($sysId,$promotionBonusId,3,1,$instanceNo)";
		echo "</td>";
		echo "</tr>";
		echo "</table>";
	echo "</td>";
	echo "</tr>";
}
echo "</table>";
?>

<?php
//CAP Plan表格
echo "<br><br>";
echo "\n $tableHeader";

echo "\n <tr bgcolor=\"#F3F3F3\">";	
echo "<td colspan=2><b>CAP Plan</b></td></tr>";
echo "<tr>";   
echo "<td colspan=2>";
echo "Reset Date:";
$resetDayId=$promotionBonusId= $objIdStr.'.'.$cos_id.'.7.1'; 
showParameter($sysId,$resetDayId,1,1); 
//echo "($sysId,$resetDayId,1,1)";
echo "</td>";
echo "</tr>";
 
for($i=0;$i<4;$i++){
	$capPlanId= $objIdStr.'.'.$cos_id.'.7.'.($i+2); 
	echo "<tr>";
	if($i % 2 == 0)
		echo "<td width=\"180\">CAP Plan $i (Home Network)</td>";
	else
		echo "<td width=\"180\">CAP Plan $i (Other Network)</td>";
	echo "<td>";
		echo "$tableHeaderNoBorder";
		echo "<tr>";
		echo "<td width=\"80\">Flag</td>";  
		echo "<td width=\"100\">";
		showParameter($sysId,$capPlanId,1,1); 
		//echo "($sysId,$capPlanId,1,1)";
		echo "</td>"; 
		
		echo "<td width=\"80\">Type</td>";  
		echo "<td width=\"100\">";
		showParameter($sysId,$capPlanId,2,1); 
		//echo "($sysId,$capPlanId,2,1)";
		echo "</td>";   
		echo "</tr>";  
		/*    
		echo "<tr>";
		echo "<td width=\"80\">Type</td>";  
		echo "<td width=\"100\">";
		showParameter($sysId,$capPlanId,2,1); 
		echo "</td>";  
		echo "</tr>";   
		*/
		echo "<tr>";
		echo "<td width=\"80\">Threshold 0 </td>"; 
		echo "<td width=\"100\">"; 
		showParameter($sysId,$capPlanId,3,1); 
		//echo "($sysId,$capPlanId,3,1)";
		echo "</td>";  
		echo "<td width=\"80\">Threshold 1 </td>";  
		echo "<td width=\"100\">";
		showParameter($sysId,$capPlanId,4,1); 
		//echo "($sysId,$capPlanId,4,1)";
		echo "</td>";  
		echo "<td width=\"80\">Threshold 2 </td>";  
		echo "<td width=\"100\">";
		showParameter($sysId,$capPlanId,5,1); 
		//echo "($sysId,$capPlanId,5,1)";
		echo "</td>";  
		
		echo "</tr>";      
		
		
		echo "<tr>";
		echo "<td width=\"80\">Tariff ID 0 </td>"; 
		echo "<td width=\"100\">"; 
		showParameter($sysId,$capPlanId,6,1);
		//echo "($sysId,$capPlanId,6,1)"; 
		echo "</td>";  
		echo "<td width=\"80\">Tariff ID 1 </td>";  
		echo "<td width=\"100\">";
		showParameter($sysId,$capPlanId,7,1); 
		//echo "($sysId,$capPlanId,7,1)";
		echo "</td>";  
		echo "<td width=\"80\">Tariff ID 2 </td>"; 
		echo "<td width=\"100\">"; 
		showParameter($sysId,$capPlanId,8,1); 
		//echo "($sysId,$capPlanId,8,1)";
		echo "<td width=\"80\">Tariff ID 3 </td>"; 
		echo "<td>"; 
		showParameter($sysId,$capPlanId,9,1); 
		//echo "($sysId,$capPlanId,9,1)";
		echo "</td>";  
		echo "</tr>";   
	
		
		echo "</table>";
	echo "</td>";
	echo "</tr>";
}

?>
</form>
<?php
adjust_content_tail();
?>
</body>
</html>   
