<?php
/*********************************************************      
 程序说明：         
    功能说明：hlr用户数据维护专用页面
		1、将用户数据表的数据导入到临时参数表。
		2、修改的用户数据保存到临时参数表中，
		3、设置用户参数时,返回值将修改用户表和临时表。

    调用关系：调用: 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{

}

$odbCodeDef=array(
		//array('inputName',	'offset'	,'remark'),
		array('OUT_LOCAL',			'00.0'	,'本地呼出'),
		array('OUT_TRK',			'00.1'	,'出局呼叫'),
		array('OUT_NATION',			'00.2'	,'国内长途'),
		array('OUT_INTERNATION',	'00.3'	,'国际长途'),
		array('All_IN_CALL',		'01.1'	,'所有来电')
);

$restrictDef=array(
		//array('inputName',	'offset'	,'remark'),
		array('restrictGrp_1',	'00.0'	,'组1'),
		array('restrictGrp_2',	'00.1'	,'组2'),
		array('restrictGrp_3',	'00.2'	,'组3'),
		array('restrictGrp_4',	'00.3'	,'组4')
);

//==========================================================
//输入变量
//==========================================================
$canSetNum = isset($canSetNum)?$canSetNum:'all';
//显示用户数据编辑页面，需要的变量
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($DEBUG) echo "<br>bgnNo=$bgnNo";	
if($DEBUG) echo "<br>endNo=$endNo";	

//---------定义需要编辑保存的字段-------
$showAttrDef=array(
	array('fieldName'=>'used_flag',			'inputName'=>'used_flag'),
	array('fieldName'=>'imsi',				'inputName'=>'imsi'),
	array('fieldName'=>'msisdn',			'inputName'=>'msisdn'),
	//array('fieldName'=>'acc_mode',			'inputName'=>'acc_mode'),
	//array('fieldName'=>'lac',				'inputName'=>'lac'),
	array('fieldName'=>'ODB_Code',			'inputName'=>'ODB_Code'),
	array('fieldName'=>'clip_state',		'inputName'=>'clip_state'),
	array('fieldName'=>'callwait_state',	'inputName'=>'callwait_state'),
	array('fieldName'=>'callhold_state',	'inputName'=>'callhold_state'),
	//array('fieldName'=>'seccall_state',		'inputName'=>'seccall_state'),
	array('fieldName'=>'group_number',		'inputName'=>'group_number'),
	array('fieldName'=>'alarm_time',		'inputName'=>'alarm_time'),
	array('fieldName'=>'call_bar_opt',		'inputName'=>'call_bar_opt'),
	array('fieldName'=>'call_bar_pwd',		'inputName'=>'call_bar_pwd'),
	//array('fieldName'=>'bar_pw_attemp',	'inputName'=>'bar_pw_attemp'),
	array('fieldName'=>'boic_state',		'inputName'=>'boic_state'),
	array('fieldName'=>'boic_hplmn',		'inputName'=>'boic_hplmn'),
	array('fieldName'=>'baic_state',		'inputName'=>'baic_state'),
	array('fieldName'=>'boc_state',			'inputName'=>'boc_state'),
	array('fieldName'=>'baoc_state',		'inputName'=>'baoc_state'),
	array('fieldName'=>'cfu_state',			'inputName'=>'cfu_state'),
	array('fieldName'=>'cfu_number',		'inputName'=>'cfu_number'),
	array('fieldName'=>'cfb_state',			'inputName'=>'cfb_state'),
	array('fieldName'=>'cfb_num',			'inputName'=>'cfb_num'),
	array('fieldName'=>'cfnry_st',			'inputName'=>'cfnry_st'),
	array('fieldName'=>'cfnry_num',			'inputName'=>'cfnry_num'),
	array('fieldName'=>'cfnry_time',		'inputName'=>'cfnry_time'),
	array('fieldName'=>'cfnrc_st',			'inputName'=>'cfnrc_st'),
	array('fieldName'=>'cfnrc_num',			'inputName'=>'cfnrc_num'),
	array('fieldName'=>'Restrict_num',		'inputName'=>'Restrict_num'),
	array('fieldName'=>'CCBS',				'inputName'=>'CCBS'),
	array('fieldName'=>'mutiPty_call',		'inputName'=>'mutiPty_call'),
	array('fieldName'=>'malicious_call',	'inputName'=>'malicious_call')
);

//如果fieldName和inputName相等，则不用做附加处理
//否则，需要根据这个变量的值来做一些附加处理，例如电话号码的前补91后补E,或是一些复选框的合并

//检查各个需要编辑的输入单元
if($DEBUG && $_SERVER['REQUEST_METHOD'] == "POST"){
	for($i=0;$i<sizeof($showAttrDef);$i++){
		$inputName	=$showAttrDef[$i][inputName];
		$inputValue	=${$inputName};
		if(strlen($inputValue)){
			echo "<br>$inputName	= $inputValue";
		}else{
			echo "<br>Can not find $inputName's value";
		}
	}
}

//处理各个的输入单元的值，组成各个需要编辑的字段值
if($_SERVER['REQUEST_METHOD'] == "POST"){
	//显示时需要处理拆分的字段，提交后也需要处理合成
	//$lac  =dechex($lac);
	
	$cfnry_time=dechex($cfnry_time);

	//ODB_Code
	$orgValue=$ODB_Code;
	for($i=0;$i<sizeof($odbCodeDef);$i++){
		$inputName	=$odbCodeDef[$i][0];
		$inputValue	=${$inputName};
		if($DEBUG) echo "<br>$inputName	= $inputValue";
		if(strlen($inputValue) == 0){
			$inputValue=0;
		}
		$inputOffset=$odbCodeDef[$i][1];
		if($DEBUG) echo "<br>setBitValue($orgValue,$inputOffset,$inputValue)";
		$orgValue=setBitValue($orgValue,$inputOffset,$inputValue);
	}
	$ODB_Code=$orgValue;

	//Restrict_num
	$orgValue=$Restrict_num;
	for($i=0;$i<sizeof($restrictDef);$i++){
		$inputName	=$restrictDef[$i][0];
		$inputValue	=${$inputName};
		if($DEBUG) echo "<br>$inputName	= $inputValue";
		if(strlen($inputValue) == 0){
			$inputValue=0;
		}
		$inputOffset=$restrictDef[$i][1];
		if($DEBUG) echo "<br>setBitValue($orgValue,$inputOffset,$inputValue)";
		$orgValue=setBitValue($orgValue,$inputOffset,$inputValue);
	}
	$Restrict_num=$orgValue;

	//格式化每个需要保存的字段，以便数据处理模块处理
	$bgnNo=0;
	$endNo=0;
	for($i=$bgnNo;$i<sizeof($showAttrDef);$i++){
		$tmpFieldName = $showAttrDef[$i][fieldName];		
		${'checkBox_'.$endNo} =1;
		${'fieldName_'.$endNo}=$tmpFieldName;
		${'editValue_'.$endNo}=${$tmpFieldName};
		if($DEBUG) echo "<br>checkBox_$endNo	= ${'checkBox_'.$endNo}";
		if($DEBUG) echo "<br>fieldName_$endNo	= ${'fieldName_'.$endNo}";
		if($DEBUG) echo "<br>editValue_$endNo	= ${'editValue_'.$endNo}";
		$endNo++;
		if($canSetNum != 'all' && $endNo > $canSetNum){
			break;
		}
	}
	//if($DEBUG) exit();
}
//==========================================================
//数据处理
//==========================================================
if (1 == $isLoadIndex) {
	$fieldNameList		= "imsi,msisdn,used_flag,lac";
} 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=1;
?>

<?php
adjust_head_frame("down");
adjust_title_head_frame("down");
adjust_title_tail_frame("down");

adjust_content_head_frame("down");	
echo "<br>";
//**********************************编辑参数时所用javascript*****************************************
?>
<script LANGUAGE="JavaScript">
function selCheckBox(thisCheckBox)
{
	if(thisCheckBox.checked == true){
		thisCheckBox.value=1;
	}else{
		thisCheckBox.value=0;
	}
}

function askSureToDel(keyName,keyId)
{
	var answer = confirm("Are you sure to delete this subscriber( "+keyName+"="
                          + keyId + ") from <?php echo"$sysTypeName";?> server?");
    if (answer == true){
		window.location.href = "<?php echo "$PHP_SELF?sysId=$sysId&dataTypeNo=$dataTypeNo&bufferNo=$bufferNo&keyValue=$keyValue&isDelete=1";?>";
		//alert('Try to send delete command');
	}else{
		return(false);
	}
}
</script>
<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>
	<?php 
	if($isTryCreate > 0){
	?>
		<td >
		<input type="submit" value="Create in <?php echo "$sysTypeName"?>" name="create" title="" class="button" onClick="javascript:document.update.isCreate.value=1;">
		<input type="hidden" value="0" name="isCreate">
		<input type="hidden" value="0" name="isChange">
		</td>
		<td>
		&nbsp;&nbsp;&nbsp;
		<input type="submit" value="Create in OMC" name="create" title=""  class="button" onClick="javascript:document.update.isCreate.value=2;">
		</td>
	<?php
	}else{
	?>
		<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>
		<input type="submit" value="Set" name="change" title=""  class="button" onClick="javascript:document.update.isChange.value=1;">

		<input type="hidden" value="0" name="isChange">
		<input type="hidden" value="0" name="isCreate">
		</td>
		
		<td>
		<input type="button" value="Delete" name="delete" title="Delete this subscriber"  class="button" onClick="askSureToDel(<?php echo"'$keyValueName','$keyValue'";?>)">
		<input type="hidden" value="0" name="isDelete">
		</td>
	<?php
	}
	?>
  <td width="100%">&nbsp;</td>
  </tr>  
</table>
<br>
<?php
//将已取出的用户数据显示出来
//$tmpRow[fieldName]

?>
<table border="1" width="100%" cellpadding="2" cellspacing="0"  bordercolor="#666666" bordercolordark="#FFFFFF" bgcolor="#FFFFFF">    
<tr bgcolor="#E6E6E6"> 
<td width="5%"> No.</td>   
<td width="35%">项目</td>   
<td width="20%">取值</td>     
<td width="40%">说明</td>    
</tr>
<?

//used_flag
$used_flag=$tmpRow[used_flag];
echo "\n <tr>";
echo "<td> $seqNo </td>";
$seqNo++;
echo "<td>使用标志</td>";
echo "<td>";
if($used_flag > '00'){
	echo "<input type=\"radio\" name=\"used_flag\" value=\"01\" checked>使用中";
	echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ";
	echo "<input type=\"radio\" name=\"used_flag\" value=\"00\">未使用";
}else{
	echo "<input type=\"radio\" name=\"used_flag\" value=\"01\">使用中";
	echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ";
	echo "<input type=\"radio\" name=\"used_flag\" value=\"00\" checked>未使用";
}
echo "</td>";
echo "<td>&nbsp;</td>";
echo "</tr>";



//imsi
$imsi=$tmpRow[imsi];
if($isTryCreate > 0){
	echo "\n <tr>";
	echo "<td> $seqNo </td>";
	$seqNo++;
	echo "<td>IMSI</td>";
	echo "<td>";
	echo "<input type=\"text\" name=\"imsi\" maxlength=\"15\" size=\"18\" value=\"$imsi\" class=\"text\">";
	echo "</td>";
	echo "<td>&nbsp;</td>";
	echo "</tr>";
}else{
	$acc_mode=$tmpRow[acc_mode];
	if($acc_mode == '01'){
		echo "\n <tr>";
		echo "<td> $seqNo </td>";
		$seqNo++;
		echo "<td>EAN编号</td>";
		echo "<td>";
		echo "</td>";
		echo "<td>&nbsp;</td>";
		echo "</tr>";

		echo "\n <tr>";
		echo "<td> $seqNo </td>";
		$seqNo++;
		echo "<td>端口号</td>";
		echo "<td>";
		echo "</td>";
		echo "<td>&nbsp;</td>";
		echo "</tr>";
	}else{
		echo "\n <tr>";
		echo "<td> $seqNo </td>";
		$seqNo++;
		echo "<td>IMSI</td>";
		echo "<td>$imsi";
		echo "<input type=\"hidden\" name=\"imsi\" value=\"$imsi\">";
		echo "</td>";
		echo "<td>&nbsp;</td>";
		echo "</tr>";
	}
}


//msisdn 
$msisdn =$tmpRow[msisdn];
$msisdn	=str_replace('E','',$msisdn);
echo "\n <tr>";
echo "<td> $seqNo </td>";
$seqNo++;
echo "<td>电话号码</td>";
echo "<td>";
echo "<input type=\"text\" name=\"msisdn\" maxlength=\"15\" size=\"18\" value=\"$msisdn\" class=\"text\">";
echo "</td>";
echo "<td>&nbsp;</td>";
echo "</tr>";

//acc_mode
$acc_mode=$tmpRow[acc_mode];
echo "\n <tr>";
echo "<td> $seqNo </td>";
$seqNo++;
echo "<td>用户类别</td>";
echo "<td>";
if($isTryCreate > 0){
	if($acc_mode == '01'){
		echo "固定用户<input type=\"radio\" name=\"acc_mode\"	value=\"01\" checked>&nbsp;&nbsp;";
		echo "移动用户<input type=\"radio\" name=\"acc_mode\"	value=\"02\" >";
	}else{
		echo "固定用户<input type=\"radio\" name=\"acc_mode\"	value=\"01\">&nbsp;&nbsp;";
		echo "移动用户<input type=\"radio\" name=\"acc_mode\"	value=\"02\" checked>";
	}
}else{
	if($acc_mode == '01'){
		echo "固定用户";
	}else{
		echo "移动用户";
	}
}
echo "";
echo "</td>";
echo "<td>&nbsp;</td>";
echo "</tr>";


//lac  
$lac  =str_replace('F','',$tmpRow[lac]);
$lac  =hexdec($lac);
echo "\n <tr>";
echo "<td> $seqNo </td>";
$seqNo++;
echo "<td>LAC编号</td>";
echo "<td>";
echo "$lac";
echo "</td>";
echo "<td>&nbsp;</td>";
echo "</tr>";

//ODB_Code
//$odbCodeDef在前面定义，因为提交后合成值也需要
$ODB_Code=$tmpRow[ODB_Code];
echo "\n <tr>";
echo "<td> $seqNo </td>";
$seqNo++;
echo "<td>用户权限(ODB)</td>";
echo "<td>";
echo "&nbsp; <input type=\"hidden\" name=\"ODB_Code\" value=\"$ODB_Code\">";
echo "</td>";
echo "<td>&nbsp;</td>";
echo "</tr>";

for($i=0;$i<sizeof($odbCodeDef);$i++){
	echo "\n <tr>";
	echo "<td> &nbsp; </td>";
	echo "<td>{$odbCodeDef[$i][2]}</td>";
	echo "<td>";
	$value=getBitValue($ODB_Code,$odbCodeDef[$i][1]);
	if($value == '0'){
		echo "无限制<input type=\"radio\" name=\"{$odbCodeDef[$i][0]}\"	value=\"1\" checked>&nbsp;&nbsp;";
		echo "禁用<input type=\"radio\" name=\"{$odbCodeDef[$i][0]}\"	value=\"0\" >";
	}else{
		echo "无限制<input type=\"radio\" name=\"{$odbCodeDef[$i][0]}\"	value=\"1\" >&nbsp;&nbsp;";
		echo "禁用<input type=\"radio\" name=\"{$odbCodeDef[$i][0]}\"	value=\"0\" checked>";
	}
	echo "</td>";
	echo "<td>&nbsp;</td>";
	echo "</tr>";
}

//增值业务====================================
echo "\n <tr>";
echo "<td> $seqNo </td>";
$seqNo++;
echo "<td>增值业务</td>";
echo "<td>&nbsp;</td>";
echo "<td>&nbsp;</td>";
echo "</tr>";


//clip_state
$clip_state=$tmpRow[clip_state];
echo "\n <tr>";
echo "<td>&nbsp;</td>";
echo "<td>来电显示</td>";
echo "<td>";   
if($clip_state == '01'){
	echo "提供<input type=\"radio\" name=\"clip_state\"	value=\"01\" checked>&nbsp;&nbsp;";
	echo "未提供<input type=\"radio\" name=\"clip_state\"	value=\"00\" >";
}else{
	echo "提供<input type=\"radio\" name=\"clip_state\"	value=\"01\" >&nbsp;&nbsp;";
	echo "未提供<input type=\"radio\" name=\"clip_state\"	value=\"00\" checked>";
}
echo "</td>";
echo "<td>&nbsp;</td>";
echo "</tr>";

//callwait_state
$tmpDef=array(
		//array('value','Name'),
		array('05','激活'),
		array('04','未激活'),
		array('00','未提供')
		);
$tmpName='callwait_state';
$callwait_state=$tmpRow[callwait_state];
echo "\n <tr>";
echo "<td>&nbsp;</td>";
echo "<td>呼叫等待</td>";
echo "<td>";
for($i=0;$i<sizeof($tmpDef);$i++){
	echo "{$tmpDef[$i][1]}<input type=\"radio\" name=\"$tmpName\"	value=\"{$tmpDef[$i][0]}\" ";
	if($tmpDef[$i][0] == $callwait_state){
		echo "checked";
	}
	echo ">&nbsp;&nbsp;";
}
echo "</td>";
echo "<td>&nbsp;</td>";
echo "</tr>";


//callhold_state
$callhold_state=$tmpRow[callhold_state];
echo "\n <tr>";
echo "<td>&nbsp;</td>";
echo "<td>呼叫保持</td>";
echo "<td>";   
if($callhold_state == '01'){
	echo "提供<input type=\"radio\" name=\"callhold_state\"	value=\"01\" checked>&nbsp;&nbsp;";
	echo "未提供<input type=\"radio\" name=\"callhold_state\"	value=\"00\" >";
}else{
	echo "提供<input type=\"radio\" name=\"callhold_state\"	value=\"01\" >&nbsp;&nbsp;";
	echo "未提供<input type=\"radio\" name=\"callhold_state\"	value=\"00\" checked>";
}
echo "</td>";
echo "<td>&nbsp;</td>";
echo "</tr>";
/*
//seccall_state
$seccall_state=$tmpRow[seccall_state];
echo "\n <tr>";
echo "<td>&nbsp;</td>";
echo "<td>恶意电话追踪</td>";
echo "<td>";   
if($seccall_state == '01'){
	echo "提供<input type=\"radio\" name=\"seccall_state\"	value=\"01\" checked>&nbsp;&nbsp;";
	echo "未提供<input type=\"radio\" name=\"seccall_state\"	value=\"00\" >";
}else{
	echo "提供<input type=\"radio\" name=\"seccall_state\"	value=\"01\" >&nbsp;&nbsp;";
	echo "未提供<input type=\"radio\" name=\"seccall_state\"	value=\"00\" checked>";
}
echo "</td>";
echo "<td>&nbsp;</td>";
echo "</tr>";
*/

