<?php
/*********************************************************      
 程序说明：         
    功能说明：vlr单个用户数据显示专用页面


    调用关系：调用: header.inc
 
    变量说明：
		输入变量：
			$keyValue	:由用户列表传来
			$sysId		:由用户列表传来或本页面指定
			$dataTypeNo	:数据类型，0=用户数据，1=冲值卡数据
			$language	:语言种类
			$canSetNum	:每次最多可以修改的字段个数

 作者：
      
修改注释：      
NO.1      
姓名：      
时间：  
修改说明： 
*********************************************************/  
require("../../inc/header.inc");
$DEBUG = 0;

if($DEBUG)echo "<br>正在调试中，给您的工作带来不便，请原谅！！：）";

//==========================================================
//变量定义
//==========================================================
$pubDb				='OMC_PUB';
$sysSubsConfTable	='OMC_PUB.sysSubsConf';
$systemConfTable	='OMC_PUB.sysConf';

$nReadComm		= 1;
$nChangeComm	= 2;
$nCreateComm	= 3;
$nDeleteComm	= 4;
$nLoadIndexComm	= 5;

$maxLevelNum = 10;

$nInteger	= 2;
$nAscStr	= 3;
$nHexStr	= 4;

//------------选择语言版本----------
if($language == 'eng'){

}else{

}

$odbGeneralDef=array(
		//array('Name',			'offset'	,'remark'),
		array('BAOC',			'00.0'	,'BAOC'),
		array('BOIC',			'00.1'	,'BOIC'),
		array('BOIC_HPLMN',		'00.2'	,'BOIC-HPLMN'),
		array('BAIC_HPLMN_CT',	'02.1'	,'BAIC-HPLMN CT'),
		array('Roaming',		'02.3'	,'Roaming'),
		array('Roaming_CT',		'02.4'	,'Roaming CT')
);

$CamelFlagDef=array(
		array('camelFlag',	'00.0'	,'Support Camel'),
		array('OCSI',		'00.1'	,'OCSI'),
		array('TCSI',		'00.2'	,'TCSI'),
		array('SMS_CSI',	'01.0'	,'SMS-CSI'),

);
//==========================================================
//输入变量
//==========================================================
$canSetNum = isset($canSetNum)?$canSetNum:'all';
//显示用户数据编辑页面，需要的变量

$sysId=$_REQUEST['sysId'];
$keyValue=$_REQUEST['keyValue'];
$sysTypeNo=$_REQUEST['sysTypeNo'];
$sysNo=$_REQUEST['sysNo'];
$subSysNo=$_REQUEST['subSysNo'];
$dataTypeNo=$_REQUEST['dataTypeNo'];
$isRead=$_REQUEST['isRead'];
$isChange=$_REQUEST['isChange'];
$isCreate=$_REQUEST['isCreate'];
$isDelete=$_REQUEST['isDelete'];
$isLoadIndex=$_REQUEST['isLoadIndex'];


if($DEBUG)echo "<br>sysId=$sysId";
if($DEBUG)echo "<br>canSetNum=$canSetNum";
if($DEBUG)echo "<br>keyValue=$keyValue";
if($DEBUG)echo "<br>sysTypeNo=$sysTypeNo";
if($DEBUG)echo "<br>sysNo=$sysNo";
if($DEBUG)echo "<br>subSysNo=$subSysNo";
if($DEBUG)echo "<br>dataTypeNo=$dataTypeNo";
//例如：
//$canSetNum =1; // 或= 'all'
//$sysId='330_0_0';
//$keyValue= '0460022157127016';

//操作类型变量
if($DEBUG)echo "<br>isRead=$isRead";
if($DEBUG)echo "<br>isChange=$isChange";
if($DEBUG)echo "<br>isCreate=$isCreate";
if($DEBUG)echo "<br>isDelete=$isDelete";
if($DEBUG)echo "<br>isLoadIndex=$isLoadIndex";


