<?php
/*********************************************************      
 程序说明：         
    功能说明：进行话务分析

    调用关系：调用:header.inc     
              被调用:      
 
    变量说明：
     返回值：无

 作者：Cui Ticun  2004-12-14     
      
修改注释：      
NO.1      
姓名：            
时间：      
修改说明：      
*********************************************************/  
require("../../inc/header.inc");
?>
<body leftmargin="15" rightmargin="10" onload="javascript:adjust_frame('down');" onresize="javascript:adjust_frame('down');" style="overflow:hidden;overflow-x:hidden;overflow-y:hidden;">
<?
adjust_head_frame("down");
adjust_title_head_frame("down");
adjust_title_tail_frame("down");

adjust_content_head_frame("down");	
echo "<br>";

$showDate = date("d",mktime(0,0,0,date("m"),date("d")-$sel_date,date("Y")));
$showDate = omc_keep_length($showDate,0,2);
$db=$csta_db;
$time_column = "csta_datetime";
$table_name='aasDetail'."_".$showDate;
$title_time=date("Y-m-d", mktime(0,0,0,date("m"),date("d")-$sel_date,date("Y")));//表头显示时间

 $sel_field_list= @mysql_list_fields($db,$table_name);
 if(!$sel_field_list)
 {
	echo "<br>$strNotFindRecord.";
	exit();
 }
$strServerStatistics = "Server statistics";
//-------确定日期范围-----
if($sel_date<0)
{
	$bgn_date=date("Y-m-d H:i:s", mktime(0,0,0,date("m"),date("d")-6,date("Y")));
	$end_date=date("Y-m-d H:i:s", mktime());
}
elseif($sel_date>0)
{
	if($sel_time)
	{
		$bgn_date=date("Y-m-d H:i:s", mktime($hou_1,$mid_1,$sec_1,date("m"),date("d")-$sel_date,date("Y")));
		$end_date=date("Y-m-d H:i:s", mktime($hou_2,$mid_2,$sec_2,date("m"),date("d")-$sel_date,date("Y")));
	}
	else
	{
		$bgn_date=date("Y-m-d H:i:s", mktime(0,0,0,date("m"),date("d")-$sel_date,date("Y")));
		$end_date=date("Y-m-d H:i:s", mktime(0,0,0,date("m"),date("d")-$sel_date+1,date("Y")));
	}
}
else
{
	if($sel_time)
	{
		$bgn_date=date("Y-m-d H:i:s", mktime($hou_1,$mid_1,$sec_1,date("m"),date("d")-$sel_date,date("Y")));
		$end_date=date("Y-m-d H:i:s", mktime($hou_2,$mid_2,$sec_2,date("m"),date("d")-$sel_date,date("Y")));
	}
	else
	{
		$bgn_date=date("Y-m-d H:i:s", mktime(0,0,0,date("m"),date("d"),date("Y")));
		$end_date=date("Y-m-d H:i:s", mktime());
	}
}

/* where语句的时间限制组成部分为$w1,系统id限制为$w2 */
$w1=" $time_column >='$bgn_date' AND $time_column <= '$end_date'";
	
//合成where语句
$where=" WHERE ".$w1;
$str_sql_all="SELECT count(*) as number_of_records FROM $table_name ".$where;
$csta_result= mysqli_query($pubConn,$str_sql_all);
$record = mysql_fetch_object($csta_result);
$number_of_records = $record->number_of_records;
if(!$number_of_records)
{      
	echo "$strNotFindRecord";
	exit();
}
$sum_sql="
		SELECT	
		SUM(pps_service_attempt) AS pps_service_attempt,
		SUM(pps_service_success) AS pps_service_success,
		SUM(msc_service_attempt) AS msc_service_attempt,
		SUM(msc_service_success) AS msc_service_success,
		SUM(invalid_call) AS invalid_call
		FROM $table_name 
	";
//echo "<br>sum_sql=$sum_sql";
$sum_res = mysqli_query($pubConn,$sum_sql);
$sum_row = @mysqli_fetch_array($sum_res);
echo mysqli_error($pubConn);

?>


<form method="POST" action="./saveCsv.php" name="selectform">
<table border="0" width="100%">
<tr>
<td width="25%">
</td>
<td width="50%">
<p align="center"><b><?php echo "$strServerStatistics"; ?></b><b>&nbsp;   
Date:<?php echo $title_time; ?></b>
</td> 

<td width="20%" align="right">      
<div onClick="window.print();" style="cursor:hand">
<img align=absBottom border=0 src="../../images/printer.gif" width="16" height="16">
</div>
</td>
</tr>      
</table> 
<table border="1" width="100%" bordercolordark="#FFFFFF" bordercolor="#808080" cellspacing="0">
<?php 
echo "  <tr bgcolor=\"#E6E6E6\">";
echo "    <td width=\"10%\">&nbsp;</td>";
echo "    <td width=\"40%\">Type</td>";
echo "    <td width=\"40%\">Number</td>";
echo "  </tr>";
echo "    <td rowspan=\"2\">PPS Service</td>";
echo "    <td>Attempt</td>";
echo "    <td>&nbsp;$sum_row[pps_service_attempt]</td>";
echo "  </tr>";
echo "  <tr>";
echo "    <td>Success</td>";
echo "    <td>&nbsp;$sum_row[pps_service_success]</td>";
echo "  </tr>";
echo "    <td rowspan=\"2\">MSC Service</td>";
echo "    <td>Attempt</td>";
echo "    <td>&nbsp;$sum_row[msc_service_attempt]</td>";
echo "  </tr>";
echo "  <tr>";
echo "    <td>Success</td>";
echo "    <td>&nbsp;$sum_row[msc_service_success]</td>";
echo "  </tr>";
echo "  <tr>";
echo "    <td>Invalid</td>";
echo "    <td>Invalid Calls</td>";
echo "    <td>&nbsp;$sum_row[invalid_call]</td>";
echo "</tr>";
echo "</table>"; 
adjust_content_tail("down");
?>
</form>
</body>
</html>
