Tickets: booked work has an end - the Schedule window has How long from 15 minutes to a day and an Agent picker that gives the ticket to someone else and takes it off the old agent's calendar; New Ticket's Schedule and a recurring ticket's Book the work for take a length; the calendar draws each booking at its length and dragging its bottom edge changes it after asking; the booking email, calendar file, ticket and guest page show the end; the double-booking warning lists the agent's tickets and timed events that overlap the booking instead of anything within two hours; database 3.8.2 adds tickets.ticket_schedule_end and recurring_tickets.recurring_ticket_schedule_minutes; 26.11.9 changelog entries

This commit is contained in:
johnnyq
2026-11-17 20:50:59 -05:00
parent 1c4c8be8de
commit 512ac75c73
18 changed files with 350 additions and 76 deletions

View File

@@ -177,7 +177,7 @@ ob_start();
<?php if (!empty($ticket['ticket_schedule'])) { ?>
<dt>Scheduled</dt>
<dd><i class="fas fa-<?= intval($ticket['ticket_onsite']) ? 'truck' : 'calendar-check' ?> text-body-secondary me-1"></i><?= escapeHtml(date('D M j, g:i A', strtotime($ticket['ticket_schedule']))) ?><?= intval($ticket['ticket_onsite']) ? ' <span class="text-body-secondary">on site</span>' : '' ?></dd>
<dd><i class="fas fa-<?= intval($ticket['ticket_onsite']) ? 'truck' : 'calendar-check' ?> text-body-secondary me-1"></i><?= escapeHtml(ticketScheduleShortText($ticket['ticket_schedule'], $ticket['ticket_schedule_end'] ?? null)) ?><?= intval($ticket['ticket_onsite']) ? ' <span class="text-body-secondary">on site</span>' : '' ?></dd>
<?php } ?>
<?php if (intval($ticket['ticket_project_id']) && $ticket['project_name'] !== null) { ?>

View File

@@ -250,12 +250,17 @@ ob_start();
<div class="input-group">
<span class="input-group-text"><i class="fa fa-fw fa-calendar-day"></i></span>
<input type="datetime-local" class="form-control" name="schedule" min="<?= date('Y-m-d\TH:i') ?>" aria-label="Date and time of the work">
<select class="form-select flex-grow-0 w-auto" name="schedule_minutes" aria-label="How long">
<?php foreach (ticketScheduleLengths() as $minutes => $label) { ?>
<option value="<?= intval($minutes) ?>" <?= intval($minutes) === CALENDAR_TICKET_MINUTES ? 'selected' : '' ?>><?= escapeHtml($label) ?></option>
<?php } ?>
</select>
<select class="form-select flex-grow-0 w-auto" name="onsite" aria-label="Visit">
<option value="0">Remote</option>
<option value="1">Onsite</option>
</select>
</div>
<div class="form-text">Leave it empty to book the work later.</div>
<div class="form-text">When, how long and where. Leave it empty to book the work later.</div>
</div>
</div>
</div>

View File

@@ -15,6 +15,11 @@ $ticket_onsite = intval($row['ticket_onsite']);
$client_name = escapeHtml($row['client_name']);
$client_id = intval($row['ticket_client_id']);
// Who does the work - the agents who can open this client's tickets, and whoever has it now - and for how long
$schedule_tech = intval($row['ticket_assigned_to']);
$schedule_agents = ticketMentionAgents($client_id);
$schedule_minutes = ticketScheduleMinutes($row['ticket_schedule'], $row['ticket_schedule_end'] ?? null);
ob_start();
?>
@@ -38,6 +43,34 @@ ob_start();
</div>
</div>
<div class="row g-2 mb-3">
<div class="col-sm-7">
<label>Agent</label>
<div class="input-group">
<span class="input-group-text"><i class="fa fa-fw fa-user-check"></i></span>
<select class="form-select select2" name="schedule_tech" id="scheduleTech">
<?php if (!$schedule_tech || !isset($schedule_agents[$schedule_tech])) { ?>
<option value="<?= $schedule_tech ?>"><?= $schedule_tech ? escapeHtml($row['user_name']) : '- Unassigned -' ?></option>
<?php } ?>
<?php foreach ($schedule_agents as $agent) { ?>
<option value="<?= intval($agent['id']) ?>" data-name="<?= escapeHtml($agent['name']) ?>" <?= intval($agent['id']) === $schedule_tech ? 'selected' : '' ?><?= selectOptionData($agent['avatar'] !== '' ? ['image' => $agent['avatar']] : ['initials' => $agent['initials'], 'shape' => 'circle', 'tone' => 'secondary']) ?>><?= escapeHtml($agent['name']) ?></option>
<?php } ?>
</select>
</div>
</div>
<div class="col-sm-5">
<label>How long</label>
<div class="input-group">
<span class="input-group-text"><i class="fa fa-fw fa-hourglass-half"></i></span>
<select class="form-select select2" name="schedule_minutes" id="scheduleMinutes">
<?php foreach (ticketScheduleLengths($schedule_minutes) as $minutes => $label) { ?>
<option value="<?= intval($minutes) ?>" <?= intval($minutes) === $schedule_minutes ? 'selected' : '' ?>><?= escapeHtml($label) ?></option>
<?php } ?>
</select>
</div>
</div>
</div>
<div class="mb-3">
<label>Visit</label>
<div class="input-group">
@@ -49,9 +82,9 @@ ob_start();
</div>
</div>
<?php if (intval($row['ticket_assigned_to'])) { ?>
<!-- What else the agent has that day, so it is not booked on top of something (agent/js/ticket_schedule_modal.js) -->
<div class="border rounded p-2 small" id="scheduleAgentDay" data-user="<?= intval($row['ticket_assigned_to']) ?>" data-ticket="<?= $ticket_id ?>" data-name="<?= escapeHtml($row['user_name']) ?>" hidden>
<?php if ($schedule_agents) { ?>
<!-- What else the chosen agent has that day, so it is not booked on top of something (agent/js/ticket_schedule_modal.js) -->
<div class="border rounded p-2 small" id="scheduleAgentDay" data-user="<?= $schedule_tech ?>" data-ticket="<?= $ticket_id ?>" data-name="<?= escapeHtml((string) $row['user_name']) ?>" hidden>
<div class="d-flex align-items-center mb-1">
<span class="fw-semibold"><i class="far fa-calendar-alt fa-fw text-secondary me-1"></i><span class="js-day-title"></span></span>
<a class="ms-auto js-day-open" href="calendar.php">Calendar</a>