<?php
$cstaConf=GetCstaConf($sysTypeNo);
if(0)
{
	echo "sel_date_from=$sel_date_from,sel_date_to=$sel_date_to<br>";
	echo "<pre>";
	print_r($cstaConf);
	echo "</pre>";
}
$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>";

$cstaData=GetCstaDataByDay($cstaConf,$startTime,$endTime,"detail");
if(0)
{
	echo "<pre>";
	print_r($cstaData);
	echo "</pre>";
}

//Table-1
{
	$bssCstaData=$cstaData[0][1];
	$table_title="BSS Statistic&nbsp;&nbsp;Date:";
	if($slot>1)
		$table_title.=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.=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\">";
	//Table title
	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=\"4%\">BSS ID</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($bssCstaData);
	if($row_num > 0)
	{
		foreach($bssCstaData as $bss_id => $data)
		{
			echo "<tr>";
			echo "<td align=\"center\">";
			echo "<a href=# onclick=\"javascript:toHourPage('$sysTypeNo','hour','0','$sel_date_from','$sel_date_to','1','{$bss_id}');\">";
			echo "$bss_id";
			echo "</a>";
			echo "</td>";
			
			echo "<td align=\"center\">";
			echo "{$data[send_packet_signal]}";
			echo "</td>";
			
			echo "<td align=\"center\">";
			echo "{$data[send_byte_signal]}";
			echo "</td>";
			
			echo "<td align=\"center\">";
			echo "{$data[recv_packet_signal]}";
			echo "</td>";
			
			echo "<td align=\"center\">";
			echo "{$data[recv_byte_signal]}";
			echo "</td>";
			
			echo "<td align=\"center\">";
			echo "{$data[send_packet_data]}";
			echo "</td>";
			
			echo "<td align=\"center\">";
			echo "{$data[send_byte_data]}";
			echo "</td>";
			
			echo "<td align=\"center\">";
			echo "{$data[recv_packet_data]}";
			echo "</td>";
			
			echo "<td align=\"center\">";
			echo "{$data[recv_byte_data]}";
			echo "</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>";
}

//Table-2
{
	$sgsnCstaData=$cstaData[1][2];

	$table_title="SGSN Statistic&nbsp;&nbsp;Date:";
	if($slot>1)
		$table_title.=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.=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\">";
	//Table title
	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%\">SGSN ID</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($sgsnCstaData);
	if($row_num > 0)
	{
		foreach($sgsnCstaData as $sgsn_id => $data)
		{
			echo "<tr>";
			echo "<td align=\"center\">";
			echo "<a href=# onclick=\"javascript:toHourPage('$sysTypeNo','hour','0','$sel_date_from','$sel_date_to','2','{$sgsn_id}');\">";
			echo "$sgsn_id";
			echo "</a>";
			echo "</td>";
			
			echo "<td align=\"center\">";
			echo "{$data[send_packet_signal]}";
			echo "</td>";
			
			echo "<td align=\"center\">";
			echo "{$data[send_byte_signal]}";
			echo "</td>";
			
			echo "<td align=\"center\">";
			echo "{$data[recv_packet_signal]}";
			echo "</td>";
			
			echo "<td align=\"center\">";
			echo "{$data[recv_byte_signal]}";
			echo "</td>";
			
			echo "<td align=\"center\">";
			echo "{$data[send_packet_data]}";
			echo "</td>";
			
			echo "<td align=\"center\">";
			echo "{$data[send_byte_data]}";
			echo "</td>";
			
			echo "<td align=\"center\">";
			echo "{$data[recv_packet_data]}";
			echo "</td>";
			
			echo "<td align=\"center\">";
			echo "{$data[recv_byte_data]}";
			echo "</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>";
}
?>
