<?php

require("../../inc/header.inc");
require("logdb.inc");
require("function.php");

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

//******
//$url_temp=$_SERVER["REQUEST_URI"];
//echo "This page URL:$url_temp<br>";

echo "<table border=\"0\" width=\"100%\">";
echo "<tr>";
echo "<td width=\"50%\">";
echo "Configuration > <a href=\"JavaScript:backpage(1,'../overview/overview.php')\" > Network</a>";
echo " > BSS Specific";
echo "</td>";
echo "</tr>";
echo "</table>";

function flash($bssid)
{
	
	echo "<script language=\"javascript\">";
			$href="$PHP_SELF?bssid=$bssid";
	echo "window.location.href='$href';";
	echo "</script>";
}
if($addtype=="BtsMgr")
{
	if($btsid>12)
	{
		echo "<script LANGUAGE=\"JavaScript\">";
		echo "alert(\"Bts number is too big!\");";
		echo "</script>";
	}
	else
	{
	$nmicmd="create BtsMgr ".$btsid;
	$objectid="BssFunc";
	putcommand($bssid,$objectid,$nmicmd);
	sleep(1);
	}
	
	flash($bssid);
}
if($deltype=="BtsMgr")
{
	//echo "BtsMgr is OK!<br>";
	$nmicmd="delete BtsMgr ".$btsid;
	$objectid="BssFunc";
	putcommand($bssid,$objectid,$nmicmd);
	sleep(1);
	flash($bssid);
}
if($upload==1)
{
	$nmicmd="upload 12";
	$objectid="BssFunc";
	putcommand($bssid,$objectid,$nmicmd);
	sleep(3);
	flash($bssid);
}

         $nmicmd="get";
         $objectid="BssFunc";
//         putcommand($bssid,$objectid,$nmicmd);

	$sqlstring = "select BsPlus,BsPlusMaxExtBtsMgr from OMCR_BssFunc where bssid=$bssid";
	//echo $sqlstring . "<BR>";
	$result = mysqli_query($pubConn,$sqlstring) or
          die("Invalid query: $sqlstring\n" . mysqli_error($pubConn));
	$row = mysqli_fetch_row($result);
	$isbsplus = $row[0];
	//if($row[0]=='')
	//{
	//	$nmicmd="get";
	//	$objectid="BssFunc";
	//	putcommand($bssid,$objectid,$nmicmd);
		//flash($bssid);
	//}
	$bsplusbtsno = $row[1];
	if($isbsplus==1)
		$checkbsstype="Bsplus";
	else if($isbsplus==0)
		$checkbsstype="BSC+BTS";


	
$db = mysql_connect($hostname, $username, $password);
mysql_select_db($dbname,$db);

$sqlstring = "select name,ip from OMCR_BSSTABLE where bssid=$bssid";

//echo $sqlstring . "<BR>";
$result = mysqli_query($pubConn,$sqlstring) or
          die("Invalid query: $sqlstring\n" . mysqli_error($pubConn));
$row = mysqli_fetch_row($result);
{
	$name = $row[0];
	$ip   = $row[1];
}
//if($software=='')
//	{
//		$nmicmd="get";
//		$objectid="Software.0";
//		putcommand($bssid,$objectid,$nmicmd);
//	}
$sqlstring = "select CurrentBuildDir,CurrentSoftwareVersion from OMCR_Software where bssid=$bssid";
//echo $sqlstring . "<BR>";
$result = mysqli_query($pubConn,$sqlstring) or
          die("Invalid query: $sqlstring\n" . mysqli_error($pubConn));
$row = mysqli_fetch_row($result);

$software = $row[0];
$version =  $row[1];
$upload = 1;
echo "<table width=\"100%\"border=\"0\" width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" bordercolor=\"#666666\" bordercolordark=\"#FFFFFF\">";
	echo "<tr>";
		echo "<td width=\"75%\"></td>";
		echo "<td width=\"15%\">";
		echo "<INPUT type=button style='width: 85' value='Get All' name=upload style='width: 95' class=chinese" .
             " onClick=\"JavaScript:upload_data('$upload','$bssid')\"></td>";
		echo "<td width=\"10%\"><a href=\"JavaScript:backpage(1,'../overview/overview.php')\"><img align=absBottom border=0 src=\"../../images/left.gif\" width=\"14\" height=\"14\">Back</a></td>";
	echo "</tr>";
echo "</table>";
echo "<table width=\"100%\"border=\"0\" width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" bordercolor=\"#666666\" bordercolordark=\"#FFFFFF\">";
	echo "<tr>";
		echo "<td width=\"20%\"><b>BSS Name:</b>&nbsp;<FONT color=#0000FF size=+2pt>$name</FONT></td>";
		echo "<td width=\"25%\"><b>IP Address:</b>&nbsp;<FONT color=#0000FF size=+2pt>$ip</FONT></td>";
		echo "<td width=\"35%\"><b>Software Version:</b>&nbsp;<FONT color=#0000FF size=+2pt>$software/$version</FONT></td>";
		echo "<td width=\"15%\"><b>BSS Type:</b>&nbsp;<FONT color=#0000FF size=+2pt>$checkbsstype</FONT></td>";
	echo "</tr>";
