<?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='hlrDetail'."_".$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.";
	adjust_content_tail("down");
	exit();
 }

if($language == 'eng')
{
	$strNcmroh="Number of current MS's Roaming outside HPLMN";
	$strArasrh="Authentication sets received";
	$strAisds="Insert subscriber data service";
	$strAlu="Location Updates";
	$strAsroh="SS related operations in HLR";
	$strArsri="Request for SM routing information";
	$strAsdssp="SM delivery status report procedures";
	$strAnsa="Number of send alerts";
	$strArm="Request for MSRN";
	$strHlrStatistic="HLR statistics";
}
else
{
	$strNcmroh="Number of current MS's Roaming outside HPLMN";
	$strArasrh="Authentication sets received";
	$strAisds="Insert subscriber data service";
	$strAlu="Location Updates";
	$strAsroh="SS related operations";
	$strArsri="Request for SM routing information";
	$strAsdssp="SM delivery status report procedures";
	$strAnsa="Number of send alerts";
	$strArm="Request for MSRN";
	$strHlrStatistic="HLR 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";
	adjust_content_tail("down");
	exit();
}
$sum_sql=" SELECT SUM(ncmroh) AS ncmroh,SUM(arasrh) AS arasrh,SUM(srasfh) AS srasfh,SUM(errash) AS errash,SUM(aisds) AS aisds, SUM(sisds) AS sisds,SUM(alu) AS alu,SUM(slu) AS slu,SUM(asroh) AS asroh,SUM(ssroh) AS ssroh,SUM(arsri) AS arsri,SUM(srsri) AS srsri,SUM(asdssp) AS asdssp,SUM(ssdsrp) AS ssdsrp,SUM(ansa) AS ansa,SUM(snsa) AS snsa,SUM(arm) AS arm,SUM(srm) AS srm FROM $table_name ".$where;
//echo "<br>sum_sql=$sum_sql";
$sum_res = mysqli_query($pubConn,$sum_sql);
$sum_row = @mysqli_fetch_array($sum_res);
echo mysqli_error($pubConn);

$ncmroh=$sum_row[ncmroh];
if($ncmroh>0)
{
	$ncmrohScale="100%";
}
else
{
	$ncmrohScale="0%";
}
$arasrh=$sum_row[arasrh];
$srasfh=$sum_row[srasfh];
$frrash=$arasrh-$srasfh;
if($arasrh>0)
{
	$arasrhScale="100%";
	$srasfhPoint=$srasfh/$arasrh;
	$srasfhScale=change_percent($srasfh/$arasrh);
	$frrashPoint=$frrash/$arasrh;
	$frrashScale=change_percent($frrash/$arasrh);
}
else
{
	$arasrhScale="0%";
	$srasfhPoint="0%";
	$srasfhScale="0%";
	$frrashPoint="0%";
	$frrashScale="0%";
}

$aisds=$sum_row[aisds];
$sisds=$sum_row[sisds];
$fisds=$aisds-$sisds;
if($aisds>0)
{
	$aisdsScale="100%";
	$sisdsPoint=$sisds/$aisds;
	$sisdsScale=change_percent($sisds/$aisds);
	$fisdsPoint=$fisds/$aisds;
	$fisdsScale=change_percent($fisds/$aisds);
}
else
{
	$aisdsScale="0%";
	$sisdsPoint="0%";
	$sisdsScale="0%";
	$fisdsPoint="0%";
	$fisdsScale="0%";
}

$alu=$sum_row[alu];
$slu=$sum_row[slu];
$flu=$alu-$slu;
if($alu>0)
{
	$aluScale="100%";
	$sluPoint=$slu/$alu;
	$sluScale=change_percent($slu/$alu);
	$fluPoint=$flu/$alu;
	$fluScale=change_percent($flu/$alu);
}
else
{
	$aluScale="0%";
	$sluPoint="0%";
	$sluScale="0%";
	$fluPoint="0%";
	$fluScale="0%";
}

