<?php
//
// Created on: 22 Feb 2001
// Usage     : bssstatusinfo.php?language="eng|gb"&bssid=0
//
// Function  : Special operation for BssFunc including
//             -> BTS creation/deletion
//             -> Show Alarms
//
// bssfunc.php ___ bssstatus.php   (upper)
//             \__ bssfuncinfo.php (bottom)
//
?>
<?php
include("nocache.inc");
include("bssfuncinfo.inc");
if (!isset($language))
    $language="eng";
$parameter="${language}namearray";

?>
<HTML>
<HEAD>
<?php
    include("header.inc");
    include("login_parm.inc");

    $db = mysql_connect($hostname, $username, $password);
    mysql_select_db($dbname,$db);
    $sqlstring = "SELECT a.ip,b.Label as name,a.connected from OMCR_BSSTABLE as a, OMCR_BssFunc as b " .
                 "WHERE a.bssid=$bssid and b.bssid=$bssid";
    //echo "$sqlstring <BR>";
    $result = mysql_query($sqlstring,$db) or
              die("Invalid query: $sqlstring\n" . mysqli_error($pubConn));
    while ( $row = mysqli_fetch_row($result) )
    {
        list($ip,$name,$connected) = $row;
    }
    if (mysqli_num_rows($result) != 1)
    {
        echo "Problem in OMCR database\n";
        return;
    }

    $sqlstring = "SELECT ObjectId,Presence from OMCR_BSSTREE " .
                 "WHERE bssid=$bssid and ObjectId REGEXP 'BtsMgr.[1-9]'";//read BtsMgr.1~12 from BssTree
    //echo "$sqlstring <BR>";
    $result = mysql_query($sqlstring,$db) or
              die("Invalid query: $sqlstring\n" . mysqli_error($pubConn));
    while ( $row = mysqli_fetch_row($result) )
    {
        list($btsid[],$presence[]) = $row;
    }

    $sqlstring = "SELECT CurrentBuildDir from OMCR_Software WHERE bssid=$bssid";
    //echo "$sqlstring <BR>";
    $result = mysql_query($sqlstring,$db) or
              die("Invalid query: $sqlstring\n" . mysqli_error($pubConn));
    list($build) = mysqli_fetch_row($result);
    if ($build == "''")
    {
        echo "<META HTTP-EQUIV=Refresh content=2>";
    }
    //else
    //    echo "ABCD${build}EFG";
?>
<SCRIPT Language="JavaScript" type="text/javascript">
<!--
    function modify(obj,nmicmd,nmiinput)
    {
        window.status = "<?=${$parameter}[confirmquestionbegin]?>"
                          + obj.value + "<?=${$parameter}[confirmquestionend]?>";
        answer = confirm("<?=${$parameter}[confirmquestionbegin]?>"
                          + obj.value + "<?=${$parameter}[confirmquestionend]?>");
        window.status = "";
        if (answer == true)
        {
            if(typeof(nmiinput) == 'object')
                nmicmd=nmicmd+"\""+nmiinput.value+"\"";
               
            window.parent.location.href = "modify.php?url=bssfunc.php" +
                                          "&language=<?=$language?>" +
                                          "&bssid=<?=$bssid?>" +
                                          "&objectid=BssFunc" +
                                          "&nmicommand=" + nmicmd +
                                          "&timeout=90";

                                            
        }
    }
//-->
</SCRIPT>
<title>BS Plus</title>
</HEAD>
<BODY>
<TABLE border=1 bordercolor=#FFFFFF width=124 cellspacing=0>
<FORM name=object_form method=post action=modify.php>
  <TR>
    <TD width="57" valign="top"><?=${$parameter}[name]?></TD>
    <TD valign="top"><INPUT name=bssname type=text size=20 value='<?=$name?>'>
    <INPUT type=button value='Set' name=setbssname style='width: 30' class=chinese onClick='modify(this.document.object_form.setbssname, "set Label=",this.document.object_form.bssname);'></TD>
    <TD bordercolor=#00FFFF valign=top rowspan=4>
