= '10') { include 'pages/bill/actions.inc.php'; } if (bill_permitted($bill_id)) { $bill_data = dbFetchRow('SELECT * FROM bills WHERE bill_id = ?', array($bill_id)); $bill_name = $bill_data['bill_name']; $today = str_replace('-', '', dbFetchCell('SELECT CURDATE()')); $yesterday = str_replace('-', '', dbFetchCell('SELECT DATE_SUB(CURDATE(), INTERVAL 1 DAY)')); $tomorrow = str_replace('-', '', dbFetchCell('SELECT DATE_ADD(CURDATE(), INTERVAL 1 DAY)')); $last_month = str_replace('-', '', dbFetchCell('SELECT DATE_SUB(CURDATE(), INTERVAL 1 MONTH)')); $rightnow = $today.date(His); $before = $yesterday.date(His); $lastmonth = $last_month.date(His); $bill_name = $bill_data['bill_name']; $dayofmonth = $bill_data['bill_day']; $day_data = getDates($dayofmonth); $datefrom = $day_data['0']; $dateto = $day_data['1']; $lastfrom = $day_data['2']; $lastto = $day_data['3']; $rate_95th = $bill_data['rate_95th']; $dir_95th = $bill_data['dir_95th']; $total_data = $bill_data['total_data']; $rate_average = $bill_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, '".$config['dateformat']['mysql']['date']."')"); $totext = dbFetchCell("SELECT DATE_FORMAT($dateto, '".$config['dateformat']['mysql']['date']."')"); $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.port_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 ''; } }//end if echo '
Back to Bills
'; print_optionbar_end(); if ($vars['view'] == 'edit' && $_SESSION['userlevel'] >= '10') { include 'pages/bill/edit.inc.php'; } else if ($vars['view'] == 'delete' && $_SESSION['userlevel'] >= '10') { include 'pages/bill/delete.inc.php'; } else if ($vars['view'] == 'reset' && $_SESSION['userlevel'] >= '10') { include 'pages/bill/reset.inc.php'; } else if ($vars['view'] == 'history') { include 'pages/bill/history.inc.php'; } else if ($vars['view'] == 'transfer') { include 'pages/bill/transfer.inc.php'; } else if ($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'; } else if ($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 . ") // //
"); }//end if $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 = ""; }//end if if ($null) { echo "
From: To:
"; }//end if if ($_GET['all']) { $ai = ''; echo "

Entire Data View

$ai"; } else if ($_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 } //end if } else { include 'includes/error-no-perm.inc.php'; }//end if