From 6ad7d78c13e0d4ff5f244620cefeb0f2dbdecb16 Mon Sep 17 00:00:00 2001
From: Robert Anderson <randerson@lbsd.net>
Date: Fri, 5 Mar 2010 08:28:07 +0000
Subject: [PATCH] * Calculate totals based on byte values of all log lines,
 then round up to nearest Mbyte

 webgui/ajax.php                                 |    8 +-
 webgui/include/ajax/functions/AdminUserLogs.php |   80 ++++++++----------------
 webgui/include/ajax/functions/WiSPUserLogs.php  |   80 ++++++++----------------
 webgui/js/app/windows/AdminUserLogs.js          |   11 ++-
 webgui/js/app/windows/WiSPUserLogs.js           |   11 ++-
 webui/user/index.php                            |   68 ++++++++++----------
 webui/user/logs.php                             |   48 ++++++--------
 7 files changed, 131 insertions(+), 175 deletions(-)
---
 webgui/ajax.php                               |  8 +-
 .../include/ajax/functions/AdminUserLogs.php  | 80 +++++++------------
 .../include/ajax/functions/WiSPUserLogs.php   | 80 +++++++------------
 webgui/js/app/windows/AdminUserLogs.js        | 11 ++-
 webgui/js/app/windows/WiSPUserLogs.js         | 11 ++-
 webui/user/index.php                          | 68 ++++++++--------
 webui/user/logs.php                           | 48 +++++------
 7 files changed, 131 insertions(+), 175 deletions(-)

diff --git a/webgui/ajax.php b/webgui/ajax.php
index dd99c5cb..0c626fd4 100644
--- a/webgui/ajax.php
+++ b/webgui/ajax.php
@@ -610,8 +610,8 @@
 			$res->addField('CalledStationID','string');
 			$res->addField('AcctSessionID','string');
 			$res->addField('FramedIPAddress','string');
-			$res->addField('AcctInputMbyte','int');
-			$res->addField('AcctOutputMbyte','int');
+			$res->addField('AcctInput','float');
+			$res->addField('AcctOutput','float');
 			$res->addField('AcctSessionTime','int');
 			$res->addField('ConnectTermReason','string');
 			$res->parseArray($rawData);
@@ -984,8 +984,8 @@
 			$res->addField('CalledStationID','string');
 			$res->addField('AcctSessionID','string');
 			$res->addField('FramedIPAddress','string');
-			$res->addField('AcctInputMbyte','int');
-			$res->addField('AcctOutputMbyte','int');
+			$res->addField('AcctInput','float');
+			$res->addField('AcctOutput','float');
 			$res->addField('AcctSessionTime','int');
 			$res->addField('ConnectTermReason','string');
 			$res->parseArray($rawData);
