0){ echo ""; }else{ echo ""; } echo "
"; //=======================================================================================| //======== Data Initial when run first ========================| //=======================================================================================| if(!isset($csta_type)) $csta_type=0; if(!isset($select_date)) $select_date=0; if(!isset($sel_date)) $sel_date=0; if(!isset($trunk_num)) $trunk_num="1,2"; if(!isset($on_top_index)) $on_top_index=0; if(!isset($sel_date_to)) $sel_date_to=0; if(!isset($sel_date_from)) $sel_date_from=0; if(!isset($sub_sub_flag)) { $sub_sub_flag=0; $sub_loc_flag=0; $tru_tol_flag=0; $tru_sub_flag=0; $tru_tru_flag=0; $tru_ip_flag=0; $sub_ip_flag=0; $inter_flag=0; $mo_flag=0; $mt_flag=0; $in_tru_flag=0; $out_tru_flag=0; $ip_inter_flag=0; } $DEBUG=0; adjust_head(); adjust_title_head(); echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo "
"; echo "$strTitlePerformance > MSC > $strBHCA"; echo ""; $helpId="3.2.5"; showHelp($helpId); echo "
"; //======up csta_type selection======== $csta_type_label=array("Service","E1","Trunk group"); echo ""; //======date selection====== echo ""; //===search button===== echo ""; echo "$strSearch"; echo ""; echo ""; //====printer button=== echo ""; echo ""; echo ""; echo "
"; adjust_title_tail(); adjust_content_head(); echo "
"; ?> "; $db="CSTA_DB"; $table_name="mscSum"; $temp=date("d",mktime(0,0,0,date("m"),date("d")-$select_date,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")-$select_date,date("Y"))); $to_time=date("Y-m-d H:i:s",mktime(0,0,0,date("m"),date("d")-$select_date+1,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
"; $key_type_relation=array(5=>0,6=>1,7=>2,8=>3,9=>4,10=>5,11=>6,12=>7,13=>8,14=>9,15=>10,16=>11); $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_oneday[$index][$datetime+1]+=$rows[1]; //echo "type:$index time:$datetime {$bhca_service_oneday[$index][$datetime]}
"; }while($rows=mysqli_fetch_array($result)); } //get the 0-hour of the day $table_name="mscSum"; $temp=date("d",mktime(0,0,0,date("m"),date("d")-$select_date-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")-$select_date-1,date("Y"))); $to_time=date("Y-m-d H:i:s",mktime(0,0,0,date("m"),date("d")-$select_date,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
"; $key_type_relation=array(5=>0,6=>1,7=>2,8=>3,9=>4,10=>5,11=>6,12=>7,13=>8,14=>9,15=>10,16=>11); $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_oneday[$index][0]+=$rows[1]; //echo "type:$index time:$datetime {$bhca_service_oneday[$index][$datetime]}
"; }while($rows=mysqli_fetch_array($result)); } //======Fake Data======= if($DEBUG) { for($i=0;$i<13;$i++) { for($j=0;$j<24;$j++) { $bhca_service_oneday[$i][$j]=rand(10,100); } } } //=====Test the 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<12;$i++) { for($j=0;$j<24;$j++) { echo "{$test_service_type_label[$i]}--$j--{$bhca_service_oneday[$i][$j]}
"; } } } //====show the table-1==== $table_title="Service"." BHCA Date:".date("Y-m-d",mktime(0,0,0,date("m"),date("d")-$select_date,date("Y"))); //table title $service_type_label=array("Subs to subs","Subs to trunk","Trunk to subs","Trunk to trunk","Intraconnection", "Sub to IP","Trunk to IP", "Mobile originated","Mobile terminated","In trunk","Out trunk","IP terminated"); echo "
$table_title
"; echo ""; echo ""; echo ""; echo ""; for($i=0;$i<12;$i++) { echo ""; echo ""; for($j=0;$j<12;$j++) { echo ""; } echo ""; echo ""; echo ""; echo ""; for($j=0;$j<12;$j++) { echo ""; } echo ""; echo ""; for($j=12;$j<24;$j++) { echo ""; } echo ""; echo ""; for($j=12;$j<24;$j++) { echo ""; } echo ""; echo ""; } echo "
Type"; echo "BHCA(calls)"; echo "
 $j
{$service_type_label[$i]}
{$bhca_service_oneday[$i][$j]}
$j
{$bhca_service_oneday[$i][$j]}
"; } //=======================================================================================| //=========== csta_type==1,E1 Table ================| //=======================================================================================| else if($csta_type==1) { //=====Data define======= for($i=0;$i<256;$i++) { for($j=0;$j<24;$j++) { $bhca_e1_oneday[$i][$j]=0; } } //=====Get Data from DB====== $device_name=isset($device_name)?$device_name:$DEFAULT_SYS; //device name $db="CSTA_DB"; $sys_entries=get_sys_total($device_name); $subsys_entries=1; $e1_entries=get_e1_total($device_name); $db="CSTA_DB"; $table_name="mscSum"; $temp=date("d",mktime(0,0,0,date("m"),date("d")-$select_date,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")-$select_date,date("Y"))); $to_time=date("Y-m-d H:i:s",mktime(0,0,0,date("m"),date("d")-$select_date+1,date("Y"))); for($i=0;$i<$sys_entries;$i++) { $select="select key_sys_id,key_subsys_id,key_e1_tg,sum(Success) as ans,csta_datetime "; $from="from $table_name "; $group=" GROUP BY key_e1_tg,csta_datetime"; $e1_where="AND key_type>0 AND key_type<3 "; $where=" WHERE key_sys_id=$i AND 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
"; $msc_no=$rows[0]+0; $e1_no=$rows[2]+0; $bhca_e1_oneday[$msc_no*128+$e1_no][$datetime]=$rows[3]+0; //echo "e1_data[$msc_no][0][$e1_no][$datetime]:{$e1_data[$msc_no][0][$e1_no][$datetime]}
"; }while($rows=@mysqli_fetch_array($result)); } } //====Fake Data============ if($DEBUG) { for($i=0;$i<256;$i++) { for($j=0;$j<24;$j++) { $bhca_e1_oneday[$i][$j]=rand(10,100); } } } //====Get the sys-0 and sys-1 data===== for($i=0;$i<256;$i++) { for($j=0;$j<24;$j++) { if($i<128) $e1_sys1_sum[$j]+=$bhca_e1_oneday[$i][$j]; else $e1_sys2_sum[$j]+=$bhca_e1_oneday[$i][$j]; } } //====Test the Data====== if(0) { for($i=0;$i<256;$i++) { for($j=0;$j<24;$j++) { echo "E1-$i--Hour-$j--{$bhca_e1_oneday[$i][$j]}
"; } } } //=====show the table-1===== $table_title="E1"." BHCA Date:".date("Y-m-d",mktime(0,0,0,date("m"),date("d")-$select_date,date("Y"))); //table title echo "
$table_title
"; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; for($i=0;$i<24;$i++) { echo ""; } //msc-0 echo ""; echo ""; for($j=0;$j<24;$j++) { echo ""; } echo ""; for($i=0;$i<128;$i++) { echo ""; echo ""; for($j=0;$j<24;$j++) { echo ""; } echo ""; } //msc=1 echo ""; echo ""; for($j=0;$j<24;$j++) { echo ""; } echo ""; for($i=128;$i<256;$i++) { echo ""; $temp=$i-128; echo ""; for($j=0;$j<24;$j++) { echo ""; } echo ""; } echo "
Equipment"; echo "BHCA(calls)"; echo "
SystemE1$i
MSC-0sys{$e1_sys1_sum[$j]}
MSC-0$i{$bhca_e1_oneday[$i][$j]}
MSC-1sys{$e1_sys2_sum[$j]}
MSC-1$temp{$bhca_e1_oneday[$i][$j]}
"; } //=======================================================================================| //=========== csta_type==2,trunk group Table ================| //=======================================================================================| else if($csta_type==2) { //=====Data define====== for($i=0;$i<=256;$i++) { for($j=0;$j<24;$j++) { $bhca_trunk_oneday[$i][$j]=0; } } //=====Get the Data from DB====== $db="CSTA_DB"; $table_name="mscSum"; $temp=date("d",mktime(0,0,0,date("m"),date("d")-$select_date,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")-$select_date,date("Y"))); $to_time=date("Y-m-d H:i:s",mktime(0,0,0,date("m"),date("d")-$select_date+1,date("Y"))); $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"; $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==TRUE) { $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_oneday[$gro][$datetime+1]+=$select_rows[ans]+0; //echo "group:$gro--time:$datetime=={$bhca_trunk_oneday[$gro][$datetime]}
"; }while($select_rows=mysqli_fetch_array($select_result)); } } //get the 0-hour of the day $table_name="mscSum"; $temp=date("d",mktime(0,0,0,date("m"),date("d")-$select_date-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")-$select_date-1,date("Y"))); $to_time=date("Y-m-d H:i:s",mktime(0,0,0,date("m"),date("d")-$select_date,date("Y"))); $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"; $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==TRUE) { $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_oneday[$gro][0]+=$select_rows[ans]+0; //echo "group:$gro--time:$datetime=={$bhca_trunk_oneday[$gro][$datetime]}
"; }while($select_rows=mysqli_fetch_array($select_result)); } } //=====Fake Data======== if($DEBUG) { for($i=0;$i<=256;$i++) { for($j=0;$j<24;$j++) { $bhca_trunk_oneday[$i][$j]=rand(10,100); } } } //======Test the Data===== if(0) { for($i=0;$i<=256;$i++) { for($j=0;$j<24;$j++) { $bhca_trunk_oneday[$i][$j]=rand(10,100); } } } //=====Show the table-1===== $table_title="Trunk group BHCA Date:".date("Y-m-d",mktime(0,0,0,date("m"),date("d")-$select_date,date("Y"))); echo "
$table_title
"; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; for($i=0;$i<24;$i++) { echo ""; } echo ""; for($i=1;$i<=256;$i++) { echo ""; $t=$i; echo ""; for($j=0;$j<24;$j++) { //$bhca_trunk_oneday[$i][$j]=number_format($bhca_trunk_oneday[$i][$j], 2, '.', ''); if($bhca_trunk_oneday[$i][$j]==0) echo ""; else echo ""; } echo ""; } echo "
 "; echo "BHCA(calls)"; echo "
