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

1396 lines
43 KiB
PHP
Executable File
Raw 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
/***** NOTE *****/
/* sub_loc=sub_trunk */
/***********************/
?>
<script language="JavaScript">
function fresh(lineOnTop)
{
var cstatype=document.myform.csta_type.value;
var up_date=document.myform.sel_date.value;
var down_date_from=document.myform.sel_date_from.value;
var down_date_to=document.myform.sel_date_to.value;
var scrollY=document.body.scrollTop;
var trunk_n;
var on_top_index=document.myform.on_top_select.value;
var lu;
var mo;
var mt;
var smo;
var smt;
if(cstatype==2)
trunk_n=document.myform.trunk_num.value;
else
trunk_n="0,1";
if(down_date_from<down_date_to)
down_date_to=down_date_from;
if(cstatype==0)
{
if(document.myform.lu_check.checked==1)
lu=1;
else
lu=0;
if(document.myform.mo_check.checked==1)
mo=1;
else
mo=0;
if(document.myform.mt_check.checked==1)
mt=1;
else
mt=0;
if(document.myform.smo_check.checked==1)
smo=1;
else
smo=0;
if(document.myform.smt_check.checked==1)
smt=1;
else
smt=0;
}
else
{
lu=1;
mo=1;
mt=1;
smo=1;
smt=1;
}
var addurl="&lineTop="+lineOnTop+"&lu_flag="+lu+"&mo_flag="+mo+"&mt_flag="+mt+"&smo_flag="+smo+"&smt_flag="+smt;
var urll='<?php echo"$PHP_SELF";?>?csta_type='+cstatype+'&select_date='+up_date+'&sel_date_from='+down_date_from+'&sel_date_to='+down_date_to+'&trunk_num='+trunk_n+'&on_top_select='+on_top_index+'&scroll_y='+scrollY+addurl;
window.location.href=urll;
}
</script>
<?php
/*
|----------------------------------------------------------------------------------------|
| This page devide into 3 parts by the value of csta_type |
| 0 : service |
| 1 : E1 |
| 2 : trunk group |
|----------------------------------------------------------------------------------------|
*/
?>
<?php
if($scroll_y > 0){
echo "<body topmargin=\"5\" leftmargin=\"12\" onLoad='self.scrollBy(0,$scroll_y)'>";
}else{
echo "<body topmargin=\"5\" leftmargin=\"12\">";
}
//=======================================================================================|
//======== 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($lu_flag))
{
$lu_flag=0;
$mo_flag=0;
$mt_flag=0;
$smo_flag=0;
$smt_flag=0;
}
$DEBUG=0;
$helpId="3.2.4";
echo "<table border=\"0\" width=\"100%\">";
echo "<tr>";
echo "<td width=\"50%\">";
echo "$strTitlePerformance > iPALIM > $strErlang";
echo "</td>";
echo "<td width=\"50%\" align=\"right\" title=\"Help\">";
//showHelp($helpId);
echo "</td>";
echo "</tr>";
echo "</table>";
//======up csta_type selection========
echo "<form name=\"myform\" method=\"POST\">";
echo "<table border=0>";
echo "<tr>";
echo "<td>";
$csta_type_label=array("Service","E1","Trunk group");
echo "<select name=\"csta_type\" onChange=\"javascript:fresh()\">";
for($i=0;$i<3;$i++)
{
//hide the E1
if($i==1)
continue;
if($i==$csta_type)
echo "<option value=$i selected>{$csta_type_label[$i]}</option>";
else
echo "<option value=$i>{$csta_type_label[$i]}</option>";
}
echo "</select>";
echo "</td>";
//======date selection======
echo "<td>";
echo "<select name=\"sel_date\" size=1>";
$day0=date("Y-m-d",mktime(0,0,0,date("m"),date("d"),date("Y")));
$day1=date("Y-m-d",mktime(0,0,0,date("m"),date("d")-1,date("Y")));
$day2=date("Y-m-d",mktime(0,0,0,date("m"),date("d")-2,date("Y")));
$day3=date("Y-m-d",mktime(0,0,0,date("m"),date("d")-3,date("Y")));
$day4=date("Y-m-d",mktime(0,0,0,date("m"),date("d")-4,date("Y")));
$day5=date("Y-m-d",mktime(0,0,0,date("m"),date("d")-5,date("Y")));
$day6=date("Y-m-d",mktime(0,0,0,date("m"),date("d")-6,date("Y")));
for($i=0;$i<7;$i++)
{
if($i==$select_date)
echo "<option selected value=$i>${day.$i}</option>";
else
echo "<option value=$i>${day.$i}</option>";
}
echo "</select>";
echo "</td>";
//===search button=====
echo "<td align=\"left\">";
echo "<div onClick=\"javascript:fresh()\" style=\"cursor:hand\">";
echo "<IMG align=absBottom border=0 src=\"../../images/search.gif\" >$strSearch";
echo "</div>";
echo "</td>";
//====printer button===
echo "<td align=\"right\">";
echo "<div onClick=\"window.print();\" style=\"position:absolute;top:55;left:820;cursor:hand\">";
echo "<img align=absBottom border=0 src=\"../../images/printer.gif\" width=16 height=16>";
echo "</div>";
echo "</td>";
echo "</tr>";
echo "</table>";
?>
<?php
//=======================================================================================|
//=========== csta_type==0,service Table ================|
//=======================================================================================|
if($csta_type==0)
{
//======Data define=========
/*
i j(hour)
0 lu 0-23
1 mo
2 mt
3 smo
4 smt
*/
for($i=0;$i<5;$i++)
{
for($j=0;$j<24;$j++)
{
$erlang_service_oneday[$i][$j]=0;
}
}
//======Get Data from DB======
//echo "sel_date:$sel_date<br>";
$db="CSTA_DB";
$table_name="ipalimSum";
$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<br>";
$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<br>";
$select="select key_type,sum(Duration) as duration,csta_datetime ";
$from="from $table_name ";
$service_where="and key_type>0 and key_type<6 ";
$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<br>";
$result=@mysqli_query($pubConn,$sql);
$rows=@mysqli_fetch_array($result);
if($rows)
{
do{
$key_type=$rows[key_type];
$index=$key_type-1;
$datetime=substr($rows[csta_datetime],11,2)+0;
if($datetime==23)
continue;
//echo "datetime=$datetime<br>";
$erlang_service_oneday[$index][$datetime+1]+=$rows[duration];
//echo "{$erlang_service_oneday[$index][$datetime]}<br>";
}while($rows=mysqli_fetch_array($result));
}
//get the 0-hour of the day
$table_name="ipalimSum";
$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<br>";
$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<br>";
$select="select key_type,sum(Duration) as duration,csta_datetime ";
$from="from $table_name ";
$service_where="and key_type>0 and key_type<6 ";
$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<br>";
$result=@mysqli_query($pubConn,$sql);
$rows=@mysqli_fetch_array($result);
if($rows)
{
do{
$key_type=$rows[key_type]-1;
$index=$key_type-1;
$datetime=substr($rows[csta_datetime],11,2)+0;
//echo "datetime=$datetime<br>";
$erlang_service_oneday[$index][0]+=$rows[duration];
//echo "{$erlang_service_oneday[$index][$datetime]}<br>";
}while($rows=mysqli_fetch_array($result));
}
//======Fake Data=======
if($DEBUG)
{
for($i=0;$i<13;$i++)
{
for($j=0;$j<24;$j++)
{
$erlang_service_oneday[$i][$j]=rand(10,100);
}
}
}
//=====Test the Data=====
if(0)
{
$test_service_type_label=array("LU","MO","MT","SMO","SMT");
for($i=0;$i<5;$i++)
{
for($j=0;$j<24;$j++)
{
echo "{$test_service_type_label[$i]}--$j--{$erlang_service_oneday[$i][$j]}<br>";
}
}
}
//=====Fix the Data=====
for($i=0;$i<5;$i++)
{
for($j=0;$j<24;$j++)
{
$erlang_service_oneday[$i][$j]=change2point($erlang_service_oneday[$i][$j]/3600);
}
}
//====show the table-1====
$table_title="Service"." Erlang Date:".date("Y-m-d",mktime(0,0,0,date("m"),date("d")-$select_date,date("Y"))); //table title
$service_type_label=array("LU","MO","MT","SMO","SMT");
echo "<center><b>$table_title</b></center>";
echo "<table width=\"100%\" border=\"1\" cellpadding=\"2\" cellspacing=\"0\" bordercolor=\"#666666\" bordercolordark=\"#FFFFFF\" bgcolor=\"#FFFFFF\">";
echo "<tr bgcolor=\"#E6E6E6\">";
echo "<td align=center>Type</td><td colspan=\"12\" align=\"center\">";
echo "Erlang(hour)";
echo "</td>";
echo "</tr>";
for($i=0;$i<5;$i++)
{
echo "<tr bgcolor=\"#E6E6E6\">";
echo "<td>&nbsp</td>";
for($j=0;$j<12;$j++)
{
echo "<td>$j</td>";
}
echo "</tr>";
echo "<tr>";
echo "<td width=\"12%\" rowspan=4>{$service_type_label[$i]}</td>";
echo "<tr>";
for($j=0;$j<12;$j++)
{
echo "<td>{$erlang_service_oneday[$i][$j]}</td>";
}
echo "</tr>";
echo "<tr bgcolor=\"#E6E6E6\">";
for($j=12;$j<24;$j++)
{
echo "<td>$j</td>";
}
echo "</tr>";
echo "<tr>";
for($j=12;$j<24;$j++)
{
echo "<td>{$erlang_service_oneday[$i][$j]}</td>";
}
echo "</tr>";
echo "</tr>";
}
echo "</table>";
}
//=======================================================================================|
//=========== 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++)
{
$erlang_trunk_oneday[$i][$j]=0;
}
}
//=====Get the Data from DB======
$db="CSTA_DB";
$table_name="ipalimSum";
$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<br>";
$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(Duration) as duration ";
$from="from $table_name ";
$where=" where csta_datetime>='$from_time' and csta_datetime<'$to_time' and key_type>0 and key_type<6";
$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<br>";
$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<br>";
//echo "datetime:$datetime<br>";
$erlang_trunk_oneday[$gro][$datetime+1]+=change2point($select_rows[duration]/3600);
//echo "group:$gro--time:$datetime=={$erlang_trunk_oneday[$gro][$datetime]}<br>";
}while($select_rows=mysqli_fetch_array($select_result));
}
}
//get the 0-hour of the day
$table_name="ipalimSum";
$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<br>";
$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(Duration) as duration ";
$from="from $table_name ";
$where=" where csta_datetime>='$from_time' and csta_datetime<'$to_time' and key_type>0 and key_type<6";
$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<br>";
$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<br>";
//echo "datetime:$datetime<br>";
$erlang_trunk_oneday[$gro][0]+=change2point($select_rows[duration]/3600);
//echo "group:$gro--time:$datetime=={$erlang_trunk_oneday[$gro][$datetime]}<br>";
}while($select_rows=mysqli_fetch_array($select_result));
}
}
//=====Fake Data========
if($DEBUG)
{
for($i=0;$i<256;$i++)
{
for($j=0;$j<24;$j++)
{
$erlang_trunk_oneday[$i][$j]=rand(10,100);
}
}
}
//======Test the Data=====
if(0)
{
for($i=0;$i<256;$i++)
{
for($j=0;$j<24;$j++)
{
$erlang_trunk_oneday[$i][$j]=rand(10,100);
}
}
}
//=====Show the table-1=====
$table_title="Trunk group Erlang Date:".date("Y-m-d",mktime(0,0,0,date("m"),date("d")-$select_date,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\">";
echo "<tr bgcolor=\"#E6E6E6\">";
echo "<td>&nbsp</td><td colspan=\"24\" align=\"center\">";
echo "Erlang(hour)";
echo "</td>";
echo "</tr>";
echo "<tr bgcolor=\"#E6E6E6\">";
echo "<td align=\"center\"><nobr>TG</td>";
for($i=0;$i<24;$i++)
{
echo "<td>$i</td>";
}
echo "</tr>";
for($i=1;$i<256;$i++)
{
echo "<tr>";
$t=$i;
echo "<td>$t</td>";
for($j=0;$j<24;$j++)
{
$erlang_trunk_oneday[$i][$j]=number_format($erlang_trunk_oneday[$i][$j], 2, '.', '');
if($erlang_trunk_oneday[$i][$j]==0)
echo "<td><font color=#AEAEAE>{$erlang_trunk_oneday[$i][$j]}</font></td>";
else
echo "<td>{$erlang_trunk_oneday[$i][$j]}</td>";
}
echo "</tr>";
}
echo "</table>";
}
//=======================================================================================|
//======== Down Selection ============|
//=======================================================================================|
//====date from selection=====
//echo "sel_date_from:$sel_date_from--sel_date_to:$sel_date_to<br>";
echo "<p><table>";
echo "<tr>";
echo "<td>";
echo "<select name=\"sel_date_from\" onChange=\"javascript:fresh()\">";
for($i=0;$i<7;$i++)
{
if($i==$sel_date_from)
echo "<option selected value=$i>${day.$i}</option>";
else
echo "<option value=$i>${day.$i}</option>";
}
echo "</select>";
echo "</td>";
echo "<td>to</td>";
echo "<td>";
echo "<select name=\"sel_date_to\">";
for($i=0;$i<=$sel_date_from;$i++)
{
if($i==$sel_date_to)
echo "<option selected value=$i>${day.$i}</option>";
else
echo "<option value=$i>${day.$i}</option>";
}
echo "</select>";
echo "</td>";
//=====trunk number text for trunk=====
echo "<td>&nbsp</td>";
echo "<td>";
if($csta_type==2)
{
echo "<input type=\"text\" size=6 name=\"trunk_num\" value=$trunk_num>";
}
//hide the trunk_num selection
else
{
echo "<input type=\"hidden\" name=\"trunk_num\" value=$trunk_num>";
}
echo "</td>";
//====search button=====
echo "<td align=\"left\">";
echo "<div onClick=\"javascript:fresh()\" style=\"cursor:hand\">";
echo "<IMG align=absBottom border=0 src=\"../../images/search.gif\">$strSearch";
echo "</div>";
echo "</td>";
//====on top selection======
//echo "csta_type:$csta_type<br>";
if($csta_type==0)
{
echo "</tr></table>";
echo "<table border=0><tr>";
echo "<td>";
if($lu_flag==1)
{
$line_select[0]=1;
echo "<input type=checkbox name=\"lu_check\" checked onClick=\"javascript:fresh(0)\">";
}
else
{
$line_select[0]=0;
$lineOnTop=0;
echo "<input type=checkbox name=\"lu_check\" onClick=\"javascript:fresh($lineOnTop)\">";
}
echo "<nobr>LU</td>";
echo "<td>";
if($mo_flag==1)
{
$line_select[1]=1;
echo "<input type=checkbox name=\"mo_check\" checked onClick=\"javascript:fresh(0)\">";
}
else
{
$line_select[1]=0;
$lineOnTop=1;
echo "<input type=checkbox name=\"mo_check\" onClick=\"javascript:fresh($lineOnTop)\">";
}
echo "<nobr>Call MO</td>";
echo "<td>";
if($mt_flag==1)
{
$line_select[2]=1;
echo "<input type=checkbox name=\"mt_check\" checked onClick=\"javascript:fresh(0)\">";
}
else
{
$line_select[2]=0;
$lineOnTop=2;
echo "<input type=checkbox name=\"mt_check\" onClick=\"javascript:fresh($lineOnTop)\">";
}
echo "<nobr>Call MT</td>";
echo "<td>";
if($smo_flag==1)
{
$line_select[3]=1;
echo "<input type=checkbox name=\"smo_check\" checked onClick=\"javascript:fresh(0)\">";
}
else
{
$line_select[3]=0;
$lineOnTop=3;
echo "<input type=checkbox name=\"smo_check\" onClick=\"javascript:fresh($lineOnTop)\">";
}
echo "<nobr>SM MO</td>";
echo "<td>";
if($smt_flag==1)
{
$line_select[4]=1;
echo "<input type=checkbox name=\"smt_check\" checked onClick=\"javascript:fresh(0)\">";
}
else
{
$line_select[4]=0;
$lineOnTop=4;
echo "<input type=checkbox name=\"smt_check\" onClick=\"javascript:fresh($lineOnTop)\">";
}
echo "SM MT</td>";
echo "<input type=hidden name=\"on_top_select\" value=0>";
}
else if($csta_type==2)
{
echo "<td width=50%>&nbsp</td>";
echo "<td>";
echo "<select name=\"on_top_select\" onChange=\"javascript:fresh()\">";
$trunk_num_select=explode(",",$trunk_num);
$service_on_top_label=array("Trunk group ".$trunk_num_select[0],"Trunk group ".$trunk_num_select[1]);
for($i=0;$i<2;$i++)
{
if($i==$on_top_select)
echo "<option value=$i selected>$service_on_top_label[$i]</option>";
else
echo "<option value=$i>$service_on_top_label[$i]</option>";
}
echo "</select><nobr>on top";
echo "</td>";
echo "<input type=hidden name=\"lu_check\" value=1>";
echo "<input type=hidden name=\"mo_check\" value=1>";
echo "<input type=hidden name=\"mt_check\" value=1>";
echo "<input type=hidden name=\"smo_check\" value=1>";
echo "<input type=hidden name=\"mt_check\" value=1>";
}
echo "</td></table>";
//=======================================================================================|
//=========== 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]}<br>";
echo "Time----sigle $sel_date From $sel_date_from to $sel_date_to slot:$slot<br>";
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<br>";
echo "Trunk num----$trunk_num<br>";
echo "on top index----$on_top_index<br>";
}
//=======================================================================================|
//=========== csta_type==0,service Graphics ================|
//=======================================================================================|
$slot=$sel_date_from-$sel_date_to+1;
if($csta_type==0)
{
//====Data define====
for($i=0;$i<5;$i++)
{
for($j=0;$j<24*$slot;$j++)
{
$erlang_service_mangdays[$i][$j]=0;
}
}
//====Get the Data from DB=====
//echo "slot:$slot<br>";
for($day=0;$day<$slot;$day++)
{
$db="CSTA_DB";
$table_name="ipalimSum";
$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<br>";
$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<br>";
$select="select key_type,sum(Duration) as duration,csta_datetime ";
$from="from $table_name ";
$service_where="and key_type>0 and key_type<6 ";
$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<p>";
$result=@mysqli_query($pubConn,$sql);
$rows=@mysqli_fetch_array($result);
if($rows)
{
do{
$key_type=$rows[key_type]+0;
$index=$key_type-1;
$datetime=substr($rows[csta_datetime],11,2)+0;
if($datetime == 23)
continue;
//echo "datetime:$datetime<br>";
$erlang_service_mangdays[$index][$datetime+1+24*$day]+=$rows[duration];
}while($rows=mysqli_fetch_array($result));
}
}
//get the 0-hour of the day
for($day=0;$day<$slot;$day++)
{
$db="CSTA_DB";
$table_name="ipalimSum";
$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<br>";
$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<br>";
$select="select key_type,sum(Duration) as duration,csta_datetime ";
$from="from $table_name ";
$service_where="and key_type>0 and key_type<6 ";
$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<p>";
$result=@mysqli_query($pubConn,$sql);
$rows=@mysqli_fetch_array($result);
if($rows)
{
do{
$key_type=$rows[key_type]+0;
$index=$key_type-1;
$datetime=substr($rows[csta_datetime],11,2)+0;
//echo "datetime:$datetime<br>";
$erlang_service_mangdays[$index][24*$day]+=$rows[duration];
}while($rows=mysqli_fetch_array($result));
}
}
//====Fix the data====
for($i=0;$i<5;$i++)
{
for($day=0;$day<$slot*24;$day++)
{
$erlang_service_mangdays[$i][$day]=change2point($erlang_service_mangdays[$i][$day]/3600);
}
}
//====Fake Data=======
if($DEBUG)
{
for($i=0;$i<12;$i++)
{
for($j=0;$j<24*$slot;$j++)
{
$erlang_service_mangdays[$i][$j]=rand(10,100);
}
}
}
//====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<12;$i++)
{
for($j=0;$j<24*$slot;$j++)
{
echo "{$test_service_type_label[$i]}--$j--{$erlang_service_mangdays[$i][$j]}<br>";
}
}
}
}
//=======================================================================================|
//=========== 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];
//====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++)
{
$erlang_trunk_mangdays[$i][$j]=0;
}
}
//====Get the Data from DB=====
//echo "slot:$slot<br>";
//trunk_num_select
for($day=0;$day<$slot;$day++)
{
$db="CSTA_DB";
$table_name="ipalimSum";
$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<br>";
$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<br>";
//tg 1
$select="select key_e1_tg,csta_datetime,sum(Duration) as duration ";
$from="from $table_name ";
$where=" where csta_datetime>='$from_time' and csta_datetime<'$to_time' and key_type>0 and key_type<6 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<br>";
$select_result=mysqli_query($pubConn,$select_sql);
if($select_result==FALSE)
exit("<b>There is no data between ".$from_time." to ".$to_time."</b>");
$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<br>";
//echo "datetime:$datetime<br>";
$erlang_trunk_mangdays[0][$datetime+1+24*$day]+=change2point($select_rows[duration]/3600);
//echo "group:$gro--time:$datetime=={$erlang_trunk_mangdays[$gro][$datetime]}<br>";
}while($select_rows=mysqli_fetch_array($select_result));
}
//tg 2
$select="select key_e1_tg,csta_datetime,sum(Duration) as duration ";
$from="from $table_name ";
$where=" where csta_datetime>='$from_time' and csta_datetime<'$to_time' and key_type>0 and key_type<6 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 "<p>$select_sql<br>";
$select_result=mysqli_query($pubConn,$select_sql);
if($select_result==FALSE)
exit("<b>There is no data between ".$from_time." to ".$to_time."</b>");
$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<br>";
//echo "ddatetime:$datetime<br>";
$erlang_trunk_mangdays[1][$datetime+1+24*$day]+=change2point($select_rows[duration]/3600);
//echo "group:$gro--time:$datetime=={$erlang_trunk_mangdays[$gro][$datetime]}<br>";
}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="ipalimSum";
$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<br>";
$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<br>";
//tg 1
$select="select key_e1_tg,csta_datetime,sum(Duration) as duration ";
$from="from $table_name ";
$where=" where csta_datetime>='$from_time' and csta_datetime<'$to_time' and key_type>0 and key_type<6 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<br>";
$select_result=mysqli_query($pubConn,$select_sql);
if($select_result==FALSE)
exit("<b>There is no data between ".$from_time." to ".$to_time."</b>");
$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<br>";
//echo "datetime:$datetime<br>";
$erlang_trunk_mangdays[0][24*$day]+=change2point($select_rows[duration]/3600);
//echo "group:$gro--time:$datetime=={$erlang_trunk_mangdays[$gro][$datetime]}<br>";
}while($select_rows=mysqli_fetch_array($select_result));
}
//tg 2
$select="select key_e1_tg,csta_datetime,sum(Duration) as duration ";
$from="from $table_name ";
$where=" where csta_datetime>='$from_time' and csta_datetime<'$to_time' and key_type>0 and key_type<6 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 "<p>$select_sql<br>";
$select_result=mysqli_query($pubConn,$select_sql);
if($select_result==FALSE)
exit("<b>There is no data between ".$from_time." to ".$to_time."</b>");
$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<br>";
//echo "ddatetime:$datetime<br>";
$erlang_trunk_mangdays[1][24*$day]+=change2point($select_rows[duration]/3600);
//echo "group:$gro--time:$datetime=={$erlang_trunk_mangdays[$gro][$datetime]}<br>";
}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++)
{
$erlang_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--{$erlang_trunk_mangdays[$i][$j]}<br>";
}
}
}
}
//=======================================================================================|
//=========== 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 erlang 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<12;$i++)
{
for($j=0;$j<$slot*24;$j++)
{
if(!isset($erlang_service_mangdays[$i][$j]))
$erlang_service_mangdays[$i][$j]=0.0;
if($line_select[$i])
{
if($maxYNum<$erlang_service_mangdays[$i][$j])
$maxYNum=$erlang_service_mangdays[$i][$j];
}
//echo "g-$i-h-$j:{$erlang_service_mangdays[$i][$j]}<br>";
}
}
//====get the points scale====
if($maxYNum<10)
$maxYNum=20;
$unitValue=$maxYNum/10;
for($i=0;$i<12;$i++)
{
for($j=0;$j<24*$slot;$j++)
{
$pointscale[$i][$j]['x']=60+30*$j/$slot;
$pointscale[$i][$j]['y']=25+(250-$erlang_service_mangdays[$i][$j]*25/$unitValue);
}
}
for($type_index=0;$type_index<12;$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<br>";
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==2)
{
$graphics_title="Trunk group ".$trunk_num." erlang 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($erlang_trunk_mangdays[$i][$j]))
$erlang_trunk_mangdays[$i][$j]=0.0;
if($maxYNum<$erlang_trunk_mangdays[$i][$j])
$maxYNum=$erlang_trunk_mangdays[$i][$j];
//echo "g-$i-H-$j:{$erlang_trunk_mangdays[$i][$j]}<br>";
}
}
//====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-$erlang_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-$erlang_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);
}
//-----<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()-4000;
$filename=$tt.".png";
if(1){
ImagePng ($im,"$filename");
ImageDestroy($im);
}
//-----<2D><>ʾͼƬ
flush();
echo "</form>";
echo "<img src=\"$filename\"></img>";
echo "</body>";
?>