billing fixes and improvements

git-svn-id: http://www.observium.org/svn/observer/trunk@2764 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2011-12-07 13:52:46 +00:00
parent 810788fd84
commit d0cee15757
7 changed files with 67 additions and 71 deletions
+6 -6
View File
@@ -147,9 +147,6 @@
$ave_count = count($tot_data);
}
$decimal = 0;
# $in_data = formatScale($in_data, $max, $decimal);
# $out_data = formatScale($out_data, $max, $decimal);
# $tot_data = formatScale($tot_data, $max, $decimal);
$average = $average / $ave_count;
for ($x=0;$x<=count($tot_data);$x++) {
array_push($ave_data, $average);
@@ -161,8 +158,11 @@
// Create the graph. These two calls are always required
$graph = new Graph($xsize, $ysize, $graph_name);
$graph->img->SetImgFormat("png");
# $graph->SetScale("textlin",0,0,$start,$end);
$graph->SetScale("textlin");
$graph->title->Set("$graph_name");
#$graph->title->Set("$graph_name");
$graph->title->SetFont(FF_FONT2, FS_BOLD, 10);
$graph->SetMarginColor("white");
$graph->SetFrame(false);
@@ -189,8 +189,8 @@
// Create the bar plots
$barplot_tot = new BarPlot($tot_data);
$barplot_tot->SetLegend("Traffic total");
$barplot_tot->SetColor("#d5d5d5");
$barplot_tot->SetFillColor("#d5d5d5@0.5");
$barplot_tot->SetColor("darkred");
$barplot_tot->SetFillColor("lightred@0.4");
$barplot_tot->value->Show();
$barplot_tot->value->SetFormatCallback('format_bytes_billing_short');
+1 -1
View File
@@ -138,7 +138,7 @@ $graph->img->SetImgFormat("png");
$graph->SetScale('datlin',0,0,$start,$end);
$graph->title->Set("$graph_name");
#$graph->title->Set("$graph_name");
$graph->title->SetFont(FF_FONT2,FS_BOLD,10);
$graph->xaxis->SetFont(FF_FONT1,FS_BOLD);
+4 -4
View File
@@ -28,12 +28,12 @@ $ds_out = "OUTOCTETS";
if($bill['bill_type'] == "cdr") {
$custom_graph = " COMMENT:'\\r' ";
$custom_graph .= " HRULE:" . $rates['rate_95th'] * 1000 . "#cc0000:'95th %ile \: ".formatRates($rates['rate_95th']*1000)." (".$rates['dir_95th'].") (CDR\: ".formatRates($bill['bill_cdr']*1000).")'";
$custom_graph .= " HRULE:" . $rates['rate_95th'] * 1000 * -1 . "#cc0000";
$custom_graph .= " HRULE:" . $rates['rate_95th'] . "#cc0000:'95th %ile \: ".formatRates($rates['rate_95th'])." (".$rates['dir_95th'].") (CDR\: ".formatRates($bill['bill_cdr']).")'";
$custom_graph .= " HRULE:" . $rates['rate_95th'] * -1 . "#cc0000";
} elseif($bill['bill_type'] == "quota") {
$custom_graph = " COMMENT:'\\r' ";
$custom_graph .= " HRULE:" . $rates['rate_average'] * 1000 . "#cc0000:'Usage \: ".formatStorage($rates['total_data']*1024*1024)." (".formatRates($rates['rate_average']*1000).")'";
$custom_graph .= " HRULE:" . $rates['rate_average'] * 1000 * -1 . "#cc0000";
$custom_graph .= " HRULE:" . $rates['rate_average'] . "#cc0000:'Usage \: ".format_bytes_billing($rates['total_data'])." (".formatRates($rates['rate_average']).")'";
$custom_graph .= " HRULE:" . $rates['rate_average'] * -1 . "#cc0000";
}
include("includes/graphs/generic_multi_bits_separated.inc.php");
+8 -22
View File
@@ -24,12 +24,6 @@ if (bill_permitted($bill_id))
$bill_name = $bill_data['bill_name'];
$dayofmonth = $bill_data['bill_day'];
$paidrate = $bill_data['bill_paid_rate'];
$paid_kb = $paidrate / 1000;
$paid_mb = $paid_kb / 1000;
if ($paidrate < 1000000) { $paidrate_text = $paid_kb . "Kbps is the CDR."; }
if ($paidrate >= 1000000) { $paidrate_text = $paid_mb . "Mbps is the CDR."; }
$day_data = getDates($dayofmonth);
@@ -154,7 +148,7 @@ if (bill_permitted($bill_id))
if ($bill_data['bill_type'] == "quota")
{
// The Customer is billed based on a pre-paid quota
// The Customer is billed based on a pre-paid quota with overage in xB
echo("<h4>Quota Bill</h4>");
@@ -162,14 +156,12 @@ if (bill_permitted($bill_id))
$unit = "MB";
$total_data = round($total_data, 2);
echo("Billing Period from " . $fromtext . " to " . $totext . "
<br />Transferred ".formatStorage($total_data * 1000 * 1000)." of ".formatStorage($bill_data['bill_gb'] * 1000 * 1000 * 1000)." (".$percent."%)
<br />Average rate " . formatRates($rate_average * 1000));
<br />Transferred ".format_byes_billing($total_data)." of ".format_bytes_billing($bill_data['bill_quota'])." (".$percent."%)
<br />Average rate " . formatRates($rate_average));
$background = get_percentage_colours($percent);
$right_background = $background['right'];
$left_background = $background['left'];
echo("<p>".print_percentage_bar (350, 20, $perc, NULL, "ffffff", $left_background, $percent . "%", "ffffff", $right_background)."</p>");
echo("<p>".print_percentage_bar (350, 20, $perc, NULL, "ffffff", $background['left'], $percent . "%", "ffffff", $background['right'])."</p>");
$type="&amp;ave=yes";
}
@@ -180,7 +172,7 @@ if (bill_permitted($bill_id))
echo("<h4>CDR / 95th Bill</h4>");
$unit = "kbps";
$cdr = $bill_data['bill_cdr'] *1000;
$cdr = $bill_data['bill_cdr'];
$rate_95th = round($rate_95th, 2);
$percent = round(($rate_95th) / $cdr * 100, 2);
@@ -188,16 +180,11 @@ if (bill_permitted($bill_id))
$type="&amp;95th=yes";
echo("<strong>" . $fromtext . " to " . $totext . "</strong>
<br />Measured ".format_si($rate_95th)."bps of ".format_si($cdr)."bps (".$percent."%)");
<br />Measured ".format_si($rate_95th)."bps of ".format_si($cdr)."bps (".$percent."%) @ 95th %ile");
if ($percent > 100) { $perc = "100"; } else { $perc = $percent; }
if ($perc > '90') { $left_background='c4323f'; $right_background='C96A73';
} elseif ($perc > '75') { $left_background='bf5d5b'; $right_background='d39392';
} elseif ($perc > '50') { $left_background='bf875b'; $right_background='d3ae92';
} elseif ($perc > '25') { $left_background='5b93bf'; $right_background='92b7d3';
} else { $left_background='9abf5b'; $right_background='bbd392'; }
$background = get_percentage_colours($percent);
echo("<p>".print_percentage_bar (350, 20, $perc, NULL, "ffffff", $left_background, $percent . "%", "ffffff", $right_background)."</p>");
echo("<p>".print_percentage_bar (350, 20, $percent, NULL, "ffffff", $background['left'], $percent . "%", "ffffff", $background['right'])."</p>");
# echo("<p>Billing Period : " . $fromtext . " to " . $totext . "<br />
# " . $paidrate_text . " <br />
@@ -206,7 +193,6 @@ if (bill_permitted($bill_id))
# <font face=\"Trebuchet MS, Verdana, Arial, Sans-Serif\" color=" . $bill_color . "><B>" . $rate_95th . "Kbps @ 95th Percentile.</b> (" . $dir_95th . ") (" . $bill_text . ")</font>
# </td><td><img src=\"images/billing-key.png\"></td></tr></table>
# <br />");
}
$lastmonth = dbFetchCell("SELECT UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 1 MONTH))");
+5 -6
View File
@@ -63,7 +63,7 @@
$in['per'] = round(($bill_data['total_data_in'] / $bill_data['total_data'] * 100), 2);
$in['bg'] = get_percentage_colours($in['per']);
$out['data'] = format_number($bill_data['total_data_out'] , $config['billing']['base']);
$out['data'] = format_bytes_billing($bill_data['total_data_out']);
$out['allow'] = $total['allow'];
$out['ave'] = format_bytes_billing($bill_data['total_data_out'] / $cur_days);
$out['est'] = format_bytes_billing($bill_data['total_data_out'] / $cur_days * $total_days);
@@ -84,7 +84,7 @@
$background = get_percentage_colours($per);
$right_background = $background['right'];
$left_background = $background['left'];
$res = print_percentage_bar(350, 20, $perc, NULL, "ffffff", $left_background, $per."%", "ffffff", $right_background);
$res = print_percentage_bar(350, 20, $per, NULL, "ffffff", $left_background, $per."%", "ffffff", $right_background);
return $res;
}
@@ -165,9 +165,8 @@
$mi .= "&amp;x=1190&amp;y=250";
$mi .= "$type'>";
echo("<h3>Billing View</h3>$bi");
#echo("<h3>Previous Bill View</h3>$li");
echo("<h3>24 Hour View</h3>$di");
echo("<h3>Monthly View</h3>$mi");
echo("<h3>Billing Period View</h3>$bi");
echo("<h3>Rolling 24 Hour View</h3>$di");
echo("<h3>Rolling Monthly View</h3>$mi");
?>