hacks to billing (this shit needs rewritten so badly)

git-svn-id: http://www.observium.org/svn/observer/trunk@2034 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2011-04-08 11:25:13 +00:00
parent 9b1ec8050d
commit e291e39781
3 changed files with 30 additions and 8 deletions

View File

@@ -9,9 +9,18 @@ if (is_numeric($_GET['id']) && ($config['allow_unauth_graphs'] || bill_permitted
$bill_query = mysql_query("SELECT * FROM `bills` WHERE bill_id = '".mres($_GET['id'])."'");
$bill = mysql_fetch_assoc($bill_query);
$day_data = getDates($bill['bill_day']);
$datefrom = $day_data['0'];
$dateto = $day_data['1'];
# $day_data = getDates($bill['bill_day']);
# $datefrom = $day_data['0'];
# $dateto = $day_data['1'];
#print_r($day_data);
$datefrom = date('YmdHis', $_GET['from']);
$dateto = date('YmdHis', $_GET['to']);
$rates = getRates($_GET['id'], $datefrom, $dateto);

View File

@@ -28,8 +28,8 @@ $rra_out = "OUTOCTETS";
if($bill['bill_type'] == "cdr") {
$custom_graph = " COMMENT:'\\r' ";
$custom_graph .= " HRULE:" . $rates['rate_average'] * 1000 . "#cc0000:'95th %ile \: ".formatRates($rates['rate_95th']*1000)." (".$rates['dir_95th'].") (CDR\: ".formatRates($bill['bill_cdr']*1000).")'";
$custom_graph .= " HRULE:" . $rates['rate_average'] * 1000 * -1 . "#cc0000";
$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";
} 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).")'";

View File

@@ -33,6 +33,8 @@ if (bill_permitted($bill_id))
$day_data = getDates($dayofmonth);
$datefrom = $day_data['0'];
$dateto = $day_data['1'];
$lastfrom = $day_data['2'];
$lastto = $day_data['3'];
$rate_data = getRates($bill_id,$datefrom,$dateto);
$rate_95th = $rate_data['rate_95th'];
$dir_95th = $rate_data['dir_95th'];
@@ -57,6 +59,9 @@ if (bill_permitted($bill_id))
$unixfrom = mysql_result(mysql_query("SELECT UNIX_TIMESTAMP('$datefrom')"), 0);
$unixto = mysql_result(mysql_query("SELECT UNIX_TIMESTAMP('$dateto')"), 0);
$unix_prev_from = mysql_result(mysql_query("SELECT UNIX_TIMESTAMP('$lastfrom')"), 0);
$unix_prev_to = mysql_result(mysql_query("SELECT UNIX_TIMESTAMP('$lastto')"), 0);
echo("<font face=\"Verdana, Arial, Sans-Serif\"><h2>
Bill : " . $bill_name . "</h2>");
@@ -186,6 +191,12 @@ if (bill_permitted($bill_id))
$yesterday = mysql_result(mysql_query("SELECT UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 1 DAY))"), 0);
$rightnow = date(U);
$li = "<img src='graph.php?type=bill_bits&amp;id=" . $bill_id;
$li .= "&amp;from=" . $unix_prev_from . "&amp;to=" . $unix_prev_to;
$li .= "&amp;width=715&amp;height=200&amp;total=1'>";
# $di = "<img src='billing-graph.php?bill_id=" . $bill_id . "&amp;bill_code=" . $_GET['bill_code'];
# $di = $di . "&amp;from=" . $yesterday . "&amp;to=" . $rightnow . "&amp;x=715&amp;y=250";
# $di = $di . "$type'>";
@@ -247,7 +258,9 @@ if (bill_permitted($bill_id))
}
else
{
echo("<h3>Billing View</h3>$bi<h3>24 Hour View</h3>$di");
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("<br /><a href=\"rate.php?" . $_SERVER['QUERY_STRING'] . "&amp;all=yes\">Graph All Data (SLOW)</a>");
}