//==========================================================
//数据处理
//==========================================================
if (1 == $isLoadIndex) {
	$fieldNameList		= "IMSI,MSISDN,IMSIDetachFlag,LAI,O_CSI";
} else {
	$fieldNameList		= "ALL";
}
if ($DEBUG) echo "fieldNameList=$fieldNameList<br>";
?>
<base target="_self">
<body leftmargin="15" rightmargin="10" onload="javascript:adjust_frame('down');" onresize="javascript:adjust_frame('down');" style="overflow:hidden;overflow-x:hidden;overflow-y:hidden;">

<?php
require("../pubSubsMng/sendComm.inc");
require("../pubSubsMng/dataProc.inc");

//==========================================================
//输出并显示数据
//==========================================================
$seqNo=0;
?>
<script LANGUAGE="JavaScript">
function keepCheckBox(thisCheckBox)
{
	if(thisCheckBox.value == 1){
		thisCheckBox.checked = true;
	}else{
		thisCheckBox.checked = false;
	}
}

</script>
<?php
adjust_head_frame("down");
adjust_title_head_frame("down");
adjust_title_tail_frame("down");

adjust_content_head_frame("down");	
echo "<br>";
?>
<form method="POST" name="update" action="<?php echo"$PHP_SELF";?>" >
  <?php
	//显示用户参数编辑页面
	?>
  <table border="0" cellpadding="0" cellspacing="0" width="100%">
    <tr>
	<td><nobr>
	<?php echo "Server Id:"?>
	<select name="sysId" size="1">
	<?php
	$selSysIdSql="SELECT sysNo,subSysNo,sysTypeName 
				FROM sysInfo,sysConf 
				WHERE sysInfo.sysTypeNo='$sysTypeNo' AND sysConf.sysTypeNo='$sysTypeNo'
				ORDER BY baseStat DESC,updateTime DESC
				";
	if($DEBUG)echo "<br>$selSysIdSql";
	$sysIdResult=mysqli_query($pubConn,$selSysIdSql);
	echo mysqli_error($pubConn);
	while($sysIdRows=mysqli_fetch_array($sysIdResult)){
		echo "<option value=\"$sysTypeNo"."_$sysIdRows[sysNo]"."_$sysIdRows[subSysNo]\"";
		if(($sysNo == $sysIdRows[sysNo]) && ($subSysNo == $sysIdRows[subSysNo]))
			echo " selected";
		echo " >$sysIdRows[sysTypeName]"."_$sysIdRows[sysNo]"."_$sysIdRows[subSysNo]";
		echo "</option>";
	}
	?>
	</select>
	</nobr>
	</td>  
	<td><nobr>
	<?php
	$showkeyValue= $keyValue;
	$keyValueName='IMSI';
	echo "&nbsp;&nbsp;$keyValueName:$showkeyValue";
	?>
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	</nobr></td>
	<td>
	<input type="submit" value="Get" name="read" title=""  class="button" onClick="javascript:document.update.isRead.value=1;">
	<input type="hidden" value="0" name="isRead">
	</td>
  <td width="100%">&nbsp;</td>
  </tr>  
</table>
<br>
<?php
//将已取出的用户数据显示出来
//$tmpRow[fieldName]

?>

<table border="1" width="100%" cellpadding="1" cellspacing="0"  bordercolor="#666666" bordercolordark="#FFFFFF">
<?php
//Table Head
echo "<tr bgcolor=\"#E6E6E6\">";
echo "<td width=\"10%\">$strID</td>";
echo "<td width=\"45%\">$strField</td>";
echo "<td width=\"45%\">$strValue</td>";
echo "</tr>";
 
//IMSI
$IMSI=$tmpRow[IMSI];
echo "<tr>";
echo "<td> $seqNo </td>";
$seqNo++;
echo "<td>IMSI</td>";
echo "<td>$IMSI &nbsp;</td>";
echo "</tr>";

//MSISDN
$MSISDN=str_replace('F','',$tmpRow[MSISDN]);
echo "<tr>";
echo "<td> $seqNo </td>";
$seqNo++;
echo "<td>MSISDN</td>";
echo "<td>$MSISDN &nbsp;</td>";
echo "</tr>";

//MS Category
$categoryDef=array(
		array('00','Unknown'),
		array('01','French language'),
		array('02','English language'),
		array('03','German language'),
		array('04','Russian language'),
		array('05','Spanish language'),
		array('0A','Ordinary'),
		array('0B','Subscriber with priority'),
		);