//group_number
$group_number=$tmpRow[group_number];
echo "\n <tr>";
echo "<td>&nbsp;</td>";
echo "<td>集团用户</td>";
echo "<td>";   
echo "<select  size=\"1\" name=\"group_number\">";
for($i=0; $i<256; $i++){
	if($i == $group_number){
		echo "<option value=\"$i\" selected>$i</option>";
	}else{
		echo "<option value=\"$i\">$i</option>";
	}
}
echo "</select>";
echo "</td>";
echo "<td>集团用户，0号代表不属于任何集团</td>";
echo "</tr>";

//alarm_time
$tmpDef=array(
		//array('value','Name'),
		array('05','激活'),
		array('04','未激活'),
		array('00','未提供')
		);
$tmpName='alarm_time';
$alarm_time=$tmpRow[alarm_time];
$alarmFlag=substr($alarm_time,2,1);
echo "\n <tr>";
echo "<td>&nbsp;</td>";
echo "<td>闹钟服务</td>";
echo "<td>";
for($i=0;$i<sizeof($tmpDef);$i++){
	echo "{$tmpDef[$i][1]}<input type=\"radio\" name=\"$tmpName\"	value=\"{$tmpDef[$i][0]}\" ";
	if($tmpDef[$i][0] == $alarmFlag){
		echo "checked";
	}
	echo ">&nbsp;&nbsp;";
}
echo "</td>";
echo "<td>&nbsp;</td>";
echo "</tr>";

