<?php
require("../sub_inc/commfunc.php");
$DEBUG = 0;
if($DEBUG) echo "<br>正在调试中！！";
?>

<script LANGUAGE="JavaScript">       
function delFirm(No,flag,init)
{
	var delValue,x,y;
	x = document.body.scrollLeft;
	y = document.body.scrollTop;
    
	if(confirm('Do you want to delete the selected?') != true)
		window.location.href='<?php echo $PHP_SELF;?>';
	else
		window.location.href='<?php echo $PHP_SELF;?>?&delflag='+flag+'&delValue='+No+'&init='+init;
}
</script>


<?php
$scroll_y = isset($scroll_y) ? $scroll_y : 0;
echo "<body topmargin=\"0\" onLoad=\"self.scrollBy(0,$scroll_y);\" leftmargin=\"12\">";

//test
//echo "smsFormatShow:$isShowSms<br>";

$helpID = "1.1.1";

$nProcFail = 0;//failure
$nWaitProc = 1;//wait
$nInProc   = 2;
$nOutProc  = 3;

$nGetComm = 0;
$nSetComm = 3;
	
$maxNum = 120;

$mtp3_sqlTable = 'OBJ_222.param_99';
$sqltable = 'OBJ_360.param_99';
$sqltable_conf = 'OBJ_360.paramConf';
$sqltable_sccp = 'OBJ_223.param_99';
$sysStatTable='OMC_PUB.sysStat';
$pubdb = 'OMC_PUB';
$sysId = '360_99_99';
$sysOid = "2.1.4.$level_4" ;

$sysId_arr=array(
	array('oid'=>$sysOid,		'sysid'=> '360_99_99',		'selectsysid'=>'-1'), 										
);

$SaveArr=array(
				array('oidstr'=>'3.3',	'setvalue'=>'01'	,'sysid'=>'350_99_99'),
);	

$url_add = './pps.php';
$post_url = "$PHP_SELF?level_4=$level_4&scroll_y=$scroll_y";
$back_url = "./pps_cos.php?level_4=$level_4";

{//update elementParamConf level_4
	$selSql = "select paramOBJ from OBJ_360.elementParamConf where paramOBJ like '2.1.4%' ";
	$Result = mysqli_query($pubConn,$selSql);
	while($rows = mysqli_fetch_array($Result))
	{
		$tmpArr = explode('.',$rows[paramOBJ]);
		$setValue = '';
		for($i=0; $i< sizeof($tmpArr); $i++)
		{
			if($i==3)
				$setValue .= ".$level_4";
			else
				$setValue .= ".{$tmpArr[$i]}";
		}
		$setValue = trim($setValue, '.');
		$updSql = "update OBJ_360.elementParamConf set paramOBJ='$setValue' where paramOBJ='{$rows[paramOBJ]}'";
		mysqli_query($pubConn,$updSql);
	}
}//end update elementParamConf level_4

if($_SERVER['REQUEST_METHOD'] == "POST")
{
	if(isset($setSys) || isset($getSys))
	{
		if(isset($setSys))
		{
			echo "<br>Setting parameters<br>";
				
			SetParam($sysId_arr);	
			session_register("SetFlag");
						
			$showType="Set";
			echo "<br>Sending save command<br>";
			SaveParam($SaveArr);
			echo "<script LANGUAGE=\"JavaScript\">";
			if(!$DEBUG)
				echo "\n window.location.href=\"../mss/pps.php?smsShow=1&scroll_y=9000\";";
			echo "\n </script>";	
			exit();			
		}
		else
		{ 
			echo "<br>Getting parameters<br>";
			session_register("GetFlag");
			GetParam($sysId_arr);
			$showType="Get";
		}
	}
	
	echo "<script LANGUAGE=\"JavaScript\">";
	if(!$DEBUG)
		echo "\n window.location.href=\"$post_url\";";
	echo "\n </script>";	
	exit();	
}				

//==========================================================
//输出并显示数据
//========================================================== 

