Fix Ticket Merging regressed from ticket select now use ticket_id instead of ticket_number

This commit is contained in:
johnnyq 2026-02-13 14:09:05 -05:00
parent fd29eb7c15
commit c0fe9813dc
3 changed files with 10 additions and 10 deletions

View File

@ -47,7 +47,7 @@ ob_start();
<div class="input-group-prepend"> <div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-tag"></i></span> <span class="input-group-text"><i class="fa fa-fw fa-tag"></i></span>
</div> </div>
<select class="form-control select2" name="merge_into_ticket_number" required> <select class="form-control select2" name="merge_into_ticket_id" required>
<option value=''>- Select a Ticket -</option> <option value=''>- Select a Ticket -</option>
<?php <?php
while ($row = mysqli_fetch_assoc($sql_merge)) { while ($row = mysqli_fetch_assoc($sql_merge)) {

View File

@ -34,7 +34,7 @@ ob_start();
</button> </button>
</div> </div>
<form action="post.php" method="post" autocomplete="off"> <form action="post.php" method="post" autocomplete="off">
<input type="hidden" id="current_ticket_id" name="ticket_id" value="<?php echo $ticket_id; ?>"> <input type="hidden" id="current_ticket_id" name="ticket_id" value="<?= $ticket_id ?>">
<div class="modal-body"> <div class="modal-body">
<div class="alert alert-dark"> <div class="alert alert-dark">
@ -47,7 +47,7 @@ ob_start();
<div class="input-group-prepend"> <div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-tag"></i></span> <span class="input-group-text"><i class="fa fa-fw fa-tag"></i></span>
</div> </div>
<select class="form-control select2" name="merge_into_ticket_number" required> <select class="form-control select2" name="merge_into_ticket_id" required>
<option value=''>- Select a Ticket -</option> <option value=''>- Select a Ticket -</option>
<?php <?php
while ($row = mysqli_fetch_assoc($sql_merge)) { while ($row = mysqli_fetch_assoc($sql_merge)) {

View File

@ -1052,19 +1052,19 @@ if (isset($_POST['bulk_merge_tickets'])) {
enforceUserPermission('module_support', 2); enforceUserPermission('module_support', 2);
$merge_into_ticket_number = intval($_POST['merge_into_ticket_number']); // Parent ticket *number* $merge_into_ticket_id = intval($_POST['merge_into_ticket_id']); // Parent ticket id
$merge_comment = sanitizeInput($_POST['merge_comment']); // Merge comment $merge_comment = sanitizeInput($_POST['merge_comment']); // Merge comment
$ticket_reply_type = 'Internal'; // Default all replies to internal $ticket_reply_type = 'Internal'; // Default all replies to internal
// NEW PARENT ticket details // NEW PARENT ticket details
// Get merge into ticket id (as it may differ from the number) // Get merge into ticket id (as it may differ from the number)
$sql = mysqli_query($mysqli, "SELECT ticket_id FROM tickets WHERE ticket_number = $merge_into_ticket_number"); $sql = mysqli_query($mysqli, "SELECT ticket_id FROM tickets WHERE ticket_id = $merge_into_ticket_id");
if (mysqli_num_rows($sql) == 0) { if (mysqli_num_rows($sql) == 0) {
flash_alert("Cannot merge into that ticket.", 'error'); flash_alert("Cannot merge into that ticket.", 'error');
redirect(); redirect();
} }
$merge_row = mysqli_fetch_assoc($sql); $merge_row = mysqli_fetch_assoc($sql);
$merge_into_ticket_id = intval($merge_row['ticket_id']); // Parent ticket ID $merge_into_ticket_number = intval($merge_row['ticket_number']); // Parent ticket Number
// Update & Close the selected tickets // Update & Close the selected tickets
if (isset($_POST['ticket_ids'])) { if (isset($_POST['ticket_ids'])) {
@ -1815,7 +1815,7 @@ if (isset($_POST['merge_ticket'])) {
enforceUserPermission('module_support', 2); enforceUserPermission('module_support', 2);
$ticket_id = intval($_POST['ticket_id']); // Child ticket ID to be closed $ticket_id = intval($_POST['ticket_id']); // Child ticket ID to be closed
$merge_into_ticket_number = intval($_POST['merge_into_ticket_number']); // Parent ticket *number* $merge_into_ticket_id = intval($_POST['merge_into_ticket_id']); // Parent ticket id
$merge_comment = sanitizeInput($_POST['merge_comment']); // Merge comment $merge_comment = sanitizeInput($_POST['merge_comment']); // Merge comment
$move_replies = intval($_POST['merge_move_replies']); // Whether to move replies to the new parent ticket $move_replies = intval($_POST['merge_move_replies']); // Whether to move replies to the new parent ticket
$ticket_reply_type = 'Internal'; // Default all replies to internal $ticket_reply_type = 'Internal'; // Default all replies to internal
@ -1836,21 +1836,21 @@ if (isset($_POST['merge_ticket'])) {
// NEW PARENT ticket details // NEW PARENT ticket details
// Get merge into ticket id (as it may differ from the number) // Get merge into ticket id (as it may differ from the number)
$sql = mysqli_query($mysqli, "SELECT ticket_id, ticket_client_id FROM tickets WHERE ticket_number = $merge_into_ticket_number"); $sql = mysqli_query($mysqli, "SELECT ticket_id, ticket_client_id FROM tickets WHERE ticket_id = $merge_into_ticket_id");
if (mysqli_num_rows($sql) == 0) { if (mysqli_num_rows($sql) == 0) {
flash_alert("Cannot merge into that ticket.", 'error'); flash_alert("Cannot merge into that ticket.", 'error');
redirect(); redirect();
} }
$merge_row = mysqli_fetch_assoc($sql); $merge_row = mysqli_fetch_assoc($sql);
$merge_into_ticket_id = intval($merge_row['ticket_id']);
$client_id = intval($merge_row['ticket_client_id']); $client_id = intval($merge_row['ticket_client_id']);
$merge_into_ticket_number = intval($merge_row['ticket_number']);
if ($client_id) { if ($client_id) {
$has_client = "&client_id=$client_id"; $has_client = "&client_id=$client_id";
} else { } else {
$has_client = ""; $has_client = "";
} }
// Sanity check // Sanity check
if ($ticket_number == $merge_into_ticket_number) { if ($ticket_id == $merge_into_ticket_id) {
flash_alert("Cannot merge into the same ticket.", 'error'); flash_alert("Cannot merge into the same ticket.", 'error');
redirect(); redirect();
} }