Files
web.ems/wxc2_omc/performance/ppsCsta/dataQueryDown.php
2024-10-22 10:34:29 +08:00

399 lines
15 KiB
PHP
Executable File

<?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>";
$moneyPara = getMoneyPara(); //显示的货币单位是最小货币单位的倍数
$showDate = date("d",mktime(0,0,0,date("m"),date("d")-$sel_date,date("Y")));
$timeItem = date("Y-m-d",mktime(0,0,0,date("m"),date("d")-$sel_date,date("Y")));
$showDate = omc_keep_length($showDate,0,2);
$db=$csta_db;
$table_name='ppsDetail'."_".$showDate;
$sel_field_list= @mysql_list_fields($db,$table_name);
if(!$sel_field_list)
{
echo "<br>$strNotFindRecord.";
exit();
}
$time_column = "csta_datetime";
if(!$sort_field )
{
$sort_field='csta_datetime'; //排序所依赖的字段名
}
if(!$sort_direction)
{
$sort_direction = 'ASC '; //排序顺序
}
$sort_direction=isset($sort_direction)?$sort_direction:'DESC'; //排序顺序
$number_records_to_display = 200; //每页纪录数
$sta_type=isset($sta_type)?$sta_type:'unit';
?>
<script LANGUAGE="JavaScript">
function goto()
{
var iurl_1,url_2,url_3,url_4,nitial_record,gotopage,number_records_to_display,sel_date,number_of_records,sort_field,sort_direction,sta_type;
gotopage=document.selectform.gotopage.value;
number_records_to_display=<?php echo $number_records_to_display; ?>;
sel_date=document.selectform.sel_date.value;
initial_record=number_records_to_display*(gotopage-1);
number_of_records=document.selectform.number_of_records.value;
sort_field=document.selectform.sort_field.value;
sort_direction=document.selectform.sort_direction.value;
sta_type=document.selectform.sta_type.value;
url_1='<?php echo $PHP_SELF;?>?initial_record='+initial_record;
url_2="&sel_date="+sel_date;
url_3="&number_of_records="+number_of_records;
url_4="&sort_field="+sort_field+"&sort_direction="+sort_direction+"&sta_type="+sta_type;
window.location.href=url_1+url_2+url_3+url_4;
}
</script>
<?php
//删除所查询的内容
if($delete)
{
$sql_query="DELETE FROM $table_name ".$where;
$sql_query=urlencode($sql_query); //将该字符串编码,适合传递
echo " <meta http-equiv=\"refresh\" content=\"0; url=./csta_query_del.php?del_sql=$sql_query\"> ";
exit();
}//endif($delete)
if(!isset($number_of_records))
{
//-------确定日期范围-----
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;
$initial_record=0;
$str_sql=" SELECT count(*) FROM $table_name ".$where;
//echo "<br>str_sql=$str_sql";
$result = mysqli_query($pubConn,$str_sql);
$record = @mysqli_fetch_array($result);
echo mysqli_error($pubConn);
$number_of_records = $record[0];
if(!$number_of_records)
{
echo "<br><font size =\"2\" color=\"#000000\">$strNotFindRecord!</font>";
exit();
}
}
if($sta_type=='unit')
{
$sel_sql=" key_sys_id,local_calling_nums,local_called_nums,trunk_out_nums,NDD_call_nums,HMT_call_nums,IDD_call_nums,call_in_nums,periodic_charge_nums,assisted_recharge_nums,assisted_withdraw_nums,recharge_success_nums,recharge_fail_nums,sm_nums,cnf_sums,csta_datetime ";
}
elseif($sta_type=='fee')
{
$sel_sql=" key_sys_id,local_calling_cost,local_called_cost,trunk_out_cost,NDD_call_cost,HMT_call_cost,IDD_call_cost,call_in_cost,periodic_charge_cost,assisted_recharge_cost,assisted_withdraw_cost,recharge_success_cost,recharge_fail_cost,sm_cost,cnf_cost,csta_datetime ";
}
else
{
$sel_sql=" key_sys_id,local_calling_duration,local_called_duration,trunk_out_duration,NDD_call_duration,HMT_call_duration,IDD_call_duration,call_in_duration,periodic_charge_duration,assisted_recharge_duration,assisted_withdraw_duration,recharge_success_duration,recharge_fail_duration,sm_duration,cnf_duration,csta_datetime ";
}
$str_sql=" SELECT $sel_sql FROM $table_name ".$where.
" ORDER BY $sort_field $sort_direction
LIMIT $initial_record, $number_records_to_display
";
//echo "<br>str_sql=$str_sql";
$result=mysqli_query($pubConn,$str_sql);
$rows = @mysqli_fetch_array($result);
echo mysqli_error($pubConn);
if(!$rows)
{
echo "<br>$strNotFindRecord";
exit();
}
if($number_of_records >= 1) {
//下面是控制分页显示,传递变量
$next_index = $initial_record + $number_records_to_display; //本页的结束数目
if ($next_index > $number_of_records){
$next_index = $number_of_records;
}
$t1 = $initial_record + 1;
$prev_index = $initial_record - $number_records_to_display;
if ($prev_index < 0) {
$prev_index = 0;
}
}
?>
<form name="selectform" action="<?php echo "$PHP_SELF?where=$where";?>">
<TABLE border="1" width="100%" cellpadding="2" cellspacing="0" bordercolor="#666666" bordercolordark="#FFFFFF" bgcolor="#FFFFFF">
<?php
//---------------------数量统计-----------------------
//所查询的充值卡数量总计
$sum_sql_1=" SUM(local_calling_nums),SUM(local_called_nums),SUM(trunk_out_nums),SUM(NDD_call_nums),SUM(HMT_call_nums),SUM(IDD_call_nums),SUM(call_in_nums),SUM(periodic_charge_nums),SUM(assisted_recharge_nums),SUM(assisted_withdraw_nums),SUM(recharge_success_nums),SUM(recharge_fail_nums),SUM(sm_nums),SUM(cnf_sums) ";
$sum_all_sql_1 = "SELECT $sum_sql_1 FROM $table_name".$where;
$sum_all_result_1 = mysqli_query($pubConn,$sum_all_sql_1);
$sum_all_rows_1 = mysqli_fetch_array($sum_all_result_1);
$sum_sql_2=" SUM(local_calling_cost),SUM(local_called_cost),SUM(trunk_out_cost),SUM(NDD_call_cost),SUM(HMT_call_cost),SUM(IDD_call_cost),SUM(call_in_cost),SUM(periodic_charge_cost),SUM(assisted_recharge_cost),SUM(assisted_withdraw_cost),SUM(recharge_success_cost),SUM(recharge_fail_cost) ,SUM(sm_cost),SUM(cnf_cost)";
$sum_all_sql_2 = "SELECT $sum_sql_2 FROM $table_name".$where;
$sum_all_result_2 = mysqli_query($pubConn,$sum_all_sql_2);
$sum_all_rows_2 = mysqli_fetch_array($sum_all_result_2);
$sum_sql_3=" SUM(local_calling_duration),SUM(local_called_duration),SUM(trunk_out_duration),SUM(NDD_call_duration),SUM(HMT_call_duration),SUM(IDD_call_duration),SUM(call_in_duration),SUM(periodic_charge_duration),SUM(assisted_recharge_duration),SUM(assisted_withdraw_duration),SUM(recharge_success_duration),SUM(recharge_fail_duration),SUM(sm_duration),SUM(cnf_duration) ";
$sum_all_sql_3 = "SELECT $sum_sql_3 FROM $table_name".$where;
$sum_all_result_3 = mysqli_query($pubConn,$sum_all_sql_3);
$sum_all_rows_3 = mysqli_fetch_array($sum_all_result_3);
echo "<tr align=\"center\">";
echo "<td width=\"9%\">$strTotal</td>";
echo "<td width=\"7%\">$strLocalCallOut</td>";
echo "<td width=\"7%\">$strLocalCallIn</td>";
echo "<td width=\"7%\">$strTrunkCallOut</td>";
echo "<td width=\"7%\">$strNDDCallOut</td>";
//echo "<td>$strHMTCallOut</td>";
echo "<td width=\"7%\">$strIDDCallOut</td>";
echo "<td width=\"7%\">$strTrunkCallIn</td>";
echo "<td width=\"7%\">$strPeriodicCharge</td>";
echo "<td width=\"7%\">$strIncrementValue</td>";
echo "<td width=\"7%\">$strDecreaseValue</td>";
echo "<td width=\"7%\">$strRechargeSuccess</td>";
//echo "<td>$strRechargeFailure</td>";
echo "<td width=\"7%\">SM</td>";
echo "<td width=\"7%\">CNF</td>";
echo "</tr>";
echo "<tr align=\"center\">";
echo "<td>$strCallTimes</td>";
echo "<td>$sum_all_rows_1[0]</td>";
echo "<td>$sum_all_rows_1[1]</td>";
echo "<td>$sum_all_rows_1[2]</td>";
echo "<td>$sum_all_rows_1[3]</td>";
//echo "<td>$sum_all_rows_1[4]</td>";
echo "<td>$sum_all_rows_1[5]</td>";
echo "<td>$sum_all_rows_1[6]</td>";
echo "<td>$sum_all_rows_1[7]</td>";
echo "<td>$sum_all_rows_1[8]</td>";
echo "<td>$sum_all_rows_1[9]</td>";
echo "<td>$sum_all_rows_1[10]</td>";
//echo "<td>$sum_all_rows_1[11]</td>";
echo "<td>$sum_all_rows_1[12]</td>";
echo "<td>$sum_all_rows_1[13]</td>";
echo "</tr>";
echo "<tr align=\"center\">";
echo "<td>$strFeeYuan</td>";
$sum_all_rows_2[0]=$sum_all_rows_2[0];//$moneyPara;
$sum_all_rows_2[1]=$sum_all_rows_2[1];//$moneyPara;
$sum_all_rows_2[2]=$sum_all_rows_2[2];//$moneyPara;
$sum_all_rows_2[3]=$sum_all_rows_2[3];//$moneyPara;
$sum_all_rows_2[4]=$sum_all_rows_2[4];//$moneyPara;
$sum_all_rows_2[5]=$sum_all_rows_2[5];//$moneyPara;
$sum_all_rows_2[6]=$sum_all_rows_2[6];//$moneyPara;
$sum_all_rows_2[7]=$sum_all_rows_2[7];//$moneyPara;
$sum_all_rows_2[8]=$sum_all_rows_2[8];//$moneyPara;
$sum_all_rows_2[9]=$sum_all_rows_2[9];//$moneyPara;
$sum_all_rows_2[10]=$sum_all_rows_2[10];//$moneyPara;
$sum_all_rows_2[11]=$sum_all_rows_2[11];//$moneyPara;
$sum_all_rows_2[12]=$sum_all_rows_2[12];//$moneyPara;
$sum_all_rows_2[13]=$sum_all_rows_2[13];//$moneyPara;
echo "<td>$sum_all_rows_2[0]</td>";
echo "<td>$sum_all_rows_2[1]</td>";
echo "<td>$sum_all_rows_2[2]</td>";
echo "<td>$sum_all_rows_2[3]</td>";
//echo "<td>$sum_all_rows_2[4]</td>";
echo "<td>$sum_all_rows_2[5]</td>";
echo "<td>$sum_all_rows_2[6]</td>";
echo "<td>$sum_all_rows_2[7]</td>";
echo "<td>$sum_all_rows_2[8]</td>";
echo "<td>$sum_all_rows_2[9]</td>";
echo "<td>$sum_all_rows_2[10]</td>";
//echo "<td>$sum_all_rows_2[11]</td>";
echo "<td>$sum_all_rows_2[12]</td>";
echo "<td>$sum_all_rows_2[13]</td>";
echo "</tr>";
echo "<tr align=\"center\">";
echo "<td>$strDurationSecond</td>";
echo "<td>$sum_all_rows_3[0]</td>";
echo "<td>$sum_all_rows_3[1]</td>";
echo "<td>$sum_all_rows_3[2]</td>";
echo "<td>$sum_all_rows_3[3]</td>";
//echo "<td>$sum_all_rows_3[4]</td>";
echo "<td>$sum_all_rows_3[5]</td>";
echo "<td>$sum_all_rows_3[6]</td>";
echo "<td>$sum_all_rows_3[7]</td>";
echo "<td>$sum_all_rows_3[8]</td>";
echo "<td>$sum_all_rows_3[9]</td>";
echo "<td>$sum_all_rows_3[10]</td>";
//echo "<td>$sum_all_rows_3[11]</td>";
echo "<td>$sum_all_rows_3[12]</td>";
echo "<td>$sum_all_rows_3[13]</td>";
echo "</tr>";
$show_initial_record=$initial_record+1;
?>
</TABLE>
<p></p>
<TABLE border="1" width="100%" cellpadding="2" cellspacing="0" bordercolor="#666666" bordercolordark="#FFFFFF" bgcolor="#FFFFFF">
<TR >
<TD><?php echo"$strDisplayRecords<FONT color=#0000ff>&nbsp;$show_initial_record - $next_index</FONT>, ($strTotal:<font color=#0000FF>$number_of_records</font>)";?></TD>
<TD align="center">&nbsp;
<?php
// NEW: Display a link for the previous set of records.
if ($initial_record != 0) {
$t1 = "initial_record=$prev_index&number_of_records=$number_of_records";
$t2 = "sel_date=$sel_date&sort_direction=$sort_direction&sta_type=$sta_type";
echo "<a href=\"$PHP_SELF?$t1&$t2\">";
echo "<IMG alt=\"$strPreviousPage\" border=\"0\" src=\"../../images/pre_page.gif\" ></a>&nbsp;";
}
// NEW: Display a link for the next set of records.
if ($next_index != $number_of_records && $number_of_records >0) {
$t1 = "initial_record=$next_index&number_of_records=$number_of_records";
$t2 = "sel_date=$sel_date&sort_direction=$sort_direction&sta_type=$sta_type";
echo "<a href=\"$PHP_SELF?$t1&$t2\">";
echo "<IMG alt=\" $strNextPage \" border=\"0\" src=\"../../images/next_page.gif\" ></a>&nbsp;";
}
if($number_of_records > 0){
$this_page = $initial_record / $number_records_to_display + 1;
$all_page = round($number_of_records / $number_records_to_display );
if($number_of_records % $number_records_to_display > 0){
$all_page = $all_page + 1;
}
}
?>
</TD>
<TD align="center"><?php echo "$strToPage";?>
<SELECT size="1" name="gotopage" onChange="javasript:goto()">
<?php
for($i=1;$i<=$all_page;$i++){
if($i== $this_page){
echo "<option selected value=\"$i\" >$i</option>";
}else{
echo "<option value=\"$i\">$i</option>";
}
}
?>
</SELECT>
</TD>
<!--
<td width="10%" align="center"><input type="submit" value="<?php echo $strDeleteQueryResult;?>" name="delete" ></td>
-->
</TR>
</TABLE>
<table border="1" width="100%" cellpadding="1" cellspacing="0" bordercolor="#666666" bordercolordark="#FFFFFF">
<?php
echo "<tr bgcolor=\"#E6E6E6\" align=\"center\">";
echo "<td width=\"6%\"><a href=\"$PHP_SELF?sort_field=key_sys_id&sel_date=$sel_date&sort_direction=ASC\">$strSystem</a></td>";
echo "<td width=\"6%\">$strLocalCallOut</td>";
echo "<td width=\"6%\">$strLocalCallIn</td>";
echo "<td width=\"6%\">$strTrunkCallOut</td>";
echo "<td width=\"6%\">$strNDDCallOut</td>";
//echo "<td>$strHMTCallOut</td>";
echo "<td width=\"6%\">$strIDDCallOut</td>";
echo "<td width=\"6%\">$strTrunkCallIn</td>";
echo "<td width=\"6%\">$strPeriodicCharge</td>";
echo "<td width=\"6%\">$strIncrementValue</td>";
echo "<td width=\"6%\">$strDecreaseValue</td>";
echo "<td width=\"6%\">$strRechargeSuccess</td>";
//echo "<td>$strRechargeFailure</td>";
echo "<td width=\"6%\">SM</td>";
echo "<td width=\"6%\">CNF</td>";
echo "<td><a href=\"$PHP_SELF?sort_field=csta_datetime&sel_date=$sel_date\">$strTime($timeItem)</a></td>";
echo "</tr>";
do{
if($sta_type=='fee'){
$rows[1]=$rows[1];//$moneyPara;
$rows[2]=$rows[2];//$moneyPara;
$rows[3]=$rows[3];//$moneyPara;
$rows[4]=$rows[4];//$moneyPara;
$rows[5]=$rows[5];//$moneyPara;
$rows[6]=$rows[6];//$moneyPara;
$rows[7]=$rows[7];//$moneyPara;
$rows[8]=$rows[8];//$moneyPara;
$rows[9]=$rows[9];//$moneyPara;
$rows[10]=$rows[10];//$moneyPara;
$rows[11]=$rows[11];//$moneyPara;
$rows[12]=$rows[12];//$moneyPara;
$rows[13]=$rows[13];//$moneyPara;
$rows[14]=$rows[14];//$moneyPara;
}
echo "<tr align=\"center\">";
echo "<td>$rows[0]</td>";
echo "<td>$rows[1]</td>";
echo "<td>$rows[2]</td>";
echo "<td>$rows[3]</td>";
//echo "<td>$rows[4]</td>";
echo "<td>$rows[5]</td>";
echo "<td>$rows[6]</td>";
echo "<td>$rows[7]</td>";
echo "<td>$rows[8]</td>";
echo "<td>$rows[9]</td>";
echo "<td>$rows[10]</td>";
echo "<td>$rows[11]</td>";
//echo "<td>$rows[12]</td>";
echo "<td>$rows[13]</td>";
echo "<td>$rows[14]</td>";
$tmpArray = explode(" ",$rows[csta_datetime]);
echo "<td>$tmpArray[1]</td>";
echo "</tr>";
}while($rows = mysqli_fetch_array($result));
?>
</table>
<input type="hidden" name="sel_date" value="<?php echo $sel_date; ?>">
<input type="hidden" name="number_of_records" value="<?php echo $number_of_records; ?>">
<input type="hidden" name="sort_field" value="<?php echo $sort_field; ?>">
<input type="hidden" name="sort_direction" value="<?php echo $sort_direction; ?>">
<input type="hidden" name="sta_type" value="<?php echo $sta_type; ?>">
</form>
<?php
adjust_content_tail("down");
?>
</body>
</html>