$alarmHour=substr($alarm_time,0,1);
$alarmMinute=substr($alarmMinute,1,1);
echo "\n <tr>";
echo "<td>&nbsp;</td>";
echo "<td>闹钟时间设置</td>";
echo "<td>";
echo "小时<select  size=\"1\" name=\"alarmHour\">";
for($i=0; $i<24; $i++){
	if($i == $alarmHour){
		echo "<option value=\"$i\" selected>$i</option>";
	}else{
		echo "<option value=\"$i\">$i</option>";
	}
}
echo "</select>";
echo "&nbsp;&nbsp;分钟<select  size=\"1\" name=\"alarmMinute\">";
for($i=0; $i<60; $i++){
	if($i == $alarmMinute){
		echo "<option value=\"$i\" selected>$i</option>";
	}else{
		echo "<option value=\"$i\">$i</option>";
	}
}
echo "</select>";
echo "</td>";
echo "<td>&nbsp;</td>";
echo "</tr>";

//呼叫限制==========================================
echo "\n <tr>";
echo "<td> $seqNo </td>";
$seqNo++;
echo "<td>呼叫限制</td>";
echo "<td>&nbsp;";
echo "</td>";
echo "<td>&nbsp;</td>";
echo "</tr>";

//call_bar_opt
$tmpDef=array(
		//array('value','Name'),
		array('00','操作员控制'),
		array('01','用户控制（使用密码）'),
		array('02','用户控制（不使用密码）')
		);
