Files
web.ems/wxc2_omc/performance/mscCsta/e1_general_down.php
agtuser 16a3fd1e1b init
2024-11-11 17:56:00 +08:00

818 lines
25 KiB
PHP
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
require("../../inc/header.inc");
?>
<?php
//====scroll the page====
if($scroll_y > 0){
echo "<body style=\"overflow-x:hidden\" topmargin=\"5\" leftmargin=\"12\" onLoad='self.scrollBy(0,$scroll_y)'>";
}else{
echo "<body style=\"overflow-x:hidden\" topmargin=\"5\" leftmargin=\"12\">";
}
?>
<?php
//========================================================================================|
//===========================Initial The Data From Index Page=============================|
//========================================================================================|
if(!isset($scroll_y))
$scroll_y=0;
if(!isset($sel_date_from))
$sel_date_from=0;
if(!isset($sel_date_to))
$sel_date_to=0;
if(!isset($sel_in_out))
$sel_in_out=0;
if(!isset($from_hour))
$from_hour="00";
if(!isset($from_minute))
$from_minute="00";
if(!isset($from_second))
$from_second="00";
if(!isset($to_hour))
$to_hour="23";
if(!isset($to_minute))
$to_minute="59";
if(!isset($to_second))
$to_second="59";
$slot=$sel_date_from-$sel_date_to+1;
$DEBUG=1;
//========================================================================================|
//============================Define The Data=============================================|
//========================================================================================|
for($i=0;$i<256;$i++)
{
for($j=0;$j<9;$j++)
{
/*
0 e1-no 0 attempt
1 e1 no 1 success
... 2 call deny
3 net busy
4 caller clear
5 sub busy
6 no answer
7 signal error
8 total call duration
*/
$e1_csta[$i][$j]=0;
}
}
//====title======
for($i=0;$i<256;$i++)
{
$trunk_element_title[$i]="";
$e1_element_title[$i]="";
$e1_status[$i]=0;
}
//===in out in&out data=====
for($i=0;$i<9;$i++)
{
$in_e1[$i]=0;
$out_e1[$i]=0;
$total_e1[$i]=0;
}
//========================================================================================|
//================================Get the title from DB===================================|
//========================================================================================|
//===get the default value of XAPP element info===
$database="OBJ_225";
$sql="select initValue from paramConf where level_1=2 and level_2=11 ";
$result=@mysqli_query($pubConn,$sql);
$rows=@mysqli_fetch_array($result);
$default_initValue=$rows[initValue];
//============
$database="OBJ_225";
$sql="select instanceNo,initValue from param_99 where level_1=2 and level_2=11 ";
$result=@mysqli_query($pubConn,$sql);
$rows=@mysqli_fetch_array($result);
if(!$DEBUG)
{
if(!$rows)
exit("No record");
do{
//echo "level_1:{$rows[level_1]} level_2:{$rows[level_2]} level_3:{$rows[level_3]} level_4:{$rows[level_4]} level_5:{$rows[level_5]} level_6:{$rows[level_6]} level_7:{$rows[level_7]} level_8:{$rows[level_8]} level_9:{$rows[level_9]} level_10:{$rows[level_10]}<br>";
if($default_initValue==$rows[initValue])
continue;
$trunk_no=hexdec(getBitValue($rows[initValue],'3.0-3.7'))+0;
//echo "$trunk_no<br>";
$value=$rows['initValue'];
$value=substr($value,28,20);
//echo "trunk_no:$trunk_no $value<br>";
//=====change the hex to ansi char======
$temp="";
for($num=0;$num<10;$num++)
{
$str=substr($value,$num*2,2);
$str=hexdec($str);
$str=chr($str);
$temp.=$str;
}
//echo "$temp<br>";
$trunk_element_title[$trunk_no]=$temp;
}while($rows=mysqli_fetch_array($result));
}
//====Fix the title====
for($i=0;$i<256;$i++)
{
$trunk_element_title[$i]=trim($trunk_element_title[$i]);
if($trunk_element_title[$i]=="")
$trunk_element_title[$i]="--";
if($i==253||$i==254)
{
$trunk_element_title[$i]="LoopBack$i";
}
}
if(!$DEBUG)
{
//=======get the e1 belong trunk no======
$database="OBJ_322";
$sql="select instanceNo,initValue from param_99 where level_1=2 and level_2=4 and level_3=2 ";
$result=@mysqli_query($pubConn,$sql);
$rows=@mysqli_fetch_array($result);
if(!$rows)
exit("No record");
do{
$e1_no=$rows['instanceNo'];
//echo "$e1_no<br>";
$value=$rows['initValue'];
$value=trim($value);
//echo "$value<br>";
$t_g=hexdec($value);
$e1_element_title[$e1_no]=$trunk_element_title[$t_g];
//echo "e1_no:$e1_no {$e1_element_title[$e1_no]}<br>";
}while($rows=mysqli_fetch_array($result));
//======get the e1 status======
$database="OBJ_322";
$sql="select instanceNo,initValue from param_99 where level_1=2 and level_2=4 and level_3=4 ";
$result=@mysqli_query($pubConn,$sql);
$rows=@mysqli_fetch_array($result);
if(!$rows)
exit("No record");
do{
$e1_no=$rows['instanceNo'];
//echo "$e1_no<br>";
$value=$rows['initValue'];
$value=trim($value);
$value=substr($value,1,1);
//echo "$value<br>";
switch($value)
{
//lock
case '0':
case '1':
case '4':
case '5':
case '8':
case '9':
case 'C':
case 'D': $e1_status[$e1_no]=0;break;
//unlock
case '2':
case '3':
case '6':
case '7':
case 'A':
case 'B':
case 'E':
case 'F': $e1_status[$e1_no]=1;break;
}
//echo "e1_no:$e1_no {$e1_element_title[$e1_no]} e1_status:{$e1_status[$e1_no]}<br>";
}while($rows=mysqli_fetch_array($result));
}
//========Fake data================
if(1)
{
//====title======
for($i=0;$i<256;$i++)
{
$trunk_element_title[$i]="TG ".$i;
$e1_element_title[$i]="TG ".$i;
$e1_status[$i]=1;//rand(0,2);
}
}
//========================================================================================|
//===========================Get Data from DB=============================================|
//========================================================================================|
$db=$csta_db;
$slot=$sel_date_from-$sel_date_to+1;
$time_column="csta_datetime";
for($day=0;$day<$slot;$day++)
{
$table_name="mscSum";
$temp=date("d",mktime(0,0,0,date("m"),date("d")-$sel_date_from+$day,date("Y")));
$table_name=$table_name."_".$temp;
$from_time=date("Y-m-d H:i:s",mktime(0,0,0,date("m"),date("d")-$sel_date_from+$day,date("Y")));
$to_time=date("Y-m-d H:i:s",mktime(0,0,0,date("m"),date("d")-$sel_date_from+$day+1,date("Y")));
//echo "table_name:$table_name<br>";
//echo "from_time:$from_time<br>";
//echo "to_time:$to_time<br>";
//echo "in_out:$sel_in_out<br>";
if($sel_in_out==0)
$e1_where="and key_type=1 ";
else if($sel_in_out==1)
$e1_where="and key_type=2 ";
else
$e1_where="and key_type>0 and key_type<3 ";
$select="select key_e1_tg,sum(Attempt) as attempt,sum(Normal) as success,sum(CallDeny) as call_deny,sum(NetBusy) as network_busy,sum(CallerClear) as caller_clear,sum(SubBusy) as sub_busy,sum(NoAnswer) as no_answer,sum(SignalErr) as signal_error,sum(Duration) as duration,key_sys_id,key_subsys_id ";
$from="from $table_name ";
$where="where $time_column >'$from_time' and $time_column <='$to_time' ".$e1_where;
$group="group by key_e1_tg ";
$order="order by key_e1_tg ";
$sql=$select.$from.$where.$group.$order;
//echo "sql:$sql<br>";
$result=@mysqli_query($pubConn,$sql);
$rows=@mysqli_fetch_array($result);
if(1)
{
if($rows)
{
do{
$msc_no=$rows[key_sys_id]+0;
$e1_no=$rows[0]+0;
for($tt=0;$tt<9;$tt++)
{
$e1_csta[$msc_no*128+$e1_no][$tt]+=$rows[$tt+1];
//echo "type-$service_type-$tt:{$service_csta[$service_type][$tt]}<br>";
}
}while($rows=mysqli_fetch_array($result));
}
}
}
//====get the in_e1,out_e1,total_e1====
for($day=0;$day<$slot;$day++)
{
$table_name="mscSum";
$temp=date("d",mktime(0,0,0,date("m"),date("d")-$sel_date_from+$day,date("Y")));
$table_name=$table_name."_".$temp;
$from_time=date("Y-m-d H:i:s",mktime(0,0,0,date("m"),date("d")-$sel_date_from+$day,date("Y")));
$to_time=date("Y-m-d H:i:s",mktime(0,0,0,date("m"),date("d")-$sel_date_from+$day+1,date("Y")));
//====in-e1 data======
$select="select key_e1_tg,sum(Attempt) as attempt,sum(Normal) as success,sum(CallDeny) as call_deny,sum(NetBusy) as network_busy,sum(CallerClear) as caller_clear,sum(SubBusy) as sub_busy,sum(NoAnswer) as no_answer,sum(SignalErr) as signal_error,sum(Duration) as duration,key_sys_id,key_subsys_id ";
$from="from $table_name ";
$e1_where="and key_type=1 ";
$where="where $time_column >'$from_time' and $time_column <='$to_time' ".$e1_where;
$group="group by key_e1_tg,key_sys_id ";
$order="order by key_e1_tg ";
$sql=$select.$from.$where.$group.$order;
//echo "sql=$sql<br>";
$result=@mysqli_query($pubConn,$sql);
$rows=@mysqli_fetch_array($result);
if(1)
{
if($rows)
{
do{
$e1_no=$rows[0]+0;
$msc_no=$rows['key_sys_id']+0;
if($e1_status[$e1_no+$msc_no*128]==0)
continue;
for($tt=0;$tt<9;$tt++)
{
$in_e1[$tt]+=$rows[$tt+1];
}
}while($rows=mysqli_fetch_array($result));
}
}
//====out_e1 data======
$select="select key_e1_tg,sum(Attempt) as attempt,sum(Normal) as success,sum(CallDeny) as call_deny,sum(NetBusy) as network_busy,sum(CallerClear) as caller_clear,sum(SubBusy) as sub_busy,sum(NoAnswer) as no_answer,sum(SignalErr) as signal_error,sum(Duration) as duration,key_sys_id,key_subsys_id ";
$from="from $table_name ";
$e1_where="and key_type=2 ";
$where="where $time_column >'$from_time' and $time_column <='$to_time' ".$e1_where;
$group="group by key_e1_tg,key_sys_id ";
$order="order by key_e1_tg ";
$sql=$select.$from.$where.$group.$order;
//echo "sql=$sql<br>";
$result=@mysqli_query($pubConn,$sql);
$rows=@mysqli_fetch_array($result);
if(1)
{
if($rows)
{
do{
$e1_no=$rows[0]+0;
$msc_no=$rows['key_sys_id']+0;
//echo "msc-$msc_no<br>";
if($e1_status[$e1_no+$msc_no*128]==0)
continue;
for($tt=0;$tt<9;$tt++)
{
$out_e1[$tt]+=$rows[$tt+1];
}
}while($rows=mysqli_fetch_array($result));
}
}
//====total_e1 data=====
$select="select key_e1_tg,sum(Attempt) as attempt,sum(Normal) as success,sum(CallDeny) as call_deny,sum(NetBusy) as network_busy,sum(CallerClear) as caller_clear,sum(SubBusy) as sub_busy,sum(NoAnswer) as no_answer,sum(SignalErr) as signal_error,sum(Duration) as duration,key_sys_id,key_subsys_id ";
$from="from $table_name ";
$e1_where="and key_type>0 and key_type<3 ";
$where="where $time_column >'$from_time' and $time_column <='$to_time' ".$e1_where;
$group="group by key_e1_tg,key_sys_id ";
$order="order by key_e1_tg ";
$sql=$select.$from.$where.$group.$order;
//echo "sql=$sql<br>";
$result=@mysqli_query($pubConn,$sql);
$rows=@mysqli_fetch_array($result);
if(1)
{
if($rows)
{
do{
$e1_no=$rows[0]+0;
$msc_no=$rows['key_sys_id']+0;
//echo "msc-$msc_no<br>";
if($e1_status[$e1_no+$msc_no*128]==0)
{
//$e1_no=$e1_no+$msc_no*128;
//echo "$e1_no<br>";
continue;
}
for($tt=0;$tt<9;$tt++)
{
$total_e1[$tt]+=$rows[$tt+1];
}
}while($rows=mysqli_fetch_array($result));
}
}
}
//========================================================================================|
//============================Fake Data===================================================|
//========================================================================================|
if(0)
{
for($i=0;$i<256;$i++)
{
for($j=0;$j<9;$j++)
{
if($i==0)
$e1_csta[$i][$j]=rand(200,300);
else
$e1_csta[$i][$j]=rand(10,100);
}
}
}
if(0)
{
for($i=0;$i<9;$i++)
{
$in_e1[$i]=rand(10,100);
$out_e1[$i]=rand(10,100);
$total_e1[$i]=$in_e1[$i]+$out_e1[$i];
}
}
//========================================================================================|
//===========================Test the data================================================|
//========================================================================================|
if(0)
{
for($i=0;$i<9;$i++)
{
echo "in-type-$i:<br>{$in_e1[$i]}<br>";
echo "out-type-$i:<br>{$out_e1[$i]}<br>";
echo "total-type-$i:<br>{$total_e1[$i]}<br>";
}
}
//========================================================================================|
//========================Draw the table-1================================================|
//========================================================================================|
$title_time=date("Y-m-d",mktime(0,0,0,date("m"),date("d")-$sel_date_from,date("Y")));
if($slot==1)
$table_title="E1 statistic Date:".$title_time;
else
$table_title="E1 statistic Date:".$title_time." to ".date("Y-m-d",mktime(0,0,0,date("m"),date("d")-$sel_date_to,date("Y")));
echo "<center><b>$table_title</b></center>";
echo "<table width=\"100%\" border=\"1\" cellpadding=\"2\" cellspacing=\"0\" bordercolor=\"#666666\" bordercolordark=\"#FFFFFF\" bgcolor=\"#FFFFFF\">";
if($sel_in_out==0)
$temp="In";
else if($sel_in_out==1)
$temp="Out";
else if($sel_in_out==2)
$temp="In&Out";
echo "<tr bgcolor=\"#E6E6E6\">";
echo "<td>&nbsp</td><td colspan=11 align=\"center\">$temp</td>";
echo "</tr>";
echo "<tr bgcolor=\"#E6E6E6\">";
echo "<td align=\"center\" width=\"6%\"><nobr>E1 No.</td>";
echo "<td align=\"center\" width=\"12%\"><nobr>Element Title</td>";
echo "<td align=\"center\" width=\"8%\">Attempt</td>";
echo "<td align=\"center\" width=\"8%\">Success</td>";
echo "<td align=\"center\" width=\"8%\"><nobr>Call deny</td>";
echo "<td align=\"center\" width=\"8%\"><nobr>Net busy</td>";
echo "<td align=\"center\" width=\"8%\">Caller clear</td>";
echo "<td align=\"center\" width=\"8%\">Sub busy</td>";
echo "<td align=\"center\" width=\"8%\">No answer</td>";
echo "<td align=\"center\" width=\"8%\">Signal error</td>";
echo "<td align=\"center\" width=\"8%\">Total call duration</td>";
echo "<td align=\"center\" width=\"10%\">Average call<br>duration(s)</td>";
echo "</tr>";
for($i=0;$i<256;$i++)
{
if($e1_status[$i]==0)
continue;
echo "<tr>";
echo "<td align=\"center\"><a target=\"_parent\" href=\"../../performance/mscCsta/e1_detail_index.php?e1_no=$i&sel_date_from=$sel_date_from&sel_date_to=$sel_date_to&sel_in_out=$sel_in_out\">$i</a></td>";
echo "<td align=\"left\">{$e1_element_title[$i]}</td>";
for($j=0;$j<9;$j++)
{
echo "<td align=\"center\">";
if($j==0)
echo "{$e1_csta[$i][$j]}";
if($j>0&&$j<8)
{
echo "{$e1_csta[$i][$j]}";
echo "<br>";
if($e1_csta[$i][0]==0)
$rate=0;
else
{
$rate=$e1_csta[$i][$j]/$e1_csta[$i][0];
$rate=$rate*100;
$rate=number_format($rate,2,"."," ");
}
if($rate==0)
$rate=0;
echo "$rate%";
}
if($j==8)
{
echo "{$e1_csta[$i][$j]}(s)";
$hour=floor($e1_csta[$i][$j]/3600);
$minute=floor($e1_csta[$i][$j]%3600/60);
$second=$e1_csta[$i][$j]%60;
if($hour==0&&$minute==0&&$second==0)
echo "<br>";
else
echo "<br>$hour:$minute:$second";
}
echo "</td>";
}
//=====average call duration=========
echo "<td align=\"center\">";
if($e1_csta[$i][1]!=0)
$ave=round($e1_csta[$i][8]/$e1_csta[$i][1]);
else
$ave=0;
echo "$ave";
echo "</td>";
echo "</tr>";
}
echo "</table>";
//========================================================================================|
//===========================Draw the table-2=============================================|
//========================================================================================|
echo "<br><center><b>$table_title</b></center>";
echo "<center>";
echo "<table width=\"100%\" border=\"1\" cellpadding=\"2\" cellspacing=\"0\" bordercolor=\"#666666\" bordercolordark=\"#FFFFFF\" bgcolor=\"#FFFFFF\">";
echo "<tr bgcolor=\"#E6E6E6\">";
echo "<td colspan=8 align=\"center\">2.Success/failure</td>";
echo "</tr>";
echo "<tr bgcolor=\"#E6E6E6\">";
echo "<td align=\"center\">Type</td>";
echo "<td align=\"center\">Success</td>";
echo "<td align=\"center\">Call deny</td>";
echo "<td align=\"center\">Net busy</td>";
echo "<td align=\"center\">Caller clear</td>";
echo "<td align=\"center\">Sub busy</td>";
echo "<td align=\"center\">No answer</td>";
echo "<td align=\"center\">Signal error</td>";
echo "</tr>";
//=====in e1 data======
echo "<tr>";
echo "<td align=\"center\">In</td>";
for($i=0;$i<7;$i++)
{
echo "<td align=\"center\">";
if($in_e1[0]!=0)
{
$rate=$in_e1[$i+1]/$in_e1[0];
$rate=$rate*100;
$rate=number_format($rate,2,"."," ");
}
else
$rate=0;
if($rate==0)
$rate=0;
echo "$rate%";
echo "</td>";
}
echo "</tr>";
//=====out e1 data=======
echo "<tr>";
echo "<td align=\"center\">Out</td>";
for($i=0;$i<7;$i++)
{
echo "<td align=\"center\">";
if($out_e1[0]!=0)
{
$rate=$out_e1[$i+1]/$out_e1[0];
$rate=$rate*100;
$rate=number_format($rate,2,"."," ");
}
else
$rate=0;
if($rate==0)
$rate=0;
echo "$rate%";
echo "</td>";
}
echo "</tr>";
//====total e1 data=======
echo "<tr>";
echo "<td align=\"center\">In&Out</td>";
for($i=0;$i<7;$i++)
{
echo "<td align=\"center\">";
if($total_e1[0]!=0)
{
$rate=$total_e1[$i+1]/$total_e1[0];
$rate=$rate*100;
$rate=number_format($rate,2,"."," ");
}
else
$rate=0;
if($rate==0)
$rate=0;
echo "$rate%";
echo "</td>";
}
echo "</table></center>";
//========================================================================================|
//============================Draw the graphics-1=========================================|
//========================================================================================|
echo "<p><b>3.In/Out(Attempt Call)</b><br>";
$sizex=510;
$sizey=240;
$im = ImageCreate ($sizex, $sizey);
$background_color=ImageColorAllocate($im,255,255,255);
imageLine($im,0,0,0,200,$black_color);
imageLine($im,0,200,600,200,$black_color);
$bgcolor=F8F8F8;
$fgcolor=000000;
$background_color = ImageColorAllocate ($im,
hexdec(substr($bgcolor, 0, 2)),
hexdec(substr($bgcolor, 2, 2)),
hexdec(substr($bgcolor, 4, 2)));
$text_color = ImageColorAllocate ($im,
hexdec(substr($fgcolor, 0, 2)),
hexdec(substr($fgcolor, 2, 2)),
hexdec(substr($fgcolor, 4, 2)));
$white_color=ImageColorAllocate($im,255,255,255);
$black_color=ImageColorAllocate($im,0,0,0);
$color[0]=ImageColorAllocate($im,0x33,0x33,0xff);
$color[1]=ImageColorAllocate($im,0x66,0xaa,0);
//====background====
ImageFilledRectangle($im,0,0,$sizex,$sizey,ImageColorAllocate ($im, 198, 198, 198));
ImageFilledRectangle($im,2,2,$sizex,$sizey,ImageColorAllocate ($im, 130, 130, 130));
$pointArr=array(0,$sizey-1,3,$sizey-4,4,$sizey-1);
Imagefilledpolygon($im, $pointArr, 3, ImageColorAllocate ($im, 130, 130, 130));
$pointArr=array($sizex-1,0,$sizex-4,3,$sizex,4);
Imagefilledpolygon($im, $pointArr, 3, ImageColorAllocate ($im, 130, 130, 130));
ImageFilledRectangle($im,2,2,$sizex-3,$sizey-3,$background_color);
imageLine($im,40,20,40,200,$black_color);
imageLine($im,40,20,490,20,$black_color);
imageLine($im,490,200,490,20,$black_color);
imageLine($im,40,200,490,200,$black_color);
//====draw the horizonal line=======
$style = array($black_color,$black_color,$black_color,$black_color,$black_color,$white_color,$white_color,$white_color,$white_color,$white_color);
imagesetstyle($im, $style);
for($i=10;$i>0;$i--)
{
$x1=40;
$y1=20+(10-$i)*18;
$x2=490;
$y2=$y1;
if($i!=10)
imageline($im,$x1,$y1,$x2,$y2,IMG_COLOR_STYLED);
imagestring($im,2,$x1-22,$y2-5,($i*10)."%",$black_color);
}
//======draw the vitical line====
$u=floor(450/9);
for($i=0;$i<10;$i++)
{
$x1=40+$i*$u;
$y1=20;
$x2=$x1;
$y2=200;
ImageDashedLine($im,$x1,$y1,$x2,$y2,$black_color);
}
//=====get the two block height====
if($total_e1[0]==0)
{
$in_e1_percent="0%";
$out_e1_percent="0%";
$height[0]=0;
$heighr[1]=0;
}
else
{
$in_e1_percent=change_percent($in_e1[0]/$total_e1[0]);
$out_e1_percent=change_percent($out_e1[0]/$total_e1[0]);
$height[0]=floor(180*$in_e1[0]/$total_e1[0]);
$height[1]=floor(180*$out_e1[0]/$total_e1[0]);
}
//======draw the data block=====
for($i=0;$i<2;$i++)
{
$x1=90+(4*$i+1)*50;
if($height[$i]==0)
$height[$i]=1;
$y1=200-$height[$i];
$x2=90+(4*$i+2)*50;
$y2=199;
imagefilledrectangle($im,$x1,$y1,$x2,$y2,$color[$i]);
}
//=====draw the legend string=====
imagestring($im,2,160,205,"In",$black_color);
imagestring($im,2,138,220,"(".$in_e1_percent.")",$black_color);
imagestring($im,2,355,205,"Out",$black_color);
imagestring($im,2,335,220,"(".$out_e1_percent.")",$black_color);
//====show the service attempt graphics=====
//-----<2D><><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޸<EFBFBD>
//delete *.png
$handle=opendir('.');
while($file=readdir($handle)){
$retval="";
$pt=strrpos($file,".");
if($pt) $retval=substr($file,$pt+1,strlen($file)-$pt);
if($retval=='png') unlink($file);
}
$tt=time()+34;
$filename="e11_".$tt.".png";
if(1)
{
ImagePng ($im,"$filename");
ImageDestroy($im);
}
//-----<2D><>ʾͼƬ
echo "<img src=\"$filename\"></img>";
//========================================================================================|
//===========================Draw the Graphics-2==========================================|
//========================================================================================|
echo "<p><b>4.Success/Failure<br>";
$sizex=600;
$sizey=250;
$image=imagecreate($sizex,$sizey);
$bgcolor=imagecolorallocate($image,255,255,255);
$black_color=ImageColorAllocate($image,0,0,0);
$white_color=imagecolorallocate($image,255,255,255);
$bgcolor=F8F8F8;
$fgcolor=000000;
$color[0]=ImageColorAllocate($image,0x33,0x33,0xff);
$color[1]=ImageColorAllocate($image,0x66,0xaa,0);
$background_color = ImageColorAllocate ($image,
hexdec(substr($bgcolor, 0, 2)),
hexdec(substr($bgcolor, 2, 2)),
hexdec(substr($bgcolor, 4, 2)));
$text_color = ImageColorAllocate ($image,
hexdec(substr($fgcolor, 0, 2)),
hexdec(substr($fgcolor, 2, 2)),
hexdec(substr($fgcolor, 4, 2)));
//===background====
ImageFilledRectangle($image,0,0,$sizex,$sizey,ImageColorAllocate ($image, 198, 198, 198));
ImageFilledRectangle($image,2,2,$sizex,$sizey,ImageColorAllocate ($image, 130, 130, 130));
$pointArr=array(0,$sizey-1,3,$sizey-4,4,$sizey-1);
Imagefilledpolygon($image, $pointArr, 3, ImageColorAllocate ($image, 130, 130, 130));
$pointArr=array($sizex-1,0,$sizex-4,3,$sizex,4);
Imagefilledpolygon($image, $pointArr, 3, ImageColorAllocate ($image, 130, 130, 130));
ImageFilledRectangle($image,2,2,$sizex-3,$sizey-3,$background_color);
imageLine($image,40,20,40,200,$black_color);
imageLine($image,40,20,580,20,$black_color);
imageLine($image,580,200,580,20,$black_color);
imageLine($image,40,200,580,200,$black_color);
//======draw the horizonal line=====
$style = array($black_color,$black_color,$black_color,$black_color,$black_color,$white_color,$white_color,$white_color,$white_color,$white_color);
imagesetstyle($image, $style);
for($i=10;$i>0;$i--)
{
$x1=40;
$y1=20+(10-$i)*18;
$x2=580;
$y2=$y1;
if($i!=10)
imageline($image,$x1,$y1,$x2,$y2,IMG_COLOR_STYLED);
imagestring($image,2,$x1-22,$y2-5,($i*10)."%",$black_color);
}
//=====draw the vitical line======
$u=floor(540/15);
for($i=0;$i<16;$i++)
{
$x1=40+$i*$u;
$y1=20;
$x2=$x1;
$y2=200;
ImageDashedLine($image,$x1,$y1,$x2,$y2,$black_color);
}
//======get the block height======
for($j=0;$j<7;$j++)
{
if($total_e1[0]==0)
$total_height[$j][0]=1;
else
{
$total_height[$j][0]=floor(180*$in_e1[$j+1]/$total_e1[0]);
}
}
for($j=0;$j<7;$j++)
{
if($total_e1[0]==0)
$total_height[$j][1]=1;
else
{
$total_height[$j][1]=floor(180*$out_e1[$j+1]/$total_e1[0]);
}
}
//=======draw the data block=====
for($i=0;$i<7;$i++)
{
for($j=0;$j<2;$j++)
{
if($total_height[$i][$j]<1)
$total_height[$i][$j]=1;
//echo "lie-$i-hang-$j-{$total_height[$i][$j]}<br>";
$x1=40+(2*$i+1)*36;
$y1=199;
for($z=0;$z<$j+1;$z++)
{
$y1=$y1-$total_height[$i][$z];
}
$x2=40+(2*$i+2)*36;
$y2=199;
for($z=0;$z<$j;$z++)
{
$y2=$y2-$total_height[$i][$z];
}
imagefilledrectangle($image,$x1,$y1,$x2,$y2,$color[$j]);
}
}
//======draw the legend string======
imagefilledrectangle($image,170,230,185,245,$color[0]);
imagestring($image,2,190,230,"In",$black_color);
imagefilledrectangle($image,360,230,375,245,$color[1]);
imagestring($image,2,380,230,"Out",$black_color);
imagestring($image,2,75,205,"Success",$black_color);
imagestring($image,2,138,205,"Call deny",$black_color);
imagestring($image,2,215,205,"Net busy",$black_color);
imagestring($image,2,294,200,"Caller",$black_color);
imagestring($image,2,297,212,"clear",$black_color);
imagestring($image,2,363,205,"SubBusy",$black_color);
imagestring($image,2,433,205,"No answer",$black_color);
imagestring($image,2,508,200,"Signal",$black_color);
imagestring($image,2,510,212,"error",$black_color);
//=====show the answer failure graphics=======
$tt=time()-525;
$file_name="e12_".$tt.".png";
imagepng($image,$file_name);
imagedestroy($image);
echo "<img src=$file_name></img>";
?>
</body>