<?php
/**
*@Purpose:	
*		1. CDR details.
*		2. support MSC / PPS / VLR / HLR / SMSC / SMLOG / CNF module.
*File name: cdrDown.php
*Author: Li Long
*Create: No20040316-1
*
*Modifications:
*No.1
*Name:Cui Ticun
*Date:2004-5-27
*Description:Support SMLog
*/
//=============================================================================

function toBreakEchoByLen($name,$len)
{
	$length=strlen($name);
	if($length > $len)
	{
		$name1=substr($name,0,$len);
		echo "$name1";
		$name2=substr($name,$len,$length);
		if($name2)
		echo "<br>$name2";
	}
	else
		echo "$name";
}

require("../../inc/header.inc");
?>

<body leftmargin="15" rightmargin="10" onload="javascript:adjust_frame('down');" onresize="javascript:adjust_frame('down');" style="overflow:hidden;overflow-x:hidden;overflow-y:hidden;">
<FORM name="selectform">

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

adjust_content_head_frame("down");	
echo "<br>";
/*****************  Get the parameter of SMLOG_CONTENT_SHOW_FLAG **************/
$sysId = $_REQUEST['sysId'];
$cdrType= $_REQUEST['cdrType'];
$serverName = $_REQUEST['serverName'];
$queryField = $_REQUEST['queryField'];
$keyWord= $_REQUEST['keyWord'];

$mscType= $_REQUEST['mscType'];
$nextTbNum= $_REQUEST['nextTbNum'];
$nextDispNum= $_REQUEST['nextDispNum'];
$preDispNum= $_REQUEST['preDispNum'];
$preTbNum= $_REQUEST['preTbNum'];
$pageNext= $_REQUEST['pageNext'];
$pagePrevious= $_REQUEST['pagePrevious'];





if($DEBUG)	echo "sysId=$sysId,cdrType=$cdrType, serverName=$serverName, queryField=$queryField<br>";

if(isset($sysId)){
	$sysIdArr=explode('_',$sysId);
	$sysTypeNo	=$sysIdArr[0];
	$sysNo		=$sysIdArr[1];
	$subSysNo	=$sysIdArr[2];
}else{
	echo "Cannot find sysId";
	exit(0);
}
global $pubConn;
$database="OMC_PUB";
$selSql = "select pubVarName,pubVarValue from omcPubVarConf where pubVarName='SMLOG_CONTENT_SHOW_FLAG'";
//echo "selSql=$selSql";
$selRes = @mysqli_query($pubConn,$selSql);

$selRow = @mysqli_fetch_array($selRes);
$SMLOG_CONTENT_SHOW_FLAG=$selRow['pubVarValue'];
//echo "SMLOG_CONTENT_SHOW_FLAG=$SMLOG_CONTENT_SHOW_FLAG<hr><hr><br>";
echo mysqli_error($pubConn);
/********************************************************************************/

$queryField = isset($queryField)?$queryField:"callingNumber";

$cntTbNum=$_REQUEST['cntTbNum'];
$cntTbNum_1=$_REQUEST['cntTbNum_1'];
$cntDispNum=$_REQUEST['cntDispNum'];

require("./cdrHeader.php");

$DEBUG = 0;


$causeForTermArr = array(
	array('num' => '0', 'cause' => 'Using'),
	array('num' => '1', 'cause' => 'Booking'),
	array('num' => '2', 'cause' => 'Delete'),
	array('num' => '3', 'cause' => 'System fail'),
	array('num' => '4', 'cause' => 'HLR fail'),
	array('num' => '5', 'cause' => 'PPS fail')
);

/*******************       Define SS code (MSC use)   ************************/
$arraySsCode[16]="allLinIdentificationSS";
$arraySsCode[17]="clip";
$arraySsCode[18]="clir";
$arraySsCode[19]="colp";
$arraySsCode[20]="colr";
$arraySsCode[21]="mci";
$arraySsCode[24]="allNameIdentificationSS";
$arraySsCode[25]="cnap";
$arraySsCode[32]="allForwardingSS";
$arraySsCode[33]="cfu";
$arraySsCode[40]="allCondForwardingSS";
$arraySsCode[41]="cfb";
$arraySsCode[42]="cfnry";
$arraySsCode[43]="cfnrc";
$arraySsCode[44]="cd";
$arraySsCode[64]="allCallCompletionSS";
$arraySsCode[65]="cw";
$arraySsCode[66]="hold";
$arraySsCode[67]="ccbs-A";
$arraySsCode[68]="ccbs-B";
$arraySsCode[80]="allMultiPartySS";
$arraySsCode[81]="multiPTY";
$arraySsCode[144]="ALLBAR";
$arraySsCode[145]="ALLBAROC";
$arraySsCode[146]="BAOC";
$arraySsCode[147]="BOIC";
$arraySsCode[148]="BOICexHC";
$arraySsCode[153]="BARALLIC";
$arraySsCode[154]="BAIC";
$arraySsCode[155]="BICRoam";
$arraySsCode[49]="ECT";

/*****************   Define display name list  *******************************/
switch($sysTypeNo){
case '270':	//CNF
	$showNameList	= "Type,$strCallISDN,$strCalledISDN,basicService,
				$strSeizureTime,callDuration(S)";
	break;
case '320':	//MSC
	$showNameList	= "$strCallType,IMSI,$strCallISDN,$strCalledISDN,RAN type,
				$strSeizureTime,$strAnswerTime,
				$strConverseTime,$strIncomingTrunkGroup,$strOutgoingTrunkGroup,
				SS code,$strResult";
	break;
case '380': //EIR
	$showNameList	= "Call Type,Status,IMEI,IMSI,Location,Event Time";
	break;
case '386': //EIR
	$showNameList	= "Call Type,Node Name,SSN,Identity,Description,Event Time";
	break;
case '325':	//VLR
	$showNameList	= "$strCallType,IMSI,MSISDN,Old LAC,New LAC,Result,
				$strUpdateTimeStamp";
	break;
case '330':	//HLR
	$showNameList	= "$strCallType,IMSI,MSISDN,$strRoutingNumber,
				$strNumberOfForwarding,$strOldLocation,$strNewLocation,
				Result,$strUpdateTimeStamp";
	break;
case '350':	//SMSC
	$showNameList	= "$strCallType,IMSI,MSISDN,Result,
				$strUpdateTimeStamp";
	break;
case '351':	//SMLOG
	require("./showSmscContent.php");
	if($cdrType==18||$cdrType==21){
		$showNameList	= "$strCaller,$strCalled,$strReceive,$strSent,DCS,$strPriority,$strSMContent";
	}elseif($cdrType==19){
		$showNameList	= "$strCaller,$strCalled,$strReceive,$strDiscarded,$strTimeToLive,DCS,$strPriority,$strSMContent";
	}else{
		$showNameList	= "$strCaller,$strCalled,$strReceive,$strLastAttempt,$strTimeToLive,DCS,$strPriority,$strSMContent";
	}
	break;
case '360':	//PPS
	$moneyPara = getMoneyPara();
	$showNameList	="$strCallType,MSISDN,$strType,$strCallISDN,
				$strCalledISDN,GPRS SGSN IP,
				$strAnswerTime,$strConverseTime,GPRS volume,Peer Address,
				$strCharge,$strBalance";
	break;
case '375':
	$showNameList="Operation Type,IMEI,MSISDN,IMSI,User Type,Seizure,Result";

	break;
default:
	break;
}

if($DEBUG)	echo "showNameList=$showNameList<br>";
$showNameArr=explode(',',$showNameList);
/*****************   Define display name list END ****************************/


?>