echo "<form method=\"POST\" name=\"Set\" action=$post_url>";
{
	echo "<table border=\"0\" width=\"100%\">";
	echo "<tr>";
	echo "<td width=\"50%\">";
	$cosNo = $level_4-1;
	echo "Configuration > <a href=\"../overview/overview.php\">Network</a> > <a href=\"./pps.php?srfShow=1\">PPS</a> > <a href=\"#\">COS $cosNo</a>";
	echo "<td width=\"50%\" align=\"right\" title=\"Help\">";
	//showHelp($helpId);
	echo "</td>";
	echo "</tr>";
	echo "</table>";
	echo "<br>";
	
{
	echo "<table width=\"100%\">";
	echo "<tr>";
		echo "<td width=\"70%\">";
			echo "<b>COS $cosNo edit:&nbsp;&nbsp;</b>";
		echo "</td>";
		echo "<td width=\"20%\" align=\"right\">";
				echo "<input type=\"submit\" title=\"$strTitleGet\" name=\"getSys\" value=\"$strGet\" class=\"button\" style=\"cursor:pointer; left: 1; top: 2; width: 60; height: 25; position: relative\">";
				echo "&nbsp;&nbsp;&nbsp;";
				echo "<input type=\"submit\" title=\"$strTitleSet\" name=\"setSys\" value=\"$strSet\" class=\"button\" style=\"cursor:pointer; left: 1; top: 2; width: 60; height: 25; position: relative\">";
			echo "</td>";
		echo "<td width=\"10%\">";
			echo "<p align=\"right\"><a href=\"../mss/pps.php?scroll_y=$sub_page_top&smsFormatShow=$isShowSms\"><img align=absBottom border=0 src=\"../../images/left.gif\" width=\"14\" height=\"14\">$strBack</a>";
		echo "</td>";
	echo "</tr>";
	echo "</table>";
}
}
?>
<TABLE  width=100%   border="1"  cellpadding="1" cellspacing="0"  bordercolor="#666666" bordercolordark="#FFFFFF" bgcolor="#FFFFFF"> 
<?php
{//Recharge Promotion
	
	{//Start Date
		$levelStartDate = "2.1.4.$level_4.1.1";
		$objWhereStr = getLevelWhere($levelStartDate);
		$setsql = "select initValue from $sqltable where $objWhereStr";
		$result = mysqli_query($pubConn,$setsql);
		echo mysqli_error($pubConn);
		$row = mysqli_fetch_array($result);
		$year = getBitValue($row[initValue],'0.0-0.7');
		$month = getBitValue($row[initValue],'01.0-01.7');
		$day = getBitValue($row[initValue],'02.0-02.7');
		$startDate = "$year-$month-$day";
	}
	
	{//end Date
		$levelEndDate = "2.1.4.$level_4.1.2";
		$objWhereStr = getLevelWhere($levelEndDate);
		$setsql = "select initValue from $sqltable where $objWhereStr";
		$result = mysqli_query($pubConn,$setsql);
		echo mysqli_error($pubConn);
		$row = mysqli_fetch_array($result);
		$year = getBitValue($row[initValue],'0.0-0.7');
		$month = getBitValue($row[initValue],'01.0-01.7');
		$day = getBitValue($row[initValue],'02.0-02.7');
		$endDate = "$year-$month-$day";
	}
	
	{//Promotion bonus
		$levelProBonus = "2.1.4.$level_4.1.3";
		$objWhereStr = getLevelWhere($levelProBonus);
		$defSql = "select initValue from $sqltable_conf where $objWhereStr";
		$defRes = mysqli_query($pubConn,$defSql);
		$defRow = mysqli_fetch_array($defRes);
		//echo "<br>$defSql";
		$setsql = "select instanceNo,initValue from $sqltable where $objWhereStr and initValue!='{$defRow[initValue]}'";
		$result = mysqli_query($pubConn,$setsql);
		echo mysqli_error($pubConn);
		$ProBonusNo=0;
		while($row = mysqli_fetch_array($result))
		{
			$promotionBonus[$ProBonusNo][cardCredit] = hexdec(getBitValue($row[initValue],'00.0-03.7'));
			$promotionBonus[$ProBonusNo][bonus] = hexdec(getBitValue($row[initValue],'04.0-07.7'));
			$promotionBonus[$ProBonusNo][validity] = hexdec(getBitValue($row[initValue],'08.0-08.7'));
			$promotionBonus[$ProBonusNo][instNo] = $row[instanceNo];
			$ProBonusNo++;
		}
		
		$setsql = "select instanceNo,initValue from $sqltable where $objWhereStr and initValue='{$defRow[initValue]}'";
		$result = mysqli_query($pubConn,$setsql);
		echo mysqli_error($pubConn);
		$row = mysqli_fetch_array($result);
		$newInstNo = $row[instanceNo];
	}

	$rowsRecPro = 4 + $ProBonusNo;
	echo "<tr >";
		echo "<td rowspan=$rowsRecPro width=\"8%\" bgcolor=\"#E6E6E6\" ><b>Recharge Promotion</b></td>";	
	echo "</tr>";
		
		echo "<tr >";
		echo "<td width=\"22%\" bgcolor=\"#E6E6E6\" >Start date</td>";
		$webName = "PPS";
		$setName = "start date";
		echo "<td colspan=\"4\" width=\"70%\"><a href=\"javascript:openSet('0','no-$levelStartDate','$sysId','$webName','$setName','$back_url')\">$startDate&nbsp;</a></td>";
		echo "</tr >";
		
		echo "<tr >";
		echo "<td width=\"22%\" bgcolor=\"#E6E6E6\" >End date</td>";
		$webName = "PPS";
		$setName = "end date";
		echo "<td colspan=\"4\" width=\"70%\"><a href=\"javascript:openSet('0','no-$levelEndDate','$sysId','$webName','$setName','$back_url')\">$endDate&nbsp;</a></td>";
		echo "</tr >";
		
		echo "<tr bgcolor=\"#E6E6E6\">";
		$rowProBonu = $ProBonusNo+1;
		echo "<td rowspan=$rowProBonu width=\"22%\" bgcolor=\"#E6E6E6\" >";
			echo "<table width=\"100%\">";
				echo "<tr>";
					echo "<td width=\"80%\">Promotion Bonus</td>";
					$webName = "PPS";
					$setName = "Promotion Bonus";
					if(!isset($newInstNo))
						$newInstNo=-1;
					echo "<td width=\"20%\" align=\"right\"><a href=\"javascript:openSet('$newInstNo','no-$levelProBonus','$sysId','$webName','$setName','$back_url')\"><font size=4>+</font></a></td>";
				echo "</tr>";
			echo "</table>";
		echo "</td>";
		echo "<td width=\"15%\">No.</td>";
		echo "<td width=\"20%\">Recharge card credit</td>";
		echo "<td width=\"15%\">Promotion bonus</td>";
		echo "<td width=\"20%\">Bonus validity</td>";
		echo "</tr>";
		for($i=0; $i< $ProBonusNo; $i++)
		{
			echo "<tr>";
			$instNo = $promotionBonus[$i][instNo];
			echo "<td><a href = \"javascript:openSet('$instNo','no-$levelProBonus','$sysId','$webName','$setName','$back_url')\">$i</a></td>";
			echo "<td>{$promotionBonus[$i][cardCredit]}</td>";
			echo "<td>{$promotionBonus[$i][bonus]}</td>";
			echo "<td>{$promotionBonus[$i][validity]}</td>";
			echo "</tr >";
		}
}//end Recharge Promotion

