From 9f136c06de2bdafa8c04a892ca322f43d436f464 Mon Sep 17 00:00:00 2001 From: Richard Lawley Date: Mon, 7 Mar 2016 12:48:27 +0000 Subject: [PATCH 1/4] Update Billing UI to match rest of app --- html/includes/modal/new_bill.inc.php | 67 +++++ html/pages/bill.inc.php | 276 +++++++++----------- html/pages/bill/addoreditbill.inc.php | 89 +++++++ html/pages/bill/delete.inc.php | 12 +- html/pages/bill/edit.inc.php | 347 +++++++++----------------- html/pages/bill/reset.inc.php | 9 +- html/pages/bill/transfer.inc.php | 157 +++++++----- html/pages/bills.inc.php | 239 ++++-------------- html/pages/bills/search.inc.php | 26 +- 9 files changed, 557 insertions(+), 665 deletions(-) create mode 100644 html/includes/modal/new_bill.inc.php create mode 100644 html/pages/bill/addoreditbill.inc.php diff --git a/html/includes/modal/new_bill.inc.php b/html/includes/modal/new_bill.inc.php new file mode 100644 index 0000000000..7cd4196016 --- /dev/null +++ b/html/includes/modal/new_bill.inc.php @@ -0,0 +1,67 @@ + + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. Please see LICENSE.txt at the top level of + * the source code distribution for details. + */ +if(is_admin() !== false) { + if (is_numeric($vars['port'])) { + $port = dbFetchRow('SELECT * FROM `ports` AS P, `devices` AS D WHERE `port_id` = ? AND D.device_id = P.device_id', array($vars['port'])); + } +?> + + + +

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

'; - - print_optionbar_start(); - - echo "Bill » "; - + if (!$vars['view']) { $vars['view'] = 'quick'; } + + function print_port_list() { + global $ports; +?>
+
+

Billed Ports

+
+
+ +
+ on +
+ +
+
+ - if ($vars['view'] == 'quick') { - echo ""; +

+ +Bill » "; + $menu_options = array( + 'quick' => 'Quick Graphs', + 'accurate' => 'Accurate Graphs', + 'transfer' => 'Transfer Graphs', + 'history' => 'Historical Graphs' + ); + if($_SESSION['userlevel'] >= '10') + { + $menu_options['edit'] = 'Edit'; + $menu_options['delete'] = 'Delete'; + $menu_options['reset'] = 'Reset'; } - - 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') { + $sep = ''; + foreach ($menu_options as $option => $text) { + echo $sep; + if ($vars['view'] == $option) { echo ""; } - echo 'Edit'; - if ($vars['view'] == 'edit') { + echo generate_link($text, $vars, array('view' => $option)); + if ($vars['view'] == $option) { 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 - + $sep = ' | '; + } + echo '
Back to Bills
'; print_optionbar_end(); @@ -166,59 +141,71 @@ if (bill_permitted($bill_id)) { 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).'
'; - } + +

Quota Bill

+ +

+ CDR / 95th Bill +

+ +Billing Period from to +

- echo '

Bill Summary

'; - - if ($bill_data['bill_type'] == 'quota') { +
+
+ +
+
+
+
+

+ Bill Summary +

+
+ + +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, $percent, null, 'ffffff', $background['left'], $percent.'%', 'ffffff', $background['right']).'

'; - $type = '&ave=yes'; +?> + + +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'; + + +
+ of + - Average rate + + of (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 +"; $li = " - +?> +
+
+

Billing View

+
+ +
+ +
+
+

24 Hour View

+
+ +
-
- - - - - - 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 +
+
+

Monthly View

+
+ +
+ \ No newline at end of file diff --git a/html/pages/bill/addoreditbill.inc.php b/html/pages/bill/addoreditbill.inc.php new file mode 100644 index 0000000000..75e64ff201 --- /dev/null +++ b/html/pages/bill/addoreditbill.inc.php @@ -0,0 +1,89 @@ +
+ +
+ +
+
+
+ +
+ + +
+
+
+
+ +
+ +
+
+ +
+
+
+ +
+ +
+
+ +
+
+
+
+ +
+ +
+
+
+

Optional Information

+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ + \ No newline at end of file diff --git a/html/pages/bill/delete.inc.php b/html/pages/bill/delete.inc.php index 6a7d247b50..e02666b40d 100644 --- a/html/pages/bill/delete.inc.php +++ b/html/pages/bill/delete.inc.php @@ -10,8 +10,12 @@ } -

Delete Bill

-
+ +
+
+
+ +

Delete Bill

@@ -31,4 +35,8 @@
+
+
+
+ diff --git a/html/pages/bill/edit.inc.php b/html/pages/bill/edit.inc.php index 3fd69c3612..9c5a84dcab 100644 --- a/html/pages/bill/edit.inc.php +++ b/html/pages/bill/edit.inc.php @@ -60,240 +60,121 @@ ); } }//end if - ?> -
- - -

