diff options
author | Jannik Schönartz | 2017-02-04 18:27:19 +0100 |
---|---|---|
committer | Jannik Schönartz | 2017-02-04 18:27:19 +0100 |
commit | 4a5abd96f895a0fd590efe2fc80162da42fd9f1d (patch) | |
tree | d6fe0bfd843f119493dd5be0eb3330fb19606465 /modules-available/locationinfo | |
parent | rooms will now bee shown (diff) | |
download | slx-admin-4a5abd96f895a0fd590efe2fc80162da42fd9f1d.tar.gz slx-admin-4a5abd96f895a0fd590efe2fc80162da42fd9f1d.tar.xz slx-admin-4a5abd96f895a0fd590efe2fc80162da42fd9f1d.zip |
API: Method added for returning the count of the pc states of (a) location(s).
Diffstat (limited to 'modules-available/locationinfo')
-rw-r--r-- | modules-available/locationinfo/api.inc.php | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/modules-available/locationinfo/api.inc.php b/modules-available/locationinfo/api.inc.php index 296354c4..421296b6 100644 --- a/modules-available/locationinfo/api.inc.php +++ b/modules-available/locationinfo/api.inc.php @@ -24,6 +24,9 @@ function HandleParameters() { } elseif ($getAction == "roomtree") { $roomIDS = Request::get('ids', 0, 'string'); getRoomTree($roomIDS); + } elseif ($getAction == "pcstates") { + $roomIDS = Request::get('ids', 0, 'string'); + getPcStates($roomIDS); } } @@ -33,6 +36,42 @@ function getMultipleInformations($roomids) { return $filteredIdList; } +function getPcStates($ids) { + $idList = getMultipleInformations($ids); + + $pcStates = array(); + foreach ($idList as $id) { + + $a['id'] = $id; + $b = array(); + $b = json_decode(getPcInfos($id), true); + $idle = 0; + $occupied = 0; + $off = 0; + $broken = 0; + + foreach ($b as $c) { + if ($c['pcState'] == 0) { + $idle++; + } elseif($c['pcState'] == 1) { + $occupied++; + } elseif($c['pcState'] == 2) { + $off++; + } elseif($c['pcState'] == 3) { + $broken++; + } + } + + $a['idle'] = $idle; + $a['occupied'] = $occupied; + $a['off'] = $off; + $a['broken'] = $broken; + $pcStates[] = $a; + } + + echo json_encode($pcStates); +} + function getRoomTree($ids) { $idList = getMultipleInformations($ids); $roomTree = array(); |