summaryrefslogtreecommitdiffstats
path: root/modules-available/locationinfo/api.inc.php
diff options
context:
space:
mode:
authorJannik Schönartz2017-01-29 08:18:18 +0100
committerJannik Schönartz2017-01-29 08:18:18 +0100
commitd311bddd350fde9c35d8a04351accee9d6e0af1d (patch)
tree61d4ce981790760bdf10a756233e4b4a12208bd6 /modules-available/locationinfo/api.inc.php
parentfrontend: added function to generate parent div (diff)
downloadslx-admin-d311bddd350fde9c35d8a04351accee9d6e0af1d.tar.gz
slx-admin-d311bddd350fde9c35d8a04351accee9d6e0af1d.tar.xz
slx-admin-d311bddd350fde9c35d8a04351accee9d6e0af1d.zip
API: Adde a method for multi handle ids and a method for returning the room tree.
Diffstat (limited to 'modules-available/locationinfo/api.inc.php')
-rw-r--r--modules-available/locationinfo/api.inc.php45
1 files changed, 45 insertions, 0 deletions
diff --git a/modules-available/locationinfo/api.inc.php b/modules-available/locationinfo/api.inc.php
index ddbd1304..296354c4 100644
--- a/modules-available/locationinfo/api.inc.php
+++ b/modules-available/locationinfo/api.inc.php
@@ -21,9 +21,54 @@ function HandleParameters() {
} elseif ($getAction == "calendar") {
$getRoomID = Request::get('id', 0, 'int');
getCalendar($getRoomID);
+ } elseif ($getAction == "roomtree") {
+ $roomIDS = Request::get('ids', 0, 'string');
+ getRoomTree($roomIDS);
}
}
+function getMultipleInformations($roomids) {
+ $idList = explode(',', $roomids);
+ $filteredIdList = array_filter($idList, 'is_numeric');
+ return $filteredIdList;
+}
+
+function getRoomTree($ids) {
+ $idList = getMultipleInformations($ids);
+ $roomTree = array();
+ foreach ($idList as $id) {
+ $dbquery = Database::simpleQuery("SELECT locationname FROM `location` WHERE locationid=:locationID", array('locationID' => $id));
+ $dbresult=$dbquery->fetch(PDO::FETCH_ASSOC);
+
+ $a['id'] = $id;
+ $a['name'] = $dbresult['locationname'];
+ $a['childs'] = getChildsRecursive($id);
+ $roomTree[] = $a;
+ }
+
+ echo json_encode($roomTree);
+}
+
+function getChildsRecursive($id) {
+ $dbquery = Database::simpleQuery("SELECT locationid, locationname FROM `location` WHERE parentlocationid=:locationID", array('locationID' => $id));
+ $array = array();
+ $dbarray = array();
+
+ while($dbresult=$dbquery->fetch(PDO::FETCH_ASSOC)) {
+ $dbarray[] = $dbresult;
+ }
+
+ foreach ($dbarray as $db) {
+ $i = $db['locationid'];
+ $a['id'] = $i;
+ $a['name'] = $db['locationname'];
+ $a['childs'] = getChildsRecursive($i);
+ $array[] = $a;
+ }
+
+ return $array;
+}
+
function randomCalendarGenerator() {
$randNum = rand(3, 7);