<?php
/*********************************************************      
 程序说明：         
    功能说明：CNF参数配置

    调用关系：调用: header.inc     
              被调用:   
 
    变量说明：

     返回值：无

 作者：
      
修改注释：      
NO.1      
姓名：            
时间：      
修改说明：      
*********************************************************/  
require("../../inc/header.inc");
$DEBUG = 0;
$maxConfNum = 40;
$maxDurNum = 30*24*4;
$maxUseNum = 24;
$hlrDb = "HLR_DB";

$statusArr=array(
		array('num' => '0',  'remark' => 'Not executable', 'color' => '#FF0000'),
		array('num' => '1',  'remark' => 'Booking', 'color' => '#00FF00'),
		array('num' => '2',  'remark' => 'On going', 'color' => '#0000FF'),
		array('num' => '3',  'remark' => 'Finished', 'color' => '#000000')
);
?>
<script LANGUAGE="JavaScript">           
function openSet(){
	URL="./e1Edit.php";
	var msgWindow = open(URL, 'newWin', 'toolbar=no,directories=no,menubar=no,scrollbars=yes,resizable=yes,status=yes,width=400,height=350');
	msgWindow.focus();
}

function checkNumValue(term){
	var change_num;
	term.style.color = "BLUE";
	term.value = term.value.toUpperCase();
     
	/*
	if(IsEmpty(confForm.cphNum) > 0){
		alert("test");      
	}
	*/

	if(term.value.length > 12){  
		var CorrectItWarning = "Please input digit numbers";
		alert(CorrectItWarning);      
		term.focus(this);
		return (false);
	}
	change_num++;
    
    var allValid = true;
	if (!allValid){  
		var ParaHex="parameter must be a hexadecimal number";
		var Capital="Capital character";
		alert(ParaHex+"，"+"("+Capital+")！");
		term.focus();
		return (false);
	}
}

</script>
<?
$sysTypeNo_0 = "111";
$sysTypeNo_1 = "270";

$db_0 = "OBJ_".$sysTypeNo_0;
$db_1 = "OBJ_".$sysTypeNo_1;

$tb_0 = "param_0";
$tb_1 = "param_1";
$tb_2 = "param_99";

$temTb = ${tb_.$sNum};
$subSysNo = floor($pNum/8);
if($DEBUG)echo "<br>subSysNo=$subSysNo";
$portNo = $pNum%8;
if($DEBUG)echo "<br>portNo=$portNo";

//Attributes of TG
$oidTg = "2.2"; 
$pTg = explode(".",$oidTg);
$i = 0;
$wTg = '';
while(isset($pTg[$i]))
{
	$lNum = $i+1;
	if($DEBUG) echo "<br>pTg[$i]=$pTg[$i]";
	$wTg = $wTg." AND level_$lNum = $pTg[$i] ";
	$i++;
}

function judgeDigit($inString){
	$stringLen = strlen($inString);
	for($i=0;$i<$stringLen;$i++){
		$tmpStr = substr($inString,$i,1);
		switch($tmpStr){
			case "0":
			case "1":
			case "2":
			case "3":
			case "4":
			case "5":
			case "6":
			case "7":
			case "8":
			case "9":
				break;
			default:
				return(0);
		}
	}
	return(1);
};

