0){ echo "
"; $result=@mysqli_query($pubConn,$sql); $rows=@mysqli_fetch_array($result); if($rows) { do{ $key_type=$rows[key_type]; $index=$key_type_relation[$key_type]+0; $datetime=substr($rows[csta_datetime],11,2)+0; if($datetime==23) continue; //echo "datetime:$datetime"; $bhca_service_mangdays[$index][$datetime+1+24*$day]+=$rows[ans]; }while($rows=mysqli_fetch_array($result)); } } //get the 0-hour of the day for($day=0;$day<$slot;$day++) { $db="CSTA_DB"; $table_name="mscSum"; $temp=date("d",mktime(0,0,0,date("m"),date("d")-$sel_date_from+$day-1,date("Y"))); $table_name=$table_name."_".$temp; //echo "table_name:$table_name"; $from_time=date("Y-m-d H:i:s",mktime(23,0,0,date("m"),date("d")-$sel_date_from+$day-1,date("Y"))); $to_time=date("Y-m-d H:i:s",mktime(0,0,0,date("m"),date("d")-$sel_date_from+$day,date("Y"))); //echo "from:$from_time--to:$to_time"; $select="select key_type,sum(Success) as ans,csta_datetime "; $from="from $table_name "; $service_where="and key_type>4 and key_type<17 "; $where="where csta_datetime >'$from_time' and csta_datetime <='$to_time' ".$service_where; $group="group by csta_datetime,key_type "; $order="order by key_type "; $sql=$select.$from.$where.$group.$order; //echo "$sql
"; $result=@mysqli_query($pubConn,$sql); $rows=@mysqli_fetch_array($result); if($rows) { do{ $key_type=$rows[key_type]; $index=$key_type_relation[$key_type]+0; $datetime=substr($rows[csta_datetime],11,2)+0; //echo "datetime:$datetime"; $bhca_service_mangdays[$index][24*$day]+=$rows[ans]; }while($rows=mysqli_fetch_array($result)); } } //====Fake Data======= if($DEBUG) { for($i=0;$i<13;$i++) { for($j=0;$j<24*$slot;$j++) { $bhca_service_mangdays[$i][$j]=rand(100,5000); } } } //====Test Data====== if(0) { $test_service_type_label=array("SUB SUB","SUB LOC","TRK TOLL","TRK SUB","TRK TRK","SUB IP", "TRK IP","INTER","MO","MT","IN TRK","OUT TRK","IP"); for($i=0;$i<13;$i++) { for($j=0;$j<24*$slot;$j++) { echo "{$test_service_type_label[$i]}--$j--{$bhca_service_mangdays[$i][$j]}"; } } } } //=======================================================================================| //=========== csta_type==1,E1 Graphics ================| //=======================================================================================| else if($csta_type==1) { //====Data define==== for($i=0;$i<3;$i++) { /* 0 IN 1 OUT 2 IN&OUT */ for($j=0;$j<24*$slot;$j++) { $bhca_e1_mangdays[$i][$j]=0; } } //====Get the Data from DB===== //echo "slot:$slot"; $device_name=isset($device_name)?$device_name:$DEFAULT_SYS; //device name $db="CSTA_DB"; $sys_entries=get_sys_total($device_name); 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; //echo "table_name:$table_name"; $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+1+$day,date("Y"))); //echo "from:$from_time--to:$to_time"; //echo "on_top_select:$on_top_select"; //===incoming e1=== $select="select sum(Success) as ans,csta_datetime "; $from="from $table_name "; $group=" GROUP BY csta_datetime "; $e1_where="AND key_type=1 "; $where=" WHERE key_subsys_id=0 and csta_datetime >'$from_time' and csta_datetime <='$to_time' ".$e1_where; $erl_sql=$select.$from.$where.$group; //echo "$erl_sql"; $result=@mysqli_query($pubConn,$erl_sql); $rows=@mysqli_fetch_array($result); if($rows) { do{ $datetime=substr($rows[csta_datetime],11,2)+0; //echo "datetime:$datetime"; $bhca_e1_mangdays[0][$datetime]=$rows[0]+0; }while($rows=@mysqli_fetch_array($result)); } //====outgoing e1===== $select="select sum(Success) as ans,csta_datetime "; $from="from $table_name "; $group=" GROUP BY csta_datetime "; $e1_where="AND key_type=2 "; $where=" WHERE key_subsys_id=0 and csta_datetime >'$from_time' and csta_datetime <='$to_time' ".$e1_where; $erl_sql=$select.$from.$where.$group; //echo "$erl_sql"; $result=@mysqli_query($pubConn,$erl_sql); $rows=@mysqli_fetch_array($result); if($rows) { do{ $datetime=substr($rows[csta_datetime],11,2)+0; //echo "datetime:$datetime"; $bhca_e1_mangdays[1][$datetime]=$rows[0]+0; }while($rows=@mysqli_fetch_array($result)); } //===in-out e1 $select="select sum(Success) as ans,csta_datetime "; $from="from $table_name "; $group=" GROUP BY csta_datetime "; $e1_where="and key_type>0 and key_type<3 "; $where=" WHERE key_subsys_id=0 and csta_datetime >'$from_time' and csta_datetime <='$to_time' ".$e1_where; $erl_sql=$select.$from.$where.$group; //echo "$erl_sql"; $result=@mysqli_query($pubConn,$erl_sql); $rows=@mysqli_fetch_array($result); if($rows) { do{ $datetime=substr($rows[csta_datetime],11,2)+0; //echo "datetime:$datetime"; $erlang_e1_mangdays[2][$datetime]=$rows[0]+0; }while($rows=@mysqli_fetch_array($result)); } } //====Fake Data======= if($DEBUG) { for($i=0;$i<3;$i++) { for($j=0;$j<24*$slot;$j++) { $bhca_e1_mangdays[$i][$j]=rand(10,100); } } } //====Test Data====== if(0) { $test_e1_type_label=array("In","Out","In&Out"); for($i=0;$i<3;$i++) { for($j=0;$j<24*$slot;$j++) { echo "{$test_e1_type_label[$i]}--$j--{$bhca_e1_mangdays[$i][$j]}"; } } } } //=======================================================================================| //=========== csta_type==2,trunk Graphics ================| //=======================================================================================| else if($csta_type==2) { $trunk_index=explode(",",$trunk_num); $trunk_index[0]=$trunk_index[0]; $trunk_index[1]=$trunk_index[1]; //echo "trunk_num:$trunk_num"; //echo "index_0:{$trunk_index[0]}---index_1:{$trunk_index[1]}"; //====Data define==== for($i=0;$i<2;$i++) { /* 0 The first trunk select 1 The second trunk select */ for($j=0;$j<24*$slot;$j++) { $bhca_trunk_mangdays[$i][$j]=0; } } //====Get the Data from DB===== //echo "slot:$slot"; //trunk_num_select for($day=0;$day<$slot;$day++) { $db="CSTA_DB"; $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; //echo "table_name:$table_name"; $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+1+$day,date("Y"))); //echo "from:$from_time--to:$to_time"; //tg 1 $select="select key_e1_tg,csta_datetime,sum(Success) as ans "; $from="from $table_name "; $where=" where csta_datetime>='$from_time' and csta_datetime<'$to_time' and key_type>2 and key_type<5 and key_e1_tg={$trunk_index[0]} "; $group=" group by key_e1_tg, csta_datetime "; $order=" order by csta_datetime,key_e1_tg "; $select_sql=$select.$from.$where.$group.$order; //echo "$select_sql"; $select_result=mysqli_query($pubConn,$select_sql); if($select_result==FALSE) exit("There is no data between ".$from_time." to ".$to_time.""); $select_rows=mysqli_fetch_array($select_result); if($select_rows) { do { //Get the hour $datetime=substr($select_rows[csta_datetime],11,2)+0; $gro=$select_rows[0]; if($datetime==23) continue; //echo "gro:$gro"; //echo "datetime:$datetime"; $bhca_trunk_mangdays[0][$datetime+1+24*$day]+=$select_rows[ans]+0; //echo "group:$gro--time:$datetime=={$erlang_trunk_mangdays[$gro][$datetime]}"; }while($select_rows=mysqli_fetch_array($select_result)); } //tg 2 $select="select key_e1_tg,csta_datetime,sum(Success) as ans "; $from="from $table_name "; $where=" where csta_datetime>='$from_time' and csta_datetime<'$to_time' and key_type>2 and key_type<5 and key_e1_tg={$trunk_index[1]} "; $group=" group by key_e1_tg, csta_datetime "; $order=" order by csta_datetime,key_e1_tg "; $select_sql=$select.$from.$where.$group.$order; //echo "
$select_sql"; $select_result=mysqli_query($pubConn,$select_sql); if($select_result==FALSE) exit("There is no data between ".$from_time." to ".$to_time.""); $select_rows=mysqli_fetch_array($select_result); if($select_rows) { do { //Get the hour $datetime=substr($select_rows[csta_datetime],11,2)+0; $gro=$select_rows[0]; if($datetime==23) continue; //echo "gro:$gro"; //echo "datetime:$datetime"; $bhca_trunk_mangdays[1][$datetime+1+24*$day]+=$select_rows[ans]+0; //echo "group:$gro--time:$datetime=={$erlang_trunk_mangdays[$gro][$datetime]}"; }while($select_rows=mysqli_fetch_array($select_result)); } } //get the 0-hour of the day for($day=0;$day<$slot;$day++) { $db="CSTA_DB"; $table_name="mscSum"; $temp=date("d",mktime(0,0,0,date("m"),date("d")-$sel_date_from+$day-1,date("Y"))); $table_name=$table_name."_".$temp; //echo "table_name:$table_name"; $from_time=date("Y-m-d H:i:s",mktime(23,0,0,date("m"),date("d")-$sel_date_from+$day-1,date("Y"))); $to_time=date("Y-m-d H:i:s",mktime(0,0,0,date("m"),date("d")-$sel_date_from+$day,date("Y"))); //echo "from:$from_time--to:$to_time"; //tg 1 $select="select key_e1_tg,csta_datetime,sum(Success) as ans "; $from="from $table_name "; $where=" where csta_datetime>='$from_time' and csta_datetime<'$to_time' and key_type>2 and key_type<5 and key_e1_tg={$trunk_index[0]} "; $group=" group by key_e1_tg, csta_datetime "; $order=" order by csta_datetime,key_e1_tg "; $select_sql=$select.$from.$where.$group.$order; //echo "$select_sql"; $select_result=mysqli_query($pubConn,$select_sql); if($select_result==FALSE) exit("There is no data between ".$from_time." to ".$to_time.""); $select_rows=mysqli_fetch_array($select_result); if($select_rows) { do { //Get the hour $datetime=substr($select_rows[csta_datetime],11,2)+0; $gro=$select_rows[0]; //echo "gro:$gro"; //echo "datetime:$datetime"; $bhca_trunk_mangdays[0][24*$day]+=$select_rows[ans]+0; //echo "group:$gro--time:$datetime=={$erlang_trunk_mangdays[$gro][$datetime]}"; }while($select_rows=mysqli_fetch_array($select_result)); } //tg 2 $select="select key_e1_tg,csta_datetime,sum(Success) as ans "; $from="from $table_name "; $where=" where csta_datetime>='$from_time' and csta_datetime<'$to_time' and key_type>2 and key_type<5 and key_e1_tg={$trunk_index[1]} "; $group=" group by key_e1_tg, csta_datetime "; $order=" order by csta_datetime,key_e1_tg "; $select_sql=$select.$from.$where.$group.$order; //echo "
$select_sql"; $select_result=mysqli_query($pubConn,$select_sql); if($select_result==FALSE) exit("There is no data between ".$from_time." to ".$to_time.""); $select_rows=mysqli_fetch_array($select_result); if($select_rows) { do { //Get the hour $datetime=substr($select_rows[csta_datetime],11,2)+0; $gro=$select_rows[0]; //echo "gro:$gro"; //echo "datetime:$datetime"; $bhca_trunk_mangdays[1][24*$day]+=$select_rows[ans]+0; //echo "group:$gro--time:$datetime=={$erlang_trunk_mangdays[$gro][$datetime]}"; }while($select_rows=mysqli_fetch_array($select_result)); } } //====Fake Data======= if($DEBUG) { for($i=0;$i<2;$i++) { for($j=0;$j<24*$slot;$j++) { $bhca_trunk_mangdays[$i][$j]=rand(10,100); } } } //====Test Data====== if(0) { $test_trunk_type_label=array("First","Second"); for($i=0;$i<2;$i++) { for($j=0;$j<24*$slot;$j++) { echo "{$test_trunk_type_label[$i]} {$trunk_index[$i]}--$j--{$bhca_trunk_mangdays[$i][$j]}"; } } } } //=======================================================================================| //=========== Draw the Graphics =============| //=======================================================================================| $sizex=800; if($csta_type==0) $sizey=430; else $sizey=380; $bgcolor=F8F8F8; $fgcolor=000000; $im = ImageCreate ($sizex, $sizey); $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))); $black_color=ImageColorAllocate($im,0,0,0); $white_color=ImageColorAllocate($im,255,255,255); //===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); //===border===== $xBgn=60; $yBgn=25; $xEnd=780; $yEnd=275; $unitXPix=30; ImageLine($im, $xBgn, $yBgn, $xBgn, $yEnd, $text_color); ImageLine($im, $xBgn, $yBgn, $xEnd, $yBgn, $text_color); ImageLine($im, $xBgn, $yEnd, $xEnd, $yEnd, $text_color); ImageLine($im, $xEnd, $yBgn, $xEnd, $yEnd, $text_color); //====draw the horizonal line==== for($i=0;$i<$slot;$i++) { $datestr[$i]=date("m-d",mktime(0,0,0,date("m"),date("d")-$sel_date_from+$i,date("Y"))); } for($i=0;$i<24;$i++) { if($i<10) $timearray[$i]="0".$i."h"; else $timearray[$i]=$i."h"; } if($slot==5) { if(3>1) { $tempd[0]=date("m-d",mktime(0,0,0,date("m"),date("d")-$sel_date_from,date("Y"))); $tempd[1]=date("m-d",mktime(0,0,0,date("m"),date("d")-$sel_date_from,date("Y"))); $tempd[2]=date("m-d",mktime(0,0,0,date("m"),date("d")-$sel_date_from,date("Y"))); $tempd[3]=date("m-d",mktime(0,0,0,date("m"),date("d")-$sel_date_from,date("Y"))); $tempd[4]=date("m-d",mktime(0,0,0,date("m"),date("d")-$sel_date_from,date("Y"))); $tempd[5]=date("m-d",mktime(0,0,0,date("m"),date("d")-$sel_date_from+1,date("Y"))); $tempd[6]=date("m-d",mktime(0,0,0,date("m"),date("d")-$sel_date_from+1,date("Y"))); $tempd[7]=date("m-d",mktime(0,0,0,date("m"),date("d")-$sel_date_from+1,date("Y"))); $tempd[8]=date("m-d",mktime(0,0,0,date("m"),date("d")-$sel_date_from+1,date("Y"))); $tempd[9]=date("m-d",mktime(0,0,0,date("m"),date("d")-$sel_date_from+1,date("Y"))); $tempd[10]=date("m-d",mktime(0,0,0,date("m"),date("d")-$sel_date_from+2,date("Y"))); $tempd[11]=date("m-d",mktime(0,0,0,date("m"),date("d")-$sel_date_from+2,date("Y"))); $tempd[12]=date("m-d",mktime(0,0,0,date("m"),date("d")-$sel_date_from+2,date("Y"))); $tempd[13]=date("m-d",mktime(0,0,0,date("m"),date("d")-$sel_date_from+2,date("Y"))); $tempd[14]=date("m-d",mktime(0,0,0,date("m"),date("d")-$sel_date_from+2,date("Y"))); $tempd[15]=date("m-d",mktime(0,0,0,date("m"),date("d")-$sel_date_from+3,date("Y"))); $tempd[16]=date("m-d",mktime(0,0,0,date("m"),date("d")-$sel_date_from+3,date("Y"))); $tempd[17]=date("m-d",mktime(0,0,0,date("m"),date("d")-$sel_date_from+3,date("Y"))); $tempd[18]=date("m-d",mktime(0,0,0,date("m"),date("d")-$sel_date_from+3,date("Y"))); $tempd[19]=date("m-d",mktime(0,0,0,date("m"),date("d")-$sel_date_from+3,date("Y"))); $tempd[20]=date("m-d",mktime(0,0,0,date("m"),date("d")-$sel_date_from+4,date("Y"))); $tempd[21]=date("m-d",mktime(0,0,0,date("m"),date("d")-$sel_date_from+4,date("Y"))); $tempd[22]=date("m-d",mktime(0,0,0,date("m"),date("d")-$sel_date_from+4,date("Y"))); $tempd[23]=date("m-d",mktime(0,0,0,date("m"),date("d")-$sel_date_from+4,date("Y"))); } for($i=0;$i<24;$i++){ ImageDashedLine($im, $xBgn + $i*30, $yBgn, $xBgn + $i*30, $yEnd, $text_color); $xstr=$tempd[$i]." ".$timearray[($i*$slot)%24]; Imagestringup($im, 2, $xBgn + $i*30 - 4, $yEnd+60, $xstr, $text_color); } } else if($slot==7) { if(3>1) { $tempd[0]=date("m-d",mktime(0,0,0,date("m"),date("d")-$sel_date_from,date("Y"))); $tempd[1]=date("m-d",mktime(0,0,0,date("m"),date("d")-$sel_date_from,date("Y"))); $tempd[2]=date("m-d",mktime(0,0,0,date("m"),date("d")-$sel_date_from,date("Y"))); $tempd[3]=date("m-d",mktime(0,0,0,date("m"),date("d")-$sel_date_from,date("Y"))); $tempd[4]=date("m-d",mktime(0,0,0,date("m"),date("d")-$sel_date_from+1,date("Y"))); $tempd[5]=date("m-d",mktime(0,0,0,date("m"),date("d")-$sel_date_from+1,date("Y"))); $tempd[6]=date("m-d",mktime(0,0,0,date("m"),date("d")-$sel_date_from+1,date("Y"))); $tempd[7]=date("m-d",mktime(0,0,0,date("m"),date("d")-$sel_date_from+2,date("Y"))); $tempd[8]=date("m-d",mktime(0,0,0,date("m"),date("d")-$sel_date_from+2,date("Y"))); $tempd[9]=date("m-d",mktime(0,0,0,date("m"),date("d")-$sel_date_from+2,date("Y"))); $tempd[10]=date("m-d",mktime(0,0,0,date("m"),date("d")-$sel_date_from+2,date("Y"))); $tempd[11]=date("m-d",mktime(0,0,0,date("m"),date("d")-$sel_date_from+3,date("Y"))); $tempd[12]=date("m-d",mktime(0,0,0,date("m"),date("d")-$sel_date_from+3,date("Y"))); $tempd[13]=date("m-d",mktime(0,0,0,date("m"),date("d")-$sel_date_from+3,date("Y"))); $tempd[14]=date("m-d",mktime(0,0,0,date("m"),date("d")-$sel_date_from+4,date("Y"))); $tempd[15]=date("m-d",mktime(0,0,0,date("m"),date("d")-$sel_date_from+4,date("Y"))); $tempd[16]=date("m-d",mktime(0,0,0,date("m"),date("d")-$sel_date_from+4,date("Y"))); $tempd[17]=date("m-d",mktime(0,0,0,date("m"),date("d")-$sel_date_from+4,date("Y"))); $tempd[18]=date("m-d",mktime(0,0,0,date("m"),date("d")-$sel_date_from+5,date("Y"))); $tempd[19]=date("m-d",mktime(0,0,0,date("m"),date("d")-$sel_date_from+5,date("Y"))); $tempd[20]=date("m-d",mktime(0,0,0,date("m"),date("d")-$sel_date_from+5,date("Y"))); $tempd[21]=date("m-d",mktime(0,0,0,date("m"),date("d")-$sel_date_from+6,date("Y"))); $tempd[22]=date("m-d",mktime(0,0,0,date("m"),date("d")-$sel_date_from+6,date("Y"))); $tempd[23]=date("m-d",mktime(0,0,0,date("m"),date("d")-$sel_date_from+6,date("Y"))); } for($i=0;$i<24;$i++){ ImageDashedLine($im, $xBgn + $i*30, $yBgn, $xBgn + $i*30, $yEnd, $text_color); $xstr=$tempd[$i]." ".$timearray[($i*$slot)%24]; Imagestringup($im, 2, $xBgn + $i*30 - 4, $yEnd+60, $xstr, $text_color); } } else { $tempi=0; for($i=0;$i<24;$i++){ ImageDashedLine($im, $xBgn + $i*30, $yBgn, $xBgn + $i*30, $yEnd, $text_color); if(($i*$slot)%24==0&&$i!=0) $tempi++; $xstr=$datestr[$tempi]." ".$timearray[($i*$slot)%24]; Imagestringup($im, 2, $xBgn + $i*30 - 4, $yEnd+60, $xstr, $text_color); } } if($csta_type==0) { //====graphics title===== $graphics_title="Service BHCA statistic graphic"; Imagestring($im, 2, 300,5, $graphics_title, $text_color); //===draw the label block==== $color[0]=ImageColorAllocate($im,0x99,0x22,0x33); $color[1]=ImageColorAllocate($im,0x99,0x00,0xcc); $color[2]=ImageColorAllocate($im,0x99,0x99,0x00); $color[3]=ImageColorAllocate($im,0x99,0x99,0x99); $color[4]=ImageColorAllocate($im,0x99,0xff,0x33); $color[5]=ImageColorAllocate($im,0xff,0x99,0x66); $color[6]=ImageColorAllocate($im,0xff,0x00,0x00); $color[7]=ImageColorAllocate($im,0xff,0xff,0x00); $color[8]=ImageColorAllocate($im,0x33,0x3,0x33); $color[9]=ImageColorAllocate($im,0x00,0xcc,0xff); $color[10]=ImageColorAllocate($im,0x00,0x22,0xcc); $color[11]=ImageColorAllocate($im,0xEE,0x00,0xff); imagefilledrectangle($im,90,350,100,360,$color[0]); imagestring($im,2,105,350,"SUB SUB",$text_color); imagefilledrectangle($im,260,350,270,360,$color[1]); imagestring($im,2,275,350,"SUB TRK",$text_color); imagefilledrectangle($im,430,350,440,360,$color[2]); imagestring($im,2,445,350,"TRK SUB",$text_color); imagefilledrectangle($im,600,350,610,360,$color[3]); imagestring($im,2,615,350,"TRK TRK",$text_color); imagefilledrectangle($im,90,370,100,380,$color[4]); imagestring($im,2,105,370,"INTRA",$text_color); imagefilledrectangle($im,260,370,270,380,$color[5]); imagestring($im,2,275,370,"SUB IP",$text_color); imagefilledrectangle($im,430,370,440,380,$color[6]); imagestring($im,2,445,370,"TRK IP",$text_color); imagefilledrectangle($im,600,370,610,380,$color[7]); imagestring($im,2,615,370,"MO",$text_color); imagefilledrectangle($im,90,390,100,400,$color[8]); imagestring($im,2,105,390,"MT",$text_color); imagefilledrectangle($im,260,390,270,400,$color[9]); imagestring($im,2,275,390,"IN TRK",$text_color); imagefilledrectangle($im,430,390,440,400,$color[10]); imagestring($im,2,445,390,"OUT TRK",$text_color); imagefilledrectangle($im,600,390,610,400,$color[11]); imagestring($im,2,615,390,"IP",$text_color); //get the biggest Y-scale value $maxYNum=0; for($i=0;$i<13;$i++) { for($j=0;$j<$slot*24;$j++) { if(!isset($bhca_service_mangdays[$i][$j])) $bhca_service_mangdays[$i][$j]=0.0; if($line_select[$i]==1) { if($maxYNum<$bhca_service_mangdays[$i][$j]) $maxYNum=$bhca_service_mangdays[$i][$j]; } //echo "g-$i-h-$j:{$bhca_service_mangdays[$i][$j]}"; } } //====get the points scale==== if($maxYNum<10) $maxYNum=20; $unitValue=$maxYNum/10; for($i=0;$i<13;$i++) { for($j=0;$j<24*$slot;$j++) { $pointscale[$i][$j]['x']=60+30*$j/$slot; $pointscale[$i][$j]['y']=25+(250-$bhca_service_mangdays[$i][$j]*25/$unitValue); } } for($type_index=0;$type_index<13;$type_index++) { if($line_select[$type_index]==1) { for($i=0;$i<24*$slot-1;$i++) { imageline($im,$pointscale[$type_index][$i]['x'],$pointscale[$type_index][$i]['y'],$pointscale[$type_index][$i+1]['x'],$pointscale[$type_index][$i+1]['y'],$color[$type_index]); } } } //echo "lineTop=$lineTop"; if($line_select[$lineTop]==1) { for($i=0;$i<24*$slot-1;$i++) { imageline($im,$pointscale[$lineTop][$i]['x'],$pointscale[$lineTop][$i]['y'],$pointscale[$lineTop][$i+1]['x'],$pointscale[$lineTop][$i+1]['y'],$color[$lineTop]); imageline($im,$pointscale[$lineTop][$i]['x'],$pointscale[$lineTop][$i]['y']+1,$pointscale[$lineTop][$i+1]['x'],$pointscale[$lineTop][$i+1]['y']+1,$color[$lineTop]); imageline($im,$pointscale[$lineTop][$i]['x'],$pointscale[$lineTop][$i]['y']+2,$pointscale[$lineTop][$i+1]['x'],$pointscale[$lineTop][$i+1]['y']+2,$color[$lineTop]); } } } else if($csta_type==1) { $graphics_title="E1 BHCA statistic graphic"; Imagestring($im, 2, 300,5, $graphics_title, $text_color); //get the block of color //blue $blockcolor[0]=ImageColorAllocate($im,0,0,255); //green $blockcolor[1]=ImageColorAllocate($im,0,255,0); //red $blockcolor[2]=ImageColorAllocate($im,255,0,0); imagefilledrectangle($im,90,350,100,360,$blockcolor[0]); imagestring($im,2,105,350,$service_on_top_label[0],$text_color); imagefilledrectangle($im,260,350,270,360,$blockcolor[1]); imagestring($im,2,275,350,$service_on_top_label[1],$text_color); imagefilledrectangle($im,430,350,440,360,$blockcolor[2]); imagestring($im,2,445,350,$service_on_top_label[2],$text_color); //==get the max num of y scale===== $maxYNum=0; for($i=0;$i<$slot*24;$i++) { $bhca_e1_mangdays[2][$i]=$bhca_e1_mangdays[0][$i]+$bhca_e1_mangdays[1][$i]; if($maxYNum<$bhca_e1_mangdays[2][$i]) $maxYNum=$bhca_e1_mangdays[2][$i]; } if($maxYNum<10) $maxYNum=20; $unitValue=$maxYNum/10; //====draw the data line===== for($type=0;$type<3;$type++) { for($i=0;$i<24*$slot;$i++) { $pointscale[$i]['x']=60+30*$i/$slot; $pointscale[$i]['y']=25+(250-$bhca_e1_mangdays[$type][$i]*25/$unitValue); } for($i=0;$i<24*$slot-1;$i++) imageline($im,$pointscale[$i]['x'],$pointscale[$i]['y'],$pointscale[$i+1]['x'],$pointscale[$i+1]['y'],$blockcolor[$type]); } //===draw the on top line again=== $on_top_select=$on_top_select+0; for($i=0;$i<24*$slot;$i++) { $pointscale[$i]['x']=60+30*$i/$slot; $pointscale[$i]['y']=25+(250-$bhca_e1_mangdays[$on_top_select][$i]*25/$unitValue); } for($i=0;$i<24*$slot-1;$i++) imageline($im,$pointscale[$i]['x'],$pointscale[$i]['y'],$pointscale[$i+1]['x'],$pointscale[$i+1]['y'],$blockcolor[$on_top_select]); } else if($csta_type==2) { $graphics_title="Trunk group ".$trunk_num." BHCA statistic graphic"; Imagestring($im, 2, 300,5, $graphics_title, $text_color); //get the block color //blue $blockcolor[0]=ImageColorAllocate($im,0,0,255); //green $blockcolor[1]=ImageColorAllocate($im,255,0,0); imagefilledrectangle($im,90,350,100,360,$blockcolor[0]); imagestring($im,2,105,350,$service_on_top_label[0],$text_color); imagefilledrectangle($im,220,350,230,360,$blockcolor[1]); imagestring($im,2,235,350,$service_on_top_label[1],$text_color); $maxYNum=0; for($i=0;$i<2;$i++) { for($j=0;$j<24*$slot;$j++) { if(!isset($bhca_trunk_mangdays[$i][$j])) $bhca_trunk_mangdays[$i][$j]=0.0; if($maxYNum<$bhca_trunk_mangdays[$i][$j]) $maxYNum=$bhca_trunk_mangdays[$i][$j]; //echo "g-$i-H-$j:{$bhca_trunk_mangdays[$i][$j]}"; } } //====draw the data line==== if($maxYNum<10) $maxYNum=20; $unitValue=$maxYNum/10; for($type=0;$type<2;$type++) { for($i=0;$i<24*$slot;$i++) { $pointscale[$i]['x']=60+30*$i/$slot; $pointscale[$i]['y']=25+(250-$bhca_trunk_mangdays[$type][$i]*25/$unitValue); } for($i=0;$i<24*$slot-1;$i++) imageline($im,$pointscale[$i]['x'],$pointscale[$i]['y'],$pointscale[$i+1]['x'],$pointscale[$i+1]['y'],$blockcolor[$type]); } //==draw the on top line again=== $on_top_select=$on_top_select+0; for($i=0;$i<24*$slot;$i++) { $pointscale[$i]['x']=60+30*$i/$slot; $pointscale[$i]['y']=25+(250-$bhca_trunk_mangdays[$on_top_select][$i]*25/$unitValue); } for($i=0;$i<24*$slot-1;$i++) imageline($im,$pointscale[$i]['x'],$pointscale[$i]['y'],$pointscale[$i+1]['x'],$pointscale[$i+1]['y'],$blockcolor[$on_top_select]); } //====the horizonal scale====== if($maxYNum<=10) { $maxYNum=20; } $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=0;$i<10;$i++){ if($i!=0) imageline($im, $xBgn, $yBgn + $i*25, $xEnd, $yBgn + $i*25, IMG_COLOR_STYLED); $scale=$maxYNum / 10 * (10 - $i); if($scale>1000*1000){ $displayMaxData = round($scale/100000)/10; $displayMaxData = $displayMaxData."M"; }elseif($scale>1000){ $displayMaxData = round($scale/100)/10; $displayMaxData = $displayMaxData."K"; }else $displayMaxData=$scale; Imagestring($im, 2, $xBgn - 50, $yBgn + $i*25 - 5, "$displayMaxData", $text_color); } //-----输出图形文件,请勿修改 //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()-4000; $filename=$tt.".png"; if(1){ ImagePng ($im,"$filename"); ImageDestroy($im); } //-----显示图片 flush(); echo "