$category=$tmpRow[MS_Category];
echo "<tr>";
echo "<td> $seqNo </td>";
$seqNo++;
echo "<td>MS category</td>";

for($i=0;$i<sizeof($categoryDef);$i++){
	if($categoryDef[$i][0] == $category){
		$showValue=$categoryDef[$i][1];
		break;
	}
}
if(strlen($showValue)){
	echo "<td>$showValue</td>";
}else{
	echo "<td>unknown($category)</td>";
}
echo "</tr>";

//Subscriber status
//0=service granted, 1=operator determined barring
$Sub_status=$tmpRow[Sub_status];
echo "<tr>";
echo "<td> $seqNo </td>";
$seqNo++;
echo "<td>ODB status</td>";
if($Sub_status > 0){
	echo "<td>Operator determined barring</td>";
}else{
	echo "<td>Service granted</td>";
}

echo "</tr>";

//ODB general
$odbGeneral=$tmpRow[ODB_General];
$odbGeneralDef=array(
		//array('Name',			'offset'	,'remark'),
		array('BAOC',			'00.0'	,'provisioned'),
		array('BOIC',			'00.1'	,'provisioned'),
		array('BOIC_exHC',		'00.2'	,'provisioned'),
		array('BPRIC',			'00.3'	,'provisioned'),
		array('BPREC',			'00.4'	,'provisioned'),
		array('SS_Access',		'00.5'	,'provisioned'),
		array('BAIC',			'02.0'	,'provisioned'),
		array('BAICRoam',		'02.1'	,'provisioned')
//		array('BR_outH',		'02.3'	,'provisioned'),
//		array('BR_outHC',		'02.4'	,'provisioned')
);
echo "<tr>";
echo "<td> $seqNo </td>";
$seqNo++;
echo "<td>ODB general</td>";
echo "<td>";
for($i=0;$i<sizeof($odbGeneralDef);$i++){
	$value=getBitValue($odbGeneral,$odbGeneralDef[$i][1]);
	if($value == '1'){
		echo "<input type=\"checkbox\" value=\"1\" onclick=\"keepCheckBox(this);\" checked  >{$odbGeneralDef[$i][0]}<br>";
	}else{
		echo "<input type=\"checkbox\" value=\"0\" onclick=\"keepCheckBox(this);\" >{$odbGeneralDef[$i][0]}<br>";
	}
}
echo "</td>";
echo "</tr>";

//Provision_ts
$provisionTs=$tmpRow[Provision_ts]; 
$provisionTsDef=array(
		//array('Name',						'offset'),
		array('Telephony provision',		'00.0'	),
		array('Emergency call provision',	'00.1'	),
		array('Short message MT provision',	'00.2'	),
		array('Short message MO provision',	'00.3'	),
);
echo "<tr>";
echo "<td> $seqNo </td>";
$seqNo++;
echo "<td>Provisioned tele service</td>";
echo "<td>";
for($i=0;$i<sizeof($provisionTsDef);$i++){
	$value=getBitValue($provisionTs,$provisionTsDef[$i][1]);
	if($value == '1'){
		echo "<input type=\"checkbox\" value=\"1\" onclick=\"keepCheckBox(this);\" checked  >{$provisionTsDef[$i][0]}<br>";
	}else{
		echo "<input type=\"checkbox\" value=\"0\" onclick=\"keepCheckBox(this);\" >{$provisionTsDef[$i][0]}<br>";
	}
}
echo "</td>";
echo "</tr>";

//TMSI
$TMSI=$tmpRow[TMSI]; 
echo "<tr>";
echo "<td> $seqNo </td>";
$seqNo++;
echo "<td>TMSI</td>";
echo "<td>$TMSI &nbsp;</td>";
echo "</tr>";

//LAI
$LAI=$tmpRow[LAI];
$MCC=substr($LAI,0,2);
$MCC=strrev($MCC);
$MCC=$MCC.strrev(substr($LAI,2,2));
$MCC=str_replace("F","",$MCC);
$MNC=substr($LAI,4,2);
$MNC=strrev($MNC);
$MNC=str_replace("F","",$MNC);
$LAC=substr($LAI,-4);
//$LAC=str_replace("F","",$LAC);