if($set || $add)
{	
	$drt = ceil(($drt_d*1440+$drt_h*60+$drt_m)/15);
	if($DEBUG)echo "<br>drt=$drt";

	$nowTime=date("Y-m-d H:i:s",mktime());
	$dstTime=date("Y-m-d H:i:s", mktime($hour,$minute,0,$month,$day,date("Y")));
	$maxTime=date("Y-m-d H:i:s", mktime(date("H"),date("i"),date("s"),date("m"),date("d")+20,date("Y")));

	if($DEBUG)echo "<br>nowTime=$nowTime";
	if($DEBUG)echo "<br>dstTime=$dstTime";
	if($DEBUG)echo "<br>maxTime=$maxTime";

	$bgnDate = date("Y-m-d H:i:s", mktime($hour,$minute,0,$month,$day,date("Y")));
	$endDate = date("Y-m-d H:i:s", mktime($hour,$minute+15*$drt,0,$month,$day,date("Y")));
	if($DEBUG)echo "<br>bgnDate=$bgnDate";
	if($DEBUG)echo "<br>endDate=$endDate";
	$bgnTime = '';
	$timeNum = 0;
	if($DEBUG)echo "<br>Analysis new group.";
	
	$sltSql = "SELECT count(*) FROM subscriberData WHERE inter_msisdn like '%$aphNum%'";
	if($DEBUG)echo "<br>sltSql=$sltSql";
	$sltRes = mysqli_query($pubConn,$sltSql);
	$sltRow = mysqli_fetch_array($sltRes);
	$aphCount = $sltRow[0];
	if($DEBUG)echo "<br>aphCount=$aphCount";

	for($i=0;$i<$maxDurNum;$i++){
		if($DEBUG)echo "<br>i=$i";
		$tmpBgnDate = date("Y-m-d H:i:s", mktime(date("H"),date("i")+$i*15,0,date("m"),date("d"),date("Y")));
		$tmpEndDate = date("Y-m-d H:i:s", mktime(date("H"),date("i")+($i+1)*15,0,date("m"),date("d"),date("Y")));
		if($DEBUG)echo "<br>tmpBgnDate=$tmpBgnDate";
		if($DEBUG)echo "<br>tmpEndDate=$tmpEndDate";

		if($tmpEndDate > $bgnDate && $tmpEndDate <= $endDate){
			$timeNum ++;
			if(strlen($bgnTime) < 1){
				$bgnTime = $i;
			}
			$nowArr[$i][0] = $grpNum;
			$nowArr[$i][1] = $cphNum;
			$nowArr[$i][2] = $maxNum;
		}else if($tmpEndDate > $endDate && $tmpBgnDate < $endDate){
			$timeNum ++;

			$nowArr[$i][0] = $grpNum;
			$nowArr[$i][1] = $cphNum;

			$nowArr[$i][2] = $maxNum;				
		}else if($tmpEndDate <= $bgnDate){
			continue;
		}else{
			break;
		}
	}
	if($DEBUG)echo "<br>Analysis all old groups.";
	//added by QShuang in 06-23.
	/************select value to see************/
	//Location management
	$tgSql = " SELECT instanceNo,initValue,editValue,readValue FROM $tb_0 WHERE subSysNo = '0' ".$wTg." ORDER BY instanceNo "; 
	if($DEBUG) echo "<br>tgSql=$tgSql";
	$tgRes = @mysqli_query($pubConn,$tgSql);
	$tgRow = @mysqli_fetch_array($tgRes);
	echo mysqli_error($pubConn);
	$wDef = " AND (";
	$defaultValue_1 = "EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE000000EE";
	
	do
	{
		$instanceNo = $tgRow[instanceNo];
		if($instanceNo == $tNum)//owner
			continue;
		$initValue = $tgRow[initValue];
		if($initValue == $defaultValue || $initValue == $defaultValue_1){
			$cnfShow[$instanceNo] = 0;
			continue;
		}else{
			$cnfShow[$instanceNo] = 1;
			$wDef = $wDef." instanceNo = $instanceNo OR ";
		}
		

		$grpNumTmp = $cnfArr[$instanceNo][0] = HexDec(substr($initValue,0,2));
		if($DEBUG)echo "<br>grpNumTmp=$grpNumTmp";

		$cphNumTmp = substr($initValue,2,16);
		$p1 = explode("E",$cphNumTmp);
		$cphNumTmp = $cnfArr[$instanceNo][1] = $p1[0];
		if($DEBUG)echo "<br>cphNumTmp=$cphNumTmp";


		$pwdTmp = $cnfArr[$instanceNo][2] = substr($initValue,18,4);

		$aphNumTmp = substr($initValue,22,16);
		$p3 = explode("E",$aphNumTmp);
		$aphNumTmp = $cnfArr[$instanceNo][3] = $p3[0];
		if($DEBUG)echo "<br>aphNumTmp=$aphNumTmp";

		$monthTmp = omc_keep_length(HexDec(substr($initValue,38,2)),0,2);
		$dayTmp = omc_keep_length(HexDec(substr($initValue,40,2)),0,2);
		$hourTmp = omc_keep_length(HexDec(substr($initValue,42,2)),0,2);
		$minuteTmp = omc_keep_length(HexDec(substr($initValue,44,2)),0,2);
		$bgnTimeTmp = $cnfArr[$instanceNo][4] = $monthTmp."-".$dayTmp." ".$hourTmp.":".$minuteTmp;
		//echo "cnfArr[$instanceNo][4]={$cnfArr[$instanceNo][4]}<br>";

		$drtTmp = $cnfArr[$instanceNo][5] = HexDec(substr($initValue,46,4));

		$bgnDate = date("Y-m-d H:i:s", mktime($hourTmp,$minuteTmp,0,$monthTmp,$dayTmp,date("Y")));

		$endDate = date("Y-m-d H:i:s", mktime($hourTmp,$minuteTmp+15*$drtTmp,0,$monthTmp,$dayTmp,date("Y")));
	
		$maxNumTmp = $cnfArr[$instanceNo][6] = HexDec(substr($initValue,50,2));

		$sttNumTmp = HexDec(substr($initValue,52,2));
		$statusTmp = $cnfArr[$instanceNo][7] = $statusArr[$sttNumTmp][remark];
		$colorArr[$instanceNo][7] = $statusArr[$sttNumTmp][color];
		if($DEBUG)echo "<br>bgnDate=$bgnDate";
		if($DEBUG)echo "<br>endDate=$endDate";
		if($DEBUG)echo "<br>statusTmp=$statusTmp";
		if($statusTmp == 'Invalid' || $statusTmp == 'Finished'){
			continue;
		}
		//echo "<br>status=$status";
		for($i=0;$i<$maxDurNum;$i++){
			if($DEBUG)echo "<br>i=$i";
			$tmpBgnDate = date("Y-m-d H:i:s", mktime(date("H"),date("i")+$i*15,0,date("m"),date("d"),date("Y")));
			$tmpEndDate = date("Y-m-d H:i:s", mktime(date("H"),date("i")+($i+1)*15,0,date("m"),date("d"),date("Y")));
			if($DEBUG)echo "<br>tmpBgnDate=$tmpBgnDate";
			if($DEBUG)echo "<br>tmpEndDate=$tmpEndDate";

			if($tmpEndDate > $bgnDate && $tmpEndDate <= $endDate){
				if(strlen($timeArr[$i][0]) < 1){
					$timeArr[$i][0] = "-".$grpNumTmp."-";
					$timeArr[$i][1] = "-".$cphNumTmp."-";
				}else{
					$timeArr[$i][0] .= $grpNumTmp."-";
					$timeArr[$i][1] .= $cphNumTmp."-";
				}
				$timeArr[$i][2] += $maxNumTmp;
			}else if($tmpEndDate > $endDate && $tmpBgnDate < $endDate){
				if(strlen($timeArr[$i][0]) < 1){
					$timeArr[$i][0] = "-".$grpNumTmp."-";
					$timeArr[$i][1] = "-".$cphNumTmp."-";
				}else{
					$timeArr[$i][0] .= $grpNumTmp."-";
					$timeArr[$i][1] .= $cphNumTmp."-";
				}
				$timeArr[$i][2] += $maxNumTmp;				
			}else if($tmpEndDate <= $bgnDate){
				continue;
			}else{
				break;
			}
		}
	}while($tgRow = @mysqli_fetch_array($tgRes));
	//echo "<br>bgnTime=$bgnTime";
	//echo "<br>timeNum=$timeNum";

	//select conf ID
	for($j=1;$j<39;$j++){
		if($j%10 == 9 || $j%10 == 0)
			continue;
		$noFind = 1;
		if($DEBUG)echo "<br>j=$j";

		for($i=$bgnTime;$i<$bgnTime+$timeNum;$i++){
			if($DEBUG)echo "<br>timeArr[$i][0]=$timeArr[$i][0]";
			if(strlen(strpos($timeArr[$i][0],"-".$j."-"))){
				$noFind = 1;
				break;
			}else{
				$noFind = 0;
			}
		}
		if($noFind == 0){
			$grpNum = $j;
			break;
		}elseif($noFind == 1 && $j == 38){
			$noUsedId = 1;
		}
	}
	//echo "<br>grpNum=$grpNum";

	for($i=$bgnTime;$i<$bgnTime+$timeNum;$i++){
		if($DEBUG)echo "<br>i=$i";
		if($DEBUG)echo "<br>grpOut=";
		if($DEBUG)echo strpos($timeArr[$i][0],"-".$nowArr[$i][0]."-");
		if($DEBUG)echo "<br>noOut=";
		if($DEBUG)echo strpos($timeArr[$i][1],"-".$nowArr[$i][1]."-");
		if($DEBUG)echo "<br>numOut=";
		if($DEBUG)echo $timeArr[$i][2]+$nowArr[$i][2];
		/*
		if(strlen(strpos($timeArr[$i][0],"-".$nowArr[$i][0]."-"))){
			$grpOutflag = 1;
			$grpOutNo = $i;
			break;
		}else*/
		if(strlen(strpos($timeArr[$i][1],"-".$nowArr[$i][1]."-"))){
			$noOutflag = 1;
			$noOutNo = $i;
			break;
		}elseif($timeArr[$i][2]+$nowArr[$i][2] > $maxUseNum){
			$numOutflag = 1;
			$numOutNo = $i;
			break;
		}
	}
	if($DEBUG){
		for($i=0;$i<10;$i++){//for test
			echo "<br>timeArr[$i][0]={$timeArr[$i][0]}";
			echo "<br>timeArr[$i][1]={$timeArr[$i][1]}";
			echo "<br>timeArr[$i][2]={$timeArr[$i][2]}";

			echo "<br>nowArr[$i][0]={$nowArr[$i][0]}";
			echo "<br>nowArr[$i][1]={$nowArr[$i][1]}";
			echo "<br>nowArr[$i][2]={$nowArr[$i][2]}";
		}
	}
	
	if($dstTime > $maxTime){
		echo "<script language=\"javascript\"> ";
		echo "alert(\"";
		echo "Start time must be within 20 days!";
		echo "\"); ";
		echo "</script>";
	}elseif($dstTime < $nowTime){
		echo "<script language=\"javascript\"> ";
		echo "alert(\"";
		echo "Start time must be later than current time!";
		echo "\"); ";
		echo "</script>";	
	}elseif($noUsedId){
		echo "<script language=\"javascript\"> ";
		echo "alert(\"";
		echo "Overload!";
		echo "\"); ";
		echo "</script>";
	}elseif(strlen($cphNum) < 1){
		echo "<script language=\"javascript\"> ";
		echo "alert(\"";
		echo "Conf number can't be blank!";
		echo "\"); ";
		echo "</script>";
	}elseif(judgeDigit($cphNum) < 1){
		echo "<script language=\"javascript\"> ";
		echo "alert(\"";
		echo "Conf number must be dec digit!";
		echo "\"); ";
		echo "</script>";	
	}elseif(strlen($pwd) < 4){
		echo "<script language=\"javascript\"> ";
		echo "alert(\"";
		echo "Password's length must be 4 digits!";
		echo "\"); ";
		echo "</script>";	
	}elseif(judgeDigit($pwd) < 1){
		echo "<script language=\"javascript\"> ";
		echo "alert(\"";
		echo "Password must be dec digit!";
		echo "\"); ";
		echo "</script>";	
	}elseif(strlen($aphNum) < 1){
		echo "<script language=\"javascript\"> ";
		echo "alert(\"";
		echo "Applicant number can't be blank!";
		echo "\"); ";
		echo "</script>";
	}elseif(judgeDigit($aphNum) < 1){
		echo "<script language=\"javascript\"> ";
		echo "alert(\"";
		echo "Applicant number must be dec digit!";
		echo "\"); ";
		echo "</script>";	
	}elseif($aphCount != 1){
		echo "<script language=\"javascript\"> ";
		echo "alert(\"";
		echo "The applicant number is not in HLR!";
		echo "\"); ";
		echo "</script>";	
	}elseif($drt < 1){
		echo "<script language=\"javascript\"> ";
		echo "alert(\"";
		echo "Duration must be more than zero!";
		echo "\"); ";
		echo "</script>";	
	}elseif($maxNum < 3){
		echo "<script language=\"javascript\"> ";
		echo "alert(\"";
		echo "Max. party must be more than 2!";
		echo "\"); ";
		echo "</script>";
	}elseif($grpOutflag){
		echo "<script language=\"javascript\"> ";
		echo "alert(\"";
		echo "Each conf ID must be unique at the same time!";
		echo "\"); ";
		echo "</script>";
	}elseif($noOutflag){
		echo "<script language=\"javascript\"> ";
		echo "alert(\"";
		echo "Each conf number must be unique at the same time!";
		echo "\"); ";
		echo "</script>";
	}elseif($numOutflag){
		echo "<script language=\"javascript\"> ";
		echo "alert(\"";
		echo "Max parties must be less than $maxUseNum at the same time!";
		echo "\"); ";
		echo "</script>";
	}else{


	$field_1 = omc_keep_length(DecHex($grpNum),0,2);
	if($DEBUG)echo "<br>field_1=$field_1";

	$field_2 = omc_keep_length($cphNum,E,16,0);
	if($DEBUG)echo "<br>field_2=$field_2";

	$field_3 = omc_keep_length($pwd,0,4);
	if($DEBUG)echo "<br>field_3=$field_3";

	$field_4 = omc_keep_length($aphNum,E,16,0);
	if($DEBUG)echo "<br>field_4=$field_4";

	$field_5 = omc_keep_length(DecHex($month),0,2).omc_keep_length(DecHex($day),0,2).omc_keep_length(DecHex($hour),0,2).omc_keep_length(DecHex($minute),0,2);

	$field_6 = omc_keep_length(DecHex($drt),0,4);

	$field_7 = omc_keep_length(DecHex($maxNum),0,2);

	//if($add)
		$sttNum = 4;

	$field_8 = omc_keep_length(DecHex($sttNum),0,2);

	$initValue = $field_1.$field_2.$field_3.$field_4.$field_5.$field_6.$field_7.$field_8;
	$initValue = strtoupper($initValue);
	if($DEBUG)echo "<br>initValue=$initValue";

	$uTgSql = " UPDATE $tb_0 set initValue = '$initValue' WHERE subSysNo = '0' AND instanceNo = '$tNum' ".$wTg; 
	if($DEBUG) echo "<br>uTgSql=$uTgSql";
	$uTgRes = @mysqli_query($pubConn,$uTgSql);
	echo mysqli_error($pubConn);

	
	echo "<script LANGUAGE=\"JavaScript\">";
	echo "window.opener.location.href='./cnfConf.php?scroll_x=$scroll_x&scroll_y=$scroll_y';";		
	echo "\n window.close();";
	echo "\n </script>";
	
	}
}

