Files
itflow/agent/modals/ticket/ticket_bulk_reply.php
johnnyq 81c80d8965 Canned responses stages 3 and 4: agents keep canned responses of their own in Your account > Canned Responses (on the standard list with Yours and Shared tabs, how often they used each, change, copy, archive and delete their own, Copy to yours from a shared one), offered to them alone and first in the picker as Yours; Save your reply as a canned response at the foot of the picker opens the draft with the ticket's contact, first name, client, ticket number, subject, link and agent swapped back to placeholders (canned_response_unfill, text only, a one-word subject left alone), offered on the ticket's category with a switch to put it back as written, and saves it in JSON without leaving the ticket so the reply stays and the new one goes straight into the picker; Admin > Canned Responses gains an Agents' own tab showing whose each is with Share with everyone, copies made there are shared, and admins can share their own or tick Share when saving a reply; files go with a response (Files tab, up to ten of the ticket attachment kinds, kept in uploads/canned_responses/<id>/, streamed by agent/canned_response_file.php to those who may use it), shown as chips under the picker with an x to leave one off, copied onto the ticket with the reply and sent with its email on a ticket and in Update & Reply; migration 3.2.4 adds canned_response_user_id and canned_response_created_by and the canned_response_files table, existing responses staying shared; the response window moves to includes/canned_response_form.php for the admin and account windows; export and import (functions/canned_response_transfer.php) of one, some or every shared response as a versioned JSON file with categories by name, what it sets up, status by name and files as base64, importing as shared with categories matched or made and leave, add as well or replace (keeping use and archived state), everything made safe and refused files named; an MSP starter pack of 27 canned responses in Starter Content loaded through the same import, with Update for the ones already added, and the Update button now driven by the pack registry; new Canned Responses report under Service Desk by response and by agent, filtered by client and by the agent who used it, admins seeing every agent's own; changelog updated
2026-10-18 15:36:00 -04:00

91 lines
4.3 KiB
PHP

<?php
require_once '../../../includes/modal_header.php';
enforceUserPermission('module_support', 2);
$ticket_ids = array_map('intval', $_GET['ticket_ids'] ?? []);
$count = count($ticket_ids);
// The canned responses for the tickets' categories, and the ones for every ticket - filled in for each ticket as it is sent
$bulk_category_ids = [];
if ($ticket_ids) {
$sql_bulk_categories = mysqli_query($mysqli, "SELECT DISTINCT ticket_category FROM tickets WHERE ticket_id IN (" . implode(',', array_filter($ticket_ids) ?: [0]) . ")");
while ($row = mysqli_fetch_row($sql_bulk_categories)) {
$bulk_category_ids[] = intval($row[0]);
}
}
$canned_picker_groups = cannedResponsePickerGroups($bulk_category_ids, $session_user_id);
$canned_picker_id = 'cannedPickerBulk';
$canned_picker_editor = 'bulkReplyDetails';
$canned_picker_ticket_id = 0;
ob_start();
?>
<div class="modal-header bg-dark">
<h5 class="modal-title"><i class="fas fa-fw fa-paper-plane me-2"></i>Update & Reply <strong><?= $count ?></strong> ticket<?= $count === 1 ? '' : 's' ?></h5>
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal"></button>
</div>
<form action="post.php" method="post" autocomplete="off">
<input type="hidden" name="csrf_token" value="<?= $_SESSION['csrf_token'] ?>">
<?php foreach ($ticket_ids as $ticket_id) { ?><input type="hidden" name="ticket_ids[]" value="<?= $ticket_id ?>"><?php } ?>
<input type="hidden" name="bulk_private_reply" value="0">
<div class="modal-body">
<div class="input-group mb-3">
<span class="input-group-text"><i class="fa fa-fw fa-thermometer-half"></i></span>
<select class="form-select select2" name="bulk_status" required>
<!-- Show all active ticket statuses, apart from new or closed as these are system-managed -->
<?php $sql_ticket_status = mysqli_query($mysqli, "SELECT ticket_status_id, ticket_status_name, ticket_status_color FROM ticket_statuses WHERE ticket_status_id != 1 AND ticket_status_id != 5 AND ticket_status_active = 1");
while ($row = mysqli_fetch_assoc($sql_ticket_status)) {
$ticket_status_id_select = intval($row['ticket_status_id']);
$ticket_status_name_select = escapeHtml($row['ticket_status_name']); ?>
<option value="<?= $ticket_status_id_select ?>"<?= selectOptionColor($row['ticket_status_color'] ?? '') ?>> <?= $ticket_status_name_select ?> </option>
<?php } ?>
</select>
</div>
<?php require __DIR__ . '/../../includes/inc_canned_response_picker.php'; ?>
<div class="mb-1">
<textarea class="form-control tinymce" rows="5" id="bulkReplyDetails" name="bulk_reply_details" placeholder="Type an update here"<?= $canned_picker_groups ? ' data-canned-picker="cannedPickerBulk"' : '' ?>></textarea>
</div>
<div class="small text-secondary mb-3">[First Name], [Ticket], [Subject] and the other placeholders are filled in for each ticket as it is sent.</div>
<div class="col-3">
<div class="mb-3">
<label>Time worked</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-stopwatch"></i></span>
<input class="form-control timepicker" id="time_worked" name="time" type="text" placeholder="HH:MM:SS" pattern="([01]?[0-9]|2[0-3]):([0-5]?[0-9]):([0-5]?[0-9])" value="00:01:00" required/>
</div>
</div>
</div>
<div class="mb-3">
<div class="form-check">
<input type="checkbox" class="form-check-input" id="bulkPrivateReplyCheckbox" name="bulk_private_reply" value="1">
<label class="form-check-label" for="bulkPrivateReplyCheckbox">Mark as internal</label>
<small class="form-text text-muted">Only agents see it.</small>
</div>
</div>
</div>
<div class="modal-footer">
<button type="submit" name="bulk_ticket_reply" class="btn btn-primary text-bold"><i class="fas fa-paper-plane me-2"></i>Update & Reply</button>
<button type="button" class="btn btn-light" data-bs-dismiss="modal"><i class="fas fa-times me-2"></i>Cancel</button>
</div>
</form>
<?php
require_once '../../../includes/modal_footer.php';