Group Ticket Replies and only search in ticket reply not ticket subject or ticket details In global search

This commit is contained in:
johnnyq
2024-03-20 13:36:04 -04:00
parent 6790464e90
commit c0115a26c5
+30 -6
View File
@@ -103,8 +103,8 @@ if (isset($_GET['query'])) {
LEFT JOIN tickets ON ticket_reply_ticket_id = ticket_id LEFT JOIN tickets ON ticket_reply_ticket_id = ticket_id
LEFT JOIN clients ON ticket_client_id = client_id LEFT JOIN clients ON ticket_client_id = client_id
WHERE ticket_reply_archived_at IS NULL WHERE ticket_reply_archived_at IS NULL
AND (ticket_reply LIKE '%$query%' OR ticket_subject LIKE '%$query%' OR ticket_details LIKE '%$query%') AND (ticket_reply LIKE '%$query%')
ORDER BY ticket_id DESC LIMIT 5" ORDER BY ticket_id DESC, ticket_reply_id ASC LIMIT 20"
); );
$q = nullable_htmlentities($_GET['query']); $q = nullable_htmlentities($_GET['query']);
@@ -648,16 +648,25 @@ if (isset($_GET['query'])) {
<div class="card-body"> <div class="card-body">
<?php <?php
$last_ticket_id = null; // Track the last ticket ID processed
while ($row = mysqli_fetch_array($sql_ticket_replies)) { while ($row = mysqli_fetch_array($sql_ticket_replies)) {
$ticket_id = intval($row['ticket_id']); $ticket_id = intval($row['ticket_id']);
// Only output the ticket header if we're at a new ticket
if ($ticket_id !== $last_ticket_id) {
if ($last_ticket_id !== null) {
// Close the previous ticket's card (except for the very first ticket)
echo '</div></div>';
}
$ticket_prefix = nullable_htmlentities($row['ticket_prefix']); $ticket_prefix = nullable_htmlentities($row['ticket_prefix']);
$ticket_number = intval($row['ticket_number']); $ticket_number = intval($row['ticket_number']);
$ticket_subject = nullable_htmlentities($row['ticket_subject']); $ticket_subject = nullable_htmlentities($row['ticket_subject']);
$ticket_reply = $purifier->purify($row['ticket_reply']);
$client_id = intval($row['ticket_client_id']); $client_id = intval($row['ticket_client_id']);
$client_name = nullable_htmlentities($row['client_name']); $client_name = nullable_htmlentities($row['client_name']);
// Output the ticket header
?> ?>
<div class="card card-outline"> <div class="card card-outline">
<div class="card-header"> <div class="card-header">
@@ -669,15 +678,30 @@ if (isset($_GET['query'])) {
</div> </div>
</div> </div>
<div class="card-body prettyContent"> <div class="card-body prettyContent">
<?php
}
$ticket_reply = $purifier->purify($row['ticket_reply']);
// Output the ticket reply
?>
<div class="media"> <div class="media">
<i class="fas fa-fw fa-reply mr-3"></i>
<div class="media-body"> <div class="media-body">
<?php echo $ticket_reply; ?> <?php echo $ticket_reply; ?>
</div> </div>
</div> </div>
</div> <hr>
</div> <?php
<?php } ?> $last_ticket_id = $ticket_id; // Update the last ticket ID
}
if ($last_ticket_id !== null) {
// Close the last ticket's card
echo '</div></div>';
}
?>
</div> </div>