Feature Show who last replied in ticket listings

This commit is contained in:
johnnyq 2024-03-23 15:59:02 -04:00
parent 4d773e895a
commit 79ea97410e
3 changed files with 77 additions and 8 deletions

View File

@ -215,6 +215,31 @@ $total_scheduled_tickets = intval($row['total_scheduled_tickets']);
$asset_id = intval($row['ticket_asset_id']);
$vendor_id = intval($row['ticket_vendor_id']);
// Get Ticket Last updated By in the last ticket reply to be show in the last Response column
$sql_ticket_reply = mysqli_query($mysqli, "SELECT * FROM ticket_replies
LEFT JOIN users ON ticket_reply_by = user_id
LEFT JOIN contacts ON ticket_reply_by = contact_id
WHERE ticket_reply_ticket_id = $ticket_id
AND ticket_reply_archived_at IS NULL
ORDER BY ticket_reply_id DESC LIMIT 1"
);
$row = mysqli_fetch_array($sql_ticket_reply);
$ticket_reply_type = nullable_htmlentities($row['ticket_reply_type']);
$ticket_reply_by = intval($row['ticket_reply_by']);
if ($ticket_reply_type == "Client") {
$ticket_reply_by_display = nullable_htmlentities($row['contact_name']);
$user_initials = initials($row['contact_name']);
$user_avatar = nullable_htmlentities($row['contact_photo']);
$avatar_link = "uploads/clients/$client_id/$user_avatar";
} else {
$ticket_reply_by_display = nullable_htmlentities($row['user_name']);
$user_id = intval($row['user_id']);
$user_avatar = nullable_htmlentities($row['user_avatar']);
$user_initials = initials($row['user_name']);
$avatar_link = "uploads/users/$user_id/$user_avatar";
}
?>
<tr class="<?php if(empty($ticket_updated_at)) { echo "text-bold"; }?>">
@ -240,7 +265,11 @@ $total_scheduled_tickets = intval($row['total_scheduled_tickets']);
<td><a href="#" data-toggle="modal" data-target="#editTicketPriorityModal<?php echo $ticket_id; ?>"><?php echo $ticket_priority_display; ?></a></td>
<td><span class='p-2 badge badge-pill badge-<?php echo $ticket_status_color; ?>'><?php echo $ticket_status; ?></span></td>
<td><a href="#" data-toggle="modal" data-target="#assignTicketModal<?php echo $ticket_id; ?>"><?php echo $ticket_assigned_to_display; ?></a></td>
<td><?php echo $ticket_updated_at_display; ?></td>
<td>
<div><?php echo $ticket_updated_at_display; ?></div>
<div><?php echo $ticket_reply_by_display; ?></div>
</td>
<td>
<?php echo $ticket_created_at_time_ago; ?>
<br>

View File

