<?php
require("../../inc/header.inc");
require("./param_comm.inc");
?>

<script LANGUAGE="JavaScript">  
function selectSysID()
{      
	clicktab(tab_sel);
}

function getAll()
{
	var sysId=document.selectform.system_id_select.value;
	updateTab(0);
	parent.param_show_table.location.href="./param_show_table.php?sysId="+sysId+"&table_id=0&instanceNo=0000&getAll=1";
}

function updateTab(tabid)
{
	//parent.param_show_up.tab_sel=tabid;
	parent.param_show_up.adjust_tab(tabid);
	//alert('click me '+tabid);
}

</script>

<body leftmargin="15" rightmargin="10" onload="javascript:clicktab(0);javascript:adjust_frame('up');javascript:adjust_tab('0');javascript:adjust_firefox();" onresize="javascript:adjust_frame('up');javascript:adjust_tab('-1');" style="overflow:hidden;overflow-x:hidden;overflow-y:hidden;" onmouseup=document.selection.empty() oncontextmenu="return false" onselectstart="return false" ondragstart="return false" onbeforecopy="return false" oncopy=document.selection.empty() onselect=document.selection.empty()>

<?php
adjust_head_frame("up");
adjust_title_head_frame("up");

define(EMS_APP_ID,0);
define(HLR_APP_ID,3);
define(PPS_APP_ID,5);
define(SMSC_APP_ID,6);
define(MSS_APP_ID,9);
define(VSS_APP_ID,8);
define(AAS_APP_ID,11);

$needMSSPub=1;



if(!isset($system_id_select))
	$system_id_select="320_99_99";
$sysTypeNo = $_REQUEST['sysTypeNo'];
//echo "system_id_select=$system_id_select<br>";
switch($sysTypeNo)
{
case SYSTYPENO_MSC:
	$sysTypeName="MSC";
	$helpId="2.1.1.1";
	break;
case SYSTYPENO_SMSC:
	$sysTypeName="SMSC";
	$helpId="2.1.1.5";
	break;
case SYSTYPENO_SMPP:
	$sysTypeName="SMPP";
	$helpId="2.1.1.20";
	break;
case SYSTYPENO_OPPS:
	$sysTypeName="OPPS";
	$helpId="2.1.1.9";
	break;
case SYSTYPENO_PPS:
	$sysTypeName="PPS";
	$helpId="none";
	break;
case SYSTYPENO_MME:
    	$sysTypeName="MME";
    	$helpId="none";
    	break;
case SYSTYPENO_SPGW:
    	$sysTypeName="SPGW";
    	$helpId="none";
    	break;
case SYSTYPENO_IMS:
	$sysTypeName="IMS";
    	$helpId="none";
    	break;
case SYSTYPENO_RCS:
    	$sysTypeName="RCS";
    	$helpId="none";
    	break;
case SYSTYPENO_UDM:
    	$sysTypeName="UDM";
    	$helpId="none";
    	break;
case SYSTYPENO_AUSF:
    	$sysTypeName="AUSF";
    	$helpId="none";
    	break;
case SYSTYPENO_MTP3:
	$sysTypeName="MTP3";
	$helpId="2.1.0";
	break;
case SYSTYPENO_SCCP:
	$sysTypeName="SCCP";
	$helpId="2.1.0";
	break;
case SYSTYPENO_AAS:
	$sysTypeName="AAS";
	$helpId="2.1.3.1";
	break;
case SYSTYPENO_VSS:
	$sysTypeName="VSS";
	$helpId="2.1.3.2";
	break;
case SYSTYPENO_VLR:
	$sysTypeName="VLR";
	$helpId="2.1.1.2";
	break;
case SYSTYPENO_HLR:
	$sysTypeName="HLR";
	$helpId="2.1.1.3";
	break;
case SYSTYPENO_AUC:
	$sysTypeName="AUC";
	$helpId="2.1.1.4";
	break;
case SYSTYPENO_SMEG:
	$sysTypeName="SMEG";
	$helpId="2.1.1.8";
	break;
case SYSTYPENO_EIR:
	$sysTypeName="EIR";
	$helpId="2.1.1.7";
	break;
case SYSTYPENO_MRFC:
	$sysTypeName="MRFC";
	$helpId="2.66";
	break;
case SYSTYPENO_PALIM:
	$sysTypeName="iPALIM";
	$helpId="2.1.1.12";
	break;
case SYSTYPENO_RLS:
	$sysTypeName="iRLS";
	$helpId="2.1.1.13";
	break;
case SYSTYPENO_MHC:
	$sysTypeName="MHC";
	$helpId="2.1.1.14";
	break;
case SYSTYPENO_MNP:
	$sysTypeName="MNP";
	$helpId="2.1.1.11";
	break;
case SYSTYPENO_XAPP:
	$sysTypeName="XAPP";
	$helpId="none";
	break;
case SYSTYPENO_GRS:
	$sysTypeName="iGRS";
	$helpId="2.1.1.17";
	break;
case SYSTYPENO_TMG:
	$sysTypeName="TMG";
	$helpId="2.1.1.19";
	break;
case SYSTYPENO_AMRMG:
	$sysTypeName="AMRMG";
	$helpId="2.1.1.15";
	break;
case SYSTYPENO_GbC:
	$sysTypeName="GbC";
	$helpId="2.1.1.16";
	break;
case SYSTYPENO_MCA:
	$sysTypeName="MCA";
	$helpId="2.1.1.21";
	break;
case SYSTYPENO_RCM:
	$sysTypeName="RCM";
	$helpId="2.1.1.21";
	break;
/*case SYSTYPENO_IUUPGW:
	$sysTypeName="IUUPGW";
	//$helpId="2.1.1.21";
	break;*/
default:
	$sysTypeName="Unknown";
	$helpId="none";
	break;
}