echo "</table>";

?>

<TABLE  border="1"  cellpadding="2" cellspacing="0" bordercolor="#666666" bordercolordark="#FFFFFF" bgcolor="#FFFFFF" width="100%">

<?php
$sqlstring = "select AdminState,OperState,AvailStatus,PointCode,NetworkIndicator from OMCR_AIf where bssid=$bssid";
			    //echo $sqlstring . "<BR>";
				$result = mysqli_query($pubConn,$sqlstring) or
				die("Invalid query: $sqlstring\n" . mysqli_error($pubConn));
				
				while($row = mysqli_fetch_row($result))
				{
					list($adminstate,$operstate,$availstatus,$pc,$ni) =$row;
				}

				if($adminstate==1)$adminstate="Locked";
				else if($adminstate==2)$adminstate="Unlocked";
				if($operstate==1)$operstate="Disable";
				else if($operstate==2)$operstate="Enable";
				if($availstatus==0)$availstatus="In_Test";
				else if($availstatus==1)$availstatus="Failed";
				else if($availstatus==2)$availstatus="Power_Off";
				else if($availstatus==3)$availstatus="Offline";
				else if($availstatus==4)$availstatus="Online";
				else if($availstatus==5)$availstatus="Dependency";
				else if($availstatus==6)$availstatus="Degraded";
				else if($availstatus==7)$availstatus="Not_Installed";
				//International =0;SPARE=1;National=2;RNational=3 
				if($ni==0)$ni="International";
				else if($ni==1)$ni="SPARE";
				else if($ni==2)$ni="National";
				else if($ni==3)$ni="RNational";
			
echo "<tr>";
	echo "<td width=\"20%\" bgcolor=\"#E6E6E6\"><a href=\"./bss_aif.php?bssid=$bssid\";><b>AIf</b></a></td>";
	       echo "<td>";
			echo "<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\">";
			echo "<tr bgcolor=\"#E6E6E6\">";
				echo "<td width=\"25%\">BSS Point Code</td>";
				echo "<td width=\"20%\">AdminState</td>";
				echo "<td width=\"20%\">OperState</td>";
				echo "<td width=\"20%\">AvailStatus</td>";
				echo "<td width=\"15%\">NI</td>";
				echo "</td>";
			echo "</tr>";
			
           
				echo "<td width=\"25%\"><a href=\"./objShow.php?language=$language&objectid=AIf.0&tablename=OMCR_AIf&bssid=$bssid\";>$pc</a></td>";
				echo "<td width=\"20%\">$availstatus</td>";
				echo "<td width=\"20%\">$operstate</td>";
				echo "<td width=\"20%\">$availstatus</td>";
				echo "<td width=\"25%\"><a href=\"./objShow.php?language=$language&objectid=AIf.0&tablename=OMCR_AIf&bssid=$bssid\";>$ni</a></td>";
			
                echo "</tr>";
                
		    echo "</table>";
echo "</tr>";
//shelf============================================================
echo "<tr>";
echo "<td width=\"20%\" bgcolor=\"#E6E6E6\"><b>SHELF</b></td>";
echo "<td>";
			echo "<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\">";
			echo "<tr bgcolor=\"#E6E6E6\">";
				echo "<td width=\"25%\">Door Alarm</td>";
				echo "<td width=\"40%\">Uplink Volume Control</td>";
				echo "<td width=\"30%\">Downlink Volume Control</td>";
				echo "</td>";
			echo "</tr>";
			
           
				echo "<td width=\"25%\"><a href=\"./objShow.php?language=$language&objectid=Shelf.0&tablename=OMCR_Wavex&bssid=$bssid\";>Disable</a></td>";
				echo "<td width=\"35%\"><a href=\"./objShow.php?language=$language&objectid=Shelf.0&tablename=OMCR_Wavex&bssid=$bssid\";>normal</a></td>";
				echo "<td width=\"35%\"><a href=\"./objShow.php?language=$language&objectid=Shelf.0&tablename=OMCR_Wavex&bssid=$bssid\";>normal</a></td>";
			
                echo "</tr>";
                
            echo "<tr>";
///////////////////////////////////////////////////////////////////////////////            
			echo "<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\">";
			echo "<tr bgcolor=\"#E6E6E6\">";
			    
				echo "<td width=\"25%\">No</td>";
				echo "<td width=\"20%\">AdminState</td>";
				echo "<td width=\"20%\">OperState</td>";
				echo "<td width=\"20%\">AvailStatus</td>";
                echo "<td width=\"15%\">Interface</td>";
            echo "</tr>";