$asroh=$sum_row[asroh];
$ssroh=$sum_row[ssroh];
$fsroh=$asroh-$ssroh;
if($asroh>0)
{
	$asrohScale="100%";
	$ssrohPoint=$ssroh/$asroh;
	$ssrohScale=change_percent($ssroh/$asroh);
	$fsrohPoint=$fsroh/$asroh;
	$fsrohScale=change_percent($fsroh/$asroh);
}
else
{
	$asrohScale="0%";
	$ssrohPoint="0%";
	$ssrohScale="0%";
	$fsrohPoint="0%";
	$fsrohScale="0%";
}

$arsri=$sum_row[arsri];
$srsri=$sum_row[srsri];
$frsri=$arsri-$srsri;
if($arsri>0)
{
	$arsriScale="100%";
	$srsriPoint=$srsri/$arsri;
	$srsriScale=change_percent($srsri/$arsri);
	$frsriPoint=$frsri/$arsri;
	$frsriScale=change_percent($frsri/$arsri);
}
else
{
	$arsriScale="0%";
	$srsriPoint="0%";
	$srsriScale="0%";
	$frsriPoint="0%";
	$frsriScale="0%";
}

$asdssp=$sum_row[asdssp];
$ssdsrp=$sum_row[ssdsrp];
$fsdsrp=$asdssp-$ssdsrp;
if($asdssp>0)
{
	$asdsspScale="100%";
	$ssdsrpPoint=$ssdsrp/$asdssp;
	$ssdsrpScale=change_percent($ssdsrp/$asdssp);
	$fsdsrpPoint=$fsdsrp/$asdssp;
	$fsdsrpScale=change_percent($fsdsrp/$asdssp);
}
else
{
	$asdsspScale="0%";
	$ssdsrpPoint="0%";
	$ssdsrpScale="0%";
	$fsdsrpPoint="0%";
	$fsdsrpScale="0%";
}

$ansa=$sum_row[ansa];
$snsa=$sum_row[snsa];
$fnsa=$ansa-$snsa;
if($ansa>0)
{
	$ansaScale="100%";
	$snsaPoint=$snsa/$ansa;
	$snsaScale=change_percent($snsa/$ansa);
	$fnsaPoint=$fnsa/$ansa;
	$fnsaScale=change_percent($fnsa/$ansa);
}
else
{
	$ansaScale="0%";
	$snsaPoint="0%";
	$snsaScale="0%";
	$fnsaPoint="0%";
	$fnsaScale="0%";
}

$arm=$sum_row[arm];
$srm=$sum_row[srm];
$frm=$arm-$srm;
if($arm>0)
{
	$armScale="100%";
	$srmPoint=$srm/$arm;
	$srmScale=change_percent($srm/$arm);
	$frmPoint=$frm/$arm;
	$frmScale=change_percent($frm/$arm);
}
else
{
	$armScale="0%";
	$srmPoint="0%";
	$srmScale="0%";
	$frmPoint="0%";
	$frmScale="0%";
}

?>


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