{//Tariff resolution
	
	{//MOTariffID
		$levelMOTariffID = "2.1.4.$level_4.2.1";
		$objWhereStr = getLevelWhere($levelMOTariffID);
		$setsql = "select initValue from $sqltable where $objWhereStr";
		$result = mysqli_query($pubConn,$setsql);
		echo mysqli_error($pubConn);
		$row = mysqli_fetch_array($result);
		$MOTariffID = $row[initValue];
	}
	
	{//MT tariff ID
		$levelMTTariffID = "2.1.4.$level_4.2.2";
		$objWhereStr = getLevelWhere($levelMTTariffID);
		$setsql = "select initValue from $sqltable where $objWhereStr";
		$result = mysqli_query($pubConn,$setsql);
		echo mysqli_error($pubConn);
		$row = mysqli_fetch_array($result);
		$MTTariffID = $row[initValue];
	}
	
	{//Tariff subscription
		$levelTariffSub = "2.1.4.$level_4.2.3";
		$objWhereStr = getLevelWhere($levelTariffSub);
		$setsql = "select initValue from $sqltable where $objWhereStr";
		$result = mysqli_query($pubConn,$setsql);
		echo mysqli_error($pubConn);
		$row = mysqli_fetch_array($result);
		$TariffSub = hexdec($row[initValue]);
		$TariffSubArr = array("Tariff set in subscriber profile","Parameter \"Basic tariff zone\"");
	}
	
	{//Recharge card validity
		$levelRechCardVali = "2.1.4.$level_4.2.4";
		$objWhereStr = getLevelWhere($levelRechCardVali);
		$defSql = "select initValue from $sqltable_conf where $objWhereStr";
		$defRes = mysqli_query($pubConn,$defSql);
		$defRow = mysqli_fetch_array($defRes);
		//echo "<br>$defSql";
		$setsql = "select instanceNo,initValue from $sqltable where $objWhereStr and initValue!='{$defRow[initValue]}'";
		$result = mysqli_query($pubConn,$setsql);
		echo mysqli_error($pubConn);
		$RechCardValNo=0;
		while($row = mysqli_fetch_array($result))
		{
			$RechargeCardVali[$RechCardValNo][Face] = hexdec(getBitValue($row[initValue],'00.0-01.7'));
			$RechargeCardVali[$RechCardValNo][MoVali] = hexdec(getBitValue($row[initValue],'02.0-03.7'));
			$RechargeCardVali[$RechCardValNo][MtVali] = hexdec(getBitValue($row[initValue],'04.0-05.7'));
			$RechargeCardVali[$RechCardValNo][instNo] = $row[instanceNo];
			$RechCardValNo++;
		}
		
		$setsql = "select instanceNo,initValue from $sqltable where $objWhereStr and initValue='{$defRow[initValue]}'";
		$result = mysqli_query($pubConn,$setsql);
		echo mysqli_error($pubConn);
		$row = mysqli_fetch_array($result);
		$newInstNo = $row[instanceNo];
	}

	$rowsRecPro = 5 + $RechCardValNo;
	echo "<tr >";
		echo "<td rowspan=$rowsRecPro width=\"8%\" bgcolor=\"#E6E6E6\" ><b>Tariff resolution</b></td>";	
	echo "</tr>";
		$webName = "PPS";
		$setName = "Tariff Resolution";
		$objId = "no-$levelMOTariffID-$levelMTTariffID-$levelTariffSub";
		echo "<tr >";
		echo "<td width=\"22%\" bgcolor=\"#E6E6E6\" >MO tariff ID</td>";
		echo "<td colspan=\"4\" width=\"70%\"><a href=\"javascript:openSet('0','$objId','$sysId','$webName','$setName','$back_url')\">$MOTariffID&nbsp;</a></td>";
		echo "</tr >";
		
		echo "<tr >";
		echo "<td width=\"22%\" bgcolor=\"#E6E6E6\" >MT tariff ID</td>";
		echo "<td colspan=\"4\" width=\"70%\"><a href=\"javascript:openSet('0','$objId','$sysId','$webName','$setName','$back_url')\">$MTTariffID&nbsp;</a></td>";
		echo "</tr >";
		
		echo "<tr >";
		echo "<td width=\"22%\" bgcolor=\"#E6E6E6\" >Tariff subscription</td>";
		echo "<td colspan=\"4\" width=\"70%\"><a href=\"javascript:openSet('0','$objId','$sysId','$webName','$setName','$back_url')\">{$TariffSubArr[$TariffSub]}&nbsp;</a></td>";
		echo "</tr >";
				
		echo "<tr bgcolor=\"#E6E6E6\">";
		$rowProBonu = $RechCardValNo+1;
		echo "<td rowspan=$rowProBonu width=\"22%\" bgcolor=\"#E6E6E6\" >";
			echo "<table width=\"100%\">";
				echo "<tr>";
					echo "<td width=\"80%\">Recharge card validity</td>";
					if(!isset($newInstNo))
						$newInstNo=-1;
					echo "<td width=\"20%\" align=\"right\"><a href=\"javascript:openSet('$newInstNo','no-$levelRechCardVali','$sysId','$webName','$setName','$back_url')\"><font size=4>+</font></a></td>";
				echo "</tr>";
			echo "</table>";
		echo "</td>";
		echo "<td width=\"10%\">No.</td>";
		echo "<td width=\"20%\">Face value</td>";
		echo "<td width=\"20%\">MO validity</td>";
		echo "<td width=\"20%\">MT validity</td>";
		echo "</tr>";
		for($i=0; $i< $RechCardValNo; $i++)
		{
			echo "<tr>";
			$instNo = $RechargeCardVali[$i][instNo];
			echo "<td><a href = \"javascript:openSet('$instNo','no-$levelRechCardVali','$sysId','$webName','$setName','$back_url')\">$i</a></td>";
			echo "<td>{$RechargeCardVali[$i][Face]}</td>";
			echo "<td>{$RechargeCardVali[$i][MoVali]}</td>";
			echo "<td>{$RechargeCardVali[$i][MtVali]}</td>";
			echo "</tr >";
		}
}//end Tariff resolution

