$paid_kb) { $over = $rate_95th - $paid_kb; $bill_text = $over . "Kbit excess."; $bill_color = "#cc0000"; } else { $under = $paid_kb - $rate_95th; $bill_text = $under . "Kbit headroom."; $bill_color = "#0000cc"; } $fromtext = dbFetchCell("SELECT DATE_FORMAT($datefrom, '%M %D %Y')"); $totext = dbFetchCell("SELECT DATE_FORMAT($dateto, '%M %D %Y')"); $unixfrom = dbFetchCell("SELECT UNIX_TIMESTAMP('$datefrom')"); $unixto = dbFetchCell("SELECT UNIX_TIMESTAMP('$dateto')"); $unix_prev_from = dbFetchCell("SELECT UNIX_TIMESTAMP('$lastfrom')"); $unix_prev_to = dbFetchCell("SELECT UNIX_TIMESTAMP('$lastto')"); # Speeds up loading for other included pages by setting it before progessing of mysql data! $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)); echo("

Bill : " . $bill_data['bill_name'] . "

"); print_optionbar_start(); echo("Bill » "); if (!$vars['view']) { $vars['view'] = "quick"; } if ($vars['view'] == "quick") { echo(""); } echo('Quick Graphs'); if ($vars['view'] == "quick") { echo(""); } echo(" | "); if ($vars['view'] == "accurate") { echo(""); } echo('Accurate Graphs'); if ($vars['view'] == "accurate") { echo(""); } echo(" | "); if ($vars['view'] == "transfer") { echo(""); } echo('Transfer Graphs'); if ($vars['view'] == "transfer") { echo(""); } echo(" | "); if ($vars['view'] == "history") { echo(""); } echo('Historical Usage'); if ($vars['view'] == "history") { echo(""); } if ($_SESSION['userlevel'] == "10") { echo(" | "); if ($vars['view'] == "edit") { echo(""); } echo('Edit'); if ($vars['view'] == "edit") { echo(""); } echo(" | "); if ($vars['view'] == "delete") { echo(""); } echo('Delete'); if ($vars['view'] == "delete") { echo(""); } echo(" | "); if ($vars['view'] == "reset") { echo(""); } echo('Reset'); if ($vars['view'] == "reset") { echo(""); } } echo('
Back to Bills
'); print_optionbar_end(); if ($vars['view'] == "edit" && $_SESSION['userlevel'] == "10") { include("pages/bill/edit.inc.php"); } elseif ($vars['view'] == "delete" && $_SESSION['userlevel'] == "10") { include("pages/bill/delete.inc.php"); } elseif ($vars['view'] == "reset" && $_SESSION['userlevel'] == "10") { include("pages/bill/reset.inc.php"); } elseif ($vars['view'] == "history") { include("pages/bill/history.inc.php"); } elseif ($vars['view'] == "transfer") { include("pages/bill/transfer.inc.php"); } elseif ($vars['view'] == "quick" || $vars['view'] == "accurate") { echo("

Billed Ports

"); ### Collected Earlier foreach ($ports as $port) { echo(generate_port_link($port) . " on " . generate_device_link($port) . "
"); } echo("

Bill Summary

"); if ($bill_data['bill_type'] == "quota") { // The Customer is billed based on a pre-paid quota with overage in xB echo("

Quota Bill

"); $percent = round(($total_data) / $bill_data['bill_quota'] * 100, 2); $unit = "MB"; $total_data = round($total_data, 2); echo("Billing Period from " . $fromtext . " to " . $totext); echo("
Transferred ".format_bytes_billing($total_data)." of ".format_bytes_billing($bill_data['bill_quota'])." (".$percent."%)"); echo("
Average rate " . formatRates($rate_average)); $background = get_percentage_colours($percent); echo("

".print_percentage_bar (350, 20, $perc, NULL, "ffffff", $background['left'], $percent . "%", "ffffff", $background['right'])."

"); $type="&ave=yes"; } elseif ($bill_data['bill_type'] == "cdr") { // The customer is billed based on a CDR with 95th%ile overage echo("

CDR / 95th Bill

"); $unit = "kbps"; $cdr = $bill_data['bill_cdr']; $rate_95th = round($rate_95th, 2); $percent = round(($rate_95th) / $cdr * 100, 2); $type="&95th=yes"; echo("" . $fromtext . " to " . $totext . "
Measured ".format_si($rate_95th)."bps of ".format_si($cdr)."bps (".$percent."%) @ 95th %ile"); $background = get_percentage_colours($percent); echo("

".print_percentage_bar (350, 20, $percent, NULL, "ffffff", $background['left'], $percent . "%", "ffffff", $background['right'])."

"); # echo("

Billing Period : " . $fromtext . " to " . $totext . "
# " . $paidrate_text . "
# " . $total_data . "MB transfered in the current billing cycle.
# " . $rate_average . "Kbps Average during the current billing cycle.

# " . $rate_95th . "Kbps @ 95th Percentile. (" . $dir_95th . ") (" . $bill_text . ") # #
"); } $lastmonth = dbFetchCell("SELECT UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 1 MONTH))"); $yesterday = dbFetchCell("SELECT UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 1 DAY))"); $rightnow = date(U); if ($vars['view'] == "accurate") { $bi = ""; $li = ""; $di = ""; $mi = ""; } if ($null) { echo("
From: To:
"); } if ($_GET['all']) { $ai = ""; echo("

Entire Data View

$ai"); } elseif ($_GET['custom']) { $cg = ""; echo("

Custom Graph

$cg"); } else { echo("

Billing View

$bi"); # echo("

Previous Bill View

$li"); echo("

24 Hour View

$di"); echo("

Monthly View

$mi"); # echo("
Graph All Data (SLOW)"); } } # End if details } else { include("includes/error-no-perm.inc.php"); } ?>