//Card ================================================================================================
//...>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


$sqlstring = "select engDisplayName,ObjectId from OMCR_BSSTREE where engDisplayName like 'Card%' and Presence=1 and ObjectId not like 'BtsMgr_Shelf%' and bssid=$bssid";
//echo $sqlstring . "<BR>";
$result = mysqli_query($pubConn,$sqlstring) or
          die("Invalid query: $sqlstring\n" . mysqli_error($pubConn));
while($row = mysqli_fetch_row($result))
{
	list($display_name[],$object_name[]) =$row;
}
$no_of_obj = count($object_name);



$sqlstring = "select engDisplayName,ObjectId from OMCR_BSSTREE where engDisplayName like 'DSP Card%' and Presence=1 and bssid=$bssid";
//echo $sqlstring . "<BR>";
$result = mysqli_query($pubConn,$sqlstring) or
          die("Invalid query: $sqlstring\n" . mysqli_error($pubConn));
    while($row = mysqli_fetch_row($result))
    {
	list($dsp_display_name[],$dsp_object_name[]) =$row;
    }
$no_of_dsp = count($dsp_object_name);
echo "<tr>";
for($i=0;$i<$no_of_obj;$i++)
{
		$conts = explode(".",$object_name[$i]);//Card.0.1
				$sqlstring = "select Presence from OMCR_BSSTREE where ObjectId='Port.0.$conts[2].0' and bssid=$bssid";
				$result = mysqli_query($pubConn,$sqlstring) or
				die("Invalid query: $sqlstring\n" . mysqli_error($pubConn));
				$row = mysqli_fetch_row($result);
				$presence0 = $row[0];
				$sqlstring = "select Presence from OMCR_BSSTREE where ObjectId='Port.0.$conts[2].1' and bssid=$bssid";
				$result = mysqli_query($pubConn,$sqlstring) or
				die("Invalid query: $sqlstring\n" . mysqli_error($pubConn));
				$row = mysqli_fetch_row($result);
				$presence1 = $row[0];
if($presence0==1&&$presence1==1){//////////////////////////////////	
	
					//print_r($object_name);		
				echo "<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\">";
				//echo "<td width=\"13%\"><a href=\"./objShow.php?language=$language&objectid=Port.0.$conts[2].0&tablename=OMCR_E1port&bssid=$bssid\";>Port 0</a>";
				echo "<td width=\"12%\"><a href=\"./objShow.php?language=$language&objectid=$object_name[$i]&tablename=OMCR_E1trmod&bssid=$bssid\";>$display_name[$i]</td>";
                

				
					
				$sqlstring = "select AdminState,OperState,AvailStatus,INTERFACE from OMCR_E1port where ObjectId='Port.0.$conts[2].0' and bssid=$bssid";
			    //echo $sqlstring . "<BR>";
				$result = mysqli_query($pubConn,$sqlstring) or
				die("Invalid query: $sqlstring\n" . mysqli_error($pubConn));
				
				while($row = mysqli_fetch_row($result))
				{
					list($adminstate,$operstate,$availstatus,$interface) =$row;
				}

				if($adminstate==1)$adminstate="Locked";
				else if($adminstate==2)$adminstate="Unlocked";
				if($operstate==1)$operstate="Disable";
				else if($operstate==2)$operstate="Enable";
				if($availstatus==0)$availstatus="In_Test";
				else if($availstatus==1)$availstatus="Failed";
				else if($availstatus==2)$availstatus="Power_Off";
				else if($availstatus==3)$availstatus="Offline";
				else if($availstatus==4)$availstatus="Online";
				else if($availstatus==5)$availstatus="Dependency";
				else if($availstatus==6)$availstatus="Degraded";
				else if($availstatus==7)$availstatus="Not_Installed";
				if($interface==0)$interface="Unused";
				else if($interface==1)$interface="AIF";
				else if($interface==2)$interface="ABIS";
				else if($interface==5)$interface="R2";
				echo "<td width=\"13%\"><a href=\"./objShow.php?language=$language&objectid=Port.0.$conts[2].0&tablename=OMCR_E1port&bssid=$bssid\";>Port 0</a>";//-----Port 0

				echo "</td>";
				echo "<td width=\"20%\">$adminstate</td>";
				echo "<td width=\"20%\">$operstate</td>";
				echo "<td width=\"20%\">$availstatus</td>";
                echo "<td width=\"15%\">$interface</td>";
			
            echo "</tr>";

			echo "<tr>";
			
			
			
            
            
			echo "<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\">";
			
				echo "<td width=\"12%\"></td>";
				$sqlstring = "select AdminState,OperState,AvailStatus,INTERFACE from OMCR_E1port where ObjectId='Port.0.$conts[2].1' and bssid=$bssid";
			    //echo $sqlstring . "<BR>";
				$result = mysqli_query($pubConn,$sqlstring) or
				die("Invalid query: $sqlstring\n" . mysqli_error($pubConn));
				
				while($row = mysqli_fetch_row($result))
				{
					list($adminstate,$operstate,$availstatus,$interface) =$row;
				}

				if($adminstate==1)$adminstate="Locked";
				else if($adminstate==2)$adminstate="Unlocked";
				if($operstate==1)$operstate="Disable";
				else if($operstate==2)$operstate="Enable";
				if($availstatus==0)$availstatus="In_Test";
				else if($availstatus==1)$availstatus="Failed";
				else if($availstatus==2)$availstatus="Power_Off";
				else if($availstatus==3)$availstatus="Offline";
				else if($availstatus==4)$availstatus="Online";
				else if($availstatus==5)$availstatus="Dependency";
				else if($availstatus==6)$availstatus="Degraded";
				else if($availstatus==7)$availstatus="Not_Installed";
				if($interface==0)$interface="Unused";
				else if($interface==1)$interface="AIF";
				else if($interface==2)$interface="ABIS";
				else if($interface==5)$interface="R2";
				
				echo "<td width=\"13%\"><a href=\"./objShow.php?language=$language&objectid=Port.0.$conts[2].1&tablename=OMCR_E1port&bssid=$bssid\";>Port 1</a>";

				echo "</td>";
				echo "<td width=\"20%\">$adminstate</td>";
				echo "<td width=\"20%\">$operstate</td>";
				echo "<td width=\"20%\">$availstatus</td>";
                echo "<td width=\"15%\">$interface</td>";
			    
            echo "</tr>";
			
			echo "</tr>";

//Dsp Card=====================================================================================
//AdminState OperaState AvailStatus DSP Type 
				echo "<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\">";
				echo "<tr bgcolor=\"#E6E6E6\">";
			    
				echo "<td width=\"25%\">Dsp No</td>";
				echo "<td width=\"20%\">AdminState</td>";
				echo "<td width=\"20%\">OperaState</td>";
				echo "<td width=\"20%\">AvailStatus</td>";
        echo "<td width=\"15%\">DSP Type</td>";
        //echo "<td width=\"15%\"></td>";
            echo "</tr>";



       for($j=0;$j<$no_of_dsp;$j++)
		   {
			   $dconts = explode(".",$dsp_object_name[$j]);//DSP.0.cardnum.dspnum.(0~3)
			   $cardnum = $dconts[2];
			   $dspnum = $dconts[3];
			   if($dconts[2] == ($i+1))  
			   {
			   	
			   	//print_r($dsp_object_name[$j]);
			   	echo "<tr onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";
			    echo "<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\">";
					//$temp=substr($dsp_display_name[$j],4);
					echo "<td width=\"12%\">$dsp_display_name[$j]</td>";
					//echo "<td width=\"13%\"><a href=\"./bss_dsp.php?dspnum=$dspnum&cardnum=$cardnum&bssid=$bssid\";>$dsp_display_name[$j]</a></td>";
					//dsp 0
					
					echo "<td width=\"13%\"><a href=\"./objShow.php?language=$language&objectid=DSP.0.$cardnum.$dspnum.0&tablename=OMCR_TrauDsp&bssid=$bssid\";>Dsp 0</a></td>";
					$sqlstring = "select Type,AdminState,OperState,AvailStatus from OMCR_TrauDsp where ObjectId='DSP.0.$cardnum.$dspnum.0' and bssid=$bssid";
			    //echo $sqlstring . "<BR>";
					$result = mysqli_query($pubConn,$sqlstring) or
					die("Invalid query: $sqlstring\n" . mysqli_error($pubConn));
					
					while($row = mysqli_fetch_row($result))
					{
						list($type,$adminstate,$operstate,$availstatus) =$row;
					}
					if($type==0)$type="Half Rate";
					else if($type==1)$type="Full Rate";
					else if($type==2)$type="Enhanced Full Rate";
					if($adminstate==1)$adminstate="Locked";
					else if($adminstate==2)$adminstate="Unlocked";
					if($operstate==1)$operstate="Disable";
					else if($operstate==2)$operstate="Enable";
					if($availstatus==0)$availstatus="In_Test";
					else if($availstatus==1)$availstatus="Failed";
					else if($availstatus==2)$availstatus="Power_Off";
					else if($availstatus==3)$availstatus="Offline";
					else if($availstatus==4)$availstatus="Online";
					else if($availstatus==5)$availstatus="Dependency";
					else if($availstatus==6)$availstatus="Degraded";
					else if($availstatus==7)$availstatus="Not_Installed";
					
					echo "<td width=\"20%\">$adminstate</td>";
					echo "<td width=\"20%\">$operstate</td>";
					echo "<td width=\"18%\">$availstatus</td>";
          echo "<td width=\"17%\">$type</td>";           
          echo "</tr>";
          
          //dsp 1
          echo "<tr>";
          echo "<td width=\"12%\"></td>";
          echo "<td width=\"13%\"><a href=\"./objShow.php?language=$language&objectid=DSP.0.$cardnum.$dspnum.1&tablename=OMCR_TrauDsp&bssid=$bssid\";>Dsp 1</a></td>";     
					$sqlstring = "select Type,AdminState,OperState,AvailStatus from OMCR_TrauDsp where ObjectId='DSP.0.$cardnum.$dspnum.1' and bssid=$bssid";
			    //echo $sqlstring . "<BR>";
			    
	    
					$result = mysqli_query($pubConn,$sqlstring) or
					die("Invalid query: $sqlstring\n" . mysqli_error($pubConn));
					
					while($row = mysqli_fetch_row($result))
					{
						list($type,$adminstate,$operstate,$availstatus) =$row;
					}
					if($type==0)$type="Half Rate";
					else if($type==1)$type="Full Rate";
					else if($type==2)$type="Enhanced Full Rate";
					if($adminstate==1)$adminstate="Locked";
					else if($adminstate==2)$adminstate="Unlocked";
					if($operstate==1)$operstate="Disable";
					else if($operstate==2)$operstate="Enable";
					if($availstatus==0)$availstatus="In_Test";
					else if($availstatus==1)$availstatus="Failed";
					else if($availstatus==2)$availstatus="Power_Off";
					else if($availstatus==3)$availstatus="Offline";
					else if($availstatus==4)$availstatus="Online";
					else if($availstatus==5)$availstatus="Dependency";
					else if($availstatus==6)$availstatus="Degraded";
					else if($availstatus==7)$availstatus="Not_Installed";
					echo "<td width=\"20%\">$adminstate</td>";
					echo "<td width=\"20%\">$operstate</td>";
					echo "<td width=\"18%\">$availstatus</td>";
          echo "<td width=\"17%\">$type</td>";    
          echo "</tr>";
          
          //dsp 2
          echo "<tr>";
          echo "<td width=\"12%\"></td>";
          echo "<td width=\"13%\"><a href=\"./objShow.php?language=$language&objectid=DSP.0.$cardnum.$dspnum.2&tablename=OMCR_TrauDsp&bssid=$bssid\";>Dsp 2</a></td>";
					$sqlstring = "select Type,AdminState,OperState,AvailStatus from OMCR_TrauDsp where ObjectId='DSP.0.$cardnum.$dspnum.2' and bssid=$bssid";
			    //echo $sqlstring . "<BR>";
					$result = mysqli_query($pubConn,$sqlstring) or
					die("Invalid query: $sqlstring\n" . mysqli_error($pubConn));
					
					while($row = mysqli_fetch_row($result))
					{
						list($type,$adminstate,$operstate,$availstatus) =$row;
					}
					if($type==0)$type="Half Rate";
					else if($type==1)$type="Full Rate";
					else if($type==2)$type="Enhanced Full Rate";
					if($adminstate==1)$adminstate="Locked";
					else if($adminstate==2)$adminstate="Unlocked";
					if($operstate==1)$operstate="Disable";
					else if($operstate==2)$operstate="Enable";
					if($availstatus==0)$availstatus="In_Test";
					else if($availstatus==1)$availstatus="Failed";
					else if($availstatus==2)$availstatus="Power_Off";
					else if($availstatus==3)$availstatus="Offline";
					else if($availstatus==4)$availstatus="Online";
					else if($availstatus==5)$availstatus="Dependency";
					else if($availstatus==6)$availstatus="Degraded";
					else if($availstatus==7)$availstatus="Not_Installed";
					echo "<td width=\"20%\">$adminstate</td>";
					echo "<td width=\"20%\">$operstate</td>";
					echo "<td width=\"18%\">$availstatus</td>";
          echo "<td width=\"17%\">$type</td>";    
          echo "</tr>";
          //dsp 3
          echo "<tr>";
          echo "<td width=\"12%\"></td>";
          echo "<td width=\"13%\"><a href=\"./objShow.php?language=$language&objectid=DSP.0.$cardnum.$dspnum.3&tablename=OMCR_TrauDsp&bssid=$bssid\";>Dsp 3</a></td>";
					$sqlstring = "select Type,AdminState,OperState,AvailStatus from OMCR_TrauDsp where ObjectId='DSP.0.$cardnum.$dspnum.3' and bssid=$bssid";
			    //echo $sqlstring . "<BR>";
					$result = mysqli_query($pubConn,$sqlstring) or
					die("Invalid query: $sqlstring\n" . mysqli_error($pubConn));
					
					while($row = mysqli_fetch_row($result))
					{
						list($type,$adminstate,$operstate,$availstatus) =$row;
					}
					if($type==0)$type="Half Rate";
					else if($type==1)$type="Full Rate";
					else if($type==2)$type="Enhanced Full Rate";
					if($adminstate==1)$adminstate="Locked";
					else if($adminstate==2)$adminstate="Unlocked";
					if($operstate==1)$operstate="Disable";
					else if($operstate==2)$operstate="Enable";
					if($availstatus==0)$availstatus="In_Test";
					else if($availstatus==1)$availstatus="Failed";
					else if($availstatus==2)$availstatus="Power_Off";
					else if($availstatus==3)$availstatus="Offline";
					else if($availstatus==4)$availstatus="Online";
					else if($availstatus==5)$availstatus="Dependency";
					else if($availstatus==6)$availstatus="Degraded";
					else if($availstatus==7)$availstatus="Not_Installed";

					echo "<td width=\"20%\">$adminstate</td>";
					echo "<td width=\"20%\">$operstate</td>";
					echo "<td width=\"18%\">$availstatus</td>";
          echo "<td width=\"17%\">$type</td>";    
          echo "</tr>";
          
          
          
          
          
          if($j==0)
			   {
			   	
			   	echo "<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\">";
					echo "<tr bgcolor=\"#E6E6E6\">";
			    
					echo "<td width=\"25%\">No</td>";
					echo "<td width=\"20%\">AdminState</td>";
					echo "<td width=\"20%\">OperState</td>";
					echo "<td width=\"20%\">AvailStatus</td>";
          echo "<td width=\"15%\">Interface</td>";
          echo "</tr>";
			   }
			   }
			   
			   
       }
				}///////////////////////////////////////////////////////////
				/*
				
			    */
}
	$sqlstring = "select Presence from OMCR_BSSTREE where ObjectId='Card.0.17' and bssid=$bssid";