{//Account control
	{//Minimum balance for MO call

		$levelMinBalance = "2.1.4.$level_4.3.1";
		$objWhereStr = getLevelWhere($levelMinBalance);
		$setsql = "select initValue from $sqltable where $objWhereStr";
		$result = mysqli_query($pubConn,$setsql);
		echo mysqli_error($pubConn);
		$row = mysqli_fetch_array($result);
		$binValue = omc_keep_length(decbin(hexdec($row[initValue])),'0',16);
		$setThreshold = substr($binValue,0,1);
		$minBalance = bindec(substr($binValue,1,15));
		$setThresholdArr = array("Not set","Set");
	}
	
	{//Maximum account validity
		$levelMaxAccountVali = "2.1.4.$level_4.3.2";
		$objWhereStr = getLevelWhere($levelMaxAccountVali);
		$setsql = "select initValue from $sqltable where $objWhereStr";
		$result = mysqli_query($pubConn,$setsql);
		echo mysqli_error($pubConn);
		$row = mysqli_fetch_array($result);
		$maxAccountVali = hexdec($row[initValue]);
	}
	
	{//Release day
		$levelReleaseDay = "2.1.4.$level_4.3.3";
		$objWhereStr = getLevelWhere($levelReleaseDay);
		$setsql = "select initValue from $sqltable where $objWhereStr";
		$result = mysqli_query($pubConn,$setsql);
		echo mysqli_error($pubConn);
		$row = mysqli_fetch_array($result);
		$ReleaseDay = hexdec($row[initValue]);
	}
	
	$rowsRecPro = 4;
	echo "<tr >";
		echo "<td rowspan=$rowsRecPro width=\"8%\" bgcolor=\"#E6E6E6\" ><b>Account control</b></td>";	
	echo "</tr>";
		$webName = "PPS";
		$setName = "Recharge Card Validity";
		$objId = "no-$levelMinBalance-$levelMaxAccountVali-$levelReleaseDay";
		echo "<tr >";
		echo "<td width=\"22%\" bgcolor=\"#E6E6E6\" >Min balance for MO call</td>";
		echo "<td colspan=\"2\" width=\"35%\">Set threshold:&nbsp;<a href=\"javascript:openSet('0','$objId','$sysId','$webName','$setName','$back_url')\">{$setThresholdArr[$setThreshold]}&nbsp;</a></td>";
		echo "<td colspan=\"2\" width=\"35%\">Min balance for MO call:&nbsp;&nbsp;<a href=\"javascript:openSet('0','$objId','$sysId','$webName','$setName','$back_url')\">$minBalance&nbsp;</a></td>";
		echo "</tr >";
		
		echo "<tr >";
		echo "<td width=\"22%\" bgcolor=\"#E6E6E6\" >Max account validity</td>";
		echo "<td colspan=\"4\" width=\"70%\"><a href=\"javascript:openSet('0','$objId','$sysId','$webName','$setName','$back_url')\">$maxAccountVali&nbsp;</a></td>";
		echo "</tr >";
		
		echo "<tr >";
		echo "<td width=\"22%\" bgcolor=\"#E6E6E6\" >Release day</td>";
		echo "<td colspan=\"4\" width=\"70%\"><a href=\"javascript:openSet('0','$objId','$sysId','$webName','$setName','$back_url')\">$ReleaseDay&nbsp;</a></td>";
		echo "</tr >";
}//end Account control