$call_bar_opt=$tmpRow[call_bar_opt];
echo "\n <tr>";
echo "<td>&nbsp;</td>";
echo "<td>控制方式</td>";
echo "<td>";
echo "<select size=\"1\" name=\"call_bar_opt\">";
for($i=0;$i<sizeof($tmpDef);$i++){
	if($tmpDef[$i][0] == $call_bar_opt){
		echo "<option value=\"{$tmpDef[$i][0]}\" selected>{$tmpDef[$i][1]}</option>";
	}else{
		echo "<option value=\"{$tmpDef[$i][0]}\" >{$tmpDef[$i][1]}</option>";
	}
}
echo "</select>";
echo "</td>";
echo "<td>&nbsp;</td>";
echo "</tr>";

//call_bar_pwd
$call_bar_pwd=$tmpRow[call_bar_pwd];
echo "\n <tr>";
echo "<td>&nbsp;</td>";
echo "<td>权限密码</td>";
echo "<td>";
echo "<input type=\"text\" name=\"call_bar_pwd\" maxlength=\"4\" value=\"$call_bar_pwd\" class=\"text\">";
echo "</td>";
echo "<td>&nbsp;</td>";
echo "</tr>";

/*
//bar_pw_attemp 
$bar_pw_attemp=$tmpRow[bar_pw_attemp];
echo "\n <tr>";
echo "<td>&nbsp;</td>";
echo "<td>允许密码输措次数</td>";
echo "<td>";
echo "<input type=\"text\" name=\"bar_pw_attemp\" maxlength=\"2\" value=\"$bar_pw_attemp\" class=\"text\">";
echo "</td>";
echo "<td>&nbsp;</td>";
echo "</tr>";
*/