//echo "<br>oType=$oType";
if($oType < 1 && !$retryInput){
	/************select value to see************/
	//Attributes of TG
	$tgSql = " SELECT instanceNo,initValue,editValue,readValue FROM $tb_0 WHERE subSysNo = '0' AND instanceNo = '$tNum' ".$wTg." ORDER BY instanceNo "; 
	if($DEBUG) echo "<br>tgSql=$tgSql";
	$tgRes = @mysqli_query($pubConn,$tgSql);
	$tgRow = @mysqli_fetch_array($tgRes);
	echo mysqli_error($pubConn);
	$wDef = " AND (";
	do
	{
		$instanceNo = $tgRow[instanceNo];
		$initValue = $tgRow[initValue];
		if($initValue == $defaultValue || $initValue == $defaultValue_1){
			$cnfShow[$instanceNo] = 0;
		}else{
			$cnfShow[$instanceNo] = 1;
		
			$wDef = $wDef." instanceNo = $instanceNo OR ";
		}
	
		//echo "<br>tgShow[$instanceNo]=$cnfShow[$instanceNo]";
		$grpNum = $cnfArr[$instanceNo][0] = HexDec(substr($initValue,0,2));
		if($DEBUG)echo "<br>grpNum=$grpNum";

		$cphNum = substr($initValue,2,16);
		$p1 = explode("E",$cphNum);
		$cphNum = $cnfArr[$instanceNo][1] = $p1[0];
		if($DEBUG)echo "<br>cphNum=$cphNum";

		$pwd = $cnfArr[$instanceNo][2] = substr($initValue,18,4);

		$aphNum = substr($initValue,22,16);
		$p3 = explode("E",$aphNum);
		$aphNum = $cnfArr[$instanceNo][3] = $p3[0];
		if($DEBUG)echo "<br>aphNum=$aphNum";

		$month = omc_keep_length(HexDec(substr($initValue,38,2)),0,2);
		$day = omc_keep_length(HexDec(substr($initValue,40,2)),0,2);
		$hour = omc_keep_length(HexDec(substr($initValue,42,2)),0,2);
		$minute = omc_keep_length(HexDec(substr($initValue,44,2)),0,2);
		$bgnTime = $cnfArr[$instanceNo][4] = $month."-".$day." ".$hour.":".$minute;

		$drt = $cnfArr[$instanceNo][5] = HexDec(substr($initValue,46,4));
		$drt_d = floor($drt*15/1440);
		$drt_h = floor(($drt*15-$drt_d*1440)/60);
		$drt_m = $drt*15-$drt_d*1440-$drt_h*60;
		if($DEBUG)echo "<br>drt=$drt";
		if($DEBUG)echo "<br>drt_d=$drt_d";
		if($DEBUG)echo "<br>drt_h=$drt_h";
		if($DEBUG)echo "<br>drt_m=$drt_m";

		$maxNum = $cnfArr[$instanceNo][6] = HexDec(substr($initValue,50,2));

		$sttNum = HexDec(substr($initValue,52,2));
		$status = $cnfArr[$instanceNo][7] = $statusArr[$sttNum][remark];


	}while($tgRow = @mysqli_fetch_array($tgRes));
}

