<?php
if(0)
{
	echo "sysTypeNo=$sysTypeNo<br>";
	echo "show_type=$show_type<br>";
	echo "page_id=$page_id<br>";
	echo "sel_date_from=$sel_date_from<br>";
	echo "sel_date_to=$sel_date_to<br>";
	echo "keyOne=$keyOne,keyTwo=$keyTwo<br>";
}

echo "<input type=\"hidden\" name=\"select_checkbox_id\" value=\"$select_checkbox_id\">";
echo "<input type=\"hidden\" name=\"scroll_y\" value=\"$scroll_y\">";

$cstaConf=GetCstaConf($sysTypeNo);

$slot=$sel_date_from-$sel_date_to+1;
$total_hour_num=$slot*24;
$startTime=date("Y-m-d H:i:s",mktime(0,0,0,date("m"),date("d")-$sel_date_from,date("Y")));
$endTime=date("Y-m-d H:i:s",mktime(23,59,59,date("m"),date("d")-$sel_date_to,date("Y")));
//echo "startTime=$startTime,endTime=$endTime<br>";

$cstaDataTmp=GetCstaDataByHour($cstaConf,$startTime,$endTime,"detail",$keyOne,$keyTwo);

if(0)
{
	echo "<pre>";
	print_r($cstaDataTmp);
	echo "</pre>";
}

//Table-1
{
	
	if($keyOne == 1)
	{
		$table_title="BSS-{$keyTwo}";
		$cstaData=$cstaDataTmp[0][$keyOne][$keyTwo];
	}
	else
	{
		$table_title="SGSN-{$keyTwo}";
		$cstaData=$cstaDataTmp[1][$keyOne][$keyTwo];
	}
if(0)
{
	echo "<pre>";
	print_r($cstaData);
	echo "</pre>";
}
	if($slot > 1)
		$table_title.=" Statistic&nbsp;&nbsp;Date:".date("Y-m-d",mktime(0,0,0,date("m"),date("d")-$sel_date_from,date("Y")))." to ".date("Y-m-d",mktime(0,0,0,date("m"),date("d")-$sel_date_to,date("Y")));
	else
		$table_title.=" Statistic&nbsp;&nbsp;Date:".date("Y-m-d",mktime(0,0,0,date("m"),date("d")-$sel_date_from,date("Y")));
	echo "<br><b><center>$table_title</center></b>";

	echo "<table width=\"100%\" border=\"1\" cellpadding=\"2\" cellspacing=\"0\" bordercolor=\"#666666\" bordercolordark=\"#FFFFFF\" bgcolor=\"#FFFFFF\">";
	echo "<tr bgcolor=\"#E6E6E6\">";
	echo "<td align=\"center\" width=\"8%\">&nbsp;</td>";
	echo "<td align=\"center\" width=\"46%\" colspan=4>Signal</td>";
	echo "<td align=\"center\" width=\"46%\" colspan=4>Data</td>";
	echo "</tr>";
	echo "<tr bgcolor=\"#E6E6E6\">";
	echo "<td align=\"center\" width=\"8%\">Time</td>";
	echo "<td align=\"center\" width=\"12%\">Send Packages</td>";
	echo "<td align=\"center\" width=\"11%\">Send Bytes</td>";
	echo "<td align=\"center\" width=\"12%\">Recv Packages</td>";
	echo "<td align=\"center\" width=\"11%\">Recv Bytes</td>";
	
	echo "<td align=\"center\" width=\"12%\">Send Packages</td>";
	echo "<td align=\"center\" width=\"11%\">Send Bytes</td>";
	echo "<td align=\"center\" width=\"12%\">Recv Packages</td>";
	echo "<td align=\"center\" width=\"11%\">Recv Bytes</td>";
	echo "</tr>";
	$row_num=count($cstaData[send_packet_signal]);
	if($row_num > 0)
	{
		for($hour=0;$hour<$total_hour_num;$hour++)
		{
			if(isset($cstaData[send_packet_signal][$hour]))
			{
				echo "<tr>";
				$hour_title=date("m-d H",mktime($hour,0,0,date("m"),date("d")-$sel_date_from,date("Y")));
				echo "<td align=\"center\">{$hour_title}H</td>";
				
				echo "<td align=\"center\">";
				echo "{$cstaData[send_packet_signal][$hour]}";
				echo "&nbsp;</td>";
				
				echo "<td align=\"center\">";
				echo "{$cstaData[send_byte_signal][$hour]}";
				echo "&nbsp;</td>";
				
				echo "<td align=\"center\">";
				echo "{$cstaData[recv_packet_signal][$hour]}";
				echo "&nbsp;</td>";
				
				echo "<td align=\"center\">";
				echo "{$cstaData[recv_byte_signal][$hour]}";
				echo "&nbsp;</td>";
				
				
				echo "<td align=\"center\">";
				echo "{$cstaData[send_packet_data][$hour]}";
				echo "&nbsp;</td>";
				
				echo "<td align=\"center\">";
				echo "{$cstaData[send_byte_data][$hour]}";
				echo "&nbsp;</td>";
				
				echo "<td align=\"center\">";
				echo "{$cstaData[recv_packet_data][$hour]}";
				echo "&nbsp;</td>";
				
				echo "<td align=\"center\">";
				echo "{$cstaData[recv_byte_data][$hour]}";
				echo "&nbsp;</td>";
				echo "</tr>";
			}
		}
	}
	else
	{
		echo "<tr>";
		echo "<td>--</td><td>--</td><td>--</td><td>--</td><td>--</td><td>--</td><td>--</td><td>--</td><td>--</td>";
		echo "</tr>";
	}
	
	echo "</table>";
	
}
?>
