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

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

//Table-1
{
	$table_title="MHC 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\">";
	echo "<tr bgcolor=\"#E6E6E6\">";
	echo "<td align=\"center\" width=\"50%\">Type</td>";
	echo "<td align=\"center\" width=\"50%\">Value</td>";
	echo "</tr>";
	
	echo "<tr>";
	echo "<td>HLR Notify MHC</td>";
	$value=$cstaData[hlr_noti_mhc]+0;
	echo "<td>$value</td>";
	echo "</tr>";
	
	echo "<tr>";
	echo "<td>MHC Notify HLR</td>";
	$value=$cstaData[mhc_noti_hlr]+0;
	echo "<td>$value</td>";
	echo "</tr>";
	
	echo "<tr>";
	echo "<td>Replication Attempt</td>";
	$value=$cstaData[rep_att]+0;
	echo "<td>$value</td>";
	echo "</tr>";
	
	echo "<tr>";
	echo "<td>Replication Success</td>";
	$value=$cstaData[rep_suc]+0;
	echo "<td>$value</td>";
	echo "</tr>";
	
	echo "<tr>";
	echo "<td>Replication Fail</td>";
	$value=$cstaData[rep_fail]+0;
	echo "<td>$value</td>";
	echo "</tr>";
	
	echo "<tr>";
	echo "<td>Verification Attempt</td>";
	$value=$cstaData[veri_att]+0;
	echo "<td>$value</td>";
	echo "</tr>";
	
	echo "<tr>";
	echo "<td>Verification Success</td>";
	$value=$cstaData[veri_suc]+0;
	echo "<td>$value</td>";
	echo "</tr>";
	
	echo "<tr>";
	echo "<td>Verification Fail</td>";
	$value=$cstaData[veri_fail]+0;
	echo "<td>$value</td>";
	echo "</tr>";
	
	echo "<tr>";
	echo "<td>Verification Deleted Attempt</td>";
	$value=$cstaData[veri_del_att]+0;
	echo "<td>$value</td>";
	echo "</tr>";
	
	echo "<tr>";
	echo "<td>Verification Deleted Success</td>";
	$value=$cstaData[veri_del_suc]+0;
	echo "<td>$value</td>";
	echo "</tr>";
	
	echo "<tr>";
	echo "<td>Verification Deleted Fail</td>";
	$value=$cstaData[veri_del_fail]+0;
	echo "<td>$value</td>";
	echo "</tr>";
	
	echo "<tr>";
	echo "<td>Verification Download Attempt</td>";
	$value=$cstaData[veri_dld_att]+0;
	echo "<td>$value</td>";
	echo "</tr>";
	
	echo "<tr>";
	echo "<td>Verification Download Success</td>";
	$value=$cstaData[veri_dld_suc]+0;
	echo "<td>$value</td>";
	echo "</tr>";
	
	echo "<tr>";
	echo "<td>Verification Download Fail</td>";
	$value=$cstaData[veri_dld_fail]+0;
	echo "<td>$value</td>";
	echo "</tr>";

  echo "<tr>";
	echo "<td>MHC Message Sent</td>";
	$value=$cstaData[mhc_msg_sent]+0;
	echo "<td>$value</td>";
	echo "</tr>";
	
	echo "<tr>";
	echo "<td>MHC Message Received</td>";
	$value=$cstaData[mhc_msg_recv]+0;
	echo "<td>$value</td>";
	echo "</tr>";
	echo "</table>";
	
}

//Table-2
{
	echo "<table border=\"1\" width=\"100%\" cellpadding=\"2\" cellspacing=\"0\" bordercolor=\"#666666\" bordercolordark=\"#FFFFFF\" bgcolor=\"#FFFFFF\">";
	echo "<tr bgcolor=\"#E6E6E6\">";
	echo "<td rowspan=2 width=\"10%\">Node Index</td>";
		echo "<td colspan=3 align=center width=\"45%\">Synchronization Outgoing</td>";
		echo "<td colspan=3 align=center width=\"45%\">Synchronization Incoming</td>";
		echo "</tr>";
		echo "<tr bgcolor=\"#E6E6E6\">";
		echo "<td align=center width=\"15%\">Attempt</td>";
		echo "<td align=center width=\"15%\">Success</td>";
		echo "<td align=center width=\"15%\">Fail</td>";
		echo "<td align=center width=\"15%\">Attempt</td>";
		echo "<td align=center width=\"15%\">Success</td>";
		echo "<td align=center width=\"15%\">Fail</td>";
		echo "</tr>";
	echo "</tr>";
	$field_label=array(
		"syn_o_a_",
		"syn_o_s_",
		"syn_o_f_",
		"syn_i_a_",
		"syn_i_s_",
		"syn_i_f_"
	);
	for($i=0;$i<16;$i++)
	{
		echo "<tr>";
		echo "<td>$i</td>";
		for($j=0;$j<6;$j++)
		{
			$field=$field_label[$j]."$i";
			$value=$cstaData[$field]+0;
			echo "<td>$value</td>";
		}
		echo "</tr>";
	}
	
	echo "</table>";

}
?>
