Link opens the standard picker under the button instead of a window - linked records ticked, tick to link and untick to unlink, saved when the picker closes with one message - for every record link, contact and asset credentials, a contact's assets, project and service tickets, a ticket's services and related tickets, with a document's or file's Link grouped by kind and quick looks reloading in place; the old link windows and the handlers only they used are removed

This commit is contained in:
johnnyq
2026-11-20 18:23:48 -05:00
parent c1bdc99c14
commit 8ac88a48fd
54 changed files with 837 additions and 1252 deletions

View File

@@ -1,45 +1,13 @@
<?php
/*
* ITFlow - POST handlers for related tickets (functions/ticket_link.php): the ticket page's
* Link window and the x on each related ticket, and Link together on the tickets list.
* ITFlow - POST handlers for related tickets (functions/ticket_link.php): the x on each related
* ticket, and Link together on the tickets list. Linking from a ticket is its Link picker
* (functions/link_picker.php).
*/
defined('FROM_POST_HANDLER') || die("Direct file access is not allowed");
// From a ticket's Link window: this ticket and the ones picked, each a ticket of a client the agent can open
if (isset($_POST['link_tickets'])) {
validateCSRFToken();
$row = ticketForRequest($_POST['ticket_id'] ?? 0, 2);
$ticket_id = intval($row['ticket_id']);
$ids = [$ticket_id];
foreach (array_unique(array_map('intval', (array) ($_POST['related_ticket_ids'] ?? []))) as $related_id) {
$related = $related_id ? ticketRow($related_id) : null;
if ($related && (!intval($related['ticket_client_id']) || hasClientAccess($related['ticket_client_id']))) {
$ids[] = $related_id;
}
}
if (count($ids) < 2) {
flashAlert('Pick the tickets to link it with.', 'error');
redirect();
}
$joined = ticketLinkTogether($ids);
$related_count = count(ticketRelated($ticket_id));
logAudit("Ticket", "Link", "$session_name linked ticket " . escapeSql(ticketReference($row)) . " with " . (count($ids) - 1) . " other ticket(s)", intval($row['ticket_client_id']), $ticket_id);
flashAlert($joined
? "<strong>" . escapeHtml(ticketReference($row)) . "</strong> is related to <strong>$related_count</strong> ticket" . ($related_count === 1 ? '' : 's') . " now"
: 'They were already related.');
redirect();
}
// The x on a related ticket - it comes out of the group, the rest stay related
if (isset($_GET['unlink_ticket'])) {