From 41ff429b1f39f107565365c206cfd6e11c875462 Mon Sep 17 00:00:00 2001 From: Udo Walter Date: Tue, 16 Jul 2019 16:06:41 +0200 Subject: [locationinfo] Add ability to select the start day of the calendar --- .../coursebackend/coursebackend_hisinone.inc.php | 7 +++-- .../locationinfo/lang/de/template-tags.json | 8 +++++ .../locationinfo/lang/en/template-tags.json | 8 +++++ modules-available/locationinfo/page.inc.php | 3 ++ .../locationinfo/templates/frontend-default.html | 10 +++++-- .../templates/page-config-panel-default.html | 34 ++++++++++++++++++++++ 6 files changed, 65 insertions(+), 5 deletions(-) diff --git a/modules-available/locationinfo/inc/coursebackend/coursebackend_hisinone.inc.php b/modules-available/locationinfo/inc/coursebackend/coursebackend_hisinone.inc.php index 7f84dd92..4664a011 100644 --- a/modules-available/locationinfo/inc/coursebackend/coursebackend_hisinone.inc.php +++ b/modules-available/locationinfo/inc/coursebackend/coursebackend_hisinone.inc.php @@ -373,9 +373,10 @@ class CourseBackend_HisInOne extends CourseBackend private function getCurrentWeekDates() { $returnValue = array(); - $startDate = time(); - for ($i = 0; $i < 7; $i++) { - $returnValue[] = date('Y-m-d', strtotime("+{$i} day 12:00", $startDate)); + $date = date('Y-m-d', strtotime('last Monday')); + for ($i = 0; $i < 14; $i++) { + $returnValue[] = $date; + $date = date('Y-m-d', strtotime($date.' +1 day')); } return $returnValue; } diff --git a/modules-available/locationinfo/lang/de/template-tags.json b/modules-available/locationinfo/lang/de/template-tags.json index 950ac512..b63ffc5a 100644 --- a/modules-available/locationinfo/lang/de/template-tags.json +++ b/modules-available/locationinfo/lang/de/template-tags.json @@ -15,6 +15,7 @@ "lang_countRoomplan": "über Raumplaner", "lang_createPanel": "Panel anlegen", "lang_credentials": "Anmeldung", + "lang_currentDay": "Aktueller Tag", "lang_day": "Tag", "lang_daysToShow": "Tage", "lang_daysToShowTooltip": "Legt die Anzahl an Tagen im Kalender fest, die angezeigt werden", @@ -35,6 +36,7 @@ "lang_for": "f\u00fcr", "lang_fourLocsHint": "Hier k\u00f6nnen Sie bis zu vier Orte ausw\u00e4hlen, die in diesem Panel angezeigt werden.", "lang_free": "Ge\u00f6ffnet", + "lang_friday": "Freitag", "lang_general": "Allgemein", "lang_generalSettings": "Allgemeine Einstellungen", "lang_ignoreSslTooltip": "Akzeptiere ung\u00fcltige, abgelaufene oder selbstsignierte SSL-Zertifikate", @@ -62,6 +64,7 @@ "lang_mode3": "Raum", "lang_mode4": "Wechselnd", "lang_modeTooltip": "Die Anzeigemodi, welche das Frontend unterst\u00fctzt", + "lang_monday": "Montag", "lang_monTilFr": "Montag - Freitag", "lang_nameTooltip": "Legt den Namen des Servers fest", "lang_noLocationsWarning": "Bitte w\u00e4hlen Sie mindestens einen Ort aus, der vom Panel angezeigt werden soll.", @@ -118,11 +121,15 @@ "lang_shortWed": "Mi", "lang_shortWednesday": "Mi", "lang_showLog": "Log", + "lang_startDay": "Start Tag", + "lang_startDayTooltip": "Der Wochentag an dem der Kalender anfängt", "lang_summaryPanel": "\u00dcbersichts-Panel", "lang_summaryUpdateIntervalTooltip": "Aktualisierungsintervall (Sekunden)", "lang_sunday": "Sonntag", "lang_switchTime": "Wechselintervall", "lang_switchTimeTooltip": "[1-120] Legt die Zeit fest, die vergeht bis ein Wechsel erfolgt (in Sekunden)", + "lang_thuesday": "Dienstag", + "lang_thursday": "Donnerstag", "lang_to": "bis", "lang_typeTooltip": "Legt fest um welchen Server-Typ es sich handelt", "lang_updateRates": "Aktualisierungsintervall", @@ -135,5 +142,6 @@ "lang_useRoomplanner": "Rechner zählen", "lang_vertical": "Vertikaler Modus", "lang_verticalTooltip": "Legt fest, ob Kalender und Raum \u00fcbereinander angezeigt werden sollen", + "lang_wednesday": "Mittwoch", "lang_when": "Wann" } \ No newline at end of file diff --git a/modules-available/locationinfo/lang/en/template-tags.json b/modules-available/locationinfo/lang/en/template-tags.json index 4820caf2..bf51b0b2 100644 --- a/modules-available/locationinfo/lang/en/template-tags.json +++ b/modules-available/locationinfo/lang/en/template-tags.json @@ -15,6 +15,7 @@ "lang_countRoomplan": "by Roomplanner", "lang_createPanel": "Create panel", "lang_credentials": "Login", + "lang_currentDay": "Current Day", "lang_day": "Day", "lang_daysToShow": "Days", "lang_daysToShowTooltip": "Defines the amount of days to show in the calendar", @@ -35,6 +36,7 @@ "lang_for": "for", "lang_fourLocsHint": "You can pick up to four locations that will be shown in this panel.", "lang_free": "Open", + "lang_friday": "Friday", "lang_general": "General", "lang_generalSettings": "General Settings", "lang_ignoreSslTooltip": "Accept invalid, expired or self-signed ssl certificates", @@ -62,6 +64,7 @@ "lang_mode3": "Room", "lang_mode4": "Switching", "lang_modeTooltip": "The display modes the frontend supports", + "lang_monday": "Monday", "lang_monTilFr": "Monday - Friday", "lang_nameTooltip": "Defines the name of the server", "lang_noLocationsWarning": "Please select at least one location this panel should display.", @@ -118,11 +121,15 @@ "lang_shortWed": "Wed", "lang_shortWednesday": "Wed", "lang_showLog": "Log", + "lang_startDay": "Start Day", + "lang_startDayTooltip": "The day of the week at which the calendar starts", "lang_summaryPanel": "Summary panel", "lang_summaryUpdateIntervalTooltip": "Update interval (seconds)", "lang_sunday": "Sunday", "lang_switchTime": "Switchtime", "lang_switchTimeTooltip": "[1-120] Sets the time between switching (in seconds)", + "lang_thuesday": "Thuesday", + "lang_thursday": "Thursday", "lang_to": "to", "lang_typeTooltip": "Defines on which type of server you want to connect to", "lang_updateRates": "Update rates", @@ -135,5 +142,6 @@ "lang_useRoomplanner": "Count PCs", "lang_vertical": "Vertical mode", "lang_verticalTooltip": "Defines whether the room and calendar are shown above each other", + "lang_wednesday": "Wednesday", "lang_when": "When" } \ No newline at end of file diff --git a/modules-available/locationinfo/page.inc.php b/modules-available/locationinfo/page.inc.php index 5292c40e..5ba555df 100644 --- a/modules-available/locationinfo/page.inc.php +++ b/modules-available/locationinfo/page.inc.php @@ -372,6 +372,7 @@ class Page_LocationInfo extends Page 'eco' => Request::post('eco', false, 'bool'), 'prettytime' => Request::post('prettytime', false, 'bool'), 'roomplanner' => Request::post('roomplanner', false, 'bool'), + 'startday' => Request::post('startday', 0, 'int'), 'scaledaysauto' => Request::post('scaledaysauto', false, 'bool'), 'daystoshow' => Request::post('daystoshow', 7, 'int'), 'rotation' => Request::post('rotation', 0, 'int'), @@ -395,6 +396,7 @@ class Page_LocationInfo extends Page 'mode' => Request::post('override'.$locationids[$i].'mode', 1, 'int'), 'roomplanner' => Request::post('override'.$locationids[$i].'roomplanner', false, 'bool'), 'vertical' => Request::post('override'.$locationids[$i].'vertical', false, 'bool'), + 'startday' => Request::post('override'.$locationids[$i].'startday', 0, 'int'), 'scaledaysauto' => Request::post('override'.$locationids[$i].'scaledaysauto', false, 'bool'), 'daystoshow' => Request::post('override'.$locationids[$i].'daystoshow', 7, 'int'), 'rotation' => Request::post('override'.$locationids[$i].'rotation', 0, 'int'), @@ -995,6 +997,7 @@ class Page_LocationInfo extends Page 'eco_checked' => $config['eco'] ? 'checked' : '', 'prettytime_checked' => $config['prettytime'] ? 'checked' : '', 'roomplanner' => $config['roomplanner'], + 'startday' => $config['startday'], 'scaledaysauto_checked' => $config['scaledaysauto'] ? 'checked' : '', 'daystoshow' => $config['daystoshow'], 'rotation' => $config['rotation'], diff --git a/modules-available/locationinfo/templates/frontend-default.html b/modules-available/locationinfo/templates/frontend-default.html index 98149bb9..c59679ee 100755 --- a/modules-available/locationinfo/templates/frontend-default.html +++ b/modules-available/locationinfo/templates/frontend-default.html @@ -499,7 +499,8 @@ optional: if (!scaleFactor) { scaleFactor = 1; } - if (!v || !isFinite(v) || isNaN(v) || v < min * scaleFactor || v > max * scaleFactor) { + if (v === null || !isFinite(v) || isNaN(v) || v < min * scaleFactor || v > max * scaleFactor) { + console.log(property) config[property] = defaultval * scaleFactor; } } @@ -522,6 +523,7 @@ optional: setRoomConfigFromUrl(config, 'calupdate', PARAM_INT, 60 * 1000); setRoomConfigFromUrl(config, 'roomupdate', PARAM_INT, 1000); + setRoomConfigFromUrl(config, 'startday', PARAM_INT); setRoomConfigFromUrl(config, 'daystoshow', PARAM_INT); setRoomConfigFromUrl(config, 'scaledaysauto', PARAM_BOOL); setRoomConfigFromUrl(config, 'vertical', PARAM_BOOL); @@ -535,6 +537,7 @@ optional: // parameter validation putInRange(config, 'switchtime', 5, 120, 6, 1000); putInRange(config, 'scale', 10, 90, 50); + putInRange(config, 'startday', 0, 7, 0); putInRange(config, 'daystoshow', 1, 7, 7); putInRange(config, 'roomupdate', 15, 5 * 60, 60, 1000); putInRange(config, 'calupdate', 1, 60, 30, 60 * 1000); @@ -738,6 +741,9 @@ optional: */ function setUpCalendar(room) { var daysToShow = room.config.daystoshow; + var startDay = room.config.startday; + var startDayDate = new Date(); + if (startDay > 0) startDayDate.setDate((startDayDate.getDate() - (startDayDate.getDay() + 6) % 7) + (startDay - 1)); generateCalendarDiv(room); room.$.calendar.weekCalendar({ timeslotsPerHour: 1, @@ -765,7 +771,7 @@ optional: $event.find(".time").css({"backgroundColor": "#25B002", "border": "1px solid #888"}); } }, - date: MyDate(), + date: startDayDate, dateFormat: "j.n", timeFormat: "G:i", scrollToHourMillis: 500, diff --git a/modules-available/locationinfo/templates/page-config-panel-default.html b/modules-available/locationinfo/templates/page-config-panel-default.html index 43a7db44..5e13190e 100644 --- a/modules-available/locationinfo/templates/page-config-panel-default.html +++ b/modules-available/locationinfo/templates/page-config-panel-default.html @@ -191,6 +191,31 @@ +
+
+
+ +
+
+ +
+
+