//echo $sqlstring . "<BR>";
				$result = mysqli_query($pubConn,$sqlstring) or
				die("Invalid query: $sqlstring\n" . mysqli_error($pubConn));
				
				while($row = mysqli_fetch_row($result))
				{
					$presence =$row[0];
				}
	 if($presence==1){
			echo "<tr>";
			
			
//====clock module=================
			echo "<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\">";
			echo "<tr bgcolor=\"#E6E6E6\">";
			    
				echo "<td width=\"25%\"></td>";
				echo "<td width=\"20%\">Part Number</td>";
				echo "<td width=\"20%\">Revision Number</td>";
				echo "<td width=\"20%\">Serial Number</td>";
                echo "<td width=\"15%\"></td>";
            echo "</tr>";


			//get the data from database
			
			$sqlstring = "select PartNumber,RevNumber,SerialNumber from OMCR_ClockMod where ObjectId='Card.0.17' and bssid=$bssid";
			    //echo $sqlstring . "<BR>";
				$result = mysqli_query($pubConn,$sqlstring) or
				die("Invalid query: $sqlstring\n" . mysqli_error($pubConn));
				
				while($row = mysqli_fetch_row($result))
				{
					list($PartNumber,$RevNumber,$SerialNumber) =$row;
				}
				
				
			echo "<tr onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";

			
			
				echo "<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\">";
		
				echo "<td width=\"25%\"><a href=\"./objShow.php?language=$language&objectid=Card.0.17&tablename=OMCR_ClockMod&bssid=$bssid\";>ClockModule</a></td>";
				echo "<td width=\"20%\">$PartNumber</td>";
				echo "<td width=\"20%\">$RevNumber</td>";
				echo "<td width=\"20%\">$SerialNumber</td>";
				echo "<td width=\"15%\"></td>";
				echo "</tr>";
	 }
         
