diff --git a/webgui/ajax.php b/webgui/ajax.php index dd99c5cb53be558abe3f72fe25d8e50105d9def8..0c626fd41e120947040017f4395bf0097b75616b 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 857eda47b85abb51713e840a18cde602b8fd97ea..2e192fe2e731aa2c999e12de4d26a028b11e4454 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 a67e775df0ba5ab405d2b622a57eb84fbaa4b6d2..32c386653ac0e2a1f8e069cab6a585e48b8febd3 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 1ccb49d720375aa962f9eca1611fb7fce97e718b..abd675f8e5bdda633bba8b6901acf737a00ba46d 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 04519ad322dffc9c9a2a7900279c9ed575ed8c98..55758fd4b71887dadef0e4e8d316b5f1b95d6942 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 153cb98833db4cd7beffadb3bb5b354cef8dca4d..40813c6ae9f7fd09f68edb7e6b727f41f9ac606e 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 a2f83ead59c4524258a1bf203925e6a2624a0e42..371cb716f1eeb61d7710d6ca64a5275fe04e506e 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 }