mirror of
https://github.com/itflow-org/itflow
synced 2026-11-25 05:47:26 +00:00
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:
@@ -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'])) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user