summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2018-04-25 17:20:57 +0200
committerSimon Rettberg2018-04-25 17:20:57 +0200
commit24a04871603b8307eb0af0f772dfe64af16c4ada (patch)
treee5f05ab3d7b147f209bf3df78a55fcbbe034e95b
parent[locationinfo] Default language to slx-admin session language for new panel (diff)
downloadslx-admin-24a04871603b8307eb0af0f772dfe64af16c4ada.tar.gz
slx-admin-24a04871603b8307eb0af0f772dfe64af16c4ada.tar.xz
slx-admin-24a04871603b8307eb0af0f772dfe64af16c4ada.zip
[locations] Restore row with unassigned machines
-rw-r--r--modules-available/locations/page.inc.php12
-rw-r--r--modules-available/locations/templates/locations.html3
2 files changed, 12 insertions, 3 deletions
diff --git a/modules-available/locations/page.inc.php b/modules-available/locations/page.inc.php
index 5010c9ab..9beae163 100644
--- a/modules-available/locations/page.inc.php
+++ b/modules-available/locations/page.inc.php
@@ -345,8 +345,10 @@ class Page_Locations extends Page
Location::getOverlappingSubnets($overlapSelf, $overlapOther);
//$locs = Location::getLocations(0, 0, false, true);
$locationList = Location::getLocationsAssoc();
+ unset($locationList[0]);
// Statistics: Count machines for each subnet
$unassigned = false;
+ $unassignedLoad = 0;
// Filter view: Remove locations we can't reach at all, but show parents to locations
// we have permission to, so the tree doesn't look all weird
@@ -383,15 +385,20 @@ class Page_Locations extends Page
// Client statistics
if (Module::get('statistics') !== false) {
$unassigned = 0;
+ $extra = '';
+ if (in_array(0, $allowedLocationIds)) {
+ $extra = ' OR locationid IS NULL';
+ }
$res = Database::simpleQuery("SELECT locationid, Count(*) AS cnt, Sum(If(state = 'OCCUPIED', 1, 0)) AS used
- FROM machine WHERE locationid IN (:allowedLocationIds) GROUP BY locationid", compact('allowedLocationIds'));
+ FROM machine WHERE (locationid IN (:allowedLocationIds) $extra) GROUP BY locationid", compact('allowedLocationIds'));
while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
$locId = (int)$row['locationid'];
if (isset($locationList[$locId])) {
$locationList[$locId]['clientCount'] = $row['cnt'];
- $locationList[$locId]['clientLoad'] = round(100 * $row['used'] / $row['cnt']) . '%';
+ $locationList[$locId]['clientLoad'] = round(100 * $row['used'] / $row['cnt']) . ' %';
} else {
$unassigned += $row['cnt'];
+ $unassignedLoad += $row['used'];
}
}
unset($loc);
@@ -482,6 +489,7 @@ class Page_Locations extends Page
'haveOverlapSelf' => !empty($overlapSelf),
'haveOverlapOther' => !empty($overlapOther),
'unassignedCount' => $unassigned,
+ 'unassignedLoad' => round(($unassignedLoad / $unassigned) * 100) . ' %',
'defaultConfig' => $defaultConfig,
'addAllowedList' => array_values($addAllowedList),
);
diff --git a/modules-available/locations/templates/locations.html b/modules-available/locations/templates/locations.html
index cd04b1c8..67f22744 100644
--- a/modules-available/locations/templates/locations.html
+++ b/modules-available/locations/templates/locations.html
@@ -96,9 +96,10 @@
<a href="?do=Statistics&amp;show=list&amp;filters=location=0">
&nbsp;{{unassignedCount}}&nbsp;
</a>
+ <span style="display:inline-block;width:5ex"></span>
</td>
<td class="text-nowrap" align="right">
- {{clientLoad}}
+ {{unassignedLoad}}
</td>
<td></td>
<td>{{defaultConfig}}</td>