diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2a97c61bf..7c1674f4a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,7 +6,7 @@ This file documents all notable changes made to ITFlow.
### Upgrading
-Update from Maintenance > Update — Queue Update hands the job to cron, which updates the files and applies this release's nineteen database changes (3.6.6 to 3.8.5) in the same pass. They add four tables for RMM providers and their alerts, a setting for device actions and one for API keys in the address, a column marking the emails the mail queue clears once sent, a column and a table for agent banners, two columns for ticket statuses with a setting for the "ticket assigned" message, a column on tickets with a setting for the "no response" message, a table for who a ticket's email replies go to, the settings for Quick tickets, columns on recurring tickets and recurring invoices for booking and making them ahead, two columns on ticket replies for when their time was worked, the settings for cron alerts, a table and a setting for labor costs, a column on users for API / service accounts, columns on tickets and recurring tickets for how long booked work takes, a column each on recurring tickets and calendar events for repeating on a weekday, two columns on agents' settings for their calendar color and what their calendar shows, and a table for the agents helping on a ticket, and change nothing that is there. Nothing else is required. This release has eleven security fixes - see Security. On Apache, ITFlow's own .htaccess now sends security headers: if you show ITFlow inside a frame on another website, it will now refuse to load there. On nginx, add the same headers to your server block if you want them - see Developer Updates.
+Update from Maintenance > Update — Queue Update hands the job to cron, which updates the files and applies this release's twenty database changes (3.6.6 to 3.8.6) in the same pass. They add four tables for RMM providers and their alerts, a setting for device actions and one for API keys in the address, a column marking the emails the mail queue clears once sent, a column and a table for agent banners, two columns for ticket statuses with a setting for the "ticket assigned" message, a column on tickets with a setting for the "no response" message, a table for who a ticket's email replies go to, the settings for Quick tickets, columns on recurring tickets and recurring invoices for booking and making them ahead, two columns on ticket replies for when their time was worked, the settings for cron alerts, a table and a setting for labor costs, a column on users for API / service accounts, columns on tickets and recurring tickets for how long booked work takes, a column each on recurring tickets and calendar events for repeating on a weekday, three columns on agents' settings for their calendar color, what their calendar shows and their own time zone, and a table for the agents helping on a ticket, and change nothing that is there. Nothing else is required. This release has eleven security fixes - see Security. On Apache, ITFlow's own .htaccess now sends security headers: if you show ITFlow inside a frame on another website, it will now refuse to load there. On nginx, add the same headers to your server block if you want them - see Developer Updates.
### Security
@@ -107,6 +107,7 @@ Update from Maintenance > Update — Queue Update hands the job to cron, which u
- Calendar: what you have shown - calendars, sources, Whose and the view - is kept to your account, so the calendar opens the same way on every computer and phone. The first time, it opens on your own calendar. With Whose set to Everyone, To schedule lists everyone's open tickets that aren't booked, with who has each. From Mountaineer IT's build of ITFlow.
- Tickets: more than one agent can work a ticket. Under Assigned to on the ticket, Additional agents adds others to help, while the ticket stays assigned to its lead. Each helper is booked at the same time as the lead - moving and cancelled with the lead's booking - at a time of their own, or not booked. A helper finds the ticket under Mine and on the dashboard, is emailed the client's replies as the lead is, and is sent their own booking with a calendar file that doesn't replace the lead's. The client's emails stay about the lead's booking. Click a helper to change their booking or take them off. From Mountaineer IT's build of ITFlow.
- Tickets: the tickets list and board show +1, +2 after the lead when others are helping - Helping when one of them is you. A helper's booking is on the calendar in their color, can be dragged to a time of their own, shows in their calendar link, and counts when someone books them for something else at the same time. From Mountaineer IT's build of ITFlow.
+- Time zones: an agent who works away from the company can pick My time zone under Account > Preferences. The calendar, the ticket's booking, the Schedule window, New Event and Edit, and the event's quick look are then on their own clock, with a note saying so, and their booking emails give their time with the company's beside it. Bookings are still kept in the company's time, so the client's emails and calendar files, and everyone else's view, don't change. From Mountaineer IT's build of ITFlow.
### Bug Fixes
@@ -233,6 +234,7 @@ Update from Maintenance > Update — Queue Update hands the job to cron, which u
- Database 3.8.3: `recurring_tickets.recurring_ticket_by_day` and `calendar_events.event_repeat_by_day`, an RFC 5545 BYDAY value (`3WE`, `-1FR`; NULL is the same date) - `byDayReady()` and the helpers in `functions/by_day.php`: `byDayRule()`, `byDayDate($year, $month, $rule)`, `byDayText()`, `byDayOptions($date)` (the rules a date can take), `byDayForDate()` (a posted rule, kept when the date takes it), `byDayFollow()` (a rule carried to a moved date) and `byDayField()`, the Repeats on picker filled by `js/repeat_on.js`, which posts `repeat_on` with `repeat_on_field`. `recurringTicketNextRun()` takes `$by_day` for month-based frequencies, passed by every caller, and `recurringTicketByDaySql()` saves it for `add_recurring_ticket`, `edit_recurring_ticket`, the bulk next run and `recurring_tickets/create` and `update` (`repeat_on`). `calendarEventFormSet()` saves `event_repeat_by_day` from `repeat_on`, or follows `repeat_on_current`; `expandRecurringEvent()`, `calendarRepeatText()` and `icsRepeatToRrule($repeat, $interval, $until, $all_day, $timezone, $by_day, $start)` (BYDAY, with BYMONTH for yearly) use it, through `calendarEventByDay()`. `events/create` and `update` take `event_repeat_by_day`. From Mountaineer IT's build of ITFlow.
- Database 3.8.4: `user_settings.user_config_calendar_color` (NULL is `calendarAgentDefaultColor()`, one of `CALENDAR_AGENT_COLORS` by user id) and `user_config_calendar_state` (JSON, `all` and `client`) - `calendarAgentSettingsReady()`. `calendarAgentColor()`, `calendarAgentColors()`, `calendarFirstName()`; `calendarAgentColorField()` (Account > Preferences, Admin > Users' Edit) posts `calendar_color` and `calendar_color_auto`, saved by `calendarAgentColorSave()` in `edit_your_user_preferences` and `edit_user`. The tickets source colors each booking by `ticket_assigned_to` and adds `agent_name` and `agent_full` (the name leaves `detail`); `calendarEventItems()` ends with `calendarEventItemsAgents()`, which colors an event by its attendee agents and leaves out of one agent's calendar an event assigned only to others. `calendarEventAgents()`, `calendarEventAgentChoices()`, `calendarEventDefaultAgents()` (New Event's `agent_id`), `calendarEventSetAgents()` and `calendarEventAgentsText()`; `assign_event` (`agent/post/event.php`) is the quick look's. `calendarLeftBehindSql()` and `calendarLeftBehindTickets()` behind `ajax.php?calendar_left_behind`, and items left behind get `itflow-cal-left-behind`. `ajax.php` `calendar_state` saves through `calendarUserStateSave()` and `calendarCleanState()` (`CALENDAR_VIEWS`); `agent/calendar.php` reads `calendarUserState()` into `data-saved-state`, which `agent/js/calendar.js` prefers to `localStorage`. `calendar_unscheduled` takes `user_id` 0 as everyone's, with `agent`. The `holidays` source reads `business_holidays`. The `timeGridSevenDays` view and `slotEventOverlap: false`. From Mountaineer IT's build of ITFlow.
- Database 3.8.5: `ticket_helpers` (`ticket_id`, `user_id`, `follows_lead`, `schedule_start`, `schedule_end`, `added_by`, `added_at`; the lead stays `ticket_assigned_to`) - `functions/ticket_helpers.php`: `ticketHelpersReady()`, `ticketHelpers()`, `ticketHelperNames()`, `ticketHelpersTidy()` (a row for whoever is now the lead is cleared once a request, its booking cancelled and `ticketHelperLeadInvite()` sent), `ticketAssignedSql()` (Mine, the assigned filter and the dashboard's My tickets), `ticketHelperSave()`, `ticketHelperRemove()`, `ticketHelperMail()` (`ticketAgentEmailContent()`'s new `helper` kind; its own UID, `ticketHelperUid()`), `ticketHelpersLeadMoved()` from `ticketSetSchedule()` (their clashes join its conflicts), `ticketHelpersLeadCancelled()` from `ticketCancelSchedule()`, `ticketHelpersMailReplied()` from `ticketMailAssigneeReplied()`, `ticketHelperCalendarItems()` (kind `helper`, in the tickets source), `ticketHelperFeedItems()`, `ticketHelperDashboardItems()` and `ticketHelperConflicts()` (in `ticketScheduleConflicts()`). Helpers are `ticketMentionAgents()`. `agent/modals/ticket/ticket_helper.php`, `agent/post/ticket_helper.php` (`save_ticket_helper`, `remove_ticket_helper`), `ticketHelpersBadge()` in the list and board, and `calendar_move` with `kind` `helper` (their own time). From Mountaineer IT's build of ITFlow.
+- Database 3.8.6: `user_settings.user_config_timezone` (NULL is the company's) - `functions/user_timezone.php`: `timezoneUsersReady()`, `timezoneOwn()`, `timezoneOf()`, `timezoneView()`, `timezoneShifted()`, `timezoneConvert()`, `timezoneToView()` and `timezoneFromView()`; `timezoneField()` and `timezoneSave()` (`edit_your_user_preferences`, posting `timezone`). Times go out on the viewer's clock and come back in the company's: `calendar_items` and `calendar_day` turn the days asked for with `timezoneFromView()` and the items with `timezoneItems()`, `calendar_move` takes `timezoneMovePost()`, `add_event` and `edit_event` take `timezoneEventPost()`, `edit_ticket_schedule`, `add_ticket` and `save_ticket_helper` turn `scheduled_date_time` and `schedule` back, and the event form, Schedule window and helper window show `timezoneToView()` with `timezoneFormHint()`. `ticketScheduleShortText()` is on the viewer's clock with `timezoneAbbr()`; `timezoneEventWhenText()` is the quick look's; `agent/calendar.php` has `data-zone` and `timezoneNote()`, and `agent/js/calendar.js` sets `now` from it. `ticketMailSchedule($row, $cal_str, $cancelled, $when_text, $start, $end)` and the helper emails give the agent's time with `timezoneWhenFor()`. From Mountaineer IT's build of ITFlow.
## [26.11.8]
diff --git a/admin/database_updates/3.8.6.php b/admin/database_updates/3.8.6.php
new file mode 100644
index 000000000..7be3eb060
--- /dev/null
+++ b/admin/database_updates/3.8.6.php
@@ -0,0 +1,24 @@
+ 0;
+ };
+
+ if (!$itflow_column('user_settings', 'user_config_timezone')) {
+ mysqli_query($mysqli, "ALTER TABLE `user_settings` ADD `user_config_timezone` varchar(64) DEFAULT NULL AFTER `user_config_calendar_state`");
+ }
diff --git a/agent/ajax.php b/agent/ajax.php
index 038a7dbd4..ab8a6cc84 100644
--- a/agent/ajax.php
+++ b/agent/ajax.php
@@ -2566,13 +2566,16 @@ if (isset($_GET['calendar_items'])) {
}
$opts = ['client_id' => $client_id, 'user_id' => intval($_GET['user_id'] ?? 0)];
+ // The days asked for are on the viewer's clock, and so are the times sent back (functions/user_timezone.php)
+ [$from, $to] = [timezoneFromView($from), timezoneFromView($to)];
+
$calendar_ids = array_filter(array_map('intval', explode(',', (string) ($_GET['calendars'] ?? ''))));
$items = calendarEventItems($calendar_ids, $from, $to, $opts);
foreach (array_filter(explode(',', (string) ($_GET['sources'] ?? ''))) as $key) {
$items = array_merge($items, calendarSourceItems($key, $from, $to, $opts));
}
- echo json_encode($items);
+ echo json_encode(timezoneItems($items));
exit;
}
@@ -2594,6 +2597,9 @@ if (isset($_POST['calendar_move'])) {
exit;
};
+ // Dropped on the viewer's clock - as the company's clock reads it (functions/user_timezone.php)
+ $_POST = timezoneMovePost($_POST);
+
$start = ticketScheduleValue($_POST['start'] ?? '');
if ($start === '') {
$fail('That is not a date and time.');
@@ -2626,7 +2632,7 @@ if (isset($_POST['calendar_move'])) {
$onsite = isset($_POST['onsite']) ? intval($_POST['onsite']) : intval($row['ticket_onsite']);
$result = ticketSetSchedule($row, $start, $onsite, $end);
- echo json_encode(['ok' => true, 'message' => ticketReference($row) . ' scheduled for ' . $result['when_text'], 'conflicts' => $result['conflicts']]);
+ echo json_encode(['ok' => true, 'message' => ticketReference($row) . ' scheduled for ' . timezoneWhenFor($start, $end, $session_user_id), 'conflicts' => $result['conflicts']]);
exit;
}
@@ -2661,7 +2667,7 @@ if (isset($_POST['calendar_move'])) {
if (!$ok) {
$fail($message);
}
- echo json_encode(['ok' => true, 'message' => $helper['user_name'] . ' booked on ' . ticketReference($row) . ' for ' . ticketScheduleWhenText($start, $end), 'conflicts' => $conflicts]);
+ echo json_encode(['ok' => true, 'message' => $helper['user_name'] . ' booked on ' . ticketReference($row) . ' for ' . timezoneWhenFor($start, $end, $session_user_id), 'conflicts' => $conflicts]);
exit;
}
@@ -2706,7 +2712,7 @@ if (isset($_POST['calendar_move'])) {
logAudit("Calendar Event", "Edit", "$session_name moved the event " . escapeSql($event['event_title']) . " to " . escapeSql(calendarWhenText($event)), intval($event['event_client_id']), $event_id);
- echo json_encode(['ok' => true, 'message' => $event['event_title'] . ' moved to ' . calendarWhenText($event) . ($sent ? " - the update was emailed to $sent " . ($sent === 1 ? 'person' : 'people') : '')]);
+ echo json_encode(['ok' => true, 'message' => $event['event_title'] . ' moved to ' . timezoneEventWhenText($event, $event['event_start'], $event['event_end']) . ($sent ? " - the update was emailed to $sent " . ($sent === 1 ? 'person' : 'people') : '')]);
exit;
}
@@ -2813,13 +2819,14 @@ if (isset($_GET['calendar_day'])) {
exit;
}
- $from = "$date 00:00:00";
- $to = "$date 23:59:59";
+ // The viewer's day, and its times on their clock (functions/user_timezone.php)
+ $from = timezoneFromView("$date 00:00:00");
+ $to = timezoneFromView("$date 23:59:59");
$opts = ['user_id' => $user_id];
- $items = array_merge(
+ $items = timezoneItems(array_merge(
calendarSourceItems('tickets', $from, $to, $opts),
calendarEventItems(array_keys(calendarList()), $from, $to, $opts)
- );
+ ));
$day = [];
foreach ($items as $item) {
diff --git a/agent/calendar.php b/agent/calendar.php
index 3d066935e..a7b02fdb6 100644
--- a/agent/calendar.php
+++ b/agent/calendar.php
@@ -65,7 +65,8 @@ foreach ($sources as $key => $source) {
data-mobile="= !empty($session_mobile) ? 1 : 0 ?>"
data-initial-date="= calendarIsDate($_GET['date'] ?? '') ? escapeHtml($_GET['date']) : '' ?>"
data-sources="= escapeHtml(json_encode($page_sources)) ?>"
- data-saved-state="= escapeHtml(json_encode($saved_state ?: new stdClass())) ?>">
+ data-saved-state="= escapeHtml(json_encode($saved_state ?: new stdClass())) ?>"
+ data-zone="= timezoneShifted() ? escapeHtml(timezoneView()) : '' ?>">
diff --git a/agent/js/calendar.js b/agent/js/calendar.js
index 215edda44..a6d28bc62 100644
--- a/agent/js/calendar.js
+++ b/agent/js/calendar.js
@@ -32,6 +32,16 @@
const agentSelect = document.getElementById('calendarAgent');
const unscheduledList = document.getElementById('calendarUnscheduled');
const leftBehindList = document.getElementById('calendarLeftBehind');
+ // Away from the company's time zone: "now" on the agent's own clock - the server sends their times moved into it
+ const zone = root.dataset.zone || '';
+ function zoneNow() {
+ const parts = {};
+ new Intl.DateTimeFormat('en-CA', {timeZone: zone, hourCycle: 'h23', year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit', second: '2-digit'})
+ .formatToParts(new Date()).forEach(function (part) {
+ parts[part.type] = part.value;
+ });
+ return parts.year + '-' + parts.month + '-' + parts.day + 'T' + parts.hour + ':' + parts.minute + ':' + parts.second;
+ }
// ---------- what this browser remembers ----------
@@ -228,6 +238,7 @@
eventOrder: 'allDay,start,-duration,title',
// Bookings at the same time sit side by side, never on top of each other
slotEventOverlap: false,
+ now: zone ? zoneNow : undefined,
views: {
// Side by side past three, the rest go behind "+N more"
timeGrid: {eventMaxStack: 3},
diff --git a/agent/modals/calendar/calendar_event.php b/agent/modals/calendar/calendar_event.php
index c08937db7..3aea6bb75 100644
--- a/agent/modals/calendar/calendar_event.php
+++ b/agent/modals/calendar/calendar_event.php
@@ -73,7 +73,7 @@ ob_start();