$tmpDef=array(
		//array('value','Name'),
		array('05','激活'),
		array('04','未激活'),
		array('00','未提供')
		);
$callBarDef=array(
		//array('fieldName','Remark'),
		array('boic_state','国际长途限制'),
		array('boic_hplmn','国内长途限制'),
		array('baic_state','呼入限制(免打扰)'),
		array('boc_state','出局呼叫限制'),
		array('baoc_state','本地呼出限制')
		);
for($j=0;$j<sizeof($callBarDef);$j++){
	$tmpName=$callBarDef[$j][0];
	$tmpValue=$tmpRow[$tmpName];
	$tmpRemark=$callBarDef[$j][1];
	echo "\n <tr>";
	echo "<td> &nbsp; </td>";
	echo "<td>$tmpRemark</td>";
	echo "<td>";
	for($i=0;$i<sizeof($tmpDef);$i++){
		echo "{$tmpDef[$i][1]}<input type=\"radio\" name=\"$tmpName\"	value=\"{$tmpDef[$i][0]}\" ";
		if($tmpDef[$i][0] == $tmpValue){
			echo "checked";
		}
		echo ">&nbsp;&nbsp;";
	}
	echo "</td>";
	echo "<td>&nbsp;</td>";
	echo "</tr>";
}

//呼叫转移===================================
echo "\n <tr>";
echo "<td> $seqNo </td>";
$seqNo++;
echo "<td>呼叫转移</td>";
echo "<td>&nbsp;";
echo "</td>";
echo "<td>&nbsp;</td>";
echo "</tr>";

