= 1000000) { $paidrate_text = $paid_mb . "Mbps is the CDR."; } $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']; $total_data = $rate_data['total_data']; $rate_average = $rate_data['rate_average']; if ($rate_95th > $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')"); echo("

Bill : " . $bill_name . "

"); print_optionbar_start(); if (!$_GET['optb']) { $_GET['optb'] = "details"; } if ($_GET['optb'] == "basic") { echo(""); } echo("Quick Graphs"); if ($_GET['optb'] == "basic") { echo(""); } echo(" | "); if ($_GET['optb'] == "details") { echo(""); } echo("Accurate Graphs"); if ($_GET['optb'] == "details") { echo(""); } if ($_SESSION['userlevel'] == "10") { echo(" | "); if ($_GET['optb'] == "edit") { echo(""); } echo("Edit"); if ($_GET['optb'] == "edit") { echo(""); } echo(" | "); if ($_GET['optb'] == "delete") { echo(""); } echo("Delete"); if ($_GET['optb'] == "delete") { echo(""); } } print_optionbar_end(); # echo("
"); if ($_GET['optb'] == "edit" && $_SESSION['userlevel'] == "10") { include("pages/bill/edit.inc.php"); } elseif ($_GET['optb'] == "delete" && $_SESSION['userlevel'] == "10") { include("pages/bill/delete.inc.php"); } elseif ($_GET['optb'] == "details" || $_GET['optb'] == "basic") { 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) . "
"); } echo("

Bill Summary

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

Quota Bill

"); $percent = round(($total_data / 1024) / $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."%)
Average rate " . formatRates($rate_average * 1000)); $background = get_percentage_colours($percent); $right_background = $background['right']; $left_background = $background['left']; echo("

".print_percentage_bar (350, 20, $perc, NULL, "ffffff", $left_background, $percent . "%", "ffffff", $right_background)."

"); $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']; if ($rate_95th > "1000") { $rate_95th = $rate_95th / 1000; $cdr = $cdr / 1000; $unit = "Mbps"; } if ($rate_95th > "1000") { $rate_95th = $rate_95th / 1000; $cdr = $cdr / 1000; $unit = "Gps"; } $rate_95th = round($rate_95th, 2); $percent = round(($rate_95th) / $cdr * 100, 2); $type="&95th=yes"; echo("" . $fromtext . " to " . $totext . "
Measured ".$rate_95th."$unit of ".$cdr."$unit (".$percent."%)"); 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'; } echo("

".print_percentage_bar (350, 20, $perc, NULL, "ffffff", $left_background, $percent . "%", "ffffff", $right_background)."

"); # 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 ($_GET['optb'] == "details") { $bi = ""; $li = ""; $di = ""; $mi = ""; } else { $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"); } ?>