echo "<form method=\"POST\" name=\"confForm\" action=\"$PHP_SELF\">";
echo "<table border=\"0\" cellpadding=\"2\" cellspacing=\"2\" width=\"100%\">";
if($oType){
	//$nowDate =  getdate();
	$month = date("m", mktime(date("H"),date("i")+6,date("s"),date("m"),date("d"),date("Y")));
	$day = date("d", mktime(date("H"),date("i")+6,date("s"),date("m"),date("d"),date("Y")));
	$hour = date("H", mktime(date("H"),date("i")+6,date("s"),date("m"),date("d"),date("Y")));
	$minute = date("i", mktime(date("H"),date("i")+6,date("s"),date("m"),date("d"),date("Y")));
	//echo "<br>month=$month";
	//echo "<br>day=$day";
	//echo "<br>hour=$hour";
	//echo "<br>minute=$minute";

	/************get default value**************/
	$defSql = " SELECT initValue FROM paramConf WHERE keyId > 0 ".$wTg;
	$defRes = @mysqli_query($pubConn,$defSql);
	$defRow = @mysqli_fetch_array($defRes);
	$defaultValue = $defRow[initValue];

	$defaultValue_1 = "EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE000000EE";

	$tgFlagSql = " SELECT instanceNo,initValue,editValue,readValue FROM $tb_0 WHERE subSysNo = '0' ".$wTg." ORDER BY instanceNo "; 
	if($DEBUG)echo "<br>tgFlagSql=$tgFlagSql";
	$tgFlagRes = @mysqli_query($pubConn,$tgFlagSql);
	$tgFlagRow = @mysqli_fetch_array($tgFlagRes);
	echo mysqli_error($pubConn);
	$crtConfNum = 0;
	do
	{
		$instanceNo = $tgFlagRow[instanceNo];
		$initValue = $tgFlagRow[initValue];
		$tmpConfId = substr($initValue,0,2);
		//echo "<br>tmpConfId=$tmpConfId";
		if($tmpConfId > 0 && $tmpConfId <= $maxConfNum){
			$confArr[$crtConfNum++] = $tmpConfId;
		}

		if($initValue == $defaultValue || $initValue == $defaultValue_1){
			$cnfShow[$instanceNo] = 0;
		}else{
			$cnfShow[$instanceNo] = 1;
		}
	}while($tgFlagRow = @mysqli_fetch_array($tgFlagRes));
	
	/*
	echo "<tr>";
	echo "<td colspan=\"4\"><b>Please add records.</b></td>";
	echo "</tr>";
	*/
	
	echo "<tr>";
	//echo "<td width=\"60\" valign=middle><nobr>Reservation  </nobr></td>";
	//echo "<td colspan=\"2\">";
	//echo "<select style=\"font-family: Verdana; font-size: 8pt\" size=\"1\" name=\"tNum\" id=\"tNum\">";
	for($i=0;$i<400;$i++)
	{
		if(!$cnfShow[$i]){
			echo "<td colspan=\"4\"><b>Reservation $i</b></td>";
			echo "<input type=\"hidden\" name=\"tNum\" value=\"$i\">";
			break;
		}
	}
	//echo "</select>";
	//echo "</td>";
	echo "</tr>";
	
	/*
	//echo "<br>crtConfNum=$crtConfNum";
	echo "<tr>";
	echo "<td width=\"60\" valign=middle><nobr>Conf ID</nobr></td>";
	echo "<td colspan=\"2\">";
	//echo "<input type=\"text\" name=\"grpNum\" size=\"3\" value=\"$grpNum\" maxLength=\"3\">";
	echo "<select name=\"grpNum\">";
	for($i=1;$i<$maxConfNum+1;$i++){
		$noShow = 0;
		for($j=0;$j<$crtConfNum;$j++){
			//echo "<br>confArr[$j]=$confArr[$j]";
			if($i == $confArr[$j]){
				$noShow = 1;
				break;
			}
		}
		if(!$noShow){
			echo "<option value=$i>$i</option>";
		}
	}
	echo "</select>";
	echo "</td>";
	echo "</tr>";
	*/
}else{
	echo "<tr>";
	echo "<td colspan=\"4\"><b>Reservation $tNum</b></td>";
	echo "</tr>";

	/*
	echo "<tr>";
	echo "<td width=\"60\" valign=middle><nobr>Conf ID</nobr></td>";
	echo "<td colspan=\"2\">";
	echo "$grpNum";
	echo "</td>";
	echo "</tr>";
	*/
}

