<?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>";

$DEBUG=0;

$db='CSTA_DB';
$call_type = isset($call_type)?$call_type:'2';
$sort_field = 'csta_datetime DESC, key_sys_id ASC';		//排序所依赖的字段名
$number_records_to_display = 200;		//每页纪录数
$time_column = "csta_datetime";

if(!isset($sel_date)){
	$sel_date = date("Y-m-d",mktime(0,0,0,date("m"),date("d"),date("Y")));
	$timeItem = date("Y-m-d",mktime(0,0,0,date("m"),date("d"),date("Y")));
	if($DEBUG) echo "<br>sel_date=$sel_date";
	$call_type=1;
}

$tmpDay = explode('-',$sel_date);
$tmpDay = $tmpDay[2];
$table_name='vssDetail'."_".$tmpDay;

$sel_field_list= @mysql_list_fields($db,$table_name);
if(!$sel_field_list){
	echo "<br>$strNotFindRecord.";
	exit();
}

$sysTypeNo=390;
switch($sysTypeNo){
	case '390':
		$helpId = "3.5";
		$callTypeDefArr=array('ISUP','VMS APP','VPS APP','Invalid Calls');
		$fieldTypeDefArr=array(
			'',
			'att_org_call,suc_org_call,att_term_call,suc_term_call',
			'att_lev_msg,suc_lev_msg,att_mnt_msg,suc_mnt_msg,acc_fail',
			'att_msc,suc_msc,att_pps,suc_pps',
			'att_invalid_call'
			);
	//	$tableTitleDefArr=array(
	//		'',
	//		'<tr bgcolor="#c6c6c6" align="center"><td>sysId</td><td>attempt</td><td>success</td><td>answered (call directly)</td><td>answered (forward)</td><td>Time</td></tr>'
	//		);
		break;
	default:
		echo "Can not support this sysTypeNo($sysTypeNo)";
		exit();
}

?>

<?php
//合成sql语句
$order=" ORDER BY $sort_field   $sort_direction";
$limit=" LIMIT $initial_record, $number_records_to_display";

if($key_sys_id<9)
	$csta_sql="SELECT * FROM $table_name WHERE key_type='$call_type' AND key_sys_id='$key_sys_id' "."\n".$order; 
else
	$csta_sql="SELECT * FROM $table_name WHERE key_type='$call_type' "."\n".$order;
if($DEBUG) echo "<br>csta_sql=$csta_sql";
$csta_result = mysqli_query($pubConn,$csta_sql);
$csta_rows = @mysqli_fetch_array($csta_result);
echo mysqli_error($pubConn);


//显示表头
echo "<table border=\"1\" width=\"100%\" cellpadding=\"2\" cellspacing=\"0\" bordercolor=\"#666666\" bordercolordark=\"#FFFFFF\" bgcolor=\"#FFFFFF\">";  
switch($call_type){
	case 1:
		echo "<tr bgcolor=\"#E6E6E6\" align=\"center\">";
		echo "<td rowspan=\"2\" width=\"10%\">system ID</td>";
		//echo "<td rowspan=\"2\" width=\"15%\">Attempt</td>";
		//echo "<td rowspan=\"2\" width=\"15%\">Success</td>";
		echo "<td colspan=\"2\" width=\"30%\">original</td>";
		echo "<td colspan=\"2\" width=\"30%\">terminal</td>";
		echo "<td rowspan=\"2\" width=\"20%\">Time($timeItem)</td>";	
		echo "</tr>";
		echo "<tr bgcolor=\"#E6E6E6\" align=\"center\">";
		echo "<td>Attempt</td>";
		echo "<td>Success</td>";
		//echo "</tr>";
		//echo "</tr>";
		//echo "<tr bgcolor=\"#E6E6E6\" align=\"center\">";
		echo "<td>Attempt</td>";
		echo "<td>Success</td>";
		echo "</tr>";
		break;
	case 2:
		echo "<tr bgcolor=\"#E6E6E6\" align=\"center\">";
		echo "<td rowspan=\"2\" width=\"10%\">system ID</td>";
		echo "<td colspan=\"2\" width=\"30%\">Leave message</td>";
		echo "<td colspan=\"2\" width=\"30%\">Maintain message</td>";
		//echo "<td colspan=\"8\" width=\"70%\">Maintenance</td>";
		echo "<td rowspan=\"2\" width=\"10%\">Access to fail</td>";
		echo "<td rowspan=\"2\" width=\"20%\">Time($timeItem)</td>";
		echo "</tr>";
		echo "<tr bgcolor=\"#E6E6E6\" align=\"center\">";
		echo "<td>Attempt</td>";
   		echo "<td>Success</td>";
		echo "<td>Attempt</td>";
		echo "<td>Success</td>";
		/*echo "<td>Attempt</td>";
		echo "<td>select greeting type</td>";
		echo "<td>host name </td>";
		echo "<td>personal greeting</td>";
		echo "<td>select language</td>";
		echo "<td>active password</td>";
		echo "<td>inactive password</td>";
		echo "<td>change password</td>";
		echo "<td>attempt</td>";
		*/echo "</tr>";
		break;
	case 3:
		echo "<tr bgcolor=\"#E6E6E6\" align=\"center\">";
		echo "<td rowspan=\"2\" width=\"10%\">system ID</td>";
		echo "<td colspan=\"2\" width=\"30%\">MSC announcement</td>";
		echo "<td colspan=\"2\" width=\"30%\">PPS service</td>";
		echo "<td rowspan=\"2\" width=\"20%\">Time($timeItem)</td>";	
		echo "</tr>";
		echo "<tr bgcolor=\"#E6E6E6\" align=\"center\">";
		echo "<td>Attempt</td>";
   		echo "<td>Success</td>";
		echo "<td>Attempt</td>";
		echo "<td>Success</td>";
		echo "</tr>";
		break;
	case 4:
		echo "<tr bgcolor=\"#E6E6E6\" align=\"center\">";
		echo "<td width=\"10%\">system ID</td>";
   		echo "<td width=\"20%\">Invalid Calls</td>";
		echo "<td width=\"20%\">Time($timeItem)</td>";
		echo "</tr>";
		break;
}
//显示表的记录
$fieldArr=explode(',',$fieldTypeDefArr[$call_type]);
do{
	echo "<tr>";
	echo "<td align=\"center\">$csta_rows[key_sys_id]</td>";
	for($i=0;$i<sizeof($fieldArr);$i++){
		$tmpFieldName= $fieldArr[$i];
		echo "<td align=\"right\">$csta_rows[$tmpFieldName]</td>";
	}
	$tmpArray = explode(" ",$csta_rows[csta_datetime]);
	echo "<td align=\"center\">$tmpArray[1]</td>";
	echo "</tr>";
}while($csta_rows= mysqli_fetch_array($csta_result));
?>
</table>
<?php
adjust_content_tail("down");
?>
</form>
</body>
</html>