<td width="20%" align="right">      
&nbsp;
</td>
<!--
<td width="5%" align="center">
<div onClick="javascript:document.selectform.submit();" style="cursor:hand">
<img align=absBottom border=0 src="../../images/save.gif" width="16" height="16">	
</div>
</td>
-->
</tr>      
</table> 
<table border="1" width="100%" cellpadding="2" cellspacing="0" bordercolor="#666666" bordercolordark="#FFFFFF" bgcolor="#FFFFFF" >  
  <tr bgcolor="#E6E6E6">
    <td width="606" colspan="4" height="16">
      <p align="center">1.<?php echo "$strPercentStatTable"; ?></td>
  </tr>             
  <tr>
    <td width="143" height="16">
      <p align="center"><?php echo "$strItem";?></td>
    <td width="151" height="16">
      <p align="center"><?php echo "$strAttribute";?></td>
    <td width="151" height="16">
      <p align="center"><?php echo "$strTimes";?></td>
    <td width="151" height="16">
      <p align="center"><?php echo "$strPercent";?></td>
  </tr>
  <tr>
    <td width="143" rowspan="1" align="center" height="40">
      <p align="center"><?php echo "$strNcmroh";?></td>
    <td width="151" height="19">
      <p align="center"><?php echo "$strAttempt";?></td>
    <td width="151" height="19">
      <p align="center">&nbsp;<?php echo "$ncmroh";?></td>
    <td width="151" height="19">
      <p align="center">&nbsp;<?php echo "$ncmrohScale";?></td>
  </tr>
  <tr>
    <td width="143" rowspan="2" align="center" height="40">
      <p align="center"><?php echo "$strArasrh";?></td>
    <td width="151" height="19">
      <p align="center"><?php echo "$strSuccess";?></td>
    <td width="151" height="19">
      <p align="center">&nbsp;<?php echo "$srasfh";?></td>
    <td width="151" height="19">
      <p align="center">&nbsp;<?php echo "$srasfhScale";?></td>
  </tr>
  <tr>
    <td width="151" height="19">
      <p align="center"><?php echo "$strFailure";?></td>
    <td width="151" height="19">
      <p align="center">&nbsp;<?php echo "$frrash";?></td>
    <td width="151" height="19">
      <p align="center">&nbsp;<?php echo "$frrashScale";?></td>
  </tr>

  <tr>
    <td width="143" rowspan="2" align="center" height="40">
      <p align="center"><?php echo "$strAisds";?></td>
    <td width="151" height="19">
      <p align="center"><?php echo "$strSuccess";?></td>
    <td width="151" height="19">
      <p align="center">&nbsp;<?php echo "$sisds";?></td>
    <td width="151" height="19">
      <p align="center">&nbsp;<?php echo "$sisdsScale";?></td>
  </tr>
  <tr>
    <td width="151" height="19">
      <p align="center"><?php echo "$strFailure";?></td>
    <td width="151" height="19">
      <p align="center">&nbsp;<?php echo "$fisds";?></td>
    <td width="151" height="19">
      <p align="center">&nbsp;<?php echo "$fisdsScale";?></td>
  </tr>
  <tr>
    <td width="143" rowspan="2" align="center" height="40"><?php echo "$strAlu";?></td>
    <td width="151" height="19">
      <p align="center"><?php echo "$strSuccess";?></td>
    <td width="151" height="19">
      <p align="center">&nbsp;<?php echo "$slu";?></td>
    <td width="151" height="19">
      <p align="center">&nbsp;<?php echo "$sluScale";?></td>
  </tr>
  <tr>
    <td width="151" height="19">
      <p align="center"><?php echo "$strFailure";?></td>
    <td width="151" height="19">
      <p align="center">&nbsp;<?php echo "$flu";?></td>
    <td width="151" height="19">
      <p align="center">&nbsp;<?php echo "$fluScale";?></td>
  </tr>
  <tr>
    <td width="143" rowspan="2" height="40">
      <p align="center"><?php echo "$strAsroh";?></td>
    <td width="151" align="center" height="19"><?php echo "$strSuccess";?></td>
    <td width="151" height="19">
      <p align="center">&nbsp;<?php echo "$ssroh";?></td>
    <td width="151" height="19">
      <p align="center">&nbsp;<?php echo "$ssrohScale";?></td>
  </tr>
  <tr>
    <td width="151" height="16">
      <p align="center"><?php echo "$strFailure";?></td>
    <td width="151" height="16">
      <p align="center">&nbsp;<?php echo "$fsroh";?></td>
    <td width="151" height="16">
      <p align="center">&nbsp;<?php echo "$fsrohScale";?></td>
  </tr>

  <tr>
    <td width="143" rowspan="2" height="40">
      <p align="center"><?php echo "$strArsri";?></td>
    <td width="151" height="19">
      <p align="center"><?php echo "$strSuccess";?></td>
    <td width="151" height="19">
      <p align="center">&nbsp;<?php echo "$srsri";?></td>
    <td width="151" height="19">
      <p align="center">&nbsp;<?php echo "$srsriScale";?></td>
  </tr>
  <tr>
    <td width="151" height="19">
      <p align="center"><?php echo "$strFailure";?></td>
    <td width="151" height="19">
      <p align="center">&nbsp;<?php echo "$frsri";?></td>
    <td width="151" height="19">
      <p align="center">&nbsp;<?php echo "$frsriScale";?></td>
  </tr>
  <tr>
    <td width="143" rowspan="2" height="40">
      <p align="center"><?php echo "$strAsdssp";?></td>
    <td width="151" height="19">
      <p align="center"><?php echo "$strSuccess";?></td>
    <td width="151" height="19">
      <p align="center">&nbsp;<?php echo "$ssdsrp";?></td>
    <td width="151" height="19">
      <p align="center">&nbsp;<?php echo "$ssdsrpScale";?></td>
  </tr>
  <tr>
    <td width="151" height="19">
      <p align="center"><?php echo "$strFailure";?></td>
    <td width="151" height="19">
      <p align="center">&nbsp;<?php echo "$fsdsrp";?></td>
    <td width="151" height="19">
      <p align="center">&nbsp;<?php echo "$fsdsrpScale";?></td>
  </tr>
  <tr>
    <td width="143" rowspan="2" height="40">
      <p align="center"><?php echo "$strAnsa";?></td>
    <td width="151" height="19">
      <p align="center"><?php echo "$strSuccess";?></td>
    <td width="151" height="19">
      <p align="center">&nbsp;<?php echo "$snsa";?></td>
    <td width="151" height="19">
      <p align="center">&nbsp;<?php echo "$snsaScale";?></td>
  </tr>
  <tr>
    <td width="151" height="19">
      <p align="center"><?php echo "$strFailure";?></td>
    <td width="151" height="19">
      <p align="center">&nbsp;<?php echo "$fnsa";?></td>
    <td width="151" height="19">
      <p align="center">&nbsp;<?php echo "$fnsaScale";?></td>
  </tr>
  <tr>
    <td width="143" rowspan="2" height="40">
      <p align="center"><?php echo "$strArm";?></td>
    <td width="151" height="19">
      <p align="center"><?php echo "$strSuccess";?></td>
    <td width="151" height="19">
      <p align="center">&nbsp;<?php echo "$srm";?></td>
    <td width="151" height="19">
      <p align="center">&nbsp;<?php echo "$srmScale";?></td>
  </tr>
  <tr>
    <td width="151" height="19">
      <p align="center"><?php echo "$strFailure";?></td>
    <td width="151" height="19">
      <p align="center">&nbsp;<?php echo "$frm";?></td>
    <td width="151" height="19">
      <p align="center">&nbsp;<?php echo "$frmScale";?></td>
  </tr>