//Bsc.0===========================================>
echo "</table>";
echo "<tr>";
echo "<td width=\"20%\" bgcolor=\"#E6E6E6\"><b>Bsc</b></td>";
echo "<td>";
			$sqlstring = "select AdminState,OperState,AvailStatus,Label,EnableVeryEarlyAssignment from OMCR_Bsc where ObjectId='Bsc.0' and bssid=$bssid";
			    //echo $sqlstring . "<BR>";
				$result = mysqli_query($pubConn,$sqlstring) or
				die("Invalid query: $sqlstring\n" . mysqli_error($pubConn));
				
				while($row = mysqli_fetch_row($result))
				{
					list($adminstate,$operstate,$availstatus,$label,$vea) =$row;
				}

				if($adminstate==1)$adminstate="Locked";
				else if($adminstate==2)$adminstate="Unlocked";
				if($operstate==1)$operstate="Disable";
				else if($operstate==2)$operstate="Enable";
				if($availstatus==0)$availstatus="In_Test";
				else if($availstatus==1)$availstatus="Failed";
				else if($availstatus==2)$availstatus="Power_Off";
				else if($availstatus==3)$availstatus="Offline";
				else if($availstatus==4)$availstatus="Online";
				else if($availstatus==5)$availstatus="Dependency";
				else if($availstatus==6)$availstatus="Degraded";
				else if($availstatus==7)$availstatus="Not_Installed";
				if($vea==0)$vea="Disable";
				else if($vea==1)$vea="Enable";
				
			echo "<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\">";
			echo "<tr bgcolor=\"#E6E6E6\">";
				echo "<td width=\"25%\">Label</td>";
				echo "<td width=\"20%\">AdminState</td>";
				echo "<td width=\"20%\">OperaState</td>";
				echo "<td width=\"20%\">AvailStatus</td>";
				echo "<td width=\"15%\">VEA</td>";
				echo "</td>";
			echo "</tr>";