{//MT call control
	{//MT call charge flag

		$levelMTCallFlag = "2.1.4.$level_4.4.1";
		$objWhereStr = getLevelWhere($levelMTCallFlag);
		$setsql = "select initValue from $sqltable where $objWhereStr";
		$result = mysqli_query($pubConn,$setsql);
		echo mysqli_error($pubConn);
		$row = mysqli_fetch_array($result);
		$MtCallFlag = hexdec($row[initValue]);
		$MtCallFlagArr = array("Not charged","Charged");
	}
	
	{//MT balance control
		$levelMTBalCtl = "2.1.4.$level_4.4.2";
		$objWhereStr = getLevelWhere($levelMTBalCtl);
		$setsql = "select initValue from $sqltable where $objWhereStr";
		$result = mysqli_query($pubConn,$setsql);
		echo mysqli_error($pubConn);
		$row = mysqli_fetch_array($result);
		$MTBalCtl = hexdec($row[initValue]);
		$MTBalCtlArr = array("No limitation","Threshold used");
	}
	
	{//MT balance threshold
		$levelMTBalThre = "2.1.4.$level_4.4.3";
		$objWhereStr = getLevelWhere($levelMTBalThre);
		$setsql = "select initValue from $sqltable where $objWhereStr";
		$result = mysqli_query($pubConn,$setsql);
		echo mysqli_error($pubConn);
		$row = mysqli_fetch_array($result);
		$MTBalThre = hexdec($row[initValue]);
	}
	
	$rowsMTCtrl = 4;
	echo "<tr >";
		echo "<td rowspan=$rowsMTCtrl width=\"8%\" bgcolor=\"#E6E6E6\" ><b>MT call control</b></td>";	
	echo "</tr>";
		$webName = "PPS";
		$setName = "MT Call Control";
		$objId = "no-$levelMTCallFlag-$levelMTBalCtl-$levelMTBalThre";
		echo "<tr >";
		echo "<td width=\"22%\" bgcolor=\"#E6E6E6\" >MT call charge flag</td>";
		echo "<td colspan=\"4\" width=\"70%\"><a href=\"javascript:openSet('0','$objId','$sysId','$webName','$setName','$back_url')\">{$MtCallFlagArr[$MtCallFlag]}&nbsp;</a></td>";
		echo "</tr >";
		
		echo "<tr >";
		echo "<td width=\"22%\" bgcolor=\"#E6E6E6\" >MT balance control</td>";
		echo "<td colspan=\"4\" width=\"70%\"><a href=\"javascript:openSet('0','$objId','$sysId','$webName','$setName','$back_url')\">{$MTBalCtlArr[$MTBalCtl]}&nbsp;</a></td>";
		echo "</tr >";
		
		echo "<tr >";
		echo "<td width=\"22%\" bgcolor=\"#E6E6E6\" >MT balance threshold</td>";
		echo "<td colspan=\"4\" width=\"70%\"><a href=\"javascript:openSet('0','$objId','$sysId','$webName','$setName','$back_url')\">$MTBalThre&nbsp;</a></td>";
		echo "</tr >";
}//end MT call control