echo "<tr>";
echo "<td> $seqNo </td>";
$seqNo++;
echo "<td>LAI(MCC-MNC-LAC)</td>";
echo "<td>$MCC-$MNC-$LAC</td>";
echo "</tr>";

//Cell_ID 
$cellId=$tmpRow[Cell_ID]; 
echo "<tr>";
echo "<td> $seqNo </td>";
$seqNo++;
echo "<td>Cell ID</td>";
echo "<td>$cellId &nbsp;</td>";
echo "</tr>";

//Location confirm
$locationConfirm=$tmpRow[LocationConfirm]; 
echo "<tr>";
echo "<td> $seqNo </td>";
$seqNo++;
echo "<td>Location confirm</td>";
if($locationConfirm > 0){
	echo "<td>Confirmed</td>";
}else{
	echo "<td>Not Confirmed</td>";
}
echo "</tr>";

//Data confirm
$dataConfirmFlag=$tmpRow[DataConfirmFlag]; 
echo "<tr>";
echo "<td> $seqNo </td>";
$seqNo++;
echo "<td>Data confirm</td>";
if($dataConfirmFlag > 0){
	echo "<td>Confirmed</td>";
}else{
	echo "<td>Not Confirmed</td>";
}
echo "</tr>";

//RadioConfirmFlag
$radioConfirmFlag=$tmpRow[RadioConfirmFlag]; 
echo "<tr>";
echo "<td> $seqNo </td>";
$seqNo++;
echo "<td>Radio confirm</td>";
if($radioConfirmFlag > 0){
	echo "<td>Confirmed</td>";
}else{
	echo "<td>Not Confirmed</td>";
}
echo "</tr>";

//IMSI detach
$IMSIDetachFlag=$tmpRow[IMSIDetachFlag]; 
echo "<tr>";
echo "<td> $seqNo </td>";
$seqNo++;
echo "<td>IMSI detach</td>";
if($IMSIDetachFlag > 0){
	echo "<td>Detached</td>";
}else{
	echo "<td>Attached</td>";
}
echo "</tr>";

//MNRF
$MNRF=$tmpRow[MNRF]; 
echo "<tr>";
echo "<td> $seqNo </td>";
$seqNo++;
echo "<td>MNRF</td>";
if($MNRF > 0){
	echo "<td>Not Reachable</td>";
}else{
	echo "<td>Reachable</td>";
}
echo "</tr>";

//LA_Not_allowed
$LANotAllowedFlag =$tmpRow[LANotAllowedFlag]; 
echo "<tr>";
echo "<td> $seqNo </td>";
$seqNo++;
echo "<td>LA_Not_allowed</td>";
if($LANotAllowedFlag > 0){
	echo "<td>Allowed</td>";
}else{
	echo "<td>Not allowed</td>";
}
echo "</tr>";

//Roaming Restricted
$RoamRestricFlag  =$tmpRow[RoamRestricFlag]; 
echo "<tr>";
echo "<td> $seqNo </td>";
$seqNo++;
echo "<td>Roaming restricted</td>";
if($RoamRestricFlag > 0){
	echo "<td>Restricted</td>";
}else{
	echo "<td>Not restricted</td>";
}
echo "</tr>";