echo "</td>";
			
			echo "<tr>";

			echo "<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\">";
			
				echo "<td width=\"25%\"><a href=\"./objShow.php?language=$language&objectid=Bsc.0&tablename=OMCR_Bsc&bssid=$bssid\";>\"$label\"</a></td>";
   				
				
				echo "<td width=\"20%\">$adminstate</td>";
				echo "<td width=\"20%\">$operstate</td>";
				echo "<td width=\"20%\">$availstatus</td>";
                echo "<td width=\"15%\"><a href=\"./objShow.php?language=$language&objectid=Bsc.0&tablename=OMCR_Bsc&bssid=$bssid\";>$vea</a></td>";
			    echo "</table>";
            echo "</tr>";

echo "<tr>";
//Add BtsMgr---------------->
$sqlstring = "select ObjectId from OMCR_BSSTREE where engDisplayName like 'BTS Manager%' and Presence=1 and bssid=$bssid";
$objectid = 'BssFunc';
$addtype  = 'BtsMgr';
//echo $sqlstring . "<BR>";
$result = mysqli_query($pubConn,$sqlstring) or
          die("Invalid query: $sqlstring\n" . mysqli_error($pubConn));
while($row = mysqli_fetch_row($result))
{
	$bts_objectid[] =$row[0];
}
$no_bts_exist=count($bts_objectid);