/*
echo "<tr>";
echo "<td width=\"60\" valign=middle><nobr>Conf ID</nobr></td>";
echo "<td colspan=\"2\">";
//echo "<input type=\"text\" name=\"grpNum\" size=\"3\" value=\"$grpNum\" maxLength=\"3\">";
echo "<select name=\"grpNum\">";
for($i=1;$i<41;$i++){
	if($i%10 == 0 || $i%10 == 9)
		continue;
	if($grpNum == $i)
		echo "<option value=\"$i\" selected>$i</option>";
	else
		echo "<option value=\"$i\">$i</option>";
}
echo "</select>";
echo "</td>";
echo "</tr>";
*/


echo "<tr>";
echo "<td width=\"60\" valign=middle><nobr>Conf number</nobr></td>";
echo "<td colspan=\"2\"><input type=\"text\" name=\"cphNum\" size=\"16\" value=\"$cphNum\" maxLength=\"16\"></td>";
echo "</tr>";
//class=\"button\"

echo "<tr>";
echo "<td width=\"60\" valign=middle><nobr>Password</nobr></td>";
echo "<td colspan=\"2\"><input type=\"text\" name=\"pwd\" size=\"4\" value=\"$pwd\" maxLength=\"4\">(Please input 4 digits)</td>";
echo "</tr>";