TG$i
$t{$bhca_trunk_oneday[$i][$j]}{$bhca_trunk_oneday[$i][$j]}
"; } //=======================================================================================| //======== Down Selection ============| //=======================================================================================| //====date from selection===== echo "

"; echo ""; echo ""; echo ""; echo ""; //=====trunk number text for trunk===== echo ""; echo ""; //====search button===== echo ""; //====on top selection====== if($csta_type==0) { echo "
"; echo ""; echo "to"; echo ""; echo " "; if($csta_type==2) { echo ""; } //hide the trunk_num selection else { echo ""; } echo ""; echo "
"; echo "$strSearch"; echo "
"; echo "
"; echo ""; echo ""; echo ""; /* delete tru to toll echo ""; */ echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; } else if($csta_type==1) { echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; } else if($csta_type==2) { echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; } echo "
"; if($sub_sub_flag==1) { $line_select[0]=1; echo ""; } else { $line_select[0]=0; $lineOnTop=0; echo ""; } echo "SUB SUB"; if($sub_loc_flag==1) { $line_select[1]=1; echo ""; } else { $line_select[1]=0; $lineOnTop=1; echo ""; } echo "SUB TRK"; if($tru_tol_flag==1) { $line_select[2]=1; echo ""; } else { $line_select[2]=0; echo ""; } echo "TRK TOLL"; if($tru_sub_flag==1) { $line_select[2]=1; echo ""; } else { $line_select[2]=0; $lineOnTop=2; echo ""; } echo "TRK SUB"; if($tru_tru_flag==1) { $line_select[3]=1; echo ""; } else { $line_select[3]=0; $lineOnTop=3; echo ""; } echo "TRK TRK"; if($inter_flag==1) { $line_select[4]=1; echo ""; } else { $line_select[4]=0; $lineOnTop=4; echo ""; } echo "INTRA"; if($sub_ip_flag==1) { $line_select[5]=1; echo ""; } else { $line_select[5]=0; $lineOnTop=5; echo ""; } echo "SUB IP"; if($tru_ip_flag==1) { $line_select[6]=1; echo ""; } else { $line_select[6]=0; $lineOnTop=6; echo ""; } echo "TRK IP"; if($mo_flag==1) { $line_select[7]=1; echo ""; } else { $line_select[7]=0; $lineOnTop=7; echo ""; } echo "MO"; if($mt_flag==1) { $line_select[8]=1; echo ""; } else { $line_select[8]=0; $lineOnTop=8; echo ""; } echo "MT"; if($in_tru_flag==1) { $line_select[9]=1; echo ""; } else { $line_select[9]=0; $lineOnTop=9; echo ""; } echo "IN TRK"; if($out_tru_flag==1) { $line_select[10]=1; echo ""; } else { $line_select[10]=0; $lineOnTop=10; echo ""; } echo "OUT TRK"; if($ip_inter_flag==1) { $line_select[11]=1; echo ""; } else { $line_select[11]=0; $lineOnTop=11; echo ""; } echo "IP "; echo "on top"; echo " "; echo "on top"; echo "
"; //=======================================================================================| //=========== Test before draw graphics ================| //=======================================================================================| if(0) { $test_csta_type_label=array("Service","E1","Trunk"); $slot=$sel_date_from-$sel_date_to+1; echo "Type----{$test_csta_type_label[$csta_type]}
"; echo "Time----sigle $sel_date From $sel_date_from to $sel_date_to slot:$slot
"; echo "Service flag-----$sub_sub_flag $sub_loc_flag $tru_tol_flag $tru_sub_flag $tru_tru_flag $sub_ip_flag $tru_ip_flag $inter_flag $mo_flag $mt_flag $in_tru_flag $out_tru_flag $ip_inter_flag
"; echo "Trunk num----$trunk_num
"; echo "on top index----$on_top_index
"; } //=======================================================================================| //=========== csta_type==0,service Graphics ================| //=======================================================================================| $slot=$sel_date_from-$sel_date_to+1; if($csta_type==0) { //====Data define==== for($i=0;$i<12;$i++) { for($j=0;$j<24*$slot;$j++) { $bhca_service_mangdays[$i][$j]=0; } } //====Get the Data from DB===== //echo "slot:$slot
"; $key_type_relation=array(5=>0,6=>1,7=>2,8=>3,9=>4,10=>5,11=>6,12=>7,13=>8,14=>9,15=>10,16=>11); 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
"; $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; 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 "

"; echo ""; adjust_content_tail(); echo ""; ?>