{//Validity solution
	{//Clear balance option
		$levelCleBalOpt = "2.1.4.$level_4.5.1";
		$objWhereStr = getLevelWhere($levelCleBalOpt);
		$setsql = "select initValue from $sqltable where $objWhereStr";
		$result = mysqli_query($pubConn,$setsql);
		echo mysqli_error($pubConn);
		$row = mysqli_fetch_array($result);
		$accountExpires = bindec(getBitValue($row[initValue],'00.0-00.0'));
		$accountReleased  = bindec(getBitValue($row[initValue],'00.1-00.1'));
		$clearArr = array("Not clear balance","Clear balance");
	}
	
	{//Validity after recharge
		$levelValiAfterRech = "2.1.4.$level_4.5.2";
		$objWhereStr = getLevelWhere($levelValiAfterRech);
		$setsql = "select initValue from $sqltable where $objWhereStr";
		$result = mysqli_query($pubConn,$setsql);
		echo mysqli_error($pubConn);
		$row = mysqli_fetch_array($result);
		$ValiAfterRech = hexdec(getBitValue($row[initValue],'00.0-00.7'));
		$ValiAfterRechArr = array("Accumulate","Replace");
	}
	
	{//Validity on zero balance
		$levelValionZero = "2.1.4.$level_4.5.3";
		$objWhereStr = getLevelWhere($levelValionZero);
		$setsql = "select initValue from $sqltable where $objWhereStr";
		$result = mysqli_query($pubConn,$setsql);
		echo mysqli_error($pubConn);
		$row = mysqli_fetch_array($result);
		$ValionZero = bindec(getBitValue($row[initValue],'00.7-00.7'));
		$ValionZeroArr = array("Not change","Change");
		$Days = bindec(getBitValue($row[initValue],'00.0-00.6'));
	}
	
	{//Activated account validity
		$levelActAcntVali = "2.1.4.$level_4.5.4";
		$objWhereStr = getLevelWhere($levelActAcntVali);
		$setsql = "select initValue from $sqltable where $objWhereStr";
		$result = mysqli_query($pubConn,$setsql);
		echo mysqli_error($pubConn);
		$row = mysqli_fetch_array($result);
		$ActbyInquir  = bindec(getBitValue($row[initValue],'00.7-00.7'));
		$ActbyInquirArr = array("Disable","Enable");
		$ValiofActiwithZero  = bindec(getBitValue($row[initValue],'00.0-00.6'));
	}
	
	{//Friends & family number
		$levelFriFamNum = "2.1.4.$level_4.5.5";
		$objWhereStr = getLevelWhere($levelFriFamNum);
		$setsql = "select initValue from $sqltable where $objWhereStr";
		$result = mysqli_query($pubConn,$setsql);
		echo mysqli_error($pubConn);
		$row = mysqli_fetch_array($result);
		$CUGflg = bindec(getBitValue($row[initValue],'00.7-00.7'));
		$FFflg = bindec(getBitValue($row[initValue],'00.6-00.6'));
		$EditionFFflag = bindec(getBitValue($row[initValue],'00.5-00.5'));
		$FreeTimesofChange  = bindec(getBitValue($row[initValue],'00.0-00.3'));
		$CugFFflagArr = array("Disable","Enable");
		$EditionFFflagArr = array("Not charge","Charge");
	}
	
	{//Support credit card
		$levelSupCreCard = "2.1.4.$level_4.5.6";
		$objWhereStr = getLevelWhere($levelSupCreCard);
		$setsql = "select initValue from $sqltable where $objWhereStr";
		$result = mysqli_query($pubConn,$setsql);
		echo mysqli_error($pubConn);
		$row = mysqli_fetch_array($result);
		$SupportFlag = hexdec(getBitValue($row[initValue],'00.0-00.7'));
		$SupportFlagArr = array("Support","Not Support");
	}
	
	{//Credit vault
		$levelCredVault = "2.1.4.$level_4.5.7";
		$objWhereStr = getLevelWhere($levelCredVault);
		$setsql = "select initValue from $sqltable where $objWhereStr";
		$result = mysqli_query($pubConn,$setsql);
		echo mysqli_error($pubConn);
		$row = mysqli_fetch_array($result);
		$binValue = omc_keep_length(decbin(hexdec($row[initValue])),'0',16);
		$SupportVaultFlag = substr($binValue,0,1);
		$CreditVault = bindec(substr($binValue,1,15));
		$SupportVaultFlagArr = array("Not Support","Support");
	}
	
	$ValiSolutionRow = 9;
	echo "<tr >";
		echo "<td rowspan=$ValiSolutionRow width=\"8%\" bgcolor=\"#E6E6E6\" ><b>Validity solution</b></td>";	
	echo "</tr>";
		$webName = "PPS";
		$setName = "Validity Solution";
		$objId = "no-$levelCleBalOpt-$levelValiAfterRech-$levelValionZero-$levelActAcntVali";
		echo "<tr >";
		echo "<td width=\"22%\" bgcolor=\"#E6E6E6\" >Clear balance option</td>";
		echo "<td colspan=\"2\" width=\"35%\">When account expires:&nbsp;<a href=\"javascript:openSet('0','$objId','$sysId','$webName','$setName','$back_url')\">{$clearArr[$accountExpires]}&nbsp;</a></td>";
		echo "<td colspan=\"2\" width=\"35%\">When account is released:&nbsp;<a href=\"javascript:openSet('0','$objId','$sysId','$webName','$setName','$back_url')\">{$clearArr[$accountReleased]}&nbsp;</a></td>";
		echo "</tr >";
		
		echo "<tr >";
		echo "<td width=\"22%\" bgcolor=\"#E6E6E6\" >Validity after recharge</td>";
		echo "<td colspan=\"4\" width=\"70%\"><a href=\"javascript:openSet('0','$objId','$sysId','$webName','$setName','$back_url')\">{$ValiAfterRechArr[$ValiAfterRech]}&nbsp;</a></td>";
		echo "</tr >";
		
		echo "<tr >";
		echo "<td width=\"22%\" bgcolor=\"#E6E6E6\" >Validity on zero balance</td>";
		echo "<td colspan=\"2\" width=\"35%\">Validity on zero balance:&nbsp;<a href=\"javascript:openSet('0','$objId','$sysId','$webName','$setName','$back_url')\">{$ValionZeroArr[$ValionZero]}&nbsp;</a></td>";
		echo "<td colspan=\"2\" width=\"35%\">Days:&nbsp;<a href=\"javascript:openSet('0','$objId','$sysId','$webName','$setName','$back_url')\">$Days&nbsp;</a></td>";
		echo "</tr >";
	
		echo "<tr >";
		echo "<td width=\"22%\" bgcolor=\"#E6E6E6\" >Activated account validity</td>";
		echo "<td colspan=\"2\" width=\"35%\">Activation by inquiring:&nbsp;<a href=\"javascript:openSet('0','$objId','$sysId','$webName','$setName','$back_url')\">{$ActbyInquirArr[$ActbyInquir]}&nbsp;</a></td>";
		echo "<td colspan=\"2\" width=\"35%\">Validity of activated account with zero balance:&nbsp;<a href=\"javascript:openSet('0','$objId','$sysId','$webName','$setName','$back_url')\">$ValiofActiwithZero&nbsp;</a></td>";
		echo "</tr >";
		
		$FriFamNumObj = "no-$levelFriFamNum";		
		echo "<tr >";
		echo "<td width=\"22%\" rowspan=\"2\" bgcolor=\"#E6E6E6\" >Friends & family number</td>";		
		echo "<td colspan=\"2\" width=\"35%\">CUG serivce flag:&nbsp;<a href=\"javascript:openSet('0','$FriFamNumObj','$sysId','$webName','$setName','$back_url')\">{$CugFFflagArr[$CUGflg]}&nbsp;</a></td>";
		echo "<td colspan=\"2\" width=\"35%\">F & F service flag:&nbsp;<a href=\"javascript:openSet('0','$FriFamNumObj','$sysId','$webName','$setName','$back_url')\">{$CugFFflagArr[$FFflg]}&nbsp;</a></td>";
		echo "</tr >";
		echo "<tr>";
		echo "<td colspan=\"2\" width=\"35%\">Edition F & F list charge flag:&nbsp;<a href=\"javascript:openSet('0','$FriFamNumObj','$sysId','$webName','$setName','$back_url')\">{$EditionFFflagArr[$EditionFFflag]}&nbsp;</a></td>";
		echo "<td colspan=\"2\" width=\"35%\">Free times of changing:&nbsp;<a href=\"javascript:openSet('0','$FriFamNumObj','$sysId','$webName','$setName','$back_url')\">$FreeTimesofChange&nbsp;</a></td>";
		echo "</tr >";
		
		$SupCreCardObj = "no-$levelSupCreCard";
		echo "<tr >";
		echo "<td width=\"22%\" bgcolor=\"#E6E6E6\" >Support credit card</td>";
		echo "<td colspan=\"4\" width=\"70%\"><a href=\"javascript:openSet('0','$SupCreCardObj','$sysId','$webName','$setName','$back_url')\">{$SupportFlagArr[$SupportFlag]}&nbsp;</a></td>";
		echo "</tr >";
		
		$CredVaultObj = "no-$levelCredVault";
		echo "<tr >";
		echo "<td width=\"22%\" bgcolor=\"#E6E6E6\" >Activated account validity</td>";
		echo "<td colspan=\"2\" width=\"35%\">Support credit vault:&nbsp;<a href=\"javascript:openSet('0','$CredVaultObj','$sysId','$webName','$setName','$back_url')\">{$SupportVaultFlagArr[$SupportVaultFlag]}&nbsp;</a></td>";
		echo "<td colspan=\"2\" width=\"35%\">Credit vault:&nbsp;<a href=\"javascript:openSet('0','$CredVaultObj','$sysId','$webName','$setName','$back_url')\">$CreditVault&nbsp;</a></td>";
		echo "</tr >";
	
}//end Validity solution

