0){ echo ""; }else{ echo ""; } ?> "; if($default_initValue==$rows[initValue]) continue; $trunk_no=hexdec(getBitValue($rows[initValue],'3.0-3.7'))+0; //echo "$trunk_no
"; $value=$rows['initValue']; $value=substr($value,28,20); //echo "trunk_no:$trunk_no $value
"; //=====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
"; $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
"; $value=$rows['initValue']; $value=trim($value); //echo "$value
"; $t_g=hexdec($value); $e1_element_title[$e1_no]=$trunk_element_title[$t_g]; //echo "e1_no:$e1_no {$e1_element_title[$e1_no]}
"; }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
"; $value=$rows['initValue']; $value=trim($value); $value=substr($value,1,1); //echo "$value
"; 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]}
"; }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
"; //echo "from_time:$from_time
"; //echo "to_time:$to_time
"; //echo "in_out:$sel_in_out
"; 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
"; $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]}
"; } }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
"; $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
"; $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
"; 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
"; $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
"; if($e1_status[$e1_no+$msc_no*128]==0) { //$e1_no=$e1_no+$msc_no*128; //echo "$e1_no
"; 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:
{$in_e1[$i]}
"; echo "out-type-$i:
{$out_e1[$i]}
"; echo "total-type-$i:
{$total_e1[$i]}
"; } } //========================================================================================| //========================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 "
$table_title
"; echo ""; 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 ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; for($i=0;$i<256;$i++) { if($e1_status[$i]==0) continue; echo ""; echo ""; echo ""; for($j=0;$j<9;$j++) { echo ""; } //=====average call duration========= echo ""; echo ""; } echo "
 $temp
E1 No.Element TitleAttemptSuccessCall denyNet busyCaller clearSub busyNo answerSignal errorTotal call durationAverage call
duration(s)
$i{$e1_element_title[$i]}"; if($j==0) echo "{$e1_csta[$i][$j]}"; if($j>0&&$j<8) { echo "{$e1_csta[$i][$j]}"; echo "
"; 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 "
"; else echo "
$hour:$minute:$second"; } echo "
"; if($e1_csta[$i][1]!=0) $ave=round($e1_csta[$i][8]/$e1_csta[$i][1]); else $ave=0; echo "$ave"; echo "
"; //========================================================================================| //===========================Draw the table-2=============================================| //========================================================================================| echo "
$table_title
"; echo "
"; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; //=====in e1 data====== echo ""; echo ""; for($i=0;$i<7;$i++) { echo ""; } echo ""; //=====out e1 data======= echo ""; echo ""; for($i=0;$i<7;$i++) { echo ""; } echo ""; //====total e1 data======= echo ""; echo ""; for($i=0;$i<7;$i++) { echo ""; } echo "
2.Success/failure
TypeSuccessCall denyNet busyCaller clearSub busyNo answerSignal error
In"; 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 "
Out"; 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 "
In&Out"; 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 "
"; //========================================================================================| //============================Draw the graphics-1=========================================| //========================================================================================| echo "

3.In/Out(Attempt Call)
"; $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===== //-----输出图形文件,请勿修改 //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); } //-----显示图片 echo ""; //========================================================================================| //===========================Draw the Graphics-2==========================================| //========================================================================================| echo "

4.Success/Failure
"; $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]}
"; $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 ""; ?>