<?php
$no_of_bts = count($btsid);
echo "<TABLE border=0>\n";
echo "<TR>";
for ($i=0; $i<$no_of_bts; $i++)
{
    echo "<TD>";
    $id=substr($btsid[$i],7);
    if ($presence[$i])
        echo "<INPUT type=button value='" . ${$parameter}[delbts] .
             " " . $id . "' name=delbts$id style='width: 95' class=chinese" .
             " onClick='modify(this.document.object_form.delbts$id, \"delete BtsMgr \" + $id);'>";
             //" onClick='javascript:parent.location.href=\"modify.php?" .
             //"url=bssfunc.php&language=$language" .
             //"&bssid=$bssid&objectid=BssFunc&nmicommand=delete BtsMgr $id&timeout=30\";'>";
    else
        echo "<INPUT type=button value='" . ${$parameter}[addbts] .
             " " . $id . "' name=addbts$id style='width: 95' class=chinese" .
             " onClick='modify(this.document.object_form.addbts$id, \"create BtsMgr \" + $id);'>";
             //" onClick='javascript:parent.location.href=\"modify.php?" .
             //"url=bssfunc.php&language=$language" .
             //"&bssid=$bssid&objectid=BssFunc&nmicommand=create BtsMgr $id&timeout=30\";'>";
    echo "</TD>";
    //if ($i && $i%2)
    if (! (($i+1)%3))
        echo "</TR><TR>\n";
}
echo "</TR></TABLE>\n";
echo "</TD>";

?>
    </TR>
  </TR>
  <TR>
    <TD width="57" valign="top"><?=${$parameter}[ipaddress]?></TD>
    <TD valign="top">
    <INPUT type="text" size="20" value='<?=$ip?>' readonly></TD>
  </TR>
  <TR>
    <TD width="57" valign="top" nowrap><?=${$parameter}[swversion]?></TD> 
    <TD valign="top"><?=$build?></TD>
  </TR>
  <TR>
    <TD width="57" valign="top"></TD>
    <TD valign="top">
<NOBR>
    <!--INPUT type=button style='width: 85' value='<?=${$parameter}[statistics]?>' name=statistics
     class=chinese onClick='javascript:window.parent.parent.location.href=
     "btsmeasframe.php?language=<?=$language?>&bssid=<?=$bssid?>";'-->
    <!--INPUT type=button style='width: 85' value='<?=${$parameter}[upload]?>'
     class=chinese onClick='javascript:parent.location.href=
     "modify.php?url=bssfunc.php&language=<?=$language?>&bssid=<?=$bssid?>&objectid=BssFunc&nmicommand=upload <?=$bssid?>&timeout=15";'-->
    <!--INPUT type=button style='width: 85' value='<?=${$parameter}[upload]?>'
     class=chinese onClick='javascript:window.parent.parent.location.href=
     "data_upload.php?language=<?=$language?>&bssid=<?=$bssid?>";'-->
<?php
		
        echo "<INPUT type=button style='width: 85' value='" . ${$parameter}[upload] .
             "' name=upload style='width: 95' class=chinese" .
             " onClick='modify(this.document.object_form.upload, \"upload \" + $id);'>";
?>
    <!--INPUT type=button style='width: 85' value='<?=${$parameter}[download]?>' name=download
     class=chinese onClick='javascript:window.parent.parent.location.href=
     "data_download.php?language=<?=$language?>&bssid=<?=$bssid?>";'>
    <INPUT type=button style='width: 85' value='<?=${$parameter}[showalarm]?>' class=chinese
     onClick='javascript:window.parent.parent.location.href="alarmframe.php?language=<?=$language?>&bssid=<?=$bssid?>";'-->
	 <INPUT type=button style='width: 85' value='--' class=chinese disabled>
	 <!--<INPUT type=button style='width: 85' value='<?=${$parameter}[swdownload]?>' class=chinese onClick='javascript:parent.location.href="sw_download.php?language=<?=$language?>&bssid=<?=$bssid?>&version=<?
if ($build == "''")
	echo "-";
else
	echo "$build";
?>";'>-->
</NOBR>
    <HR size=1 color=#00FFFF>
    <INPUT type=button style='width: 85' value='<?=${$parameter}[cfgupload]?>' class=chinese onClick='javascript:parent.location.href="cfg_upload.php?language=<?=$language?>&bssid=<?=$bssid?>&version=<?
if ($build == "''")
	echo "-";
else
	echo "$build";
?>";'>
    <INPUT type=button style='width: 85' value='<?=${$parameter}[cfgdownload]?>' class=chinese onClick='javascript:parent.location.href="cfg_download.php?language=<?=$language?>&bssid=<?=$bssid?>&version=<?
if ($build == "''")
	echo "-";
else
	echo "$build";
?>";'>
    
    </TD>
    </TD>
  </TR>                       
  </FORM>
</TABLE>                       
</BODY>    
</HTML>    