echo "<tr>";
echo "<td width=\"60\" valign=middle><nobr>Applicant</nobr></td>";
echo "<td colspan=\"16\"><input type=\"text\" name=\"aphNum\" size=\"16\" value=\"$aphNum\" maxLength=\"16\"></td>";
echo "</tr>";

echo "<tr>";
echo "<td width=\"60\" valign=middle><nobr>Start time</nobr></td>";
echo "<td colspan=\"2\">";
//echo "<input type=\"text\" name=\"month\" size=\"2\" value=\"$month\" maxLength=\"2\">-";
echo "<select name=\"month\">";
for($i=1;$i<13;$i++){
	if($month == $i)
		echo "<option value=\"$i\" selected>$i</option>";
	else
		echo "<option value=\"$i\">$i</option>";
}
echo "</select>";
echo "-";
echo "<select name=\"day\">";
for($i=1;$i<32;$i++){
	if($day == $i)
		echo "<option value=\"$i\" selected>$i</option>";
	else
		echo "<option value=\"$i\">$i</option>";
}
echo "</select>";
echo "&nbsp;&nbsp;";
//echo "<input type=\"text\" name=\"day\" size=\"2\" value=\"$day\" maxLength=\"2\">&nbsp;";
echo "<select name=\"hour\">";
for($i=0;$i<24;$i++){
	if($hour == $i)
		echo "<option value=\"$i\" selected>$i</option>";
	else
		echo "<option value=\"$i\">$i</option>";
}
echo "</select>";
echo ":";
//echo "<input type=\"text\" name=\"hour\" size=\"2\" value=\"$hour\" maxLength=\"2\">:";
echo "<select name=\"minute\">";
for($i=0;$i<60;$i++){
	if($minute == $i)
		echo "<option value=\"$i\" selected>$i</option>";
	else
		echo "<option value=\"$i\">$i</option>";
}
echo "</select>";
//echo "<input type=\"text\" name=\"minute\" size=\"2\" value=\"$minute\" maxLength=\"2\">";
//echo "(e.g. 06-13 09:50)";
echo "</td>";
echo "</tr>";