{//SM inquiry/notification
	{//Feedback SM
		$levelFeedbackSM = "2.1.4.$level_4.6.1";
		$objWhereStr = getLevelWhere($levelFeedbackSM);
		$setsql = "select initValue from $sqltable where $objWhereStr";
		$result = mysqli_query($pubConn,$setsql);
		echo mysqli_error($pubConn);
		$row = mysqli_fetch_array($result);
		$rechargeSendSM = bindec(getBitValue($row[initValue],'00.0-00.0'));
		$inquirySendSM = bindec(getBitValue($row[initValue],'00.1-00.1'));
		$sendSMArr = array("Disable","Enable");
	}
	
	{//Inquiry SM
		$levelInquirySM = "2.1.4.$level_4.6.2";
		$objWhereStr = getLevelWhere($levelInquirySM);
		$setsql = "select initValue from $sqltable where $objWhereStr";
		$result = mysqli_query($pubConn,$setsql);
		echo mysqli_error($pubConn);
		$row = mysqli_fetch_array($result);
		$chargeOnInqSM = bindec(getBitValue($row[initValue],'00.7-00.7'));
		$freeSmEveryDay = bindec(getBitValue($row[initValue],'00.0-00.6'));
		$chargeOnInqSMArr = array("Not charged","Charged");
	}
	
	{//SM for expiry
		$levelSMforexpiry = "2.1.4.$level_4.6.3";
		$objWhereStr = getLevelWhere($levelSMforexpiry);
		$setsql = "select initValue from $sqltable where $objWhereStr";
		$result = mysqli_query($pubConn,$setsql);
		echo mysqli_error($pubConn);
		$row = mysqli_fetch_array($result);
		
		$SendSMNoti = bindec(getBitValue($row[initValue],'00.7-00.7'));
		$DaysPrior2Expiry  = bindec(getBitValue($row[initValue],'00.0-00.6'));
		$SendSMNotiArr = array("Disable","Enable");
	}
	
	{//SM for low balance
		$levelLowBalSM = "2.1.4.$level_4.6.4";
		$objWhereStr = getLevelWhere($levelLowBalSM);
		$setsql = "select initValue from $sqltable where $objWhereStr";
		$result = mysqli_query($pubConn,$setsql);
		echo mysqli_error($pubConn);
		$row = mysqli_fetch_array($result);
		$binValue = omc_keep_length(decbin(hexdec($row[initValue])),'0',16);
		$SendSMNotiLovBal = substr($binValue,0,1);
		$BalLevel2sendSM = bindec(substr($binValue,1,15));
		//$SendSMNotiLovBal = bindec(getBitValue($row[initValue],'01.7-01.7'));
		//$BalLevel2sendSM  = bindec(getBitValue($row[initValue],'00.0-01.6'));
	}	
	$SMInquiry = 5;
	echo "<tr >";
		echo "<td rowspan=$SMInquiry width=\"8%\" bgcolor=\"#E6E6E6\" ><b>SM inquiry/notification</b></td>";	
	echo "</tr>";
		$webName = "PPS";
		$setName = "SM Inquiry Notification";
		$objId = "no-$levelFeedbackSM-$levelInquirySM-$levelSMforexpiry-$levelLowBalSM";
		echo "<tr >";
		echo "<td width=\"22%\" bgcolor=\"#E6E6E6\" >Feedback SM</td>";
		echo "<td colspan=\"2\" width=\"35%\">Send SM for recharge result:&nbsp;<a href=\"javascript:openSet('0','$objId','$sysId','$webName','$setName','$back_url')\">{$sendSMArr[$rechargeSendSM]}&nbsp;</a></td>";
		echo "<td colspan=\"2\" width=\"35%\">Send SM for inquiry result:&nbsp;<a href=\"javascript:openSet('0','$objId','$sysId','$webName','$setName','$back_url')\">{$sendSMArr[$rechargeSendSM]}&nbsp;</a></td>";
		echo "</tr >";
		
		echo "<tr >";
		echo "<td width=\"22%\" bgcolor=\"#E6E6E6\" >Inquiry SM</td>";
		echo "<td colspan=\"2\" width=\"35%\">Charge on inquiry SM:&nbsp;<a href=\"javascript:openSet('0','$objId','$sysId','$webName','$setName','$back_url')\">{$chargeOnInqSMArr[$chargeOnInqSM]}&nbsp;</a></td>";
		echo "<td colspan=\"2\" width=\"35%\">Free SM every day:&nbsp;<a href=\"javascript:openSet('0','$objId','$sysId','$webName','$setName','$back_url')\">$freeSmEveryDay&nbsp;</a></td>";
		echo "</tr >";
		
		echo "<tr >";
		echo "<td width=\"22%\" bgcolor=\"#E6E6E6\" >SM notification for expiry</td>";
		echo "<td colspan=\"2\" width=\"35%\">Send SM notification:&nbsp;<a href=\"javascript:openSet('0','$objId','$sysId','$webName','$setName','$back_url')\">{$SendSMNotiArr[$SendSMNoti]}&nbsp;</a></td>";
		echo "<td colspan=\"2\" width=\"35%\">Days prior to expiry date:&nbsp;<a href=\"javascript:openSet('0','$objId','$sysId','$webName','$setName','$back_url')\">$DaysPrior2Expiry&nbsp;</a></td>";
		echo "</tr >";
		
		echo "<tr >";
		echo "<td width=\"22%\" bgcolor=\"#E6E6E6\" >SM notification for low balance</td>";
		echo "<td colspan=\"2\" width=\"35%\">Send SM notification:&nbsp;<a href=\"javascript:openSet('0','$objId','$sysId','$webName','$setName','$back_url')\">{$SendSMNotiArr[$SendSMNotiLovBal]}&nbsp;</a></td>";
		echo "<td colspan=\"2\" width=\"35%\">Balance level to send SM:&nbsp;<a href=\"javascript:openSet('0','$objId','$sysId','$webName','$setName','$back_url')\">$BalLevel2sendSM&nbsp;</a></td>";
		echo "</tr >";	
}//end SM inquiry/notification