$tmpFieldArr=array(
	//array('showName_1','fielname_1','showName_2','fielname_2'),
	array('CFU status',		'CFU_ST',	'CFU: Forward to number',	'CFU_Num'),
	array('CFB status',		'CFB_ST',	'CFB: Forward to number',	'CFB_Num'),
	array('CFNRy status',	'CFNRy_ST',	'CFNRy: Forward to number',	'CFNRy_Num'),
	array('CFNRc status',	'CFNRc_ST',	'CFNRc: Forward to number',	'CFNRc_Num')
);
$tmpDefArr=array(
		//array('Name',						'offset'),
		array('A bit (indicate active state)',		'00.0'	),
		array('R bit (indicate registration state)','00.1'	),
		array('P bit (indicate provision state)',	'00.2'	),
		array('Q bit (indicate quiescent state)',	'00.3'	),
		array('Notification to calling party',		'00.5'	),
		array('Notification to forwarding party',	'00.7'	)
);
for($i=0;$i<sizeof($tmpFieldArr);$i++){
	$showName_1		=$tmpFieldArr[$i][0];
	$showValue_1	=$tmpRow[$tmpFieldArr[$i][1]];
	//echo "showValue_1=$showValue_1";
	echo "<tr>";
	echo "<td> $seqNo </td>";
	$seqNo++;
	echo "<td>$showName_1</td>";
	echo "<td>";
	//$valuetest=getBitValue(04,00.7);
	//echo "valuetest=$valuetest";
	for($j=0;$j<sizeof($tmpDefArr);$j++){
		$value=getBitValue($showValue_1,$tmpDefArr[$j][1]);
		//echo "j=$j,value=$value";
		if($value == '1'){
			echo "<input type=\"checkbox\" value=\"1\" onclick=\"keepCheckBox(this);\" checked  >{$tmpDefArr[$j][0]}<br>";
		}else{
			echo "<input type=\"checkbox\" value=\"0\" onclick=\"keepCheckBox(this);\" >{$tmpDefArr[$j][0]}<br>";
		}
	}
	echo "</td>";
	echo "</tr>";

	$showName_2		=$tmpFieldArr[$i][2];
	$showValue_2	=$tmpRow[$tmpFieldArr[$i][3]];
	echo "<tr>";
	echo "<td> $seqNo </td>";
	$seqNo++;
	echo "<td>$showName_2</td>";
	echo "<td>$showValue_2 &nbsp;</td>";
	echo "</tr>";
}

//Barring all calls
$allBarFlag  =$tmpRow[ALLBAR]; 
echo "<tr>";
echo "<td> $seqNo </td>";
$seqNo++;
echo "<td>Barring all calls</td>";
if($allBarFlag > 0){
	echo "<td>Yes</td>";
}else{
	echo "<td>No</td>";
}
echo "</tr>";

$tmpFieldArr=array(
//	array('showName','fieldName'),
	array('BAOC','BAOC'),
	array('BOIC','BOIC'),
	array('BOIC-ExHC','BOICexHC'),
	array('BAIC','BAIC'),
	array('BICRoam','BICRoam')
);

$tmpDef=array(
		//array('Name',						'offset'),
		array('A bit (indicate active state)',		'00.0'	),
		array('R bit (indicate registration state)','00.1'	),
		array('P bit (indicate provision state)',	'00.2'	),
		array('Q bit (indicate quiescent state)',	'00.3'	)
);
for($i=0;$i<sizeof($tmpFieldArr);$i++){
	$showName  =$tmpFieldArr[$i][0]; 
	$showValue =$tmpRow[$tmpFieldArr[$i][1]]; 
	echo "<tr>";
	echo "<td> $seqNo </td>";
	$seqNo++;
	echo "<td>$showName</td>";
	echo "<td>";
	for($j=0;$j<sizeof($tmpDef);$j++){
		$value=getBitValue($showValue,$tmpDef[$j][1]);
		if($value == '1'){
			echo "<input type=\"checkbox\" value=\"1\" checked  onclick=\"keepCheckBox(this);\" >{$tmpDef[$j][0]}<br>";
		}else{
			echo "<input type=\"checkbox\" value=\"0\" onclick=\"keepCheckBox(this);\">{$tmpDef[$j][0]}<br>";
		}
	}
	echo "</td>";
	echo "</tr>";
}