</table>
<p> </p>
<p> </p>
<p> </p>
<table border="0" cellPadding="0" cellSpacing="0" height="220"  style="BORDER-BOTTOM: rgb(0,0,0) 1px solid; BORDER-LEFT: rgb(0,0,0) 1px solid; BORDER-RIGHT: medium none; BORDER-TOP: medium none" > 
<tr> 
<td colspan="17" height="20"> 
<b><img border="0" src="../../images/Icon-0.gif" width="2" height="1">&nbsp;<INPUT type="text" size="10" name="topNumber_2" id="topNumber"  value="100" style="border-left:medium none;border-right:medium none;border-top:medium none;border-bottom:medium none; solid rgb(0,0,0)"   readonly><INPUT type="hidden" size="10" name="org_topNumber_2" id="topNumber"  value="100" ></b>2.<?php echo "$strPercentStatLegend";?>
</td> 
</tr> 
<tr> 
<td valign="bottom" height="40" width="20"><img border="0" src="../../images/Icon-0.gif" width="2" height="1"></td> 
<td valign="bottom" height="200" width="40" rowspan="5"><img border="0" src="../../images/dark_blue.GIF" width="40" height="<?php echo 200*$srasfhPoint; ?>"></td>
<td valign="bottom" height="200" width="40" rowspan="5"><img border="0" src="../../images/red.gif" width="40" height="<?php echo 200*$frrashPoint; ?>"></td>
<td valign="bottom" height="200" width="20" rowspan="5"></td>
<td valign="bottom" height="200" width="40" rowspan="5"><img border="0" src="../../images/dark_blue.GIF" width="40" height="<?php echo 200*$sisdsPoint; ?>"></td>
<td valign="bottom" height="200" width="40" rowspan="5"><img border="0" src="../../images/red.gif" width="40" height="<?php echo 200*$fisdsPoint; ?>"></td>
<td valign="bottom" height="200" width="20" rowspan="5"></td>
<td valign="bottom" height="200" width="40" rowspan="5"><img border="0" src="../../images/dark_blue.GIF" width="40" height="<?php echo 200*$sluPoint; ?>"></td>
<td valign="bottom" height="200" width="40" rowspan="5"><img border="0" src="../../images/red.gif" width="40" height="<?php echo 200*$fluPoint; ?>"></td>
<td valign="bottom" height="200" width="20" rowspan="5"></td>
<td valign="bottom" height="200" width="40" rowspan="5"><img border="0" src="../../images/dark_blue.GIF" width="40" height="<?php echo 200*$ssrohPoint; ?>"></td>
<td valign="bottom" height="200" width="40" rowspan="5"><img border="0" src="../../images/red.gif" width="40" height="<?php echo 200*$fsrohPoint; ?>"></td>
<td valign="bottom" height="200" width="20" rowspan="5"></td>
<td valign="bottom" height="200" width="40" rowspan="5"><img border="0" src="../../images/dark_blue.GIF" width="40" height="<?php echo 200*$srsriPoint; ?>"></td>
<td valign="bottom" height="200" width="40" rowspan="5"><img border="0" src="../../images/red.gif" width="40" height="<?php echo 200*$frsriPoint; ?>"></td>
<td valign="bottom" height="200" width="20" rowspan="5"></td>	
<td valign="bottom" height="200" width="40" rowspan="5"><img border="0" src="../../images/dark_blue.GIF" width="40" height="<?php echo 200*$ssdsrpPoint; ?>"></td>
<td valign="bottom" height="200" width="40" rowspan="5"><img border="0" src="../../images/red.gif" width="40" height="<?php echo 200*$fsdsrpPoint; ?>"></td>
<td valign="bottom" height="200" width="20" rowspan="5"></td>	
<td valign="bottom" height="200" width="40" rowspan="5"><img border="0" src="../../images/dark_blue.GIF" width="40" height="<?php echo 200*$snsaPoint; ?>"></td>
<td valign="bottom" height="200" width="40" rowspan="5"><img border="0" src="../../images/red.gif" width="40" height="<?php echo 200*$fnsaPoint; ?>"></td>
<td valign="bottom" height="200" width="20" rowspan="5"></td>	
<td valign="bottom" height="200" width="40" rowspan="5"><img border="0" src="../../images/dark_blue.GIF" width="40" height="<?php echo 200*$srmPoint; ?>"></td>
<td valign="bottom" height="200" width="40" rowspan="5"><img border="0" src="../../images/red.gif" width="40" height="<?php echo 200*$frmPoint; ?>"></td>

