diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c1674f4a..e3fc2efa6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -108,6 +108,7 @@ Update from Maintenance > Update — Queue Update hands the job to cron, which u - 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. +- Dispatch: a new page under Support puts each agent's booked work beside the tickets still to give out. The queue on the left has three tabs - No agent, Not booked (with an agent, nothing booked) and Left behind - most urgent first, with a search, a client and a priority filter. Day shows a column for each agent through the day; Week a row for each agent with a column for each day. Drag a ticket from the queue onto an agent and a time, or drag a booking to another agent or time, and the Schedule window opens with the agent, the time, how long and onsite or remote filled in - Schedule it gives the ticket to that agent and books it, emailing them the calendar file, the agent who had it the cancellation, and the contact and watchers unless you switch that off. Drag a booking back onto the queue to take it off the schedule. One-off events move the same way, to another time or agent. Workload shows each agent's open tickets (leading and helping), SLAs breached or close to it, tickets past due, not booked or gone quiet, and the hours booked today and this week against the working hours in Admin > SLA - flagged Falling behind, Watch, Overloaded or Has room against the team. Click an agent for their tickets, or drop a ticket from the queue on one to give it to them. Under it, This week shows tickets in and closed each day, against last week and the last four, the week's SLA results and each agent's share. Which agents show, the view and weekends are kept to your account, and an agent on their own time zone sees it on their clock. Seeing Dispatch takes Support in your role; booking from it takes Support at Modify. From Mountaineer IT's build of ITFlow. ### Bug Fixes @@ -235,6 +236,7 @@ Update from Maintenance > Update — Queue Update hands the job to cron, which u - 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. +- Dispatch (`agent/dispatch.php`, `agent/js/dispatch.js`, `functions/dispatch.php`): `dispatchCan()` (Support at View), `dispatchCanEdit()` (`calendarCanScheduleTickets()`), `dispatchAgents()` (active agents who are admins or have Support at Modify, with `calendarAgentColor()`), `dispatchState()` / `dispatchStateSave()` (the `dispatch` key of `user_settings.user_config_calendar_state`, which `calendarUserStateSave()` now keeps: `view`, `hidden`, `weekends`), `dispatchBusinessHours()` and `dispatchWorkingDay()` from `getSlaSettings()`, `dispatchQueue($tab, $filters)` (`unassigned`, `unbooked`, `left_behind` via `calendarLeftBehindSql()`, with each tab's count), `dispatchItems($from, $to, $agent_ids)` (the tickets, helper bookings, events and holidays sources per agent, `extendedProps.agent` and `reference` added, only tickets and one-off events editable, through `timezoneItems()`), `dispatchBook()` (`ticketChangeAssignee()`, `ticketMailScheduleAgentCancelled()` for the agent who had it, then `ticketSetSchedule()`), `dispatchUnbook()` (`ticketCancelSchedule()`), `dispatchAssign()` (refused for a booked ticket), `dispatchEventMove()` (a one-off event in time and from one agent to another with `calendarEventSetAgents()`, `calendarSendInvites()` with `update` to those who have it), `dispatchWorkload()` with `dispatchWorkloadFlags()`, and `dispatchWeekStats()` (tickets given this week read from the `assigned the ticket to ` history lines). `agent/ajax.php`: GET `dispatch_queue`, `dispatch_items`, `dispatch_workload`, `dispatch_week`; POST (CSRF) `dispatch_state`, and with `dispatchCanEdit()`, after `timezoneMovePost()`, `dispatch_book`, `dispatch_unbook`, `dispatch_assign` and `dispatch_event_move` - JSON `{ok, message, conflicts}` or `{error}` with 400/403. `ticketSetSchedule()` and `ticketMailSchedule()` take `$tell_client` (default true) to leave the contact and watchers out. Day is a FullCalendar `timeGridDay` per agent in one scroller (`drop` for the queue's `FullCalendar.Interaction.Draggable`, `eventReceive` between columns, `eventDragStop` over the queue to unbook); Week and Workload use SortableJS. From Mountaineer IT's build of ITFlow. ## [26.11.8] diff --git a/agent/ajax.php b/agent/ajax.php index ab8a6cc84..cc1a4c562 100644 --- a/agent/ajax.php +++ b/agent/ajax.php @@ -2716,6 +2716,96 @@ if (isset($_POST['calendar_move'])) { exit; } +/* + * Dispatch (functions/dispatch.php, agent/js/dispatch.js) - JSON: + * GET ?dispatch_queue=unassigned|unbooked|left_behind [&client_id &priority &q] the queue and each tab's count + * GET ?dispatch_items=1&from=Y-m-d&to=Y-m-d&agents=1,2 the board's bookings, events and holidays + * GET ?dispatch_workload=1&agents=1,2&first_day=0|1 each agent's open tickets, SLAs and booked hours + * GET ?dispatch_week=1&agents=1,2&first_day=0|1 this week's tickets in and closed, SLAs, each agent's share + * POST dispatch_book=1 ticket_id agent_id start minutes onsite tell_client give it to the agent and book it + * POST dispatch_unbook=1 ticket_id take its booking off + * POST dispatch_assign=1 ticket_id agent_id give it to the agent, not booked + * POST dispatch_event_move=1 event_id start end all_day from to a one-off event to another time or agent + * POST dispatch_state=1 view hidden weekends what this agent had on Dispatch + * Times come and go on the viewer's clock (functions/user_timezone.php). Looking takes + * Support at View; changing anything but your own view takes Modify. + */ +if (isset($_GET['dispatch_queue']) || isset($_GET['dispatch_items']) || isset($_GET['dispatch_workload']) || isset($_GET['dispatch_week']) + || isset($_POST['dispatch_book']) || isset($_POST['dispatch_unbook']) || isset($_POST['dispatch_assign']) || isset($_POST['dispatch_event_move']) || isset($_POST['dispatch_state'])) { + + header('Content-Type: application/json'); + $fail = function ($message, $code = 400) { + http_response_code($code); + echo json_encode(['error' => $message]); + exit; + }; + if (!dispatchCan()) { + $fail('Dispatch takes Support in your role.', 403); + } + $agent_list = function ($value) { + return array_filter(array_map('intval', explode(',', (string) $value))); + }; + + if (isset($_GET['dispatch_queue'])) { + echo json_encode(dispatchQueue((string) $_GET['dispatch_queue'], $_GET)); + exit; + } + if (isset($_GET['dispatch_items'])) { + $from = calendarIsDate($_GET['from'] ?? '') ? $_GET['from'] : date('Y-m-d'); + $to = calendarIsDate($_GET['to'] ?? '') ? $_GET['to'] : $from; + if ($to < $from || strtotime($to) - strtotime($from) > 86400 * 42) { + $to = $from; + } + echo json_encode(dispatchItems($from, $to, $agent_list($_GET['agents'] ?? ''))); + exit; + } + if (isset($_GET['dispatch_workload'])) { + echo json_encode(dispatchWorkload($agent_list($_GET['agents'] ?? ''), intval($_GET['first_day'] ?? 0) === 1 ? 1 : 0)); + exit; + } + if (isset($_GET['dispatch_week'])) { + echo json_encode(dispatchWeekStats($agent_list($_GET['agents'] ?? ''), intval($_GET['first_day'] ?? 0) === 1 ? 1 : 0)); + exit; + } + + validateCSRFToken(); + if (isset($_POST['dispatch_state'])) { + echo json_encode(['ok' => dispatchStateSave($_POST)]); + exit; + } + if (!dispatchCanEdit()) { + $fail('Booking and moving tickets takes Support at Modify in your role - you can look, not change.', 403); + } + // Picked on the viewer's own clock - as the company's clock reads it + $_POST = timezoneMovePost($_POST); + + if (isset($_POST['dispatch_book'])) { + [$ok, $message, $conflicts] = dispatchBook($_POST['ticket_id'] ?? 0, $_POST['agent_id'] ?? 0, (string) ($_POST['start'] ?? ''), + $_POST['minutes'] ?? CALENDAR_TICKET_MINUTES, !empty($_POST['onsite']), !empty($_POST['tell_client'])); + if (!$ok) { + $fail($message); + } + echo json_encode(['ok' => true, 'message' => $message, 'conflicts' => $conflicts]); + exit; + } + if (isset($_POST['dispatch_unbook'])) { + [$ok, $message] = dispatchUnbook($_POST['ticket_id'] ?? 0); + $ok ? print(json_encode(['ok' => true, 'message' => $message])) : $fail($message); + exit; + } + if (isset($_POST['dispatch_assign'])) { + [$ok, $message] = dispatchAssign($_POST['ticket_id'] ?? 0, $_POST['agent_id'] ?? 0); + $ok ? print(json_encode(['ok' => true, 'message' => $message])) : $fail($message); + exit; + } + if (isset($_POST['dispatch_event_move'])) { + [$ok, $message] = dispatchEventMove($_POST['event_id'] ?? 0, (string) ($_POST['start'] ?? ''), (string) ($_POST['end'] ?? ''), + !empty($_POST['all_day']), $_POST['from'] ?? 0, $_POST['to'] ?? 0); + $ok ? print(json_encode(['ok' => true, 'message' => $message])) : $fail($message); + exit; + } +} + /* * The calendar's To schedule list: an agent's open tickets with no work booked * (most urgent first), to drag onto the calendar - in one client, or all. diff --git a/agent/dispatch.php b/agent/dispatch.php new file mode 100644 index 000000000..84a0003dd --- /dev/null +++ b/agent/dispatch.php @@ -0,0 +1,238 @@ + Settings > Modules).', 'error'); + redirect('/agent/calendar.php'); +} + +$agents = dispatchAgents(); +$state = dispatchState(); +$can_edit = dispatchCanEdit(); +$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT user_config_calendar_first_day FROM user_settings WHERE user_id = $session_user_id")); +$first_day = intval($row['user_config_calendar_first_day'] ?? 0); +$clients = mysqli_fetch_all(mysqli_query($mysqli, "SELECT client_id, client_name FROM clients WHERE client_archived_at IS NULL" . clientScopeSql('client_id') . " ORDER BY client_name"), MYSQLI_ASSOC); +$tell_client = intval($config_ticket_client_general_notifications) === 1; + +?> + +
+ +
+
+

+ Dispatch + + View only + + +

+ + + +
+ + + +
+
+ + + +
+
+ + +
+ +
+
+ +
+
+
+
+ +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ +
+
+
+
+
+
+
+
+ + +
+
+

This week

+ Every ticket you can see - the table has the agents ticked under Agents +
+
+
Loading...
+
+
+
+ + + + + + + + + + + + + + + + diff --git a/agent/includes/side_nav.php b/agent/includes/side_nav.php index 3e4a9fb66..3f5f0ab5e 100644 --- a/agent/includes/side_nav.php +++ b/agent/includes/side_nav.php @@ -101,6 +101,12 @@

+