$tmpDefArr=array(
//	array('showName','fieldName'),
	array('CLIP','CLIP'),
	array('CLIR','CLIR'),
	array('COLP','COLP'),
	array('COLR','COLR'),
	array('AOCI','AOCI'),
	array('AOCC','AOCC'),
	array('Call hold','CallHold'),
	array('Call wait','CallWait'),
	array('ECT','ECT'),
	array('MPTY','MPTY')
);
$tmpDef=array(
		//array('Name',						'offset'),
		array('A bit (indicate active state)',		'00.0'	),
		array('R bit (indicate registration state)','00.1'	),
		array('P bit (indicate provision state)',	'00.2'	),
		array('Q bit (indicate quiescent state)',	'00.3'	)
);
for($i=0;$i<sizeof($tmpDefArr);$i++){
	$showName	=$tmpDefArr[$i][0]; 
	$showValue  =$tmpRow[$tmpDefArr[$i][1]]; 
	echo "<tr>";
	echo "<td> $seqNo </td>";
	$seqNo++;
	echo "<td>$showName</td><td>";
	/*
	if($showValue > 0){
		echo "<td>Actived</td>";
	}else{
		echo "<td>Not Actived</td>";
	}
	*/
	for($j=0;$j<sizeof($tmpDef);$j++){
		$value=getBitValue($showValue,$tmpDef[$j][1]);
		if($value == '1'){
			echo "<input type=\"checkbox\" value=\"1\" checked  onclick=\"keepCheckBox(this);\" >{$tmpDef[$j][0]}<br>";
		}else{
			echo "<input type=\"checkbox\" value=\"0\" onclick=\"keepCheckBox(this);\">{$tmpDef[$j][0]}<br>";
		}
	}
	echo "</td></tr>";
}

//O_CSI
$O_CSI =$tmpRow[O_CSI];
$oCsiFlag=substr($O_CSI,0,1);
$oCsiScpNum=substr($O_CSI,4,12);
$oCsiScpNum=str_replace('F','',$oCsiScpNum);
echo "<tr>";
echo "<td> $seqNo </td>";
$seqNo++;
echo "<td>O-CSI</td>";
if(strlen($O_CSI) == 0){
	echo "<td>Not Provisioned</td>";
}else{
	echo "<td>";
	echo "Provisioned";
	echo "<br>SCF Number:$oCsiScpNum";
	echo "</td>";
	echo "</tr>";
}

//SMS_CSI
$SMS_CSI =$tmpRow[SMS_CSI];
$smsCsiFlag=substr($SMS_CSI,0,1);
$smsCsiNum=substr($SMS_CSI,4,12);
$smsCsiNum=str_replace('F','',$smsCsiNum);
echo "<tr>";
echo "<td> $seqNo </td>";
$seqNo++;
echo "<td>SMS-CSI</td>";
if(strlen($SMS_CSI) == 0){
	echo "<td>Not Provisioned</td>";
}else{
	echo "<td>";
	echo "Provisioned";
	echo "<br>SCF Number:$smsCsiNum";
	echo "</td>";
	echo "</tr>";
}

//MSISDN opt
$msisdn_opt=$tmpRow[MSISDN_opt];
$msisdn_opt=str_replace('F','',$msisdn_opt);
echo "<tr>";
echo "<td> $seqNo </td>";
$seqNo++;
echo "<td>MSISDN(Opt)</td>";
if(trim($msisdn_opt)=="")
	echo "<td>--</td>";
else
	echo "<td>$msisdn_opt</td>";
	
//opps flag
$opps_flag=$tmpRow[OppsFlag]+0;
$opps_flag_label=array(0=>"OPR Not Registerd",
												1=>"OPR WithOut Roam Agreement OPRState",
												2=>"OPR With Roam Agreeement OPRState",
												3=>"OPR With Roam Agreeement RoamingState",
												4=>"IMDXPrivate",
												5=>"IMDXHbrid",
												6=>"IMDXPublic");
echo "<tr>";
echo "<td> $seqNo </td>";
$seqNo++;
echo "<td>OPPS Flag</td>";
if($opps_flag<0 || $opps_flag>6)
	echo "<td>--</td>";
else
	echo "<td>{$opps_flag_label[$opps_flag]}</td>";
?>
</table>

<?php
//*****************************************隐藏输入框,用于传递值****************************************
echo "\n<input type=\"hidden\" name=\"dataTypeNo\"		value=\"$dataTypeNo\">";
echo "\n<input type=\"hidden\" name=\"keyFieldName\"	value=\"$indexFieldName\">";
echo "\n<input type=\"hidden\" name=\"keyValue\"		value=\"$keyValue\">";
?>
<p>&nbsp;</p>
<?php
adjust_content_tail("down");
?>
</body>
</html>