Bill Properties

-
-
-
- - +
+
+
+
+

Bill Properties

+
+
+ + + + +
+
+ +
+
+ +
-
-
-
- -
-
- -
-
- -
-
-
- - -
-
- - -
-
-
-

Optional Information

-
-
-
- - -
-
-
-
-
-
- - -
-
-
-
-
-
- - -
-
- - -
-

Billed Ports

-
-
- ", $devicebtn); - $devicebtn = str_replace("
',;", "
',", $devicebtn); - $portbtn = str_replace('interface-upup', 'btn', generate_port_link($port)); - $portbtn = str_replace('interface-updown', 'btn btn-warning', $portbtn); - $portbtn = str_replace('interface-downdown', 'btn btn-warning', $portbtn); - $portbtn = str_replace('interface-admindown', 'btn btn-warning disabled', $portbtn); - $portbtn = str_replace("overlib('", "overlib('
", $portbtn); - $portbtn = str_replace("
',;", "
',", $portbtn); - $portalias = (empty($port['ifAlias']) ? '' : ' - '.$port['ifAlias'].''); - $devicebtn = str_replace('">'.$port['hostname'], '" style="color: #000;"> '.$port['hostname'], $devicebtn); - $portbtn = str_replace('">'.strtolower($port['ifName']), '" style="color: #000;"> '.$port['ifName'].''.$portalias, $portbtn); - echo '
\n"; - echo " \n"; - echo ' \n"; - echo "
\n"; - echo "
\n"; - echo "
\n"; - echo ' '.$devicebtn."\n"; - echo ' '.$portbtn."\n"; - echo "
\n"; - echo "
\n"; - echo ' Remove Interface\n"; - echo "
\n"; - echo "
\n"; - } - - if (!$emptyCheck) { - echo "
\n"; - echo " There are no ports assigned to this bill\n"; - echo "
\n"; - } - } - ?>
- -
- - -
-

Add Port

-
-
-
- - +
+
+
+

Billed Ports

+
+
+
+ +
+ +
+ + + + + + + + + +
+ +
There are no ports assigned to this bill + + +
+ + +
+ +

Add Port

+ +
+ + + +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
-
-
-
- - -
-
- - +
diff --git a/html/pages/bill/reset.inc.php b/html/pages/bill/reset.inc.php index 728963abdb..5dc2b18244 100644 --- a/html/pages/bill/reset.inc.php +++ b/html/pages/bill/reset.inc.php @@ -12,8 +12,10 @@ } -

Reset Bill

-
+
+
+
+

Reset Bill

@@ -39,4 +41,7 @@
+
+
+
\ No newline at end of file diff --git a/html/pages/bill/transfer.inc.php b/html/pages/bill/transfer.inc.php index 8898382943..bcbc60beef 100644 --- a/html/pages/bill/transfer.inc.php +++ b/html/pages/bill/transfer.inc.php @@ -30,12 +30,6 @@ $lastmonth = dbFetchCell('SELECT UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 1 $yesterday = dbFetchCell('SELECT UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 1 DAY))'); $rightnow = date(U); -echo '

Billed Ports

'; - -foreach ($ports as $port) { - echo generate_port_link($port).' on '.generate_device_link($port).'
'; -} - $cur_days = date('d', (strtotime('now') - strtotime($datefrom))); $total_days = date('d', (strtotime($dateto) - strtotime($datefrom))); @@ -81,65 +75,84 @@ function showPercent($per) { $background = get_percentage_colours($per); $right_background = $background['right']; $left_background = $background['left']; - $res = print_percentage_bar(350, 20, $per, null, 'ffffff', $left_background, $per.'%', 'ffffff', $right_background); + $res = print_percentage_bar(200, 20, $per, null, 'ffffff', $left_background, $per.'%', 'ffffff', $right_background); return $res; }//end showPercent() +?> -echo '

Bill Summary

'; -echo '

Quota Bill (Billing Period from '.$fromtext.' to '.$totext.')

'; -echo ''; -echo ' '; -echo ' '; -echo ' '; -echo ' '; -echo ' '; -echo ' '; -echo ' '; -echo ' '; -echo ' '; -echo ' '; -echo ' '; -echo ' '; -echo ' '; -echo ' '; -echo ' '; -echo ' '; -echo ' '; -echo ' '; +

Transfer Report

+Billing Period from to +

-echo ' '; -echo ' '; -echo ' '; -echo ' '; -echo ' '; -echo ' '; -echo ' '; -echo ' '; -echo ' '; -echo ' '; -echo ' '; -echo ' '; -echo ' '; -echo ' '; -echo ' '; -echo ' '; -echo ' '; -echo ' '; -if ($ousage['over'] > 0 && $bill_data['bill_type'] == 'quota') { - echo ' '; - echo ' '; - echo ' '; - echo ' '; - echo ' '; - echo ' '; - echo ' '; - echo ' '; -} +
+
+ +
+
+
+
+