@ -162,8 +162,8 @@ if (isset($_GET['ticket_id'])) {
$row = mysqli_fetch_array($ticket_total_reply_time);
$ticket_total_reply_time = nullable_htmlentities($row['ticket_total_reply_time']);
// Client Tags
$client_tag_name_display_array = array();
$client_tag_id_array = array();
$sql_client_tags = mysqli_query($mysqli, "SELECT * FROM client_tags LEFT JOIN tags ON client_tags.client_tag_tag_id = tags.tag_id WHERE client_tags.client_tag_client_id = $client_id ORDER BY tag_name ASC");
@ -185,16 +185,17 @@ if (isset($_GET['ticket_id'])) {
}
$client_tags_display = implode(' ', $client_tag_name_display_array);
// Get the number of responses
// Get the number of ticket Responses
$ticket_responses_sql = mysqli_query($mysqli, "SELECT COUNT(ticket_reply_id) AS ticket_responses FROM ticket_replies WHERE ticket_reply_archived_at IS NULL AND ticket_reply_ticket_id = $ticket_id");
$row = mysqli_fetch_array($ticket_responses_sql);
$ticket_responses = intval($row['ticket_responses']);
// Get & format asset warranty expiry
$date = date('Y-m-d H:i:s');
$dt_value = $asset_warranty_expire; //sample date
$warranty_check = date('m/d/Y', strtotime('-8 hours'));
if ($dt_value <= $date) {
$dt_value = "Expired on $asset_warranty_expire";
$warranty_status_color = 'red';
@ -207,16 +208,25 @@ if (isset($_GET['ticket_id'])) {
$warranty_status_color = 'red';
}
// Get all ticket replies
$sql_ticket_replies = mysqli_query($mysqli, "SELECT * FROM ticket_replies LEFT JOIN users ON ticket_reply_by = user_id LEFT JOIN contacts ON ticket_reply_by = contact_id WHERE ticket_reply_ticket_id = $ticket_id AND ticket_reply_archived_at IS NULL ORDER BY ticket_reply_id DESC");
// Get all ticket replies
$sql_ticket_replies = mysqli_query($mysqli, "SELECT * FROM ticket_replies
LEFT JOIN users ON ticket_reply_by = user_id
LEFT JOIN contacts ON ticket_reply_by = contact_id
WHERE ticket_reply_ticket_id = $ticket_id
AND ticket_reply_archived_at IS NULL
ORDER BY ticket_reply_id DESC"
);
// Get other tickets for this asset
if (!empty($asset_id)) {
$sql_asset_tickets = mysqli_query($mysqli, "SELECT * FROM tickets WHERE ticket_asset_id = $asset_id ORDER BY ticket_number DESC");
$ticket_asset_count = mysqli_num_rows($sql_asset_tickets);
}
// Get technicians to assign the ticket to
// Get Technicians to assign the ticket to
$sql_assign_to_select = mysqli_query(
$mysqli,
"SELECT users.user_id, user_name FROM users
@ -226,7 +236,9 @@ if (isset($_GET['ticket_id'])) {
AND user_archived_at IS NULL
ORDER BY user_name ASC"
);
// Get Ticket Attachments
$sql_ticket_attachments = mysqli_query(
$mysqli,
"SELECT * FROM ticket_attachments

View File

@ -398,6 +398,31 @@ $user_active_assigned_tickets = intval($row['total_tickets_assigned']);
$asset_id = intval($row['ticket_asset_id']);
$vendor_id = intval($row['ticket_vendor_id']);
// Get Ticket Last updated By in the last ticket reply to be show in the last Response column
$sql_ticket_reply = mysqli_query($mysqli, "SELECT * FROM ticket_replies
LEFT JOIN users ON ticket_reply_by = user_id
LEFT JOIN contacts ON ticket_reply_by = contact_id
WHERE ticket_reply_ticket_id = $ticket_id
AND ticket_reply_archived_at IS NULL
ORDER BY ticket_reply_id DESC LIMIT 1"
);
$row = mysqli_fetch_array($sql_ticket_reply);
$ticket_reply_type = nullable_htmlentities($row['ticket_reply_type']);
$ticket_reply_by = intval($row['ticket_reply_by']);
if ($ticket_reply_type == "Client") {
$ticket_reply_by_display = nullable_htmlentities($row['contact_name']);
$user_initials = initials($row['contact_name']);
$user_avatar = nullable_htmlentities($row['contact_photo']);
$avatar_link = "uploads/clients/$client_id/$user_avatar";
} else {
$ticket_reply_by_display = nullable_htmlentities($row['user_name']);
$user_id = intval($row['user_id']);
$user_avatar = nullable_htmlentities($row['user_avatar']);
$user_initials = initials($row['user_name']);
$avatar_link = "uploads/users/$user_id/$user_avatar";
}
?>
<tr class="<?php if (empty($ticket_updated_at)) {
@ -440,7 +465,10 @@ $user_active_assigned_tickets = intval($row['total_tickets_assigned']);
<td><a href="#" data-toggle="modal" data-target="#editTicketPriorityModal<?php echo $ticket_id; ?>"><span class='p-2 badge badge-pill badge-<?php echo $ticket_priority_color; ?>'><?php echo $ticket_priority; ?></span></a></td>
<td><span class='p-2 badge badge-pill badge-<?php echo $ticket_status_color; ?>'><?php echo $ticket_status; ?></span> <?php if ($ticket_status == 'On Hold' && isset ($ticket_scheduled_for)) { echo "<div class=\"mt-1\"> <small class='text-secondary'> $ticket_scheduled_for </small></div>"; } ?></td>
<td><a href="#" data-toggle="modal" data-target="#assignTicketModal<?php echo $ticket_id; ?>"><?php echo $ticket_assigned_to_display; ?></a></td>
<td><?php echo $ticket_updated_at_display; ?></td>
<td>
<div><?php echo $ticket_updated_at_display; ?></div>
<div><?php echo $ticket_reply_by_display; ?></div>
</td>
<td>
<?php echo $ticket_created_at_time_ago; ?>
<br>