//call_bar_opt
$tmpDef=array(
		//array('value','Name'),
		array('05','激活'),
		array('04','未激活'),
		array('00','未提供')
		);

$cfDef=array(
		//array('fieldName_1','Remark_1','fieldName_2','Remark_2'),
		array('cfu_state',	'无条件转移(CFU)',			'cfu_number',	'无条件转移号码'),
		array('cfb_state',	'遇忙转移(CFB)',		'cfb_num',		'遇忙转移号码'),
		array('cfnry_st',	'无应答转移(CFNRy)',	'cfnry_num',	'无应答转移号码',	'cfnry_time',	'无应答转移时间设置'),
		array('cfnrc_st',	'不在服务区转移(CFNRc)','cfnrc_num',	'不在服务区转移号码')
		);
for($j=0;$j<sizeof($cfDef);$j++){
	$tmpName_1		=$cfDef[$j][0];
	$tmpValue_1		=$tmpRow[$tmpName_1];
	$tmpRemark_1	=$cfDef[$j][1];

	$tmpName_2		=$cfDef[$j][2];
	$tmpValue_2		=str_replace('E','',$tmpRow[$tmpName_2]);
	$tmpValue_2		=str_replace('F','',$tmpRow[$tmpName_2]);
	$tmpRemark_2	=$cfDef[$j][3];
	echo "\n <tr>";
	echo "<td> &nbsp; </td>";
	echo "<td>$tmpRemark_1</td>";
	echo "<td>";
	for($i=0;$i<sizeof($tmpDef);$i++){
		echo "{$tmpDef[$i][1]}<input type=\"radio\" name=\"$tmpName_1\"	value=\"{$tmpDef[$i][0]}\" ";
		if($tmpDef[$i][0] == $tmpValue_1){
			echo "checked";
		}
		echo ">&nbsp;&nbsp;";
	}
	echo "</td>";
	echo "<td>&nbsp;</td>";
	echo "</tr>";

	echo "\n <tr>";
	echo "<td> &nbsp; </td>";
	echo "<td>$tmpRemark_2</td>";
	echo "<td>";
	echo "<input type=\"text\" name=\"$tmpName_2\" value=\"$tmpValue_2\" maxlength=\"16\" class=\"text\">";
	echo "</td>";
	echo "<td>&nbsp;</td>";
	echo "</tr>";
	
	if(strlen($cfDef[$j][4]) > 0){
		$tmpName_3		=$cfDef[$j][4];
		$tmpValue_3		=hexdec($tmpRow[$tmpName_3]);
		$tmpRemark_3	=$cfDef[$j][5];
		echo "\n <tr>";
		echo "<td> &nbsp; </td>";
		echo "<td>$tmpRemark_3</td>";
		echo "<td>";
		echo "<input type=\"text\" name=\"$tmpName_3\" value=\"$tmpValue_3\" maxlength=\"3\" size=\"5\" class=\"text\">(s)";
		echo "</td>";
		echo "<td>&nbsp;</td>";
		echo "</tr>";
	}
}