+ +

+
+
+
+
@@ -385,6 +410,7 @@ document.addEventListener("DOMContentLoaded", function () { addLocation(lids[i], $name.text()); } + $('#startday option[value="{{startday}}"]').attr("selected", "selected"); $('#daystoshow option[value="{{daystoshow}}"]').attr("selected", "selected"); $('#rotation option[value="{{rotation}}"]').attr("selected", "selected"); $('#mode option[value="{{mode}}"]').attr("selected", "selected"); @@ -474,6 +500,11 @@ document.addEventListener("DOMContentLoaded", function () { '
' + '

' + '
')); + $content.append($('
' + + '
' + + '
' + + '

' + + '
')); $content.append($('
' + '
' + '
' + @@ -514,6 +545,7 @@ document.addEventListener("DOMContentLoaded", function () { $('#override' + id + 'roomplanner').val(overrides[id].roomplanner ? 1 : 0); if (overrides[id].vertical) $('#override' + id + 'vertical').bootstrapSwitch('state', true); if (overrides[id].scaledaysauto) $('#override' + id + 'scaledaysauto').bootstrapSwitch('state', true); + $('#override' + id + 'startday').val(overrides[id].startday); $('#override' + id + 'daystoshow').val(overrides[id].daystoshow); $('#override' + id + 'rotation').val(overrides[id].rotation); scale.val(overrides[id].scale); @@ -522,6 +554,8 @@ document.addEventListener("DOMContentLoaded", function () { $('#override' + id + 'roomplanner').val($('#input-roomplanner').val()); if ($('#input-vertical').bootstrapSwitch('state')) $('#override' + id + 'vertical').bootstrapSwitch('state', true); if ($('#scaledaysauto').bootstrapSwitch('state')) $('#override' + id + 'scaledaysauto').bootstrapSwitch('state', true); + console.log($('#startday').val()) + $('#override' + id + 'startday').val($('#startday').val()); $('#override' + id + 'daystoshow').val($('#daystoshow').val()); $('#override' + id + 'rotation').val($('#rotation').val()); scale.val($('#input-scale').val()); -- cgit v1.2.3-55-g7522