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

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

 作者：    
      
修改注释：      
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;">
<?php
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='vssDetail'."_".$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();
 }

if($language == 'eng')
{
	$showArr[0][0] = $stratt_term_call = "Total call";
	$showArr[1][0] = $stratt_snd_call = "Leave message";
	$showArr[2][0] = $stratt_rcv_call = "Pickup message";
	$showArr[3][0] = $stratt_get_call = "Help prompt";
	$showArr[4][0] = $stratt_own_call = "Record host name";
	$showArr[5][0] = $stratt_grt_call = "Record greetings";
	$showArr[6][0] = $stratt_vce_call = "Record announcement";
	$showArr[7][0] = $stratt_frm_msc  = "Call status announcement";
	$showArr[8][0] = $stratt_frm_pps  = "PPS announcement";
	$strServerStatistics = "Server statistics";
	$strVmsStatistic = "VSS statistic";
}
else
{
	$showArr[0][0] = $stratt_term_call = "Termination calls";
	$showArr[1][0] = $stratt_snd_call = "Send voice mail";
	$showArr[2][0] = $stratt_rcv_call = "Receive voice mail";
	$showArr[3][0] = $stratt_get_call = "Help prompt";
	$showArr[4][0] = $stratt_own_call = "Record owner's name";
	$showArr[5][0] = $stratt_grt_call = "Record persional greeting";
	$showArr[6][0] = $stratt_vce_call = "Record voice announcement";
	$showArr[7][0] = $stratt_frm_msc  = "MSC VPS calls";
	$showArr[8][0] = $stratt_frm_pps  = "PPS VPS calls";
	$strServerStatistics = "Server statistics";
	$strVmsStatistic = "VSS statistic";
}

//-------确定日期范围-----
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();
}
if($key_sys_id>9)
	$sum_sql="
		SELECT	
		SUM(att_org_call) AS att_org_call_sum,
		SUM(suc_org_call) AS suc_org_call_sum,
		SUM(att_term_call) AS att_term_call_sum,
		SUM(suc_term_call) AS suc_term_call_sum,
	
		SUM(att_lev_msg) AS att_lev_msg_sum,
		SUM(suc_lev_msg) AS suc_lev_msg_sum,
		SUM(att_mnt_msg) AS att_mnt_msg_sum,
		SUM(suc_mnt_msg) AS suc_mnt_msg_sum,
		SUM(acc_fail) AS acc_fail_sum,

		FROM $table_name 
	";
else
	$sum_sql="
		SELECT	
		SUM(att_org_call) AS att_org_call_sum,
		SUM(suc_org_call) AS suc_org_call_sum,
		SUM(att_term_call) AS att_term_call_sum,
		SUM(suc_term_call) AS suc_term_call_sum,
	
		SUM(att_lev_msg) AS att_lev_msg_sum,
		SUM(suc_lev_msg) AS suc_lev_msg_sum,
		SUM(att_mnt_msg) AS att_mnt_msg_sum,
		SUM(suc_mnt_msg) AS suc_mnt_msg_sum,
		SUM(acc_fail) AS acc_fail_sum

		FROM $table_name WHERE key_sys_id='$key_sys_id' GROUP BY key_sys_id
	";

//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%\">Call Type</td>";
echo "    <td width=\"40%\">Number</td>";
echo "  </tr>";
/*echo "  <tr>";
echo "    <td rowspan=\"4\">VAS</td>";
echo "    <td>MSC Announcement Attempt</td>";
echo "    <td>&nbsp;$sum_row[att_msc_sum]</td>";
echo "  </tr>";
echo "  <tr>";
echo "    <td>MSC Announcement Success</td>";
echo "    <td>&nbsp;$sum_row[suc_msc_sum]</td>";
echo "  </tr>";
echo "  <tr>";
echo "    <td>PPS Announcement Attempt</td>";
echo "    <td>&nbsp;$sum_row[att_pps_sum]</td>";
echo "  </tr>";
echo "  <tr>";
echo "    <td>PPS Announcement Success</td>";
echo "    <td>&nbsp;$sum_row[suc_pps_sum]</td>";
echo "  </tr>";
echo "  <tr>";
*/echo "    <td rowspan=\"5\">VSS</td>";
echo "    <td>leave message attempt</td>";
echo "    <td>&nbsp;$sum_row[att_lev_msg_sum]</td>";
echo "  </tr>";
echo "  <tr>";
echo "    <td>leave message success</td>";
echo "    <td>&nbsp;$sum_row[suc_lev_msg_sum]</td>";
echo "  </tr>";
echo "  <tr>";
echo "    <td>maintain message attempt</td>";
echo "    <td>&nbsp;$sum_row[att_mnt_msg_sum]</td>";
echo "  </tr>";
echo "  <tr>";
echo "    <td>maintain message success</td>";
echo "    <td>&nbsp;$sum_row[suc_mnt_msg_sum]</td>";
echo "  </tr>";
echo "  <tr>";
echo "    <td>fail to access</td>";
echo "    <td>&nbsp;$sum_row[acc_fail_sum]</td>";
echo "  </tr>";
echo "  <tr>";
echo "    <td rowspan=\"4\">ISUP</td>";
echo "    <td>original attempt</td>";
echo "    <td>&nbsp;$sum_row[att_org_call_sum]</td>";
echo "  </tr>";
echo "  <tr>";
echo "    <td>original success</td>";
echo "    <td>&nbsp;$sum_row[suc_org_call_sum]</td>";
echo "  </tr>";
echo "  <tr>";
echo "    <td>terminal attempt</td>";
echo "    <td>&nbsp;$sum_row[att_term_call_sum]</td>";
echo "  </tr>";
echo "  <tr>";
echo "    <td>terminal success</td>";
echo "    <td>&nbsp;$sum_row[suc_term_call_sum]</td>";
echo "  </tr>";
/*echo "  <tr>";
echo "    <td>Invalid</td>";
echo "    <td>Invalid Calls</td>";
echo "    <td>&nbsp;$sum_row[att_invalid_call_sum]</td>";
echo "</tr>";
*/echo "</table>"; 

adjust_content_tail("down");
?>
</form>
</body>
</html>
