From 0704a71fc270dbe34b53a67eec79447fce51295b Mon Sep 17 00:00:00 2001 From: Adam Amstrong Date: Fri, 2 Dec 2011 17:11:28 +0000 Subject: [PATCH] implement standard URL scheme for billing. git-svn-id: http://www.observium.org/svn/observer/trunk@2753 61d68cd4-352d-0410-923a-c4978735b2b8 --- html/pages/bill.inc.php | 77 ++++++++++--------- html/pages/bill/history.inc.php | 29 ++++--- .../{bandwidth.inc.php => transfer.inc.php} | 4 - html/pages/bills.inc.php | 14 ++-- html/pages/bills/pmonth.inc.php | 12 +-- 5 files changed, 70 insertions(+), 66 deletions(-) rename html/pages/bill/{bandwidth.inc.php => transfer.inc.php} (97%) diff --git a/html/pages/bill.inc.php b/html/pages/bill.inc.php index 92ce40e11d..c8aee48468 100644 --- a/html/pages/bill.inc.php +++ b/html/pages/bill.inc.php @@ -1,6 +1,7 @@

Bill : " . $bill_name . "

"); @@ -80,67 +86,67 @@ if (bill_permitted($bill_id)) echo("Bill » "); - if (!$_GET['optb']) { $_GET['optb'] = "details"; } - if ($_GET['opta'] == "admin_history") { $_GET['optb'] = $_GET['opta']; } + if (!$vars['view']) { $vars['view'] = "quick"; } + if ($_GET['opta'] == "admin_history") { $vars['view'] = $_GET['opta']; } - if ($_GET['optb'] == "basic") { echo(""); } - echo("Quick Graphs"); - if ($_GET['optb'] == "basic") { echo(""); } + if ($vars['view'] == "basic") { echo(""); } + echo('Quick Graphs'); + if ($vars['view'] == "basic") { echo(""); } echo(" | "); - if ($_GET['optb'] == "details") { echo(""); } - echo("Accurate Graphs"); - if ($_GET['optb'] == "details") { echo(""); } + if ($vars['view'] == "details") { echo(""); } + echo('Accurate Graphs'); + if ($vars['view'] == "details") { echo(""); } echo(" | "); - if ($_GET['optb'] == "bandwidth") { echo(""); } - echo("Bandwidth Graphs"); - if ($_GET['optb'] == "bandwidth") { echo(""); } + if ($vars['view'] == "transfer") { echo(""); } + echo('Transfer Graphs'); + if ($vars['view'] == "transfer") { echo(""); } echo(" | "); - if ($_GET['optb'] == "history") { echo(""); } - echo("Historical Usage"); - if ($_GET['optb'] == "history") { echo(""); } + if ($vars['view'] == "history") { echo(""); } + echo('Historical Usage'); + if ($vars['view'] == "history") { echo(""); } if ($_SESSION['userlevel'] == "10") { echo(" | "); - if ($_GET['optb'] == "edit") { echo(""); } - echo("Edit"); - if ($_GET['optb'] == "edit") { echo(""); } + if ($vars['view'] == "edit") { echo(""); } + echo('Edit'); + if ($vars['view'] == "edit") { echo(""); } echo(" | "); - if ($_GET['optb'] == "delete") { echo(""); } - echo("Delete"); - if ($_GET['optb'] == "delete") { echo(""); } + if ($vars['view'] == "delete") { echo(""); } + echo('Delete'); + if ($vars['view'] == "delete") { echo(""); } } - echo('
Back to Bills
'); + echo('
Back to Bills
'); print_optionbar_end(); - if ($_GET['optb'] == "edit" && $_SESSION['userlevel'] == "10") + if ($vars['view'] == "edit" && $_SESSION['userlevel'] == "10") { include("pages/bill/edit.inc.php"); } - elseif ($_GET['optb'] == "delete" && $_SESSION['userlevel'] == "10") + elseif ($vars['view'] == "delete" && $_SESSION['userlevel'] == "10") { include("pages/bill/delete.inc.php"); } - elseif ($_GET['optb'] == "history") + elseif ($vars['view'] == "history") { include("pages/bill/history.inc.php"); } - elseif ($_GET['optb'] == "bandwidth") + elseif ($vars['view'] == "transfer") { - include("pages/bill/bandwidth.inc.php"); + include("pages/bill/transfer.inc.php"); } - elseif ($_GET['optb'] == "details" || $_GET['optb'] == "basic") { + elseif ($vars['view'] == "quick" || $vars['view'] == "accurate") { $bill_data = dbFetchRow("SELECT * FROM bills WHERE bill_id = ?", array($bill_id)); @@ -202,10 +208,7 @@ if (bill_permitted($bill_id)) echo("