$array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12);
//print_r($array);

for($n=0;$n<$no_bts_exist;$n++)
{
	$bts_num = explode(".",$bts_objectid[$n]);
	$num[$n] = $bts_num[1];
	unset($array[$num[$n]-1]);
}
$array = array_values($array);
//print_r($array);
$btsid = $array[0];

echo "<td width=\"20%\" bgcolor=\"#E6E6E6\">";
echo "<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" ><tr >";
	echo "<td align=left><b>BtsMgr</b></td>";
			echo "<td align=\"right\"><a href=\"javascript:addTheObj('$bssid','$objectid','$btsid','-1','-1','$addtype')\">+</a></td>";
echo "</tr></table>";
		
//BtsMgr>======================================================================
$sqlstring = "select engDisplayName,ObjectId from OMCR_BSSTREE where engDisplayName like 'BTS Manager%' and ObjectId<>'BtsMgr.0' and Presence=1 and bssid=$bssid";
//echo $sqlstring . "<BR>";
$result = mysqli_query($pubConn,$sqlstring) or
          die("Invalid query: $sqlstring\n" . mysqli_error($pubConn));
while($row = mysqli_fetch_row($result))
{
	list($bts_display_name[],$bts_object_name[]) =$row;
}
$no_of_bts = count($bts_object_name);