echo "<tr>";
echo "<td width=\"60\" valign=middle><nobr>Duration</nobr></td>";
//echo "<td colspan=\"2\"><input type=\"text\" name=\"drt\" size=\"6\" value=\"$drt\" maxLength=\"6\">(x15min)</td>";
echo "<td colspan=\"2\">";
echo "<select name=\"drt_d\">";
for($i=0;$i<10;$i++){
	if($drt_d == $i)
		echo "<option value=\"$i\" selected>$i</option>";
	else
		echo "<option value=\"$i\">$i</option>";
}
echo "</select>";
echo "D&nbsp;&nbsp;";
echo "<select name=\"drt_h\">";
for($i=0;$i<24;$i++){
	if($drt_h == $i)
		echo "<option value=\"$i\" selected>$i</option>";
	else
		echo "<option value=\"$i\">$i</option>";
}
echo "</select>";
echo "H&nbsp;&nbsp;";
echo "<select name=\"drt_m\">";
for($i=1;$i<60;$i++){
	if($drt_m == $i)
		echo "<option value=\"$i\" selected>$i</option>";
	else
		echo "<option value=\"$i\">$i</option>";
}
echo "</select>";
echo "M&nbsp;&nbsp;";

/*
echo "<select name=\"drt\">";
for($i=1;$i<960+1;$i++){
	if($drt == $i)
		echo "<option value=\"$i\" selected>$i</option>";
	else
		echo "<option value=\"$i\">$i</option>";
}
echo "</select>";
echo "(x15min)";
*/
echo "</td>";
echo "</tr>";