Billed Ports

"); - $ports = dbFetchRows("SELECT * FROM `bill_ports` AS B, `ports` AS P, `devices` AS D - WHERE B.bill_id = ? AND P.interface_id = B.port_id - AND D.device_id = P.device_id", array($bill_id)); - + ### Collected Earlier foreach ($ports as $port) { echo(generate_port_link($port) . " on " . generate_device_link($port) . "
"); @@ -219,11 +222,11 @@ if (bill_permitted($bill_id)) echo("

Quota Bill

"); - $percent = round(($total_data / 1024) / $bill_data['bill_gb'] * 100, 2); + $percent = round(($total_data / 1000) / $bill_data['bill_gb'] * 100, 2); $unit = "MB"; $total_data = round($total_data, 2); echo("Billing Period from " . $fromtext . " to " . $totext . " -
Transferred ".formatStorage($total_data * 1024 * 1024)." of ".formatStorage($bill_data['bill_gb'] * 1024 * 1024 * 1024)." (".$percent."%) +
Transferred ".formatStorage($total_data * 1000 * 1000)." of ".formatStorage($bill_data['bill_gb'] * 1000 * 1000 * 1000)." (".$percent."%)
Average rate " . formatRates($rate_average * 1000)); $background = get_percentage_colours($percent); @@ -276,7 +279,7 @@ if (bill_permitted($bill_id)) $yesterday = dbFetchCell("SELECT UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 1 DAY))"); $rightnow = date(U); - if ($_GET['optb'] == "details") { + if ($vars['view'] == "accurate") { $bi = " 'yes')); + $url = $PHP_SELF."/bill/".$bill_id."/history/detail=all/"; + echo(" @@ -48,10 +51,10 @@ - + "); - foreach (dbFetchRows("SELECT * FROM `bill_history` WHERE `bill_id` = ? ORDER BY `bill_datefrom` AND `bill_dateto` DESC LIMIT 24", array($bill_id)) as $history) + foreach (dbFetchRows("SELECT * FROM `bill_history` WHERE `bill_id` = ? ORDER BY `bill_datefrom` DESC LIMIT 24", array($bill_id)) as $history) { if (bill_permitted($history['bill_id'])) { @@ -85,6 +88,8 @@ $total_data = (($type == "Quota") ? "".$total_data."" : $total_data); $rate_95th = (($type == "CDR") ? "".$rate_95th."" : $rate_95th); + $url = generate_url($vars, array('detail' => $history['id'])); + echo(" @@ -98,15 +103,15 @@ "); - if ($detail == ($i+1) || $detail == "all") { - $img['bitrate'] = showDetails($history['bill_id'], "bitrate", strtotime($datefrom), strtotime($dateto), $type); - $img['bw_day'] = showDetails($history['bill_id'], "day", strtotime($datefrom), strtotime($dateto)); - $img['bw_hour'] = showDetails($history['bill_id'], "hour", strtotime($datefrom), strtotime($dateto)); + if ($vars['detail'] == $history['id'] || $vars['detail'] == "all") { + $img['bitrate'] = showDetails($bill_id, "bitrate", strtotime($datefrom), strtotime($dateto), $type); + $img['bw_day'] = showDetails($bill_id, "day", strtotime($datefrom), strtotime($dateto)); + $img['bw_hour'] = showDetails($bill_id, "hour", strtotime($datefrom), strtotime($dateto)); echo(" - + - + "); diff --git a/html/pages/bills/pmonth.inc.php b/html/pages/bills/pmonth.inc.php index a3855f8fc2..a6b0e707ac 100644 --- a/html/pages/bills/pmonth.inc.php +++ b/html/pages/bills/pmonth.inc.php @@ -32,7 +32,7 @@ $percent = $history['bill_percent']; $dir_95th = $history['dir_95th']; $rate_95th = formatRates($history['rate_95th'] * 1000); - $total_data = formatStorage($history['traf_total'] * 1024 * 1024); + $total_data = formatStorage($history['traf_total'] * 1000 * 1000); $background = get_percentage_colours($percent); $row_colour = ((!is_integer($i/2)) ? $list_colour_a : $list_colour_b); @@ -45,11 +45,11 @@ $out = formatRates($history['rate_95th_out'] * 1000); $overuse = (($history['bill_overuse'] <= 0) ? "-" : "".formatRates($history['bill_overuse'] * 1000).""); } elseif ($type == "Quota") { - $allowed = formatStorage($history['bill_allowed'] * 1024 * 1024); - $used = formatStorage($history['total_data'] * 1024 * 1024); - $in = formatStorage($history['traf_in'] * 1024 * 1024); - $out = formatStorage($history['traf_out'] * 1024 * 1024); - $overuse = (($history['bill_overuse'] <= 0) ? "-" : "".formatStorage($history['bill_overuse'] * 1024 * 1024).""); + $allowed = formatStorage($history['bill_allowed'] * 1000 * 1000); + $used = formatStorage($history['total_data'] * 1000 * 1000); + $in = formatStorage($history['traf_in'] * 1000 * 1000); + $out = formatStorage($history['traf_out'] * 1000 * 1000); + $overuse = (($history['bill_overuse'] <= 0) ? "-" : "".formatStorage($history['bill_overuse'] * 1000 * 1000).""); } $total_data = (($type == "Quota") ? "".$total_data."" : $total_data);
Total 95 percentile Overusage\"Show Show all details "all"))."\">\"Show Show all details
$overuse ".print_percentage_bar(250, 20, $perc, NULL, "ffffff", $background['left'], $percent."%", "ffffff", $background['right'])." - \"Show + \"Show \"PDF
diff --git a/html/pages/bill/bandwidth.inc.php b/html/pages/bill/transfer.inc.php similarity index 97% rename from html/pages/bill/bandwidth.inc.php rename to html/pages/bill/transfer.inc.php index d8c0f585ed..e600fbac4f 100644 --- a/html/pages/bill/bandwidth.inc.php +++ b/html/pages/bill/transfer.inc.php @@ -36,10 +36,6 @@ echo("

Billed Ports

"); - $ports = dbFetchRows("SELECT * FROM `bill_ports` AS B, `ports` AS P, `devices` AS D - WHERE B.bill_id = ? AND P.interface_id = B.port_id - AND D.device_id = P.device_id", array($bill_id)); - foreach ($ports as $port) { echo(generate_port_link($port) . " on " . generate_device_link($port) . "
"); diff --git a/html/pages/bills.inc.php b/html/pages/bills.inc.php index 129b0d326f..ed8c22096e 100644 --- a/html/pages/bills.inc.php +++ b/html/pages/bills.inc.php @@ -117,12 +117,12 @@ elseif ($_GET['opta'] == "add") $overuse = (($overuse <= 0) ? "-" : "".formatRates($overuse * 1000).""); } elseif ($bill['bill_type'] == "quota") { $type = "Quota"; - $allowed = formatStorage($bill['bill_gb']* 1024 * 1024 * 1024); - $used = formatStorage($rate_data['total_data'] * 1024 * 1024); - $percent = round(($rate_data['total_data'] / ($bill['bill_gb'] * 1024)) * 100,2); + $allowed = formatStorage($bill['bill_gb']* 1000 * 1000 * 1000); + $used = formatStorage($rate_data['total_data'] * 1000 * 1000); + $percent = round(($rate_data['total_data'] / ($bill['bill_gb'] * 1000)) * 100,2); $background = get_percentage_colours($percent); - $overuse = $rate_data['total_data'] - ($bill['bill_gb'] * 1024); - $overuse = (($overuse <= 0) ? "-" : "".formatStorage($overuse * 1024 * 1024).""); + $overuse = $rate_data['total_data'] - ($bill['bill_gb'] * 1000); + $overuse = (($overuse <= 0) ? "-" : "".formatStorage($overuse * 1000 * 1000).""); } $right_background = $background['right']; @@ -132,14 +132,14 @@ elseif ($_GET['opta'] == "add") echo("
".$bill['bill_name']."
".strftime("%F", strtotime($datefrom))." to ".strftime("%F", strtotime($dateto))."
"bill", 'bill_id' => $bill['bill_id']))."'>".$bill['bill_name']."
".strftime("%F", strtotime($datefrom))." to ".strftime("%F", strtotime($dateto))."
$notes $type $allowed $used $overuse ".print_percentage_bar (250, 20, $perc, NULL, "ffffff", $background['left'], $percent . "%", "ffffff", $background['right'])."Edit Edit "bill", 'bill_id' => $bill['bill_id'], 'view' => "edit"))."'>Edit Edit