From c32e9c871b7a486ebb8fc95260ef0cc4633f8672 Mon Sep 17 00:00:00 2001 From: Jared Vititoe Date: Tue, 20 Jan 2026 21:54:04 -0500 Subject: [PATCH] feat: Add timezone setting in preferences + clickable logo - Add timezone dropdown to settings modal with common timezones - Save/load timezone preference per user - Apply user's timezone preference after authentication - Override system default with user preference if set - Make dashboard logo clickable (returns to default filters) - Show current timezone in settings Co-Authored-By: Claude Opus 4.5 --- assets/js/settings.js | 8 ++++++++ index.php | 15 +++++++++++++++ views/DashboardView.php | 25 ++++++++++++++++++++++++- 3 files changed, 47 insertions(+), 1 deletion(-) diff --git a/assets/js/settings.js b/assets/js/settings.js index 5586558..edda8e8 100644 --- a/assets/js/settings.js +++ b/assets/js/settings.js @@ -45,6 +45,13 @@ function applyPreferences() { document.body.classList.add(`table-${density}`); } + // Timezone - use server default if not set + const timezone = userPreferences.timezone || window.APP_TIMEZONE || 'America/New_York'; + const timezoneSelect = document.getElementById('userTimezone'); + if (timezoneSelect) { + timezoneSelect.value = timezone; + } + // Notifications const notificationsCheckbox = document.getElementById('notificationsEnabled'); if (notificationsCheckbox) { @@ -71,6 +78,7 @@ async function saveSettings() { default_status_filters: Array.from(document.querySelectorAll('[name="defaultFilters"]:checked')) .map(cb => cb.value).join(','), table_density: document.getElementById('tableDensity').value, + timezone: document.getElementById('userTimezone').value, notifications_enabled: document.getElementById('notificationsEnabled').checked ? '1' : '0', sound_effects: document.getElementById('soundEffects').checked ? '1' : '0', toast_duration: document.getElementById('toastDuration').value diff --git a/index.php b/index.php index 97ad2df..30baaa9 100644 --- a/index.php +++ b/index.php @@ -36,6 +36,21 @@ if (!str_starts_with($requestPath, '/api/')) { // Initialize audit log model $GLOBALS['auditLog'] = new AuditLogModel($conn); + + // Check if user has a timezone preference and apply it + if ($currentUser && isset($currentUser['user_id'])) { + require_once 'models/UserPreferencesModel.php'; + $prefsModel = new UserPreferencesModel($conn); + $userTimezone = $prefsModel->getPreference($currentUser['user_id'], 'timezone', null); + if ($userTimezone) { + // Override system timezone with user preference + date_default_timezone_set($userTimezone); + $GLOBALS['config']['TIMEZONE'] = $userTimezone; + $now = new DateTime('now', new DateTimeZone($userTimezone)); + $GLOBALS['config']['TIMEZONE_OFFSET'] = $now->getOffset() / 60; + $GLOBALS['config']['TIMEZONE_ABBREV'] = $now->format('T'); + } + } } // Simple router diff --git a/views/DashboardView.php b/views/DashboardView.php index 31ad6c4..cdf211e 100644 --- a/views/DashboardView.php +++ b/views/DashboardView.php @@ -77,7 +77,7 @@
- 🎫 Tinker Tickets + 🎫 Tinker Tickets
@@ -484,6 +484,29 @@
+ +
+ + + + Current: () + +