+ Bill Summary +

+
+
BandwidthUsedAllowedAverageEstimated
Transferred:'.$total['data'].''.$total['allow'].''.$total['ave'].''.$total['est'].''.showPercent($total['per']).'
Inbound:'.$in['data'].''.$in['allow'].''.$in['ave'].''.$in['est'].''.showPercent($in['per']).'
Outbound:'.$out['data'].''.$out['allow'].''.$out['ave'].''.$out['est'].''.showPercent($out['per']).'
Already overusage:'.$ousage['data'].''.$ousage['allow'].''.$ousage['ave'].''.$ousage['est'].''.showPercent($ousage['per']).'
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 && $bill_data['bill_type'] == 'quota') { ?> + + + + + + + + + + + +
BandwidthUsedAllowedAverageEstimated
Transferred
Inbound
Outbound
Already overusage
+
+
+
-echo ''; + +"; +?> -echo "

Billing Period View

$bi"; -echo "

Rolling 24 Hour View

$di"; -echo "

Rolling Monthly View

$mi"; +
+
+

Billing Period View

+
+
+ +
+
+ +
+
+

Rolling 24 Hour View

+
+
+ +
+
+ +
+
+

Rolling Monthly View

+
+
+ +
+
\ No newline at end of file diff --git a/html/pages/bills.inc.php b/html/pages/bills.inc.php index f9fef2120c..fbb62fabed 100644 --- a/html/pages/bills.inc.php +++ b/html/pages/bills.inc.php @@ -1,6 +1,13 @@ '; - if (is_numeric($bill_id) && is_numeric($_POST['port'])) { dbInsert(array('bill_id' => $bill_id, 'port_id' => $_POST['port']), 'bill_ports'); - $message .= $message_break.'Port '.mres($_POST['port']).' added!'; - $message_break .= '
'; } + + header('Location: /' . generate_url(array('page' => 'bill', 'bill_id' => $bill_id))); + exit(); } $pagetitle[] = 'Billing'; @@ -86,171 +91,12 @@ if ($vars['view'] == 'history') { include 'pages/bills/search.inc.php'; include 'pages/bills/pmonth.inc.php'; } -else if ($vars['view'] == 'add') { - if (is_numeric($vars['port'])) { - $port = dbFetchRow('SELECT * FROM `ports` AS P, `devices` AS D WHERE `port_id` = ? AND D.device_id = P.device_id', array($vars['port'])); - } - -?> - -Bill » "; - if (!$vars['view']) { - $vars['view'] = 'add'; - } - - if ($_SESSION['userlevel'] >= '10') { - if ($vars['view'] == 'add') { - echo ""; - } - - echo 'Add'; - if ($vars['view'] == 'add') { - echo ''; - } - } - - echo ''; - print_optionbar_end(); -?> - -

Bill : Add Bill

- -
- - -'.$port['hostname'], '" style="color: #000;"> '.$port['hostname'], $devicebtn); - $devicebtn = str_replace("overlib('", "overlib('
", $devicebtn); - $devicebtn = str_replace("
',;", "
',", $devicebtn); - $portbtn = str_replace('">'.strtolower($port['ifName']), '" style="color: #000;"> '.$port['ifName'].''.$portalias, $portbtn); - $portbtn = str_replace("overlib('", "overlib('
", $portbtn); - $portbtn = str_replace("
',;", "
',", $portbtn); - echo "
\n"; - echo ' \n"; - echo " Ports\n"; - echo "
\n"; - echo "
\n"; - echo "
\n"; - echo ' '.$devicebtn."\n"; - echo ' '.$portbtn."\n"; - echo "
\n"; - echo "
\n"; - echo "
\n"; - echo "
\n"; - } -?> - -
- -
- -
-
-
-
-
- -
- CDR 95th - Quota -
-
-
-
-
-
-
- -
-
- -
-
-
-
- -
-
- -
- -
-
-
-
-

Optional Information

-
- -
- -
-
-
-
-
- -
- -
-
-
-
-
- -
- -
-
-
-
- -
- - - + include 'includes/modal/new_bill.inc.php'; +?> + + @@ -259,7 +105,9 @@ else { - "; + + + - - - - - - - - - - "; - - $i++; - } +?> + + + + + + + + + + + + +
Billing name TypeOverusage
'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, $percent, null, 'ffffff', $background['left'], $percent.'%', 'ffffff', $background['right'])." 'bill', 'bill_id' => $bill['bill_id'], 'view' => 'edit'))."'>Edit Edit
+ 'bill', 'bill_id' => $bill['bill_id'])) ?>'> +
+ to +
'bill', 'bill_id' => $bill['bill_id'], 'view' => 'edit')) ?>'>Edit Edit
+ + +'; } diff --git a/html/pages/bills/search.inc.php b/html/pages/bills/search.inc.php index b4662ca602..ffa5f6e7f6 100644 --- a/html/pages/bills/search.inc.php +++ b/html/pages/bills/search.inc.php @@ -5,47 +5,39 @@ ?>
-
+
Bills -
-
-
-
-
-
-
-
-
- -
+ + +
Current Billing Period Current Billing Period'; + echo ' Current Billing Period'; } else { // FIXME - generate_url - echo 'Previous Billing Period Previous Billing Period'; + echo ' Previous Billing Period'; } ?> -
-
- Add Add Bill += 10) { ?> + +
From bd640ebc084d371ffc2d3ea3e57372a04d3c0234 Mon Sep 17 00:00:00 2001 From: Richard Lawley Date: Tue, 8 Mar 2016 18:45:55 +0000 Subject: [PATCH 2/4] Update History Page to match --- html/pages/bill/history.inc.php | 48 ++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 19 deletions(-) diff --git a/html/pages/bill/history.inc.php b/html/pages/bill/history.inc.php index 6770271c82..95de8a76b2 100644 --- a/html/pages/bill/history.inc.php +++ b/html/pages/bill/history.inc.php @@ -9,9 +9,18 @@ $img['his'] = ''; +?> -echo $img['his']; +

Historical Usage

+
+
+

Monthly Usage

+
+ +
+ + 'yes')); $url = $PHP_SELF.'/bill/'.$bill_id.'/history/detail=all/'; -echo ' +echo '
+ - - - - - - - - - - + + + + + + + + + '; + + + + '; 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'])) { @@ -68,7 +80,6 @@ foreach (dbFetchRows('SELECT * FROM `bill_history` WHERE `bill_id` = ? ORDER BY $total_data = format_number($history['traf_total'], $config['billing']['base']); $background = get_percentage_colours($percent); - $row_colour = ((!is_integer($i / 2)) ? $list_colour_a : $list_colour_b); if ($type == 'CDR') { $allowed = formatRates($history['bill_allowed']); @@ -91,7 +102,7 @@ foreach (dbFetchRows('SELECT * FROM `bill_history` WHERE `bill_id` = ? ORDER BY $url = generate_url($vars, array('detail' => $history['bill_hist_id'])); echo ' - + @@ -123,9 +134,8 @@ foreach (dbFetchRows('SELECT * FROM `bill_history` WHERE `bill_id` = ? ORDER BY '; } - - $i++; } //end if }//end foreach -echo '
PeriodTypeAllowedInboundOutboundTotal95th %ileOverusage + PeriodTypeAllowedInboundOutboundTotal95th %ileOverusage Show details Show all details - -
'.strftime('%Y-%m-%d', strtotime($datefrom)).' to '.strftime('%Y-%m-%d', strtotime($dateto))." $type
'; +echo ' +'; From fca483439ea2e0e34e19e3fd6c102698c0fea3e4 Mon Sep 17 00:00:00 2001 From: Richard Lawley Date: Tue, 8 Mar 2016 19:12:15 +0000 Subject: [PATCH 3/4] Remove Edit link if not admin --- html/pages/bills.inc.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/html/pages/bills.inc.php b/html/pages/bills.inc.php index fbb62fabed..01deb9d873 100644 --- a/html/pages/bills.inc.php +++ b/html/pages/bills.inc.php @@ -154,7 +154,11 @@ else { - 'bill', 'bill_id' => $bill['bill_id'], 'view' => 'edit')) ?>'>Edit Edit + + = 10) { ?> + 'bill', 'bill_id' => $bill['bill_id'], 'view' => 'edit')) ?>'>Edit Edit + + From 972429838b7c2f935257ada8c39c4721244f2dfe Mon Sep 17 00:00:00 2001 From: Richard Lawley Date: Wed, 9 Mar 2016 08:26:32 +0000 Subject: [PATCH 4/4] Redirect to edit page afer add bill --- html/pages/bills.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html/pages/bills.inc.php b/html/pages/bills.inc.php index 01deb9d873..759a0697d1 100644 --- a/html/pages/bills.inc.php +++ b/html/pages/bills.inc.php @@ -79,7 +79,7 @@ if ($_POST['addbill'] == 'yes') { dbInsert(array('bill_id' => $bill_id, 'port_id' => $_POST['port']), 'bill_ports'); } - header('Location: /' . generate_url(array('page' => 'bill', 'bill_id' => $bill_id))); + header('Location: /' . generate_url(array('page' => 'bill', 'bill_id' => $bill_id, 'view' => 'edit'))); exit(); }