<?php

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

$DEBUG = 0;
if($DEBUG) echo "<br>正在调试中，给您的工作带来不便，请原谅！！：^_^";
function flash($bssid)
{
	echo "<br><b>$action</b><br>";
	echo "<script language=\"javascript\">";
			$href="$PHP_SELF?bssid=$bssid";
	echo "window.location.href='$href';";
	echo "</script>";
}
if($addtp=='SmMsg')
{
	$nmicmd="create SmMsg ".$msgnum;
	$objectid="SmsCb.0";
	putcommand($bssid,$objectid,$nmicmd);
	flash($bssid);
}
if($deltp=='SmMsg')
{
	$nmicmd="delete SmMsg ".$msgnum;
	$objectid="SmsCb.0";
	putcommand($bssid,$objectid,$nmicmd);
	flash($bssid);
}

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 "<a href=\"JavaScript:backpage(1,'./bssSpecific.php?bssid=$bssid')\" > BSS Specific</a> > SmMsg";
echo "</td>";
echo "</tr>";
echo "</table>";
echo "<br>";
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')\">";
		echo "</td>";
		echo "<td width=\"10%\"><a href=\"JavaScript:backpage(1,'./bssSpecific.php?bssid=$bssid')\"><img align=absBottom border=0 src=\"../../images/left.gif\" width=\"14\" height=\"14\">Back</a><td>";
	echo "</tr>";
echo "</table>";
?>
<TABLE  border="1"  cellpadding="2" cellspacing="0" bordercolor="#666666" bordercolordark="#FFFFFF" bgcolor="#FFFFFF" width="100%">

<?php

echo "<tr>";
//Check SmMsg is ok.......
$sqlstring = "select ObjectId from OMCR_BSSTREE where ObjectId like 'SmMsg.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($smmsg_object[]) =$row;
}
//echo "$adjhand_object[0]";
$no_of_msg = count($smmsg_object);
$array = array(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31);
//print_r($array);

for($n=0;$n<$no_of_msg;$n++)
{
	$msg_num = explode(".",$smmsg_object[$n]);
	$num[$n] = $msg_num[2];
	unset($array[$num[$n]]);
}
$array = array_values($array);
//print_r($array);
$msgnum = $array[0];
$objectid = "SmMsg.0.".$msgnum;
$addtp = "SmMsg";
echo "<td width=\"20%\" bgcolor=\"#E6E6E6\">";
echo "<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" ><tr >";
echo "<td align=left><b>SmMsg</b></td>";
			echo "<td align=\"right\"><a href=javascript:addMsg('$bssid','$objectid','$msgnum','$addtp')>+</a></td>";
echo "</tr></table>";

//////////////////////////////SmMsg Parametet//////////////////////////////////////////
echo "<td>";
			echo "<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\">";
			echo "<tr bgcolor=\"#E6E6E6\">";
				echo "<td width=\"13.6%\">MsgId</td>";
				echo "<td width=\"13.6%\">SerialNo</td>";
				echo "<td width=\"19.6%\">NumBroadcast</td>";
				echo "<td width=\"19.6%\">RepetitionRate</td>";
				echo "<td width=\"16.6%\">NumPages</td>";
				echo "<td width=\"16.6%\">Delete</td>";
				echo "</td>";
			echo "</tr>";

for($i=0;$i<$no_of_msg;$i++)
{
		$msgconts = explode(".",$smmsg_object[$i]);
		$sqlstring = "select MsgId,SerialNo,numBroadcast,RepetitionRate,NumPages from OMCR_SmMsg where bssid=$bssid and ObjectId like 'SmMsg.0.$msgconts[2]'";
				//echo $sqlstring . "<BR>";
				$result = mysqli_query($pubConn,$sqlstring) or
				die("Invalid query: $sqlstring\n" . mysqli_error($pubConn));
				
				while($row = mysqli_fetch_row($result))
				{
					list($msgid,$serialno,$numbc,$rr,$np) =$row;
				}
		$ref = "./objShow.php?language=$language&objectid=SmMsg.0.$msgconts[2]&tablename=OMCR_SmMsg&bssid=$bssid";
		echo "<tr>";
				echo "<td width=\"13.6%\"><a href=$ref>$msgid</a></td>";
				echo "<td width=\"13.6%\"><a href=$ref>$serialno</a></td>";
				echo "<td width=\"19.6%\"><a href=$ref>$numbc</a></td>";
				echo "<td width=\"19.6%\"><a href=$ref>$rr</a></td>";
				echo "<td width=\"16.6%\"><a href=$ref>$np</a></td>";
				echo "<td width=\"16.6%\">";
				$objectid = "SmMsg.0.".$msgconts[2];
				$msgnum  = $msgconts[2];
				$deltp = "SmMsg";
				echo "<input type=\"checkbox\" name=\"select this\" title=\"Select this to delete\"  value=\"1\" onClick=\"javascript:delMsg('$bssid','$objectid','$msgnum','$deltp',this)\"></td>";
				echo "</tr>";

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