From 70f51cef049bd878aa4e25a0c13cac263ef5bad8 Mon Sep 17 00:00:00 2001 From: Adam Amstrong Date: Tue, 6 Dec 2011 22:26:47 +0000 Subject: [PATCH] fix previous commit :) git-svn-id: http://www.observium.org/svn/observer/trunk@2759 61d68cd4-352d-0410-923a-c4978735b2b8 --- billing-calculate.php | 6 +++--- discovery.php | 2 +- html/bandwidth-graph.php | 2 +- html/pages/bill/history.inc.php | 2 +- includes/common.php | 12 +++++++++--- 5 files changed, 15 insertions(+), 9 deletions(-) diff --git a/billing-calculate.php b/billing-calculate.php index 9fdb8a009..b5f85bf1c 100755 --- a/billing-calculate.php +++ b/billing-calculate.php @@ -22,7 +22,7 @@ foreach (dbFetchRows("SELECT * FROM `bills` ORDER BY `bill_name`") as $bill) $datefrom = $day_data['0']; $dateto = $day_data['1']; - $check = dbFetchRow("SELECT * FROM `bill_hist` WHERE bill_id = ? AND bill_datefrom = ? AND bill_dateto = ? LIMIT 1", array($bill['bill_id'], $datefrom, $dateto)); + $check = dbFetchRow("SELECT * FROM `bill_history` WHERE bill_id = ? AND bill_datefrom = ? AND bill_dateto = ? LIMIT 1", array($bill['bill_id'], $datefrom, $dateto)); $period = getPeriod($bill['bill_id'],$datefrom,$dateto); @@ -90,7 +90,7 @@ foreach (dbFetchRows("SELECT * FROM `bills` ORDER BY `bill_name`") as $bill) 'bill_percent' => $percent, 'updated' => array('NOW()')); - dbUpdate($update, 'bill_hist', '`bill_hist_id` = ?', array($bill['bill_id'])); + dbUpdate($update, 'bill_history', '`bill_hist_id` = ?', array($bill['bill_id'])); echo(" Updated history! "); } else { @@ -115,7 +115,7 @@ foreach (dbFetchRows("SELECT * FROM `bills` ORDER BY `bill_name`") as $bill) 'bill_dateto' => $dateto, 'bill_id' => $bill['bill_id'] ); # print_r($update); - dbInsert($update, 'bill_hist'); + dbInsert($update, 'bill_history'); echo(" Generated history! "); } echo("\n\n"); diff --git a/discovery.php b/discovery.php index 222e28f2b..81c6ab446 100755 --- a/discovery.php +++ b/discovery.php @@ -116,7 +116,7 @@ if (file_exists('.svn')) if ($db_rev+0 < 2758) { - include('upgrade-scripts/fix-billing-2757.php'); ## Rewrites all sensor RRDs. Nothing will work without this after 1757 + include('upgrade-scripts/fix-billing-2758.inc.php'); ## Rewrites all sensor RRDs. Nothing will work without this after 1757 } if ($dbu_rev+0 > $db_rev) diff --git a/html/bandwidth-graph.php b/html/bandwidth-graph.php index b79a7db20..2ee7d734e 100644 --- a/html/bandwidth-graph.php +++ b/html/bandwidth-graph.php @@ -68,7 +68,7 @@ if ($imgtype == "historical") { $i = "0"; - foreach (dbFetchRows("SELECT * FROM `bill_hist` WHERE `bill_id` = ? ORDER BY `bill_datefrom` LIMIT 12", array($bill_id)) as $data) { + foreach (dbFetchRows("SELECT * FROM `bill_history` WHERE `bill_id` = ? ORDER BY `bill_datefrom` LIMIT 12", array($bill_id)) as $data) { $datefrom = strftime("%e %b %Y", strtotime($data['bill_datefrom'])); $dateto = strftime("%e %b %Y", strtotime($data['bill_dateto'])); diff --git a/html/pages/bill/history.inc.php b/html/pages/bill/history.inc.php index 9b8bf8ec5..b8f46df23 100644 --- a/html/pages/bill/history.inc.php +++ b/html/pages/bill/history.inc.php @@ -54,7 +54,7 @@ "all"))."\">\"Show Show all details "); - foreach (dbFetchRows("SELECT * FROM `bill_hist` WHERE `bill_id` = ? ORDER BY `bill_datefrom` 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'])) { diff --git a/includes/common.php b/includes/common.php index a0dd93784..fb4edb498 100644 --- a/includes/common.php +++ b/includes/common.php @@ -475,12 +475,18 @@ function format_si($rate, $round = 2) return round($rate, $round).$ext; } -function format_bi($size, $round = '2') +function format_bi($value, $round = '2') { + if($value < "0") + { + $neg = 1; + $value = $value * -1; + } $sizes = Array('', 'k', 'M', 'G', 'T', 'P', 'E'); $ext = $sizes[0]; - for ($i = 1; (($i < count($sizes)) && ($size >= 1024)); $i++) { $size = $size / 1024; $ext = $sizes[$i]; } - return round($size, $round).$ext; + for ($i = 1; (($i < count($sizes)) && ($value >= 1024)); $i++) { $value = $value / 1024; $ext = $sizes[$i]; } + if($neg) { $value = $value * -1; } + return round($value, $round).$ext; } function format_number($value, $base = '1000', $round=2)