<!-------------------------TABLE START::   Display CDR details ------------------------------->
<TABLE width="100%" border="1" cellpadding="2" cellspacing="0" bordercolor="#666666" bordercolordark="#FFFFFF" bgcolor="#FFFFFF">
	<TR bgcolor="#E6E6E6">
	<?php
		for($i=0;$i<sizeof($showNameArr);$i++){
			if($showNameArr[$i]=="Content")
			{
				if($SMLOG_CONTENT_SHOW_FLAG=="Yes")
					echo "<td align=\"center\">{$showNameArr[$i]}</td>";	
			}
			else
			{
				echo "<td align=\"center\">";
				echo "$showNameArr[$i]";
				echo "</td>";
			}	
			
		}
	?>
	<TR>

<?php

/**************   Select field from CDR tables start *************************/
$dispNum = 0;

global $cdrDbConn;
if(!isset($cntTbNum_1))		$cntTbNum_1	= 0;
$limitMin	= $cntDispNum;
$limitMax	= $dispNumOfPerPage;
$preTbNum=$cntTbNum_1;

if($DEBUG)	
echo "while(($dispNum<$dispNumOfPerPage)&&($cntTbNum_1<24)){<br>";
while(($dispNum<$dispNumOfPerPage)&&($cntTbNum_1<24)){
	
	$showTb	= $tbName[$cntTbNum_1];
	if($language == 'gb'){
		$typeFld = " $typeTb.description ";
		$srcFld = " $srcTb.description ";
	}else{
		$typeFld = " $typeTb.description_2 ";
		$srcFld = " $srcTb.description_2 ";
	}

	$order  = " ORDER BY $sortFld ";
	if($keyWord){
		if($queryField=="callingNumber")
			$rrType=6;
		else
			$rrType=7;
		$aWhere = " AND ($queryField like '%$keyWord%' or(recordType=$rrType and serviceCentre like '%$keyWord%'))";
		if($sysId==375)
			$aWhere = " AND $queryField like '%$keyWord%' ";
		else if($sysId==386)
		{
			$aWhere = " AND $queryField like '%$keyWord%' ";
		}
		else if($sysId==380)
		{
			if($eirType == "imei")
				$aWhere = " AND servedIMEI like '%$keyWord%' ";
			else
				$aWhere = " AND servedIMSI like '%$keyWord%' ";
		}
	}

	$bWhere = " WHERE $showTb.recordType = cdrTypeConf.key_type ";
	
	$where = $bWhere.$aWhere;
	$limit  = " LIMIT $limitMin, $limitMax";

	$select = " SELECT *,$typeFld as showType FROM $showTb,$typeTb ";
	
	if($cdrType==18||$cdrType==19||$cdrType==20||$cdrType==21){
		if($keyWord){
			$selSql="SELECT * FROM $showTb WHERE recordType=$cdrType AND $queryField like '%$keyWord%' ".$order.$limit;
		}else{
			$selSql="SELECT * FROM $showTb WHERE recordType=$cdrType".$order.$limit;
		}
	}else{
		if($sysId == 320)
		{
			$mscType=trim($mscType);
			if($mscType == "call")
			{
				$where.=" AND (recordType>=0 and recordType<=5) ";
			}
			else if($mscType == "sm")
			{
				$where.=" AND (recordType>=6 and recordType<=7) ";
			}
			else
			{
				
			}
		}
		if($sysId==375 || $sysId==386)
			$order=" ORDER BY releaseTime DESC ";	
		$selSql = $select.$where.$order.$limit;
	}
	if($DEBUG) 
		echo "<br>down selSql=$selSql<br>";

	$selRes = @mysqli_query($cdrDbConn,$selSql);
	$selRow = @mysqli_fetch_array($selRes);
	$tRecord = @mysqli_num_rows($selRes);
	if($tRecord=="")
		$tRecord = 0;	
	$dispNum = $dispNum + $tRecord;
//	echo mysqli_error($pubConn);
	if(($cntDispNum+$dispNumOfPerPage) > $selRow[0]){
		$cntTbNum_1++;
		$limitMin	= 0;
		if($cntTbNum_1<$nextTbNum){
			$limitMax	= $dispNumOfPerPage;
		}else{
			$limitMax	= $nextDispNum;
		}
	}
	if($DEBUG) echo "<br>tRecord=$tRecord, dispNum=$dispNum<br>";
/**************   Select field from CDR tables end   *************************/

/****************   Display CDR details     **********************************/
	switch($sysTypeNo){
	case '270':	//CNF CDR START
		if($tRecord){
			do{
				$recordType			=	$selRow['recordType'];
				$key_sys_id			=	$selRow['key_sys_id'];
				
				if(5 == $recordType){
					$callingNumber		=	$selRow['callingNumber'];
					$calledNumber		=	$selRow['calledNumber'];
					$basicService		=   $selRow['basicService'];
					$releaseTime		=	$selRow['releaseTime'];
					$callDuration		=   $selRow['callDuration'];
					$causeForTerm		=	$selRow['causeForTerm'];
					
					echo "<tr>";
	
					echo "<td>"; 
					if($causeForTerm<6){
						echo "{$causeForTermArr[$causeForTerm][cause]}";
					}else{
						echo "-- ";
					}
					echo "</td>";
				
					echo "<td>";
					if($callingNumber){
						echo "$callingNumber";
					}else{
						echo "--";
					}
					echo "</td>";
	
					echo "<td>";
					if($calledNumber){
						echo "$calledNumber";
					}else{
						echo "--";
					}
					echo "</td>";
	
					echo "<td>"; 
					if($basicService){
						echo "$basicService";
					}else{
						echo "-- ";
					}
					echo "</td>";
					
					echo "<td>"; 
					if($releaseTime){
						$pieces	= explode(" ",$releaseTime);
						echo "$pieces[1]";
					}else{
						echo "-- ";
					}
					echo "</td>";
	
					echo "<td>"; 
					if($callDuration){
						echo "$callDuration";
					}else{
						echo "-- ";
					}
					echo "</td>";
					echo "</tr>";
	
				}
			}while(@$selRow = @mysqli_fetch_array($selRes));
		}
		break;
		//CNF CDR END
	case '320':	//MSC CDR START
		if($tRecord){
			do{
				$recordType			=	$selRow[recordType];
				$key_sys_id			=	$selRow[key_sys_id];
				$showType			=	$selRow[showType];
				if($recordType == 16)
					continue;
				
				//if($recordType == 7)	echo "recordType=$recordType<br>";
				if($recordType < 6 || $recordType==15){
					$servedIMSI			=	$selRow[servedIMSI];
					$callingNumber		=	$selRow[callingNumber];
					$calledNumber		=	$selRow[calledNumber];
					$recordingEntity	=	$selRow[recordingEntity];
					$mscIncomingTKGP	=	$selRow[mscIncomingTKGP];
					$mscOutgoingTKGP	=	$selRow[mscOutgoingTKGP];
					$supplServicesUsed	=	$selRow[supplServicesUsed];
					$seizureTime		=	$selRow[seizureTime];
					$answerTime			=	$selRow[answerTime];
					$releaseTime		=	$selRow[releaseTime];
					$callDuration		=	$selRow[callDuration];
					$dataVolume			=	$selRow[dataVolume];
					$causeForTerm		=	$selRow[causeForTerm];
					$diagnostics		=	$selRow[diagnostics];
					$sequenceNumber		=	$selRow[sequenceNumber];
					$callReference		=	$selRow[callReference];
					$recordExtensions	=	$selRow[recordExtensions];
					$releaseType		=	$selRow[releaseType];
					$air_type      = $selRow[SystemType];
					//debug_log("/tmp/debug.txt",air_type);
					//debug_log("/tmp/debug.txt",$air_type);
				
					echo "<tr>";
					echo "<td>$showType</td>";
				
					echo "<td>";
					if($servedIMSI){
						echo "$servedIMSI";
					}else{
						echo "--";
					}
					echo "</td>";
	
					echo "<td>";
					if($callingNumber){
						echo "$callingNumber";
					}else{
						echo "--";
					}
					echo "</td>";
	
					echo "<td>";
					if($calledNumber){
						echo "$calledNumber";
					}else{
						echo "--";
					}
					echo "</td>";
						
					echo "<td>";
					if($recordType == 0 || $recordType== 1){
						if($air_type == 0){
							echo "Unknown";
						}elseif($air_type == 1){
							echo "UMTS";
						}elseif($air_type == 2)
						{
							echo "GSM";
						}
					}
					else{
						echo "--";
					}	
					echo "</td>";
	
					echo "<td>";
					if($seizureTime){
						$pieces	= explode(" ",$seizureTime);
						echo "$pieces[1]";
					}else{
						echo "-- ";
					}
					echo "</td>";
	
					echo "<td>";
					if($answerTime){
						$pieces	= explode(" ",$answerTime);
						echo "$pieces[1]";
					}else{
						echo "-- ";
					}
					echo "</td>";
	
					echo "<td>$callDuration</td>";
					echo "<td>$mscIncomingTKGP&nbsp;</td>";
					echo "<td>$mscOutgoingTKGP&nbsp;</td>";
	
					echo "<td>";
					if($arraySsCode[$supplServicesUsed]){
						echo "$arraySsCode[$supplServicesUsed]&nbsp;";
					}else{
						echo "-- ";
					}
					echo "</td>";
	
					echo "<td>";
					if($causeForTerm){
						echo "N";
					}else{
						echo "Y";
					}
					echo "</td>";
					echo "</tr>";
				}elseif($recordType < 8){
					$serviceCentre		=	$selRow[serviceCentre];
					$servedIMSI			=	$selRow[servedIMSI];
					$servedIMEI			=	$selRow[servedIMEI];
					$servedMSISDN		=	$selRow[servedMSISDN];
					$recordingEntity	=	$selRow[recordingEntity];
					$location_mscNumber	=	$selRow[location_mscNumber];
					$releaseTime		=	$selRow[releaseTime];
					$diagnostics		=	$selRow[diagnostics];
					$calledNumber		=	$selRow[calledNumber];
					$air_type      =$selRow[SystemType];
					echo "<tr>";
					echo "<td>$showType</td>";

					echo "<td>";
					if($servedIMSI){
						echo "$servedIMSI";
					}else{
						echo "--";
					}
					echo "</td>";
					
					if($recordType < 7){
						echo "<td>"; 
						if($servedMSISDN){
							echo "$servedMSISDN";
						}else{
							echo "--";
						}
						echo "</td>";
					
						/*echo "<td>"; 
						if($serviceCentre){
							echo "$serviceCentre";
						}else{
							echo "-- ";
						}
						echo "</td>";*/
						echo "<td>"; 
						if($calledNumber){
							echo "$calledNumber";
						}else{
							echo "-- ";
						}
						echo "</td>";
												
						echo "<td>";
						if($recordType == 6){
							if($air_type == 0){
								echo "Unknown";
							}elseif($air_type == 1){
								echo "UMTS";
							}elseif($air_type == 2)
							{
								echo "GSM";
							}
						}
						else{
							echo "--";
						}	
						echo "</td>";
					}else{			
						echo "<td>"; 
						if($serviceCentre){
							echo "$serviceCentre";
						}else{
							echo "-- ";
						}
						echo "</td>";
	
						echo "<td>"; 
						if($servedMSISDN){
							echo "$servedMSISDN";
						}else{
							echo "--";
						}
						echo "</td>";
					
						echo "<td>";
						if($recordType == 7){
							if($air_type == 0){
								echo "Unknown";
							}elseif($air_type == 1){
								echo "UMTS";
							}elseif($air_type == 2)
							{
								echo "GSM";
							}
						}
						else{
							echo "--";
						}	
						echo "</td>";
					}
	
					echo "<td>"; 
					if($releaseTime){
						$pieces	= explode(" ",$releaseTime);
						echo "$pieces[1]";
					}else{
						echo "-- ";
					}
					echo "</td>";
			
					echo "<td>--</td>";
					echo "<td>--</td>";
					echo "<td>--</td>";
					echo "<td>--</td>";
					echo "<td>--</td>";
			
					echo "<td>"; 
					if($diagnostics){
						echo "N";
					}else{
						echo "<font color=\"000000\">Y</font> ";
					}
					echo "</td>";
				}else{
					$servedIMSI			=	$selRow[servedIMSI];
					$serviceCentre		=	$selRow[serviceCentre];
					$callingNumber		=	$selRow[callingNumber];
					$calledNumber		=	$selRow[calledNumber];
					$recordingEntity	=	$selRow[recordingEntity];
					$mscIncomingTKGP	=	$selRow[mscIncomingTKGP];
					$mscOutgoingTKGP	=	$selRow[mscOutgoingTKGP];
					$supplServicesUsed	=	$selRow[supplServicesUsed];
					$seizureTime		=	$selRow[seizureTime];
					$answerTime			=	$selRow[answerTime];
					$releaseTime		=	$selRow[releaseTime];
					$callDuration		=	$selRow[callDuration];
					$dataVolume			=	$selRow[dataVolume];
					$causeForTerm		=	$selRow[causeForTerm];
					$diagnostics		=	$selRow[diagnostics];
					$sequenceNumber		=	$selRow[sequenceNumber];
					$callReference		=	$selRow[callReference];
					$recordExtensions	=	$selRow[recordExtensions];
					$releaseType		=	$selRow[releaseType];
					$air_type      =$selRow[SystemType];
					
					echo "<tr>";
					echo "<TD>$showType</TD>";
				
					echo "<td>";
					if($servedIMSI){
						echo "$servedIMSI";
					}else{
						echo "--";
					}
					echo "</td>";
	
					echo "<td>";
					if($serviceCentre){
						echo "$serviceCentre";
					}else{
						echo "--";
					}
					echo "</td>";
	
					echo "<td>";
					if($calledNumber){
						echo "$calledNumber";
					}else{
						echo "--";
					}
					echo "</td>";
	
					echo "<td>";
						if($recordType == 14){
							if($air_type == 0){
								echo "Unknown";
							}elseif($air_type == 1){
								echo "UMTS";
							}elseif($air_type == 2)
							{
								echo "GSM";
							}
						}
						else{
							echo "--";
						}	
						echo "</td>";
	
					echo "<td>";
					if($releaseTime){
						$pieces	= explode(" ",$releaseTime);
						echo "$pieces[1]";
					}else{
						echo "-- ";
					}
					echo "</td>";
	
					echo "<td>";
					if($answerTime){
						$pieces	= explode(" ",$answerTime);
						echo "$pieces[1]";
					}else{
						echo "-- ";
					}
					echo "</td>";
	
					echo "<td>--</td>";
					echo "<td>--</td>";
					echo "<td>--</td>";
	
					echo "<td>";
					if($arraySsCode[$supplServicesUsed]){
						echo "$arraySsCode[$supplServicesUsed]&nbsp;";
					}else{
						echo "-- ";
					}
					echo "</td>";
	
					echo "<td>";
					if($diagnostics){
						echo "N";
					}else{
						echo "Y";
					}
					echo "</td>";
					echo "</tr>";
				}
			}while(@$selRow = @mysqli_fetch_array($selRes));
		}
		break;
		//MSC CDR details END
	case '325':	//VLR
		if($tRecord){
			do{
				$recordType			=	$selRow[recordType];
				$key_sys_id			=	$selRow[key_sys_id];
				$showType			=	$selRow[showType];
				
				if($recordType == 13){
					$servedIMSI			=	$selRow[servedIMSI];
					$servedMSISDN		=	$selRow[servedMSISDN];
					$oldLoc_area		=	$selRow[oldLoc_area];
					$newLoc_area		=	$selRow[newLoc_area];
					$msClassmark		=	$selRow[msClassmark];
					$recordingEntity	=	$selRow[recordingEntity];
					$releaseTime		=	$selRow[releaseTime];
					$diagnostics		=	$selRow[diagnostics];
					
					echo "<tr>";
					echo "<td>$showType</td>";
				
					echo "<td>";
					if($servedIMSI){
						echo "$servedIMSI";
					}else{
						echo "--";
					}
					echo "</td>";
	
					echo "<td>"; 
					if($servedMSISDN){
						echo "$servedMSISDN";
					}else{
						echo "--";
					}
					echo "</td>";
	
					echo "<td>"; 
					if($oldLoc_area){
						echo "hexdec($oldLoc_area)";
					}else{
						echo "--";
					}
					echo "</td>";
	
					echo "<td>"; 
					if($newLoc_area){
						echo "hexdec($newLoc_area)";
					}else{
						echo "--";
					}
					echo "</td>";
					
					echo "<td>"; 
					if($diagnostics){
						echo "N";
					}else{
						echo "<font color=\"000000\">Y</font> ";
					}
					echo "</td>";
					
					echo "<td>"; 
					if($releaseTime){
						$pieces	= explode(" ",$releaseTime);
						echo "$pieces[1]";
					}else{
						echo "-- ";
					}
					echo "</td>";
					echo "</tr>";
				}
			}while(@$selRow = @mysqli_fetch_array($selRes));
		}
		break;
		//VLR CDR END
	case '330':	//HLR CDR START
		if($tRecord){
			do{
				$recordType			=	$selRow[recordType];
				$key_sys_id			=	$selRow[key_sys_id];
				$showType			=	$selRow[showType];
				
				if($recordType == 11){
					$recordType			=	$selRow[recordType];
					$servedIMSI			=	$selRow[servedIMSI];
					$servedMSISDN		=	$selRow[servedMSISDN];
					$recordingEntity		=	$selRow[recordingEntity];
					$routingNumber		=	$selRow[routingNumber];
					$releaseTime			=	$selRow[releaseTime];
					$numberOfForwarding	=	$selRow[numberOfForwarding];
					$diagnostics			=	$selRow[diagnostics];
					
					echo "<tr>";
					echo "<td>$showType</td>";
				
					echo "<td>";
					if($servedIMSI){
						echo "$servedIMSI";
					}else{
						echo "--";
					}
					echo "</td>";
					
					echo "<td>"; 
					if($servedMSISDN){
						echo "$servedMSISDN";
					}else{
						echo "--";
					}
					echo "</td>";
	
					echo "<td>"; 
					if($routingNumber){
						echo "$routingNumber";
					}else{
						echo "-- ";
					}
					echo "</td>";
	
					echo "<td>"; 
					if($numberOfForwarding){
						echo "$numberOfForwarding";
					}else{
						echo "-- ";
					}
					echo "</td>";
	
					echo "<td>--</td>"; 
					echo "<td>--</td>"; 
					
					echo "<td>"; 
					if($diagnostics){
						echo "N";
					}else{
						echo "<font color=\"000000\">Y</font> ";
					}
					echo "</td>";
					
					echo "<td>"; 
					if($releaseTime){
						$pieces	= explode(" ",$releaseTime);
						echo "$pieces[1]";
					}else{
						echo "-- ";
					}
					echo "</td>";
					echo "</tr>";
				}elseif($recordType == 12){
					$servedIMSI			=	$selRow[servedIMSI];
					$oldLoc_mscNumber	=	$selRow[oldLoc_mscNumber];
					$newLoc_mscNumber	=	$selRow[newLoc_mscNumber];
					$recordingEntity	=	$selRow[recordingEntity];
					$releaseTime		=	$selRow[releaseTime];
					$diagnostics		=	$selRow[diagnostics];
	
					echo "<tr>";
					echo "<td>$showType</td>";
				
					echo "<td>";
					if($servedIMSI){
						echo "$servedIMSI";
					}else{
						echo "--";
					}
					echo "</td>";
					
					echo "<td>--</td>"; 
					echo "<td>--</td>"; 
					echo "<td>--</td>"; 
	
					echo "<td>"; 
					if($oldLoc_mscNumber){
						echo "$oldLoc_mscNumber";
					}else{
						echo "--";
					}
					echo "</td>";
	
					echo "<td>"; 
					if($newLoc_mscNumber){
						echo "$newLoc_mscNumber";
					}else{
						echo "--";
					}
					echo "</td>";
					
					echo "<td>"; 
					if($diagnostics){
						echo "N";
					}else{
						echo "<font color=\"000000\">Y</font> ";
					}
					echo "</td>";
					
					echo "<td>"; 
					if($releaseTime){
						$pieces	= explode(" ",$releaseTime);
						echo "$pieces[1]";
					}else{
						echo "-- ";
					}
					echo "</td>";
					echo "</tr>";
				}
			}while(@$selRow = @mysqli_fetch_array($selRes));
		}
		break;
		//HLR CDR END
	case '350':	//	 SMSC
		if($tRecord){
			do{
				$recordType			=	$selRow[recordType];
				$key_sys_id			=	$selRow[key_sys_id];
				$showType			=	$selRow[showType];
				
				if($DEBUG) echo "<br>recordType=$recordType";
				if($recordType == 8 || $recordType == 9){
					$servedIMSI			=	$selRow[servedIMSI];
					$servedMSISDN		=	$selRow[servedMSISDN];
					$recordingEntity	=	$selRow[recordingEntity];
					$releaseTime		=	$selRow[releaseTime];
					$diagnostics		=	$selRow[diagnostics];
					
					echo "<tr align=\"center\">";
					echo "<td align=\"center\">";
					echo "$showType ";
					echo "</td>";
				
					echo "<td align=\"center\">";
					if($servedIMSI)
						echo "$servedIMSI";
					else
						echo "--";
					echo "</td>";
					
					echo "<td align=\"center\">"; 
					if($servedMSISDN)
						echo "$servedMSISDN";
					else
						echo "--";
					echo "</td>";
					
					echo "<td align=\"center\">"; 
					if($diagnostics)
						echo "N";
					else
						echo "<font color=\"000000\">Y</font> ";
					echo "</td>";
					
					echo "<td align=\"center\">"; 
					if($releaseTime) {
						$pieces	= explode(" ",$releaseTime);
						echo "$pieces[1]";
					}else
						echo "-- ";
					echo "</td>";
					echo "</tr>";
				}
			}while(@$selRow = @mysqli_fetch_array($selRes));
		}
		break;
	case '351':	//	 SMLOG
		if($tRecord){
			do{
				$recordType			=	$selRow[recordType];
				$key_sys_id			=	$selRow[key_sys_id];
					
				if($recordType == 18&&$cdrType==18)
				{
					$callingNumber		=	$selRow[callingNumber];
					$calledNumber		=	$selRow[calledNumber];
					$releaseTime		=	$selRow[releaseTime];
					$smdcs				=   $selRow[smdcs];
					$smcontent 			=	$selRow[smcontent];
					$priority			=	$selRow[priority];
					$receiveTime		=	$selRow[receiveTime];
					$instance			=	$selRow[instance];
					$seqNum				=	$selRow[seqNum];

					echo "<tr>";
									
					echo "<td>";
					if($callingNumber){
						echo "$callingNumber";
					}else{
						echo "--";
					}
					echo "</td>";
	
					echo "<td>";
					if($calledNumber){
						echo "$calledNumber";
					}else{
						echo "--";
					}
					echo "</td>";

					echo "<td>"; 
					if($receiveTime){
						$pieces	= explode(" ",$receiveTime);
						echo "$pieces[1]";
					}else{
						echo "-- ";
					}
					echo "</td>";

					echo "<td>"; 
					if($releaseTime){
						$pieces	= explode(" ",$releaseTime);
						echo "$pieces[1]";
					}else{
						echo "-- ";
					}
					echo "</td>";
					
					echo "<td>"; 
					if(strlen($smdcs)){
						echo "$smdcs";
					}else{
						echo "-- ";
					}
					echo "</td>";

					echo "<td>"; 
					if(strlen($priority)){
						echo "$priority";
					}else{
						echo "-- ";
					}
					echo "</td>";
					if($SMLOG_CONTENT_SHOW_FLAG=="Yes")
					{
						echo "<td>";
	                    if($smcontent){//Changed by hewd
	                    $encodeType=substr(decbin($smdcs),-4,-2);
	                    //echo "smdcs=$smdcs--encodeType=$encodeType----content=$smcontent---";
	                    switch($encodeType)
	                    {
	                    	case '00':
	                        case '0':
	                        case '':
						        echo "$smcontent";
	                            break;
	                        case '01':
	                        case '10':
	                            $utfContent=encodeUTF8($smcontent,$smdcs);
	                            echo "$utfContent";
	                            break;
	                        }
	                    }else{
	                      	echo "-- ";
	                    }
	                    echo "</td>";
           }
                	

	
					echo "</tr>";
					
					
				  /*$seqNum=$seqNum-1;
					for($i=0;$i<24;$i++){
						
						$m=($i<10?"0":"").$i;    
						$tmpTb="cdrFromSMLOG_$m";
						$tmpSql="SELECT * FROM $tmpTb WHERE recordType=17 AND seqNum=$seqNum";
						if($DEBUG) echo "<br>tmpSql=$tmpSql<br>";
						$tmpRes = @mysqli_query($pubConn,$tmpSql);
						$tmpRow = @mysqli_fetch_array($tmpRes);
						if($tmpRow)	break;
					}
					if($tmpRow){
						$callingNumber		=	$tmpRow[callingNumber];
						$calledNumber		=	$tmpRow[calledNumber];
						$releaseTime		=	$tmpRow[releaseTime];
						$smdcs				=   $tmpRow[smdcs];
						$smcontent 			=	$tmpRow[smcontent];
						$priority			=	$tmpRow[priority];
						$receiveTime		=	$tmpRow[receiveTime];
						$instance			=	$tmpRow[instance];
	
						echo "<tr>";
						echo "<td>MO</td>";
					
						echo "<td>";
						if($callingNumber){
							echo "$callingNumber";
						}else{
							echo "--";
						}
						echo "</td>";
		
						echo "<td>";
						if($calledNumber){
							echo "$calledNumber";
						}else{
							echo "--";
						}
						echo "</td>";

						echo "<td>"; 
						if($receiveTime){
							$pieces	= explode(" ",$receiveTime);
							echo "$pieces[1]";
						}else{
							echo "-- ";
						}
						echo "</td>";
						
						echo "<td>"; 
						if($releaseTime){
							$pieces	= explode(" ",$releaseTime);
							echo "$pieces[1]";
						}else{
							echo "-- ";
						}
						echo "</td>";
					
						echo "<td>"; 
						if(strlen($smdcs)){
							echo "$smdcs";
						}else{
							echo "-- ";
						}
						echo "</td>";
	
						echo "<td>"; 
						if(strlen($priority)){
							echo "$priority";
						}else{
							echo "-- ";
						}
						echo "</td>";
	
						echo "<td>"; 
						if($smcontent){//Changed by hewd
							$utfContent=encodeUTF8($smcontent,$smdcs);
							echo "$utfContent";
						}else{
							echo "-- ";
						}
						echo "</td>";
	
						echo "</tr>";
					}*/

				}
				if($recordType == 19&&$cdrType==19)
				{
					$callingNumber		=	$selRow[callingNumber];
					$calledNumber		=	$selRow[calledNumber];
					$releaseTime		=	$selRow[releaseTime];
					$smdcs				=   $selRow[smdcs];
					$smcontent 			=	$selRow[smcontent];
					$priority			=	$selRow[priority];
					$receiveTime		=	$selRow[receiveTime];
					$instance			=	$selRow[instance];
					$delayTime			=	$selRow[delayTime];

					echo "<tr>";
									
					echo "<td>";
					if($callingNumber){
						echo "$callingNumber";
					}else{
						echo "--";
					}
					echo "</td>";
	
					echo "<td>";
					if($calledNumber){
						echo "$calledNumber";
					}else{
						echo "--";
					}
					echo "</td>";

					echo "<td>"; 
					if($receiveTime){
						$pieces	= explode(" ",$receiveTime);
						echo "$pieces[1]";
					}else{
						echo "-- ";
					}
					echo "</td>";

					echo "<td>"; 
					if($releaseTime){
						$pieces	= explode(" ",$releaseTime);
						echo "$pieces[1]";
					}else{
						echo "-- ";
					}
					echo "</td>";

					echo "<td>"; 
					if($delayTime){
						$delayHour	= $delayTime/3600;
						$delayHour	=intval($delayHour);
						$delayHour=($delayHour<10?"0":"").$delayHour;  
						$delayMinute= $delayTime%3600/60;
						$delayMinute	=intval($delayMinute);
						$delayMinute=($delayMinute<10?"0":"").$delayMinute;  
						$delaySecond= $delayTime%3600%60;
						$delaySecond=($delaySecond<10?"0":"").$delaySecond;    
						echo "$delayHour:$delayMinute:$delaySecond";
					}else{
						echo "-- ";
					}
					echo "</td>";
					
					echo "<td>"; 
					if(strlen($smdcs)){
						echo "$smdcs";
					}else{
						echo "-- ";
					}
					echo "</td>";

					echo "<td>"; 
					if(strlen($priority)){
						echo "$priority";
					}else{
						echo "-- ";
					}
					echo "</td>";
	
					if($SMLOG_CONTENT_SHOW_FLAG=="Yes")
					{
						echo "<td>";
	                    if($smcontent){//Changed by hewd
	                    $encodeType=substr(decbin($smdcs),-4,-2);
	                    //echo "smdcs=$smdcs--encodeType=$encodeType----content=$smcontent---";
	                    switch($encodeType)
	                    {
	                    	case '00':
	                        case '0':
	                        case '':
						        echo "$smcontent";
	                            break;
	                        case '01':
	                        case '10':
	                            $utfContent=encodeUTF8($smcontent,$smdcs);
	                            echo "$utfContent";
	                            break;
	                        }
	                    }else{
	                      	echo "-- ";
	                    }
	                    echo "</td>";
           }
	
					echo "</tr>";
				}
				if($recordType == 20&&$cdrType==20){
					$callingNumber		=	$selRow[callingNumber];
					$calledNumber		=	$selRow[calledNumber];
					$releaseTime		=	$selRow[releaseTime];
					$smdcs				=   $selRow[smdcs];
					$smcontent 			=	$selRow[smcontent];
					$priority			=	$selRow[priority];
					$receiveTime		=	$selRow[receiveTime];
					$delayTime			=	$selRow[delayTime];
					$instance			=	$selRow[instance];
					$seqNum				=	$selRow[seqNum];

					echo "<tr>";
														
					echo "<td>";
					if($callingNumber){
						echo "$callingNumber";
					}else{
						echo "--";
					}
					echo "</td>";
	
					echo "<td>";
					if($calledNumber){
						echo "$calledNumber";
					}else{
						echo "--";
					}
					echo "</td>";

					echo "<td>"; 
					if($receiveTime){
						$pieces	= explode(" ",$receiveTime);
						echo "$pieces[1]";
					}else{
						echo "-- ";
					}
					echo "</td>";
					
					echo "<td>"; 
					if($releaseTime){
						$pieces	= explode(" ",$releaseTime);
						echo "$pieces[1]";
					}else{
						echo "-- ";
					}
					echo "</td>";
					
					echo "<td>"; 
					if($delayTime){
						$delayHour	= $delayTime/3600;
						$delayHour	=intval($delayHour);
						$delayHour=($delayHour<10?"0":"").$delayHour; 
						$delayMinute= $delayTime%3600/60;
						$delayMinute	=intval($delayMinute);
						$delayMinute=($delayMinute<10?"0":"").$delayMinute;    
						$delaySecond= $delayTime%3600%60;
						$delaySecond=($delaySecond<10?"0":"").$delaySecond;    
						echo "$delayHour:$delayMinute:$delaySecond";
					}else{
						echo "-- ";
					}
					echo "</td>";


					echo "<td>"; 
					
					if(strlen($smdcs)){
                        echo "$smdcs";
                    }else{
                        echo "-- ";
                    }


					echo "</td>";

					echo "<td>"; 
					if(strlen($priority)){
						echo "$priority";
					}else{
						echo "-- ";
					}
					echo "</td>";
	
					if($SMLOG_CONTENT_SHOW_FLAG=="Yes")
					{
						echo "<td>";
	                    if($smcontent){//Changed by hewd
	                    $encodeType=substr(decbin($smdcs),-4,-2);
	                    //echo "smdcs=$smdcs--encodeType=$encodeType----content=$smcontent---";
	                    switch($encodeType)
	                    {
	                    	case '00':
	                        case '0':
	                        case '':
						        echo "$smcontent";
	                            break;
	                        case '01':
	                        case '10':
	                            $utfContent=encodeUTF8($smcontent,$smdcs);
	                            echo "$utfContent";
	                            break;
	                        }
	                    }else{
	                      	echo "-- ";
	                    }
	                    echo "</td>";
           }
	
					echo "</tr>";
					
				  /*$seqNum=$seqNum-1;
					for($i=0;$i<24;$i++){
						
						$m=($i<10?"0":"").$i;    
						$tmpTb="cdrFromSMLOG_$m";
						$tmpSql="SELECT * FROM $tmpTb WHERE recordType=17 AND seqNum=$seqNum";
						if($DEBUG) echo "<br>tmpSql=$tmpSql<br>";
						$tmpRes = @mysqli_query($pubConn,$tmpSql);
						$tmpRow = @mysqli_fetch_array($tmpRes);
						if($tmpRow)	break;
					}
					if($tmpRow){
						$callingNumber		=	$tmpRow[callingNumber];
						$calledNumber		=	$tmpRow[calledNumber];
						$releaseTime		=	$tmpRow[releaseTime];
						$smdcs				=   $tmpRow[smdcs];
						$smcontent 			=	$tmpRow[smcontent];
						$priority			=	$tmpRow[priority];
						$receiveTime		=	$tmpRow[receiveTime];
						$delayTime			=	$tmpRow[delayTime];
						$instance			=	$tmpRow[instance];

						echo "<tr>";
						echo "<td>Wait to send</td>";
									
						echo "<td>";
						if($callingNumber){
							echo "$callingNumber";
						}else{
							echo "--";
						}
						echo "</td>";
		
						echo "<td>";
						if($calledNumber){
							echo "$calledNumber";
						}else{
							echo "--";
						}
						echo "</td>";
	
						echo "<td>"; 
						if($receiveTime){
							$pieces	= explode(" ",$receiveTime);
							echo "$pieces[1]";
						}else{
							echo "-- ";
						}
						echo "</td>";
					
						echo "<td>"; 
						if($releaseTime){
							$pieces	= explode(" ",$releaseTime);
							echo "$pieces[1]";
						}else{
							echo "-- ";
						}
						echo "</td>";
						
						echo "<td>"; 
						if($delayTime){
							$delayHour	= $delayTime/3600;
							$delayHour	=intval($delayHour);
							$delayHour=($delayHour<10?"0":"").$delayHour; 
							$delayMinute= $delayTime%3600/60;
							$delayMinute	=intval($delayMinute);
							$delayMinute=($delayMinute<10?"0":"").$delayMinute;    
							$delaySecond= $delayTime%3600%60;
							$delaySecond=($delaySecond<10?"0":"").$delaySecond;    
							echo "$delayHour:$delayMinute:$delaySecond";
						}else{
							echo "-- ";
						}
						echo "</td>";

						echo "<td>"; 
						if(strlen($smdcs)){
							echo "$smdcs";
						}else{
							echo "-- ";
						}
						echo "</td>";

						echo "<td>"; 
						if(strlen($priority)){
							echo "$priority";
						}else{
							echo "-- ";
						}
						echo "</td>";
	
						echo "<td>"; 
						if($smcontent){//Changed by hewd
							$utfContent=encodeUTF8($smcontent,$smdcs);
							echo "$utfContent";
						}else{
							echo "-- ";
						}
						echo "</td>";
		
						echo "</tr>";
					}*/
				}

				if($recordType == 21&&$cdrType==21){
					$callingNumber		=	$selRow[callingNumber];
					$calledNumber		=	$selRow[calledNumber];
					$releaseTime		=	$selRow[releaseTime];
					$smdcs				=   $selRow[smdcs];
					$smcontent 			=	$selRow[smcontent];
					$priority			=	$selRow[priority];
					$receiveTime		=	$selRow[receiveTime];
					$instance			=	$selRow[instance];
					$seqNum				=	$selRow[seqNum];

					echo "<tr>";
									
					echo "<td>";
					if($callingNumber){
						echo "$callingNumber";
					}else{
						echo "--";
					}
					echo "</td>";
	
					echo "<td>";
					if($calledNumber){
						echo "$calledNumber";
					}else{
						echo "--";
					}
					echo "</td>";

					echo "<td>"; 
					if($receiveTime){
						$pieces	= explode(" ",$receiveTime);
						echo "$pieces[1]";
					}else{
						echo "-- ";
					}
					echo "</td>";

					echo "<td>"; 
					if($releaseTime){
						$pieces	= explode(" ",$releaseTime);
						echo "$pieces[1]";
					}else{
						echo "-- ";
					}
					echo "</td>";
					
					echo "<td>"; 
					if(strlen($smdcs)){
						echo "$smdcs";
					}else{
						echo "-- ";
					}
					echo "</td>";

					echo "<td>"; 
					if(strlen($priority)){
						echo "$priority";
					}else{
						echo "-- ";
					}
					echo "</td>";
					if($SMLOG_CONTENT_SHOW_FLAG=="Yes")
					{
						echo "<td>";
	                    if($smcontent){//Changed by hewd
	                    $encodeType=substr(decbin($smdcs),-4,-2);
	                    //echo "smdcs=$smdcs--encodeType=$encodeType----content=$smcontent---";
	                    switch($encodeType)
	                    {
	                    	case '00':
	                        case '0':
	                        case '':
						        echo "$smcontent";
	                            break;
	                        case '01':
	                        case '10':
	                            $utfContent=encodeUTF8($smcontent,$smdcs);
	                            echo "$utfContent";
	                            break;
	                        }
	                    }else{
	                      	echo "-- ";
	                    }
	                    echo "</td>";
           }
                	

	
					echo "</tr>";
					
					
				  /*$seqNum=$seqNum-1;
					for($i=0;$i<24;$i++){
						
						$m=($i<10?"0":"").$i;    
						$tmpTb="cdrFromSMLOG_$m";
						$tmpSql="SELECT * FROM $tmpTb WHERE recordType=17 AND seqNum=$seqNum";
						if($DEBUG) echo "<br>tmpSql=$tmpSql<br>";
						$tmpRes = @mysqli_query($pubConn,$tmpSql);
						$tmpRow = @mysqli_fetch_array($tmpRes);
						if($tmpRow)	break;
					}
					if($tmpRow){
						$callingNumber		=	$tmpRow[callingNumber];
						$calledNumber		=	$tmpRow[calledNumber];
						$releaseTime		=	$tmpRow[releaseTime];
						$smdcs				=   $tmpRow[smdcs];
						$smcontent 			=	$tmpRow[smcontent];
						$priority			=	$tmpRow[priority];
						$receiveTime		=	$tmpRow[receiveTime];
						$instance			=	$tmpRow[instance];
	
						echo "<tr>";
						echo "<td>MO</td>";
					
						echo "<td>";
						if($callingNumber){
							echo "$callingNumber";
						}else{
							echo "--";
						}
						echo "</td>";
		
						echo "<td>";
						if($calledNumber){
							echo "$calledNumber";
						}else{
							echo "--";
						}
						echo "</td>";

						echo "<td>"; 
						if($receiveTime){
							$pieces	= explode(" ",$receiveTime);
							echo "$pieces[1]";
						}else{
							echo "-- ";
						}
						echo "</td>";
						
						echo "<td>"; 
						if($releaseTime){
							$pieces	= explode(" ",$releaseTime);
							echo "$pieces[1]";
						}else{
							echo "-- ";
						}
						echo "</td>";
					
						echo "<td>"; 
						if(strlen($smdcs)){
							echo "$smdcs";
						}else{
							echo "-- ";
						}
						echo "</td>";
	
						echo "<td>"; 
						if(strlen($priority)){
							echo "$priority";
						}else{
							echo "-- ";
						}
						echo "</td>";
	
						echo "<td>"; 
						if($smcontent){//Changed by hewd
							$utfContent=encodeUTF8($smcontent,$smdcs);
							echo "$utfContent";
						}else{
							echo "-- ";
						}
						echo "</td>";
	
						echo "</tr>";
					}*/

				}
			}while(@$selRow = @mysqli_fetch_array($selRes));
		}
		break;
		//SMSC/SMLOG CDR END
	case '375':

		$operationType_label=array(0=>"Manual-Registration",
									1=>"Auto-Registration",
									2=>"Account Deletion",
									3=>"Account Enquiry",
									4=>"Switch to Roaming",
									5=>"Switch to OPR",
									6=>"HLR Account Creation",
									7=>"HLR Account Deletion",
									8=>"PPS Account Creation",
									9=>"VLR Location Update");

		$oprFlag_label=array(0=>"Not in Use",1=>"In Use",2=>"In Roaming");
		$termType_label=array(
						 0=>"Normal Release",
				     1=>"No Such MSISDN",
				     2=>"HLR Account Creation Failed",
				     3=>"HLR Account Deletion Failed",
				     4=>"PPS Account Creation Failed",
				     5=>"Can't Assign Process",
				     6=>"Can’t Assign MSISDN",
				     7=>"IMEI Exists",
				     8=>"License Exceecd",
				     9=>"No Such IMEI",
				     10=>"SIM Card Changed",
				     11=>"Get OPR Status Failed",
				     12=>"VLR Location Update Failed");
		if($tRecord){
			do{
				$recordType=$selRow[recordType];
				$key_sys_id=$selRow[key_sys_id];
				$operationType=$selRow[operationType]+0;
				$imei=$selRow[imei];
				$msisdn=$selRow[msisdn];
				$imsi=$selRow[imsi];
				$oprFlag=$selRow[oprFlag]+0;
				$termType=$selRow[termType]+0;
				$seizureTime=$selRow[releaseTime];
				echo "<tr>";


				//
				/*
				if($recordType == 21)
					echo "<td>OPR</td>";
				else if($recordType == 22)
					echo "<td>IMDM</td>";
				else
					echo "<td>--</td>";
				*/
				//
				if($operationType==NULL)
					echo "<td>--</td>";
				else
					echo "<td>{$operationType_label[$operationType]}</td>";

				//
				if($imei)
					echo "<td>$imei</td>";
				else
					echo "<td>--</td>";
				//
				if($msisdn)
					echo "<td>$msisdn</td>";
				else
					echo "<td>--</td>";
				//
				if($imsi)
					echo "<td>$imsi</td>";
				else
					echo "<td>--</td>";

				if($oprFlag<3 && $oprFlag>=0)
					echo "<td>{$oprFlag_label[$oprFlag]}";
				else
					echo "<td>--</td>";
				//
				if($seizureTime)
				{
					$pieces = explode(" ",$seizureTime);
                        		echo "<td>$pieces[1]</td>";
				}
				else
					echo "<td>--</td>";
				if($termType>0)
        	echo "<td>N</td>";
        else
          echo "<td>Y</td>";
				
				echo "</tr>";
			}while(@$selRow = @mysqli_fetch_array($selRes));
		}
			break;
	case '380':

		$status_label=array(0=>"White List",1=>"Black List",2=>"Grey List",3=>"Unknown");

		if($tRecord){
			do{
				$recordType=$selRow[recordType];
				$key_sys_id=$selRow[key_sys_id];
				$eir_imei=$selRow[servedIMEI];
				$eir_imsi=$selRow[servedIMSI];
				$eir_status=$selRow[status];
				$eir_location=$selRow[location];
				$eir_event_time=$selRow[releaseTime];
				echo "<tr>";

				if($recordType == 23)
					echo "<td>IMEI Ticket</td>";
				else
					echo "<td>--</td>";
				
				if($eir_status>=0 && $eir_status<=3)
					echo "<td>{$status_label[$eir_status]}</td>";
				else
					echo "<td>--</td>";
				
				if($eir_imei)
					echo "<td>$eir_imei</td>";
				else
					echo "<td>--</td>";
				//
				if($eir_imsi)
					echo "<td>$eir_imsi</td>";
				else
					echo "<td>--</td>";

				if($eir_location)
					echo "<td>$eir_location</td>";
				else
					echo "<td>--</td>";
				//
				if($eir_event_time)
				{
					$pieces = explode(" ",$eir_event_time);
                        		echo "<td>$pieces[1]</td>";
				}
				else
					echo "<td>--</td>";
					
				
				echo "</tr>";
			}while(@$selRow = @mysqli_fetch_array($selRes));
		}
			break;
	case '386':

	
		if($tRecord){
			do{
				$recordType=$selRow[recordType];
				$key_sys_id=$selRow[key_sys_id];
				$mhc_nodeName=$selRow[nodeName];
				$mhc_ssn=$selRow[ssn]+0;
				$mhc_identity=$selRow[identity];
				$mhc_desc=$selRow[6];
				$mhc_time=$selRow[releaseTime];
				echo "<tr>";


				
				if($recordType == 24)
					echo "<td>MHC</td>";
				else
					echo "<td>--</td>";
				
				
				if(trim($mhc_nodeName)=="")
					echo "<td>--</td>";
				else
					echo "<td>$mhc_nodeName</td>";

				//
				if(trim($mhc_ssn)=="")
					echo "<td>--</td>";
				else
					echo "<td>$mhc_ssn</td>";
				//
				if(trim($mhc_identity)=="")
					echo "<td>--</td>";
				else
					echo "<td>$mhc_identity</td>";
				//
				if(trim($mhc_desc)=="")
					echo "<td>--</td>";
				else
					echo "<td>$mhc_desc</td>";

				
				//
				if($mhc_time)
				{
					$pieces = explode(" ",$mhc_time);
                        		echo "<td>$pieces[1]</td>";
				}
				else
					echo "<td>--</td>";
				
				
				echo "</tr>";
			}while(@$selRow = @mysqli_fetch_array($selRes));
		}
			break;
	case '360':	//PPS CDR START
		if($tRecord){
			do{
				$recordType			=	$selRow[recordType];
				$key_sys_id			=	$selRow[key_sys_id];
				$showType			=	$selRow[showType];
				
				if($recordType == 0 || $recordType == 1 || $recordType == 2){
					$key_sys_id			=	$selRow[key_sys_id];
					$servedIMSI			=	$selRow[servedIMSI];
					$servedMSISDN		=	$selRow[servedMSISDN];
					$callType			=	$selRow[callType];
					$callingNumber		=	$selRow[callingNumber];
					$calledNumber		=	$selRow[calledNumber];
					$recordingEntity	=	$selRow[recordingEntity];
					$seizureTime		=	$selRow[seizureTime];
					$answerTime			=	$selRow[answerTime];
					$releaseTime		=	$selRow[releaseTime];
					$callDuration		=	$selRow[callDuration];
					$causeForTerm		=	$selRow[causeForTerm];
					$callReference		=	$selRow[callReference];
					$releaseType		=	$selRow[releaseType];
					$charge				=	$selRow[charge];
					$balance			=	$selRow[balance];
					$gprs_sgsn_ip=$selRow[gprs_sgsn_ip];
					$gprs_volume=$selRow[gprs_volume]+0;
					$peer_address=$selRow[peerAddress];
					
					if($moneyPara){
						$charge = $charge;//$moneyPara;		//规范显示两位小数
						$balance = $balance;//$moneyPara;		//规范显示两位小数
					}else{
						$charge = 0;		
						$balance = 0;	
					}
					
					"$strCallType,MSISDN,$strType,$strCallISDN,
				$strCalledISDN,GPRS SGSN IP,
				$strAnswerTime,$strConverseTime,GPRS volume,Peer Address,
				$strCharge,$strBalance";
					
					echo "<tr>";
					echo "<td>$showType</td>";

					/*				
					echo "<td>";
					if($servedIMSI){
						echo "$servedIMSI";
					}else{
						echo "--";
					}
					echo "</td>";
					*/
					
					echo "<td>"; 
					if($servedMSISDN){
						echo "$servedMSISDN";
					}else{
						echo "--";
					}
					echo "</td>";
					
					echo "<td>"; 
					switch($callType){
						case '100': echo "$strLocalCallOut";
							break;
						case '101': echo "$strTrunkCallOut";
							break;
						case '102': echo "$strNDDCallOut";
							break;
						case '103': echo "$strHMTCallOut";
							break;
						case '104': echo "$strIDDCallOut";
							break;
						case '105': echo "$strLocalCallIn";
							break;
						case '106': echo "$strTrunkCallIn";
							break;
						case '107': echo "$strPeriodicCharge";
							break;
						case '108': echo "$strIncrementValue";
							break;
						case '109': echo "$strDecreaseValue";
							break;
						case '110': echo "$strRechargeSuccess";
							break;
						case '111': echo "$strRechargeFailure";
							break;
						case '112': echo "MO short message";
							break;
						case '113': echo "MT short message";
							break;
						case '114': echo "Conference call";
							break;
						case '115': echo "Third party charge";
							break;
						case '138': echo "Debit";
							break;
						case '139': echo "Refund";
							break;
						case '140': echo "Transfer out";
							break;
						case '141': echo "Transfer in";
							break;
						case '142': echo "GPRS";
							break;
						case '143': echo "VAS SMS Send";
							break;
						case '144': echo "VAS MMS Send";
							break;
						case '145': echo "VAS MMS Retrieve";
							break;
						case '146': echo "VAS MMS Email";
							break;
						case '147': echo "Bundle Plan Charge";
							break;
						case '148': echo "Data Refund";
							break;
						case '150': echo "Rent ID 1";
							break;
						case '151': echo "Rent ID 2";
                                                        break;
						case '152': echo "Rent ID 3";
                                                        break;
						case '153': echo "Rent ID 4";
                                                        break;
						case '154': echo "Rent ID 5";
                                                        break;
						case '155': echo "Rent ID 6";
                                                        break;
						case '156': echo "Rent ID 7";
                                                        break;
						case '157': echo "Rent ID 8";
                                                        break;
						case '158': echo "FF Activation";
                                                        break;
                                                case '159': echo "FF number edit";
                                                        break;

						default: echo "--";
							break;
					}
					echo "</td>";
	
					echo "<td>"; 
					if($callingNumber){
						toBreakEchoByLen($callingNumber,12);
						/*
						$len=strlen($callingNumber);
						if($len > 8)
						{
							$callingNumber1=substr($callingNumber,0,8);
							echo "$callingNumber1";
							$callingNumber2=substr($callingNumber,8,$len);
							echo "<br>$callingNumber2";
							//$callingNumber=$callingNumber1." ".$callingNumber2;
							}
							else
								echo "$callingNumber";*/
					}else{
						echo "--";
					}
					echo "</td>";

					echo "<td>"; 
					if($calledNumber){
						toBreakEchoByLen($calledNumber,12);
						/*$len=strlen($calledNumber);
						if($len > 8)
						{
							$calledNumber1=substr($calledNumber,0,8);
							echo "$calledNumber1";
							$calledNumber2=substr($calledNumber,8,$len);
							echo "<br>$calledNumber2";
							//$calledNumber=$calledNumber1." ".$calledNumber2;
						}
						else
							echo "$calledNumber";*/
					}else{
						echo "--";
					}
					echo "</td>";
					
					echo "<td>"; 
					if($gprs_sgsn_ip){
						echo "$gprs_sgsn_ip";
					}else{
						echo "--";
					}
					echo "</td>";

					/*
					echo "<td>"; 
					if($seizureTime){
						$pieces	= explode(" ",$seizureTime);
						echo "$pieces[1]";
					}else{
						echo "--";
					}
					echo "</td>";
					*/
					
					echo "<td>"; 
					if($answerTime){
						$pieces	= explode(" ",$answerTime);
						echo "$pieces[1]";
					}else{
						echo "-- ";
					}
					echo "</td>";
				
					echo "<td>"; 
					if($callDuration){
						echo "$callDuration";
					}else{
						echo "-- ";
					}
					echo "</td>";
					
					echo "<td>"; 
					echo "$gprs_volume";
					echo "</td>";
					
					echo "<td>"; 
					if($peer_address){
						toBreakEchoByLen($peer_address,15);
						/*$len=strlen($peer_address);
						if($len > 15)
						{
							$peer_address1=substr($peer_address,0,15);
							echo "$peer_address1";
							$peer_address2=substr($peer_address,15,$len);
							if($peer_address2)
								echo "<br>$peer_address2";
						}
						else
							echo "$peer_address";*/
					}else{
						echo "-- ";
					}
					echo "</td>";
					
					echo "<td align=\"right\">$charge</td>";
					echo "<td align=\"right\">$balance</td>";
					/*
					if($moneyPara < 10){
						printf("<td align=\"right\">%5.0f</td>", $charge);
						printf("<td align=\"right\">%5.0f</td>", $balance);
					}elseif($moneyPara < 100){
						printf("<td align=\"right\">%5.1f</td>", $charge);
						printf("<td align=\"right\">%5.1f</td>", $balance);
					}else{
						printf("<td align=\"right\">%5.2f</td>", $charge);
						printf("<td align=\"right\">%5.2f</td>", $balance);
					}*/
				}
			}while(@$selRow = @mysqli_fetch_array($selRes));
		}
		break;
		//PPS CDR END
	default:
		break;
	}//END switch*/
}//END while
?>
</TABLE>
<!--------------------TABLE END::   Display  CDR details --------------------->
<BR>
</FORM>
<?php
adjust_content_tail("down");
?>
</BODY>