//Restrict_num
$Restrict_num=$tmpRow[Restrict_num];
echo "\n <tr>";
echo "<td> $seqNo </td>";
$seqNo++;
echo "<td>呼叫组限制</td>";
echo "<td>";
echo "<input type=\"hidden\" name=\"Restrict_num\" value=\"$Restrict_num\">";
echo "<nobr>";
for($i=0;$i<sizeof($restrictDef);$i++){
	$value=getBitValue($Restrict_num,$restrictDef[$i][1]);
	if($value == '1'){
		echo "{$restrictDef[$i][2]}<input type=\"checkbox\" name=\"{$restrictDef[$i][0]}\"	 onClick=selCheckBox(this) value=\"1\" checked>&nbsp;&nbsp;";
	}else{
		echo "{$restrictDef[$i][2]}<input type=\"checkbox\" name=\"{$restrictDef[$i][0]}\"	 onClick=selCheckBox(this) value=\"0\" >&nbsp;&nbsp;";
	}
}
echo "</nobr>";
echo "</td>";
echo "<td>&nbsp;</td>";
echo "</tr>";

$tmpCallDef=array(
		//array('fieldName','Remark'),
		array('CCBS','遇忙回叫'),
		array('mutiPty_call','三方通话'),
		array('malicious_call','通话中转移')
		);
$tmpDef=array(
		//array('value','Name'),
		array('01','提供'),
		array('00','未提供')
		);
for($j=0;$j<sizeof($tmpCallDef);$j++){
	$tmpName=$tmpCallDef[$j][0];
	$tmpValue=$tmpRow[$tmpName];
	$tmpRemark=$tmpCallDef[$j][1];
	echo "\n <tr>";
	echo "<td> $seqNo </td>";
	$seqNo++;
	echo "<td>$tmpRemark</td>";
	echo "<td>";
	for($i=0;$i<sizeof($tmpDef);$i++){
		echo "{$tmpDef[$i][1]}<input type=\"radio\" name=\"$tmpName\"	value=\"{$tmpDef[$i][0]}\" ";
		if($tmpDef[$i][0] == $tmpValue){
			echo "checked";
		}
		echo ">&nbsp;&nbsp;";
	}
	echo "</td>";
	echo "<td>&nbsp;</td>";
	echo "</tr>";
}
?>
</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\">";
?>

</form>
&nbsp;
<?php
adjust_content_tail("down");
?>
</body>
</html>
<?php
flush();
?>