$sql="select sysTypeNo,sysTypeName,maxSysNum,maxSubSysNum from OMC_PUB.sysConf where needParamConf = '1' and sysTypeNo='$sysTypeNo' ";
//echo "sql=$sql<br>";
$res=@mysqli_query($pubConn,$sql);
$row=@mysqli_fetch_array($res);
$maxSysNum=$row['maxSysNum'];
$maxSubSysNum=$row['maxSubSysNum']; 


$statSql="select sysTypeNo,sysNo,subSysNo FROM sysInfo WHERE sysTypeNo='$sysTypeNo' ";
$statRes=@mysqli_query($pubConn,$statSql);
$count=mysqli_num_rows($statRes);
echo mysqli_error($pubConn);
//echo "sql=$statSql<br>";

echo "<table id=\"table_up\" border=\"0\" width=\"100%\">";
echo "<tr>";
echo "<td width=\"50%\">";
echo "Configuration > NSS > $sysTypeName";
echo "</td>";
echo "<td width=\"50%\" align=\"right\" title=\"Help\">";

echo "<form method=\"post\" name=\"selectform\" action=\"$PHP_SELF\">";

echo "System ID:";
	echo "<select name=\"system_id_select\" onChange=\"javascript:selectSysID()\">";
	//application
	if(floor($sysTypeNo/100) == 3)  //ne in 300-400
	{
		$sysid=$sysTypeNo."_99_99";
		//The AAS do not need public parameter setting,Who need public---!=
		//When more MSC,no MSC_pub
		if($sysTypeNo != SYSTYPENO_AAS && $sysTypeNo != SYSTYPENO_VSS && $sysTypeNo != SYSTYPENO_TMG && $sysTypeNo != SYSTYPENO_AMRMG && $sysTypeNo != SYSTYPENO_GbC && $sysTypeNo != SYSTYPENO_MCA)
		{
			if($system_id_select == $sysid)
				echo "<option value=\"$sysid\" selected>";
			else
				echo "<option value=\"$sysid\">";
			echo "{$sysTypeName}_pub</option>";
		}
			
		// for($i=0;$i<$maxSysNum;$i++)
		// {
		// 	$sysid=$sysTypeNo."_".$i."_0";
		// 	echo "<option value=\"$sysid\" ";
		// 	if($sysid == $system_id_select)
		// 		echo "selected";
		// 	echo ">";
		// 	echo "{$sysTypeName}_{$i}</option>";
		// }

		//by lai order to realNe in select
 	for($i=0;$i<$count;$i++)
	{
	$statRow=@mysqli_fetch_array($statRes);
	$sysid=$statRow['sysTypeNo']."_".$statRow['sysNo']."_".$statRow['subSysNo'];
	echo "<option value=\"$sysid\" ";
	if($sysid == $system_id_select)
		echo "selected";
	echo ">";
	echo "{$sysTypeName}_{$statRow['sysNo']}</option>";
	}
	}

	//platform
	else
	{
		//mtp3,sccp
		if($sysTypeNo == SYSTYPENO_MTP3 || $sysTypeNo == SYSTYPENO_SCCP)
		{
			for($i=0;$i<$maxSysNum;$i++) 
			{
				//Now,only VSS MSS and AAS use MTP3 or SSCP Parameters
				if( $i == AAS_APP_ID || $i == PPS_APP_ID ||$i == HLR_APP_ID ||$i ==SMSC_APP_ID)
				{
					$sysName=$sysTypeName.'('.$PlatTypeDefArr[$i]['remark'].'_Pub)';
					$sysId=$sysTypeNo.'_'.$i.'_99';
					//default display MSS

						echo "<option value=\"$sysId\">$sysName</option>";
					
					/*
					for($j=0;$j<$PlatTypeDefArr[$i][maxSysNum];$j++)
					{
						$sysName=$sysTypeName.'('.$PlatTypeDefArr[$i][remark].'_'.$j.')';
						$sysId =$systype_no_select.'_'.$i.'_'.$j;
						echo "<option value=\"$sysId\">$sysName</option>";
					}
					*/
				}

				
				else if($i == VSS_APP_ID)
				{
					// for($si=0;$si<10;$si++)
					// {
					// 	$sysName=$sysTypeName."(".$PlatTypeDefArr[$i][remark]."_$si)";
					// 	$sysId =$sysTypeNo."_".$i."_$si";
					// 	echo "<option value=\"$sysId\" selected>$sysName</option>";
					// }

					//by lai order to realNe in select
					for($si=0;$si<$count;$si++)
					{
						$statRow=@mysqli_fetch_array($statRes);
						if($statRow['sysNo']==$i){
							$sysName=$sysTypeName."(".$PlatTypeDefArr[$i]['remark']."_".$statRow['subSysNo'].")";
							$sysId=$statRow['sysTypeNo']."_".$i."_".$statRow['subSysNo'];
							echo "<option value=\"$sysId\" >$sysName</option>";
						} //end if
	
					}//end for

				}


				
				//MTP3,SCCP MSC需要拆分开来也要保留PUB
				else if($i == MSS_APP_ID)
				{	
					if($needMSSPub){
						$sysName=$sysTypeName.'('.$PlatTypeDefArr[$i][remark].'_Pub)';
						$sysId=$sysTypeNo.'_'.$i.'_99';
						echo "<option value=\"$sysId\" selected>$sysName</option>";
					}


					// for($j=0;$j<$maxSysNum;$j++)
					// {
					// 	$sysName=$sysTypeName."(".$PlatTypeDefArr[$i][remark]."_$j)";
					// 	$sysId =$sysTypeNo."_".$i."_$j";
					// 	echo "<option value=\"$sysId\">$sysName</option>";
					// }

					
					//by lai order to realNe in select
					$infoSql="select sysTypeNo,sysNo,subSysNo FROM sysInfo WHERE sysTypeNo='$sysTypeNo' ";
					$infoRes=@mysqli_query($pubConn,$infoSql);
					$infoCount=mysqli_num_rows($infoRes);
					for($j=0;$j<$infoCount;$j++)
					{
						$infoRow=@mysqli_fetch_array($infoRes);
						if($infoRow['sysNo']==$i){

							$sysName=$sysTypeName."(".$PlatTypeDefArr[$i][remark]."_".$infoRow['subSysNo'].")";
							$sysId=$infoRow['sysTypeNo']."_".$i."_".$infoRow['subSysNo'];
							//if($statRow['sysNo']=$i)
							echo "<option value=\"$sysId\">$sysName</option>";
						} //end if
	
					}//end for
				}

			}
		}
		//other platform
		else
		{
			for($i=0;$i<$maxSysNum;$i++)
			{
				//Now,only MSS use other plat modules' Parameters
				if($sysTypeNo == SYSTYPENO_SMPP)
				{
					if($i == MSS_APP_ID || $i == VSS_APP_ID || $i == EMS_APP_ID || $i == SMSC_APP_ID || $i == PPS_APP_ID  )
					{	
						if($i == SMSC_APP_ID)
						{
							$sysName=$sysTypeName.'('.$PlatTypeDefArr[$i][remark].'_pub)';
							$sysId =$sysTypeNo.'_'.$i.'_99';
							if(MSS_APP_ID == $i)
								echo "<option value=\"$sysId\" selected>$sysName</option>";
							else
								echo "<option value=\"$sysId\">$sysName</option>";
						}
						
						if($i == PPS_APP_ID)
						{
							$sysName=$sysTypeName.'('.$PlatTypeDefArr[$i][remark].'_pub)';
							$sysId =$sysTypeNo.'_'.$i.'_99';
							if(MSS_APP_ID == $i)
								echo "<option value=\"$sysId\" selected>$sysName</option>";
							else
								echo "<option value=\"$sysId\">$sysName</option>";
						}

						//ISSUE-3
						else if($i == MSS_APP_ID)
						{
							$sysName=$sysTypeName.'('.$PlatTypeDefArr[$i][remark].'_pub)';
							$sysId =$sysTypeNo.'_'.$i.'_99';
							if(MSS_APP_ID == $i)
								echo "<option value=\"$sysId\" selected>$sysName</option>";
							else
								echo "<option value=\"$sysId\">$sysName</option>";
						}
						else if($i == EMS_APP_ID)
						{
							$sysName=$sysTypeName.'('.$PlatTypeDefArr[$i][remark].'_0)';
							$sysId =$sysTypeNo.'_'.$i.'_0';
							echo "<option value=\"$sysId\" selected>$sysName</option>";
							
							$sysName=$sysTypeName.'('.$PlatTypeDefArr[$i][remark].'_1)';
							$sysId =$sysTypeNo.'_'.$i.'_1';
							echo "<option value=\"$sysId\" selected>$sysName</option>";
						}
						else if($i == VSS_APP_ID)
						{
							for($si=0;$si<10;$si++)
							{
								$sysName=$sysTypeName."(".$PlatTypeDefArr[$i][remark]."_$si)";
								$sysId =$sysTypeNo."_".$i."_$si";
								echo "<option value=\"$sysId\" selected>$sysName</option>";
							}
						}
						
						//now the system is all public
						/*
						for($j=0;$j<$PlatTypeDefArr[$i][maxSysNum];$j++)
						{
							$sysName=$sysTypeName.'('.$PlatTypeDefArr[$i][remark].'_'.$j.')';
							$sysId=$systype_no_select.'_'.$i.'_'.$j;
							echo "<option value=\"$sysId\">$sysName</option>";
						}
						*/
					}
				}
				else
				{
					if($i == MSS_APP_ID ||  $i == PPS_APP_ID ||$i == HLR_APP_ID ||$i ==SMSC_APP_ID)
					{
						$sysName=$sysTypeName.'('.$PlatTypeDefArr[$i][remark].'_pub)';
						$sysId =$sysTypeNo.'_'.$i.'_99';
						if(MSS_APP_ID == $i)
							echo "<option value=\"$sysId\" selected>$sysName</option>";
						else
							echo "<option value=\"$sysId\">$sysName</option>";
					}
				}
			}
		}
	}
	echo "</select>&nbsp;&nbsp;";

