summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--modules-available/locationinfo/api.inc.php51
-rw-r--r--modules-available/locationinfo/page.inc.php28
-rw-r--r--modules-available/locationinfo/templates/config.html2
-rw-r--r--modules-available/locationinfo/templates/location-info.html23
4 files changed, 61 insertions, 43 deletions
diff --git a/modules-available/locationinfo/api.inc.php b/modules-available/locationinfo/api.inc.php
index 106f6498..7c90c0f5 100644
--- a/modules-available/locationinfo/api.inc.php
+++ b/modules-available/locationinfo/api.inc.php
@@ -91,20 +91,27 @@ function updateCalendar($locationid, $serverid, $serverroomid) {
}
function getConfig($locationID) {
- $dbquery = Database::simpleQuery("SELECT l.locationname, li.config FROM `location_info` AS li
- RIGHT JOIN `location` AS l ON l.locationid=li.locationid WHERE l.locationid=:locationID", array('locationID' => $locationID));
+ $dbquery = Database::simpleQuery("SELECT l.locationname, li.config, li.serverroomid, s.servertype, s.serverurl FROM `location_info` AS li
+ RIGHT JOIN `location` AS l ON l.locationid=li.locationid
+ LEFT JOIN `setting_location_info` AS s ON s.serverid=li.serverid
+ WHERE l.locationid=:locationID", array('locationID' => $locationID));
$config = array();
- while($dbresult=$dbquery->fetch(PDO::FETCH_ASSOC)) {
- $config = json_decode($dbresult['config'], true);
- $config['room'] = $dbresult['locationname'];
- $date = getdate();
- $config['time'] = $date['year'] . "-" . $date['mon'] . "-" . $date['mday'] . " " . $date['hours'] . ":" . $date['minutes'] . ":" . $date['seconds'];
+ $dbresult=$dbquery->fetch(PDO::FETCH_ASSOC);
+
+ $config = json_decode($dbresult['config'], true);
+ $config['room'] = $dbresult['locationname'];
+ $date = getdate();
+ $config['time'] = $date['year'] . "-" . $date['mon'] . "-" . $date['mday'] . " " . $date['hours'] . ":" . $date['minutes'] . ":" . $date['seconds'];
+
+ if($dbresult['servertype'] === "Frontend") {
+ $config['calendarqueryurl'] = $dbresult['serverurl'] . "/" . $dbresult['serverroomid'] . ".json";
}
+
if (empty($config)) {
echo json_encode(array());
} else {
- echo json_encode($config);
+ echo json_encode($config, JSON_UNESCAPED_SLASHES);
}
}
@@ -230,31 +237,3 @@ function getPcInfos($locationID, $coords) {
return $str;
}
-function fetchNewTimeTable($locationID){
- //Get room information
- $dbquery1 = Database::simpleQuery("SELECT serverid, serverroomid FROM location_info WHERE locationid = :id", array('id' => $locationID));
- $dbd1=$dbquery1->fetch(PDO::FETCH_ASSOC);
- $serverID = $dbd1['serverid'];
- $roomID = $dbd1['serverroomid'];
- //Get login data for the server
- $dbquery2 = Database::simpleQuery("SELECT serverurl, servertype, login, passwd FROM `setting_location_info` WHERE serverid = :id", array('id' => $serverID));
- $dbd2=$dbquery2->fetch(PDO::FETCH_ASSOC);
- $url = $dbd2['serverurl'];
- $type = $dbd2['servetype'];
- $lname = $dbd2['login'];
- $passwd = $dbd2['passwd'];
- //Return json with dates
- if($type == 'HISinOne'){
- $array = file_get_contents($url . $roomID . '.json');
- $ttable = json_decode($array);
- $results = count($ttable);
- for ($r = 0; $r < $results; $r++){
- unset($ttable[$r]->allDay);
- }
-
- }
- else{
- $ttable = "{}";
- }
- return json_encode($ttable);
- }
diff --git a/modules-available/locationinfo/page.inc.php b/modules-available/locationinfo/page.inc.php
index f855c5c5..e9ce1159 100644
--- a/modules-available/locationinfo/page.inc.php
+++ b/modules-available/locationinfo/page.inc.php
@@ -312,11 +312,34 @@ class Page_LocationInfo extends Page
}
}
+ $servertypes = array();
+ $type['type'] = "HISinOne";
+ $servertypes[] = $type;
+ $type['type'] = "DAVINCI";
+ $servertypes[] = $type;
+ $type['type'] = "Frontend";
+ $servertypes[] = $type;
+
$serverlist = array();
$dbquery2 = Database::simpleQuery("SELECT * FROM `setting_location_info`");
while($db=$dbquery2->fetch(PDO::FETCH_ASSOC)) {
$server['id'] = $db['serverid'];
$server['name'] = $db['servername'];
+
+ $serverty = array();
+ foreach ($servertypes as $type) {
+ $st = array();
+ if ($type['type'] == $db['servertype']) {
+ $st['type'] = $type['type'];
+ $st['active'] = true;
+ } else {
+ $st['type'] = $type['type'];
+ $st['active'] = false;
+ }
+ $serverty[] = $st;
+ }
+ $server['types'] = $serverty;
+/*
if ($db['servertype'] == 'HISinOne') {
$server['HISinOne'] = true;
$server['DAVINCI'] = false;
@@ -324,6 +347,7 @@ class Page_LocationInfo extends Page
$server['HISinOne'] = false;
$server['DAVINCI'] = true;
}
+*/
$server['url'] = $db['serverurl'];
$server['user'] = $db['login'];
$server['password'] = $db['passwd'];
@@ -331,7 +355,7 @@ class Page_LocationInfo extends Page
}
Render::addTemplate('location-info', array(
- 'list' => array_values($pcs), 'serverlist' => array_values($serverlist),
+ 'list' => array_values($pcs), 'serverlist' => array_values($serverlist), 'servertypelist' => array_values($servertypes),
));
}
@@ -460,5 +484,5 @@ class Page_LocationInfo extends Page
'roomupdate' => $array['roomupdate'], 'configupdate' => $array['configupdate'],
'serverlist' => array_values($serverList), 'serverid' => $serverid, 'serverroomid' => $serverroomid));
}
-
+
}
diff --git a/modules-available/locationinfo/templates/config.html b/modules-available/locationinfo/templates/config.html
index 577f8f94..1cbcbe31 100644
--- a/modules-available/locationinfo/templates/config.html
+++ b/modules-available/locationinfo/templates/config.html
@@ -34,7 +34,7 @@
</div>
<div style="float: left; margin-left: 15px;">
<Label>{{lang_mode}}</Label><br>
- <select name="mode" onchange=vertical_cb(this.value);>
+ <select name="mode" onchange="vertical_cb(this.value);">
<option value="1" id="mode1">{{lang_mode1}}</option>
<option value="2" id="mode2">{{lang_mode2}}</option>
<option value="3" id="mode3">{{lang_mode3}}</option>
diff --git a/modules-available/locationinfo/templates/location-info.html b/modules-available/locationinfo/templates/location-info.html
index 534f7acb..98786934 100644
--- a/modules-available/locationinfo/templates/location-info.html
+++ b/modules-available/locationinfo/templates/location-info.html
@@ -24,9 +24,10 @@
<tr class=tablerow>
<td align="center"><input id="input-id-{{id}}" name="id" type="hidden" value="{{id}}">{{id}}</td>
<td id="type-{{id}}">
- <select disabled id="input-type-{{id}}" name="type" value="{{type}}">
- <option id="HISinOne" value="HISinOne" {{#HISinOne}}selected{{/HISinOne}}>HISinOne
- <option id="DAVINCI" value="DAVINCI" {{#DAVINCI}}selected{{/DAVINCI}}>DAVINCI
+ <select disabled id="input-type-{{id}}" name="type" value="{{type}}" onchange="servertype_changed(this.value, {{id}});">
+ {{#types}}
+ <option id="{{type}}" value="{{type}}" {{#active}}selected{{/active}} >{{type}}
+ {{/types}}
</select>
</td>
<td id="name-{{id}}" style="padding:8px;">
@@ -188,6 +189,16 @@ function deleteButtonClick(id) {
}
};
+function servertype_changed(value, id) {
+ if (value == "Frontend") {
+ $('#input-user-' + id).removeAttr('required');
+ $('#input-password-' + id).removeAttr('required');
+ } else {
+ $('#input-user-' + id).attr('required');
+ $('#input-password-' + id).attr('required');
+ }
+};
+
function editButtonClick(id) {
var name = $('#input-name-' + id);
var url = $('#input-url-' + id);
@@ -213,6 +224,8 @@ function editButtonClick(id) {
preEditPassword = password.val();
preEditType = type.val();
+ servertype_changed(preEditType, id);
+
$('#btncell-' + id).html('\
<button class="btn btn-sm btn-success" title="{{lang_save}}" onclick="saveButtonClick(' + id + ');">&#10004</button> \
<button class="btn btn-sm btn-danger" title="{{lang_cancel}}" onclick="cancelButtonClick(' + id + ');">&#10008</button>');
@@ -280,7 +293,9 @@ function deleteNewServer() {
function addNewServerRow() {
$('#lastServerTableElement').before('<tr class=tablerow id="new">\
<td align="center"><input id="input-id-0" name="id" type="hidden" form="serverForm-0" value="0"></td>\
- <td id="type-0"><select id="input-type-0" name="type" form="serverForm-0"><option value="HISinOne">HISinOne<option value="DAVINCI">DAVINCI</select></td>\
+ <td id="type-0"><select id="input-type-0" name="type" form="serverForm-0" onchange="servertype_changed(this.value, 0)">\
+ {{#servertypelist}}<option value="{{type}}"> {{type}}{{/servertypelist}}\
+ </select></td>\
<td id="name-0" style="padding:0;"><input required id="input-name-0" name="name" type="text" form="serverForm-0" value="" style="padding:0;height:100%;width:100%;"></input></td>\
<td id="url-0" style="padding:0;"><a><input required id="input-url-0" name="url" type="text" form="serverForm-0" value="" style="padding:0;height:100%;width:100%;"></input></a></td>\
<td id="user-0" style="padding:0;"><input required id="input-user-0" name="user" type="text" form="serverForm-0" value="" style="padding:0;height:100%;width:100%;"></input></td>\