$bsplus = 0;
echo "<td>";
			echo "<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\">";
			echo "<tr bgcolor=\"#E6E6E6\">";
				echo "<td width=\"25%\">BtsMgr_Num</td>";
				echo "<td width=\"20%\">BtsMgrName</td>";
				echo "<td width=\"20%\">E1UseType</td>";
				echo "<td width=\"20%\">RfdType</td>";
				echo "<td width=\"15%\">Delete</td>";
				echo "</td>";
			echo "</tr>";

			//BtsMgr 0 >>>>>>>Bsplus
			if($isbsplus==1)
			{
			$sqlstring = "select Label,E1UseType,RfdType from OMCR_BtsMgr where ObjectId='BtsMgr.$bsplus' and bssid=$bssid";
			    //echo $sqlstring . "<BR>";
				$btsid=0;
				$result = mysqli_query($pubConn,$sqlstring) or
				die("Invalid query: $sqlstring\n" . mysqli_error($pubConn));
				
				while($row = mysqli_fetch_row($result))
				{
					list($label,$e1tp,$rfd) =$row;
				}

				
				if($e1tp==0)$e1tp="Dedicated";
				else if($e1tp==1)$e1tp="DC_String";
				else if($e1tp==2)$e1tp="DC_Ring";
				else if($e1tp==3)$e1tp="XConnect";
				
			echo "<tr onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";
			echo "<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\">";
			           
				echo "<td width=\"25%\"><a href=\"./bss_btsmgr.php?btsid=$btsid&bssid=$bssid\";><b>0</b></a></td>";//bsplus
				$helf = "./objShow.php?language=$language&objectid=BtsMgr.0&tablename=OMCR_BtsMgr&bssid=$bssid&btsid=$btsid";
				echo "<td width=\"20%\"><a href='$helf';>\"$label\"</a></td>";
				echo "<td width=\"20%\">$e1tp</td>";
				echo "<td width=\"20%\">$rfd</td>";
                echo "<td width=\"15%\"></td>";
				//echo "<input type=\"checkbox\" name=\"seleceAll\" title=\"Select all to delete\"  value=\"1\" //onClick=selectAllToDel('$flag',this,0,$valid_num)></td>";
			echo "</tr>";
			}
			//BtsMgr (1~12)==========================================================>
            
			for($k=0;$k<$no_of_bts;$k++)
		   {
			   $bconts = explode(".",$bts_object_name[$k]);
			   $btsid = $bconts[1];
				$sqlstring = "select Label,E1UseType,RfdType from OMCR_BtsMgr where ObjectId='BtsMgr.$bconts[1]' and bssid=$bssid";
			    //echo $sqlstring . "<BR>";
				$result = mysqli_query($pubConn,$sqlstring) or
				die("Invalid query: $sqlstring\n" . mysqli_error($pubConn));
				
				while($row = mysqli_fetch_row($result))
				{
					list($label,$e1tp,$rfd) =$row;
				}

				if($e1tp==0)$e1tp="Dedicated";
				else if($e1tp==1)$e1tp="DC_String";
				else if($e1tp==2)$e1tp="DC_Ring";
				else if($e1tp==3)$e1tp="XConnect";
			
			echo "<tr onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";
			echo "<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\">";
			
				echo "<td width=\"25%\"><a href=\"./bss_btsmgr.php?btsid=$btsid&bssid=$bssid\";><b>$bconts[1]</b></a>";
                      
				echo "</td>";
				$deltype="BtsMgr";
				$btsid  =$bconts[1];
				$objectid="BssFunc";
				$helf = "./objShow.php?language=$language&objectid=BtsMgr.$btsid&tablename=OMCR_BtsMgr&bssid=$bssid&btsid=$btsid";
				
				echo "<td width=\"20%\"><a href='$helf';>\"$label\"</a></td>";
				echo "<td width=\"20%\">$e1tp</td>";
				echo "<td width=\"20%\">$rfd</td>";
                echo "<td width=\"20%\">";
				echo "<input type=\"checkbox\" name=\"select this\" title=\"Select this to delete\"  value=\"1\" onClick=\"javascript:delTheObj('$bssid','$objectid','$btsid','-1','-1','$deltype',this)\"></td>";
		   }
            echo "</tr>";
			echo "</table>";
echo "</td>";
echo "</tr>";
//SmsCb..>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
$sqlstring = "select CBCHLoading_0,CBCHLoading_1,CBCHLoading_2,CBCHLoading_3,CBCHLoading_4 from OMCR_SmsCb where 					ObjectId='SmsCb.0' and bssid=$bssid";
			$result = mysqli_query($pubConn,$sqlstring) or
				die("Invalid query: $sqlstring\n" . mysqli_error($pubConn));
				
				while($row = mysqli_fetch_row($result))
				{
					list($cbc0,$cbc1,$cbc2,$cbc3,$cbc4) =$row;
				}
$ref = "./objShow.php?language=$language&objectid=SmsCb.0&tablename=OMCR_SmsCb&bssid=$bssid";
echo "<tr>";
echo "<td width=\"20%\" bgcolor=\"#E6E6E6\"><b><a href=\"./bss_smmsg.php?bssid=$bssid\">SmsCb</b></a></td>";
echo "<td>";
			echo "<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\">";
			echo "<tr bgcolor=\"#E6E6E6\">";
				echo "<td width=\"25%\">CBCHLoading_0</td>";
				echo "<td width=\"20%\">CBCHLoading_1</td>";
				echo "<td width=\"20%\">CBCHLoading_2</td>";
				echo "<td width=\"20%\">CBCHLoading_3</td>";
				echo "<td width=\"15%\">CBCHLoading_4</td>";
			echo "</tr>";
			echo "<tr>";
				echo "<td width=\"25%\"><a href=$ref>$cbc0</a></td>";
				echo "<td width=\"20%\">$cbc1</td>";
				echo "<td width=\"20%\">$cbc2</td>";
				echo "<td width=\"20%\">$cbc3</td>";
				echo "<td width=\"15%\">$cbc4</td>";
				echo "</td>";
			echo "</tr>";


			echo "</table>";
echo "</td>";
echo "</tr>";
			
?>