echo "<tr>";
echo "<td width=\"60\" valign=middle><nobr>Max. party</nobr></td>";
//echo "<td colspan=\"2\"><input type=\"text\" name=\"maxNum\" size=\"3\" value=\"$maxNum\" maxLength=\"3\"></td>";
echo "<td colspan=\"2\">";
echo "<select name=\"maxNum\">";
for($i=3;$i<13;$i++){
	if($maxNum == $i)
		echo "<option value=\"$i\" selected>$i</option>";
	else
		echo "<option value=\"$i\">$i</option>";
}
echo "</select>";
echo "</td>";
echo "</tr>";
echo "<input type=\"hidden\" name=\"sttNum\" value=\"$sttNum\">";
echo "</table>";
//echo "<br><u><b>Remark:</b></u>";
echo "<br>";
if($oType){
	echo "<input type=\"submit\" name=\"add\" value = \"Add\" class=\"button\">";
	echo "&nbsp;&nbsp;";
}else{
	echo "<input type=\"submit\" name=\"set\" value = \"Set\" class=\"button\">";
	echo "&nbsp;&nbsp;";
	echo "<input type=\"hidden\" name=\"tNum\" value =\"$tNum\">";
	//echo "<input type=\"hidden\" name=\"grpNum\" value =\"$grpNum\">";
}
echo "<input type=\"reset\" name=\"Reset\" value =\"Reset\" class=\"button\">";
echo "<input type=\"hidden\" name=\"scroll_x\" value =\"$scroll_x\">";
echo "<input type=\"hidden\" name=\"scroll_y\" value =\"$scroll_y\">";
echo "<input type=\"hidden\" name=\"retryInput\" value =\"1\">";
echo "</form>";
?>
<B>Remarks:</B><br><br>
Reservation: Reservation number of the conference. A CNF supports 400 conference reservations<br><br>
Conf ID: The Conf ID ranges from 1 to 40. A CNF contains four cards. Each card can host ten groups (Card 0-3 has conference 1-10, 11-20, 21-30, and 31-40 respectively). When to select Conf ID, do not assign a group ID to more than one conference which are scheduled at the same time, and make sure that at any time, do not arrange groups with totally more than 30 conference parties on a single card at the same time<br><br>
Conf number: Before setting the Conf number, make sure that the prefix to CNF has been set in MSC. There are total 40 different conference numbers available for 40 conferences. Each conference number is dedicated to one conference and begins with the same CNF prefix. Both conference number and group ID is in control of a conference. For example, the prefix to the CNF is set as 8888 in MSC. We can set 888801 to 888840 for group 1 to 40 respectively<br><br>
Applicant: The Applicant is a system subscriber who will be charged for this conference. The applicant can be suggested by any proposer and confirmed by operator<br><br>
Password: A 4-digit Password used to secure entering to a conference. This password may be proposed by either operator or applicant<br><br>
Start time: The Start time is scheduled per reservation. The format is month-day hour-minute. Debiting will be starts at this scheduled time unless this conference is canceled before the start time<br><br>
Duration: Booked duration of a conference, unit = 15 minutes. Conference will be concluded when the duration is used up<br><br>
Max. party: Limits the quantity of parties for this conference. The quantity of parties is involved in debiting. Conference debiting = Duration x Billing rate x Max party num. System supports maximum 15 parties for a single conference. Each party will be charged as normal call during the conference<br><br>
Status: Read only, status of conference, refreshed on a daily basis. Booked = conference is booked, In use = ongoing conference, Finished = conference has finished, Invalid = applicant is invalid because of low balance or suspended



</html>