</tr> 
<tr><td valign="bottom" height="40" width="20"><img border="0" src="../../images/Icon-0.gif" width="2" height="1"></td></tr> 
<tr><td valign="bottom" height="40" width="20"><img border="0" src="../../images/Icon-0.gif" width="2" height="1"></td></tr> 
<tr><td valign="bottom" height="40" width="20"><img border="0" src="../../images/Icon-0.gif" width="2" height="1"></td></tr> 
<tr><td valign="bottom" height="40" width="20"></td></tr> 
</table>
<table width=800>
<tr align="center">
<td width=20>&nbsp;</td>
<td width=80><?php echo "$strArasrh";?></td>
<td width=20>&nbsp;</td>
<td width=80><?php echo "$strAisds";?></td>
<td width=20>&nbsp;</td>
<td width=80><?php echo "$strAlu";?></td>
<td width=20>&nbsp;</td>
<td width=80><?php echo "$strAsroh";?></td>
<td width=20>&nbsp;</td>
<td width=80><?php echo "$strArsri";?></td>
<td width=20>&nbsp;</td>
<td width=80><?php echo "$strAsdssp";?></td>
<td width=20>&nbsp;</td>
<td width=80><?php echo "$strAnsa";?></td>
<td width=20>&nbsp;</td>
<td width=80><?php echo "$strArm";?></td>
</tr>
</table>
<p></p>
<table border="0" width="330" height="18">
  <tr>
    <td width="60" height="18"><b><?php echo $strLegend; ?>:</b></td>
    <td width="18" height="18"><img border="0" src="../../images/legend_dark_blue.GIF" width="18" height="18"></td>
    <td width="182" height="18"><?php echo "$strSuccess"; ?></td>
    <td width="18" height="18"><img border="0" src="../../images/red.gif" width="18" height="18"></td>
    <td width="182" height="18"><?php echo "$strFailure"; ?></td>
  </tr>
</table>
<?php
adjust_content_tail("down");
?>
</body>
</html>