echo "<input type=\"button\" onclick=\"javascript:getAll();\" name=\"get_all\" value=\"$strGetAll\" class=\"button\" style=\"$buttonStyle\">"; 
echo "&nbsp;&nbsp;";

if($helpId != "none")
	showHelp($helpId);
echo "</td>";
echo "</tr>";
echo "</table>";
echo "<br>";

$tabConf=GetTabConf($sysTypeNo);
$num=sizeof($tabConf);
InitTab($sysTypeNo);
echo "<span id=\"left_id\" onclick=\"javascript:left_tab();\" style=\"display:none;cursor:hand;z-index:0;position:absolute;top:36px;left:0px;width:18px;height:22px;background-image:url(./images/left_arrow.gif);background-repeat:no-repeat;\"></span>";
for($i=0;$i<$num;$i++)
{
	$id=GetGlobalID();
	AddTab($id,$tabConf[$i][OID],$tabConf[$i][Name],"image0.gif","image2.gif",123,17);
}
echo "<span id=\"right_id\" onclick=\"javascript:right_tab();\" style=\"display:none;cursor:hand;z-index:0;position:absolute;top:36px;left:823px;width:18px;height:22px;background-image:url(./images/right_arrow.gif);background-repeat:no-repeat;\"></span>";

if(0)
{
	echo "<pre>";
	print_r($tabConf);
	echo "</pre>";
}

adjust_title_tail_frame("up");
adjust_content_head_frame("up");
adjust_content_tail_frame("up");

?>

</body>