diff --git a/webgui/include/ajax/functions/AdminUserLogs.php b/webgui/include/ajax/functions/AdminUserLogs.php
index 857eda47..2e192fe2 100644
--- a/webgui/include/ajax/functions/AdminUserLogs.php
+++ b/webgui/include/ajax/functions/AdminUserLogs.php
@@ -144,11 +144,11 @@ function getAdminUserLogsSummary($params) {
 
 	$res = DBSelect("
 		SELECT
-			@TP@accounting.AcctSessionTime,
-			@TP@accounting.AcctInputOctets,
-			@TP@accounting.AcctInputGigawords,
-			@TP@accounting.AcctOutputOctets,
-			@TP@accounting.AcctOutputGigawords
+			SUM(@TP@accounting.AcctSessionTime) / 60 AS TotalSessionTime,
+			SUM(@TP@accounting.AcctInputOctets) / 1024 / 1024 +
+			SUM(@TP@accounting.AcctInputGigawords) * 4096 +
+			SUM(@TP@accounting.AcctOutputOctets) / 1024 / 1024 +
+			SUM(@TP@accounting.AcctOutputGigawords) * 4096 AS TotalTraffic
 		FROM
 			@TP@accounting, @TP@users
 		WHERE
@@ -163,35 +163,17 @@ function getAdminUserLogsSummary($params) {
 	}
 
 	# Set total traffic and uptime used
-	$totalTraffic = 0;
-	$totalUptime = 0;
-	while ($row = $res->fetchObject()) {
-
-		# Traffic in
-		if (isset($row->acctinputoctets) && $row->acctinputoctets > 0) {
-			$totalTraffic += ceil($row->acctinputoctets / 1024 / 1024);
-		}
-		if (isset($row->acctinputgigawords) && $row->acctinputgigawords > 0) {
-			$totalTraffic += ceil($row->acctinputgigawords * 4096);
-		}
-		# Traffic out
-		if (isset($row->acctoutputoctets) && $row->acctoutputoctets > 0) {
-			$totalTraffic += ceil($row->acctoutputoctets / 1024 / 1024);
-		}
-		if (isset($row->acctoutputgigawords) && $row->acctoutputgigawords > 0) {
-			$totalTraffic += ceil($row->acctoutputgigawords * 4096);
-		}
-
-		# Uptime
-		$sessionTimeItem = 0;
-		if (isset($row->acctsessiontime) && $row->acctsessiontime > 0) {
-			$totalUptime += ceil($row->acctsessiontime / 60);
-		}
-	}
+	$row = $res->fetchObject();
 
 	# Add usage to our return array
-	$resultArray['trafficUsage'] = (int)$totalTraffic;
-	$resultArray['uptimeUsage'] = (int)$totalUptime;
+	$resultArray['trafficUsage'] = 0;
+	$resultArray['uptimeUsage'] = 0;
+	if (isset($row->totaltraffic) && $row->totaltraffic > 0) {
+		$resultArray['trafficUsage'] += $row->totaltraffic;
+	}
+	if (isset($row->totalsessiontime) && $row->totalsessiontime > 0) {
+		$resultArray['uptimeUsage'] += $row->totalsessiontime;
+	}
 
 	# Loop through topups and add to return array
 	$resultArray['trafficTopups'] = 0;
@@ -241,12 +223,12 @@ function getAdminUserLogs($params) {
 					@TP@accounting.CalledStationID,
 					@TP@accounting.AcctSessionID,
 					@TP@accounting.FramedIPAddress,
-					@TP@accounting.AcctInputOctets,
-					@TP@accounting.AcctInputGigawords,
-					@TP@accounting.AcctOutputOctets,
-					@TP@accounting.AcctOutputGigawords,
+					@TP@accounting.AcctInputOctets / 1024 / 1024 +
+					@TP@accounting.AcctInputGigawords * 4096 AS AcctInput,
+					@TP@accounting.AcctOutputOctets / 1024 / 1024 +
+					@TP@accounting.AcctOutputGigawords * 4096 AS AcctOutput,
 					@TP@accounting.AcctTerminateCause,
-					@TP@accounting.AcctSessionTime
+					@TP@accounting.AcctSessionTime / 60 AS AcctSessionTime
 				FROM
 					@TP@accounting, @TP@users
 				WHERE
@@ -266,26 +248,20 @@ function getAdminUserLogs($params) {
 	while ($row = $sth->fetchObject()) {
 
 		# Input
-		$acctInputMbyte = 0;
-		if (isset($row->acctinputoctets) && $row->acctinputoctets > 0) {
-			$acctInputMbyte += ceil($row->acctinputoctets / 1024 / 1024);
-		}
-		if (isset($row->acctinputgigawords) && $row->acctinputgigawords > 0) {
-			$acctInputMbyte += ceil($row->acctinputgigawords * 4096);
+		$acctInput = 0;
+		if (isset($row->acctinput) && $row->acctinput > 0) {
+			$acctInput += $row->acctinput;
 		}
 		# Output
-		$acctOutputMbyte = 0;
-		if (isset($row->acctoutputoctets) && $row->acctoutputoctets > 0) {
-			$acctOutputMbyte += ceil($row->acctoutputoctets / 1024 / 1024);
-		}
-		if (isset($row->acctoutputgigawords) && $row->acctoutputgigawords > 0) {
-			$acctOutputMbyte += ceil($row->acctoutputgigawords * 4096);
+		$acctOutput = 0;
+		if (isset($row->acctoutput) && $row->acctoutput > 0) {
+			$acctOutput += $row->acctoutput;
 		}
 
 		# Uptime
 		$acctSessionTime = 0;
 		if (isset($row->acctsessiontime) && $row->acctsessiontime > 0) {
-			$acctSessionTime += ceil($row->acctsessiontime / 60);
+			$acctSessionTime += $row->acctsessiontime;
 		}
 
 		# Build array for this row
@@ -305,8 +281,8 @@ function getAdminUserLogs($params) {
 		$item['CalledStationID'] = $row->calledstationid;
 		$item['AcctSessionID'] = $row->acctsessionid;
 		$item['FramedIPAddress'] = $row->framedipaddress;
-		$item['AcctInputMbyte'] = (int)$acctInputMbyte;
-		$item['AcctOutputMbyte'] = (int)$acctOutputMbyte;
+		$item['AcctInput'] = $acctInput;
+		$item['AcctOutput'] = $acctOutput;
 		$item['AcctSessionTime'] = (int)$acctSessionTime;
 		$item['ConnectTermReason'] = strRadiusTermCode($row->acctterminatecause);
 
diff --git a/webgui/include/ajax/functions/WiSPUserLogs.php b/webgui/include/ajax/functions/WiSPUserLogs.php
index a67e775d..32c38665 100644
--- a/webgui/include/ajax/functions/WiSPUserLogs.php
+++ b/webgui/include/ajax/functions/WiSPUserLogs.php
@@ -144,11 +144,11 @@ function getWiSPUserLogsSummary($params) {
 
 	$res = DBSelect("
 		SELECT
-			@TP@accounting.AcctSessionTime,
-			@TP@accounting.AcctInputOctets,
-			@TP@accounting.AcctInputGigawords,
-			@TP@accounting.AcctOutputOctets,
-			@TP@accounting.AcctOutputGigawords
+			SUM(@TP@accounting.AcctSessionTime) / 60 AS TotalSessionTime,
+			SUM(@TP@accounting.AcctInputOctets) / 1024 / 1024 +
+			SUM(@TP@accounting.AcctInputGigawords) * 4096 +
+			SUM(@TP@accounting.AcctOutputOctets) / 1024 / 1024 +
+			SUM(@TP@accounting.AcctOutputGigawords) * 4096 AS TotalTraffic
 		FROM
 			@TP@accounting, @TP@users
 		WHERE
@@ -163,35 +163,17 @@ function getWiSPUserLogsSummary($params) {
 	}
 
 	# Set total traffic and uptime used
-	$totalTraffic = 0;
-	$totalUptime = 0;
-	while ($row = $res->fetchObject()) {
-
-		# Traffic in
-		if (isset($row->acctinputoctets) && $row->acctinputoctets > 0) {
-			$totalTraffic += ceil($row->acctinputoctets / 1024 / 1024);
-		}
-		if (isset($row->acctinputgigawords) && $row->acctinputgigawords > 0) {
-			$totalTraffic += ceil($row->acctinputgigawords * 4096);
-		}
-		# Traffic out
-		if (isset($row->acctoutputoctets) && $row->acctoutputoctets > 0) {
-			$totalTraffic += ceil($row->acctoutputoctets / 1024 / 1024);
-		}
-		if (isset($row->acctoutputgigawords) && $row->acctoutputgigawords > 0) {
-			$totalTraffic += ceil($row->acctoutputgigawords * 4096);
-		}
-
-		# Uptime
-		$sessionTimeItem = 0;
-		if (isset($row->acctsessiontime) && $row->acctsessiontime > 0) {
-			$totalUptime += ceil($row->acctsessiontime / 60);
-		}
-	}
+	$row = $res->fetchObject();
 
 	# Add usage to our return array
-	$resultArray['trafficUsage'] = (int)$totalTraffic;
-	$resultArray['uptimeUsage'] = (int)$totalUptime;
+	$resultArray['trafficUsage'] = 0;
+	$resultArray['uptimeUsage'] = 0;
+	if (isset($row->totaltraffic) && $row->totaltraffic > 0) {
+		$resultArray['trafficUsage'] += $row->totaltraffic;
+	}
+	if (isset($row->totalsessiontime) && $row->totalsessiontime > 0) {
+		$resultArray['uptimeUsage'] += $row->totalsessiontime;
+	}
 
 	# Loop through topups and add to return array
 	$resultArray['trafficTopups'] = 0;
@@ -241,12 +223,12 @@ function getWiSPUserLogs($params) {
 					@TP@accounting.CalledStationID,
 					@TP@accounting.AcctSessionID,
 					@TP@accounting.FramedIPAddress,
-					@TP@accounting.AcctInputOctets,
-					@TP@accounting.AcctInputGigawords,
-					@TP@accounting.AcctOutputOctets,
-					@TP@accounting.AcctOutputGigawords,
+					@TP@accounting.AcctInputOctets / 1024 / 1024 +
+					@TP@accounting.AcctInputGigawords * 4096 AS AcctInput,
+					@TP@accounting.AcctOutputOctets / 1024 / 1024 +
+					@TP@accounting.AcctOutputGigawords * 4096 AS AcctOutput,
 					@TP@accounting.AcctTerminateCause,
-					@TP@accounting.AcctSessionTime
+					@TP@accounting.AcctSessionTime / 60 AS AcctSessionTime
 				FROM
 					@TP@accounting, @TP@users
 				WHERE
@@ -266,26 +248,20 @@ function getWiSPUserLogs($params) {
 	while ($row = $sth->fetchObject()) {
 
 		# Input
-		$acctInputMbyte = 0;
-		if (isset($row->acctinputoctets) && $row->acctinputoctets > 0) {
-			$acctInputMbyte += ceil($row->acctinputoctets / 1024 / 1024);
-		}
-		if (isset($row->acctinputgigawords) && $row->acctinputgigawords > 0) {
-			$acctInputMbyte += ceil($row->acctinputgigawords * 4096);
+		$acctInput = 0;
+		if (isset($row->acctinput) && $row->acctinput > 0) {
+			$acctInput += $row->acctinput;
 		}
 		# Output
-		$acctOutputMbyte = 0;
-		if (isset($row->acctoutputoctets) && $row->acctoutputoctets > 0) {
-			$acctOutputMbyte += ceil($row->acctoutputoctets / 1024 / 1024);
-		}
-		if (isset($row->acctoutputgigawords) && $row->acctoutputgigawords > 0) {
-			$acctOutputMbyte += ceil($row->acctoutputgigawords * 4096);
+		$acctOutput = 0;
+		if (isset($row->acctoutput) && $row->acctoutput > 0) {
+			$acctOutput += $row->acctoutput;
 		}
 
 		# Uptime
 		$acctSessionTime = 0;
 		if (isset($row->acctsessiontime) && $row->acctsessiontime > 0) {
-			$acctSessionTime += ceil($row->acctsessiontime / 60);
+			$acctSessionTime += $row->acctsessiontime;
 		}
 
 		# Build array for this row
@@ -305,8 +281,8 @@ function getWiSPUserLogs($params) {
 		$item['CalledStationID'] = $row->calledstationid;
 		$item['AcctSessionID'] = $row->acctsessionid;
 		$item['FramedIPAddress'] = $row->framedipaddress;
-		$item['AcctInputMbyte'] = (int)$acctInputMbyte;
-		$item['AcctOutputMbyte'] = (int)$acctOutputMbyte;
+		$item['AcctInput'] = $acctInput;
+		$item['AcctOutput'] = $acctOutput;
 		$item['AcctSessionTime'] = (int)$acctSessionTime;
 		$item['ConnectTermReason'] = strRadiusTermCode($row->acctterminatecause);
 
diff --git a/webgui/js/app/windows/AdminUserLogs.js b/webgui/js/app/windows/AdminUserLogs.js
index 1ccb49d7..abd675f8 100644
--- a/webgui/js/app/windows/AdminUserLogs.js
+++ b/webgui/js/app/windows/AdminUserLogs.js
@@ -193,11 +193,13 @@ function showAdminUserLogsWindow(id) {
 				},
 				{
 					header: "Input Mbyte",
-					dataIndex: 'AcctInputMbyte'
+					dataIndex: 'AcctInput',
+					renderer: renderUsageFloat
 				},
 				{
 					header: "Output Mbyte",
-					dataIndex: 'AcctOutputMbyte'
+					dataIndex: 'AcctOutput',
+					renderer: renderUsageFloat
 				},
 				{
 					header: "Session Uptime",
@@ -243,8 +245,8 @@ function showAdminUserLogsWindow(id) {
 				{type: 'string',  dataIndex: 'CalledStationID'},
 				{type: 'string',  dataIndex: 'AcctSessionID'},
 				{type: 'string',  dataIndex: 'FramedIPAddress'},
-				{type: 'numeric',  dataIndex: 'AcctInputMbyte'},
-				{type: 'numeric',  dataIndex: 'AcctOutputMbyte'},
+				{type: 'numeric',  dataIndex: 'AcctInput'},
+				{type: 'numeric',  dataIndex: 'AcctOutput'},
 				{type: 'numeric',  dataIndex: 'AcctSessionTime'},
 				{type: 'string',  dataIndex: 'ConnectTermReason'}
 			]
@@ -344,4 +346,5 @@ function showAdminUserLogsWindow(id) {
 	adminUserLogsWindow.show();
 }
 
+
 // vim: ts=4
diff --git a/webgui/js/app/windows/WiSPUserLogs.js b/webgui/js/app/windows/WiSPUserLogs.js
index 04519ad3..55758fd4 100644
--- a/webgui/js/app/windows/WiSPUserLogs.js
+++ b/webgui/js/app/windows/WiSPUserLogs.js
@@ -193,11 +193,13 @@ function showWiSPUserLogsWindow(id) {
 				},
 				{
 					header: "Input Mbyte",
-					dataIndex: 'AcctInputMbyte'
+					dataIndex: 'AcctInput',
+					renderer: renderUsageFloat
 				},
 				{
 					header: "Output Mbyte",
-					dataIndex: 'AcctOutputMbyte'
+					dataIndex: 'AcctOutput',
+					renderer: renderUsageFloat
 				},
 				{
 					header: "Session Uptime",
@@ -243,8 +245,8 @@ function showWiSPUserLogsWindow(id) {
 				{type: 'string',  dataIndex: 'CalledStationID'},
 				{type: 'string',  dataIndex: 'AcctSessionID'},
 				{type: 'string',  dataIndex: 'FramedIPAddress'},
-				{type: 'numeric',  dataIndex: 'AcctInputMbyte'},
-				{type: 'numeric',  dataIndex: 'AcctOutputMbyte'},
+				{type: 'numeric',  dataIndex: 'AcctInput'},
+				{type: 'numeric',  dataIndex: 'AcctOutput'},
 				{type: 'numeric',  dataIndex: 'AcctSessionTime'},
 				{type: 'string',  dataIndex: 'ConnectTermReason'}
 			]
@@ -344,4 +346,5 @@ function showWiSPUserLogsWindow(id) {
 	wispUserLogsWindow.show();
 }
 
+
 // vim: ts=4
diff --git a/webui/user/index.php b/webui/user/index.php
index 153cb988..40813c6a 100644
--- a/webui/user/index.php
+++ b/webui/user/index.php
@@ -50,11 +50,11 @@ function displayDetails() {
 
 	$sql = "
 		SELECT
-			AcctSessionTime,
-			AcctInputOctets,
-			AcctInputGigawords,
-			AcctOutputOctets,
-			AcctOutputGigawords
+			SUM(AcctSessionTime) / 60 AS AcctSessionTime,
+			SUM(AcctInputOctets) / 1024 / 1024 +
+			SUM(AcctInputGigawords) * 4096 AS AcctInputTraffic,
+			SUM(AcctOutputOctets) / 1024 / 1024 +
+			SUM(AcctOutputGigawords) * 4096 AS AcctOutputTraffic
 		FROM
 			${DB_TABLE_PREFIX}accounting
 		WHERE
@@ -67,26 +67,22 @@ function displayDetails() {
 	# Set total traffic and uptime used
 	$totalTraffic = 0;
 	$totalUptime = 0;
-	while ($row = $res->fetchObject()) {
-		# Traffic in
-		if (isset($row->acctinputoctets) && $row->acctinputoctets > 0) {
-			$totalTraffic += ceil($row->acctinputoctets / 1024 / 1024);
-		}
-		if (isset($row->acctinputgigawords) && $row->acctinputgigawords > 0) {
-			$totalTraffic += ceil($row->acctinputgigawords * 4096);
-		}
-		# Traffic out
-		if (isset($row->acctoutputoctets) && $row->acctoutputoctets > 0) {
-			$totalTraffic += ceil($row->acctoutputoctets / 1024 / 1024);
-		}
-		if (isset($row->acctoutputgigawords) && $row->acctoutputgigawords > 0) {
-			$totalTraffic += ceil($row->acctoutputgigawords * 4096);
-		}
 
-		# Uptime
-		if (isset($row->acctsessiontime) && $row->acctsessiontime > 0) {
-			$totalUptime += ceil($row->acctsessiontime / 60);
-		}
+	# Pull in row
+	$row = $res->fetchObject();
+
+	# Traffic in
+	if (isset($row->acctinputtraffic) && $row->acctinputtraffic > 0) {
+		$totalTraffic += $row->acctinputtraffic;
+	}
+	# Traffic out
+	if (isset($row->acctoutputtraffic) && $row->acctoutputtraffic > 0) {
+		$totalTraffic += $row->acctoutputtraffic;
+	}
+
+	# Uptime
+	if (isset($row->acctsessiontime) && $row->acctsessiontime > 0) {
+		$totalUptime += $row->acctsessiontime;
 	}
 
 	# Fetch user uptime and traffic cap
@@ -350,13 +346,17 @@ function displayDetails() {
 <?php
 				} else {
 ?>
-					<td class="value"><?php echo $topupTrafficRemaining; ?> MB</td>
+					<td class="value"><?php printf("%.2f",$topupTrafficRemaining); ?> MB</td>
 <?php
 				}
 				if (isset($currentTrafficTopup['Used']) && isset($currentTrafficTopup['Cap'])) {
 ?>
-					<td class="value"><?php echo $currentTrafficTopup['Used'];
-							print("/".$currentTrafficTopup['Cap']); ?> MB</td>
+					<td class="value">
+						<?php 
+							printf("%.2f",$currentTrafficTopup['Used']);
+							print("/").$currentTrafficTopup['Cap'];
+						?> MB
+					</td>
 <?php
 				} else {
 ?>
@@ -364,7 +364,7 @@ function displayDetails() {
 <?php
 				}
 ?>
-				<td class="value"><?php echo $totalTraffic; ?> MB</td>
+				<td class="value"><?php printf("%.2f",$totalTraffic); ?> MB</td>
 			</tr>
 			<tr>
 				<td colspan="4" class="section">Uptime Usage</td>
@@ -396,13 +396,17 @@ function displayDetails() {
 <?php
 				} else {
 ?>
-					<td class="value"><?php echo $topupUptimeRemaining; ?> Min</td>
+					<td class="value"><?php printf("%.2f",$topupUptimeRemaining); ?> Min</td>
 <?php
 				}
 				if (isset($currentUptimeTopup['Used']) && isset($currentUptimeTopup['Cap'])) {
 ?>
-					<td class="value"><?php echo $currentUptimeTopup['Used'];
-							print("/".$currentUptimeTopup['Cap']); ?> Min</td>
+					<td class="value">
+						<?php
+							printf("%.2f",$currentUptimeTopup['Used']);
+							print("/").$currentUptimeTopup['Cap'];
+						?> Min
+					</td>
 <?php
 				} else {
 ?>
@@ -410,7 +414,7 @@ function displayDetails() {
 <?php
 				}
 ?>
-				<td class="value"><?php echo $totalUptime; ?> Min</td>
+				<td class="value"><?php printf("%.2f",$totalUptime); ?> Min</td>
 			</tr>
 <!--
 			<tr>
diff --git a/webui/user/logs.php b/webui/user/logs.php
index a2f83ead..371cb716 100644
--- a/webui/user/logs.php
+++ b/webui/user/logs.php
@@ -118,17 +118,17 @@ function displayLogs() {
 			# Accounting query FIXME nas receive and transmit rates
 			$sql = "
 				SELECT
-						EventTimestamp, 
-						CallingStationID, 
-						AcctSessionTime, 
-						AcctInputOctets, 
-						AcctInputGigawords, 
-						AcctOutputOctets, 
-						AcctOutputGigawords, 
+						EventTimestamp,
+						CallingStationID,
+						AcctSessionTime / 60 AS AcctSessionTime,
+						AcctInputOctets / 1024 / 1024 +
+						AcctInputGigawords * 4096 AS AcctInputMbyte,
+						AcctOutputOctets / 1024 / 1024 +
+						AcctOutputGigawords * 4096 AS AcctOutputMbyte,
 						AcctTerminateCause
-				FROM 
-						${DB_TABLE_PREFIX}accounting 
-				WHERE 
+				FROM
+						${DB_TABLE_PREFIX}accounting
+				WHERE
 						Username = ".$db->quote($_SESSION['username'])."
 						$extraSQL
 				ORDER BY
@@ -147,34 +147,28 @@ function displayLogs() {
 
 				# Input data calculation
 				$inputData = 0;
-				if (isset($row->acctinputoctets) && $row->acctinputoctets > 0) {
-					$inputData += ceil($row->acctinputoctets / 1024 / 1024);
-				}
-				if (isset($row->acctinputgigawords) && $row->acctinputgigawords > 0) {
-					$inputData += ceil($row->acctinputgigawords * 4096);
+				if (isset($row->acctinputmbyte) && $row->acctinputmbyte > 0) {
+					$inputData += $row->acctinputmbyte;
 				}
 				$totalInput += $inputData;
 
 				# Output data calculation
 				$outputData = 0;
-				if (isset($row->acctoutputoctets) && $row->acctoutputoctets > 0) {
-					$outputData += ceil($row->acctoutputoctets / 1024 / 1024);
-				}
-				if (isset($row->acctoutputgigawords) && $row->acctoutputgigawords > 0) {
-					$outputData += ceil($row->acctoutputgigawords * 4096);
+				if (isset($row->acctoutputmbyte) && $row->acctoutputmbyte > 0) {
+					$outputData += $row->acctoutputmbyte;
 				}
 				$totalOutput += $outputData;
 
 				# Uptime calculation
 				$sessionTime = 0;
 				if (isset($row->acctsessiontime) && $row->acctsessiontime > 0) {
-					$sessionTime += ceil($row->acctsessiontime / 60);
+					$sessionTime += $row->acctsessiontime;
 				}
 				$totalTime += $sessionTime;
 ?>
 				<tr>
 					<td class="desc"><?php echo $row->eventtimestamp; ?></td>
-					<td class="desc"><?php echo $sessionTime; ?></td>
+					<td class="desc"><?php printf("%.2f",$sessionTime); ?></td>
 					<td class="desc"><?php echo $row->callingstationid; ?></td>
 					<td class="center desc"><?php echo strRadiusTermCode($row->acctterminatecause); ?></td>
 					<td class="center desc">
@@ -191,8 +185,8 @@ function displayLogs() {
 							}
 						?>
 					</td>
-					<td class="right desc"><?php echo $inputData; ?></td>
-					<td class="right desc"><?php echo $outputData; ?></td>
+					<td class="right desc"><?php printf("%.2f",$inputData); ?></td>
+					<td class="right desc"><?php printf("%.2f",$outputData); ?></td>
 				</tr>
 <?php
 			}
@@ -207,12 +201,12 @@ function displayLogs() {
 ?>
 				<tr>
 					<td colspan="6" class="right">Sub Total:</td>
-					<td class="right desc"><?php echo $totalInput; ?></td>
-					<td class="right desc"><?php echo $totalOutput; ?></td>
+					<td class="right desc"><?php printf("%.2f",$totalInput); ?></td>
+					<td class="right desc"><?php printf("%.2f",$totalOutput); ?></td>
 				</tr>
 				<tr>
 					<td colspan="6" class="right">Total:</td>
-					<td colspan="2" class="center desc"><?php echo $totalTraffic; ?></td>
+					<td colspan="2" class="center desc"><?php printf("%.2f",$totalTraffic); ?></td>
 				</tr>
 <?php
 			}
-- 
GitLab