echo "</table>";

{
	echo "<table width=\"100%\">";
	echo "<tr>";
		echo "<td width=\"70%\">";
			echo "&nbsp;&nbsp;";
		echo "</td>";
		echo "<td width=\"20%\" align=\"right\">";
				echo "<input type=\"submit\" title=\"$strTitleGet\" name=\"getSys\" value=\"$strGet\" class=\"button\" style=\"cursor:pointer; left: 1; top: 2; width: 60; height: 25; position: relative\">";
				echo "&nbsp;&nbsp;&nbsp;";
				echo "<input type=\"submit\" title=\"$strTitleSet\" name=\"setSys\" value=\"$strSet\" class=\"button\" style=\"cursor:pointer; left: 1; top: 2; width: 60; height: 25; position: relative\">";
			echo "</td>";
		echo "<td width=\"10%\">";
			echo "<p align=\"right\"><a href=\"../mss/pps.php?scroll_y=$sub_page_top&smsFormatShow=$isShowSms\"><img align=absBottom border=0 src=\"../../images/left.gif\" width=\"14\" height=\"14\">$strBack</a>";
		echo "</td>";
	echo "</tr>";
	echo "</table>";
}

echo "<input type=\"hidden\" name=\"level_4\" value=$level_4>";
echo "</form>";
?>

<script LANGUAGE="JavaScript"> 

function openSet(instanceNo,objIdStr,sysId,webname,setname,backurl)
{
	setname=escape(setname);
	if(instanceNo==-1)
	{
		alert("There are no more instance!");
		return;
	}
	y = document.body.scrollTop;
	backurl = backurl+'&scroll_y='+y;
	backurl=escape(backurl);
	URL="./paramconf.php?instanceNo="+instanceNo+"&objIdStr="+objIdStr+"&sysId="+sysId+"&webname="+webname+"&setname="+setname+"&backurl="+backurl+"&sub_page_top="+y;	
	window.location.href=URL;
}
</script>

