General ticket updates/cleanup

- Tickets & Client Tickets: General tidy up, fix broken vars, remove unneeded vars, add comments
- Client Portal: Show assigned agent for open tickets
This commit is contained in:
Marcus Hill
2024-03-24 11:31:46 +00:00
parent b47aba1d5a
commit ccb1bf9b0d
3 changed files with 308 additions and 281 deletions
+42 -31
View File
@@ -144,7 +144,6 @@ $total_scheduled_tickets = intval($row['total_scheduled_tickets']);
$ticket_priority = nullable_htmlentities($row['ticket_priority']); $ticket_priority = nullable_htmlentities($row['ticket_priority']);
$ticket_status = nullable_htmlentities($row['ticket_status']); $ticket_status = nullable_htmlentities($row['ticket_status']);
$ticket_billable = intval($row['ticket_billable']); $ticket_billable = intval($row['ticket_billable']);
$ticket_vendor_ticket_number = nullable_htmlentities($row['ticket_vendor_ticket_number']);
$ticket_created_at = nullable_htmlentities($row['ticket_created_at']); $ticket_created_at = nullable_htmlentities($row['ticket_created_at']);
$ticket_created_at_time_ago = timeAgo($row['ticket_created_at']); $ticket_created_at_time_ago = timeAgo($row['ticket_created_at']);
$ticket_updated_at = nullable_htmlentities($row['ticket_updated_at']); $ticket_updated_at = nullable_htmlentities($row['ticket_updated_at']);
@@ -192,13 +191,8 @@ $total_scheduled_tickets = intval($row['total_scheduled_tickets']);
} else { } else {
$ticket_assigned_to_display = nullable_htmlentities($row['user_name']); $ticket_assigned_to_display = nullable_htmlentities($row['user_name']);
} }
$contact_id = intval($row['ticket_contact_id']);
$contact_name = nullable_htmlentities($row['contact_name']); $contact_name = nullable_htmlentities($row['contact_name']);
$contact_title = nullable_htmlentities($row['contact_title']);
$contact_email = nullable_htmlentities($row['contact_email']); $contact_email = nullable_htmlentities($row['contact_email']);
$contact_phone = formatPhoneNumber($row['contact_phone']);
$contact_extension = nullable_htmlentities($row['contact_extension']);
$contact_mobile = formatPhoneNumber($row['contact_mobile']);
$contact_archived_at = nullable_htmlentities($row['contact_archived_at']); $contact_archived_at = nullable_htmlentities($row['contact_archived_at']);
if (empty($contact_archived_at)) { if (empty($contact_archived_at)) {
$contact_archived_display = ""; $contact_archived_display = "";
@@ -211,13 +205,10 @@ $total_scheduled_tickets = intval($row['total_scheduled_tickets']);
$contact_display = "$contact_archived_display$contact_name<br><small class='text-secondary'>$contact_email</small>"; $contact_display = "$contact_archived_display$contact_name<br><small class='text-secondary'>$contact_email</small>";
} }
// Get who last updated the ticket - to be shown in the last Response column
$asset_id = intval($row['ticket_asset_id']); $ticket_reply_type = "Client"; // Default to client for unreplied tickets
$vendor_id = intval($row['ticket_vendor_id']); $ticket_reply_by_display = ""; // Default none
$sql_ticket_reply = mysqli_query($mysqli, "SELECT ticket_reply_type, contact_name, user_name FROM ticket_replies
// 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 users ON ticket_reply_by = user_id
LEFT JOIN contacts ON ticket_reply_by = contact_id LEFT JOIN contacts ON ticket_reply_by = contact_id
WHERE ticket_reply_ticket_id = $ticket_id WHERE ticket_reply_ticket_id = $ticket_id
@@ -225,30 +216,36 @@ $total_scheduled_tickets = intval($row['total_scheduled_tickets']);
ORDER BY ticket_reply_id DESC LIMIT 1" ORDER BY ticket_reply_id DESC LIMIT 1"
); );
$row = mysqli_fetch_array($sql_ticket_reply); $row = mysqli_fetch_array($sql_ticket_reply);
if ($row) {
$ticket_reply_type = nullable_htmlentities($row['ticket_reply_type']); $ticket_reply_type = nullable_htmlentities($row['ticket_reply_type']);
$ticket_reply_by = intval($row['ticket_reply_by']);
if ($ticket_reply_type == "Client") { if ($ticket_reply_type == "Client") {
$ticket_reply_by_display = nullable_htmlentities($row['contact_name']); $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 { } else {
$ticket_reply_by_display = nullable_htmlentities($row['user_name']); $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"; }?> <?php if ($ticket_reply_type == "Client") { echo "table-warning"; } ?>"> <tr class="<?php if(empty($ticket_updated_at)) { echo "text-bold"; }?> <?php if ($ticket_reply_type == "Client") { echo "table-warning"; } ?>">
<td><a href="ticket.php?ticket_id=<?php echo $ticket_id; ?>"><span class="badge badge-pill badge-secondary p-3"><?php echo "$ticket_prefix$ticket_number"; ?></span></a></td>
<!-- Ticket Number -->
<td>
<a href="ticket.php?ticket_id=<?php echo $ticket_id; ?>"><span class="badge badge-pill badge-secondary p-3"><?php echo "$ticket_prefix$ticket_number"; ?></span></a>
</td>
<!-- Ticket Subject -->
<td> <td>
<a href="ticket.php?ticket_id=<?php echo $ticket_id; ?>"><?php echo $ticket_subject; ?></a> <a href="ticket.php?ticket_id=<?php echo $ticket_id; ?>"><?php echo $ticket_subject; ?></a>
</td> </td>
<td><a href="#" data-toggle="modal" data-target="#editTicketContactModal<?php echo $ticket_id; ?>"><?php echo $contact_display; ?></a></td>
<!-- Ticket Contact -->
<td>
<a href="#" data-toggle="modal" data-target="#editTicketContactModal<?php echo $ticket_id; ?>"><?php echo $contact_display; ?></a>
</td>
<!-- Ticket Billable (if accounting enabled -->
<?php if ($config_module_enable_accounting) { ?> <?php if ($config_module_enable_accounting) { ?>
<td class="text-center"> <td class="text-center">
<a href="#" data-toggle="modal" data-target="#editTicketBillableModal<?php echo $ticket_id; ?>"> <a href="#" data-toggle="modal" data-target="#editTicketBillableModal<?php echo $ticket_id; ?>">
@@ -262,25 +259,39 @@ $total_scheduled_tickets = intval($row['total_scheduled_tickets']);
</td> </td>
<?php } ?> <?php } ?>
<td><a href="#" data-toggle="modal" data-target="#editTicketPriorityModal<?php echo $ticket_id; ?>"><?php echo $ticket_priority_display; ?></a></td> <!-- Ticket Priority -->
<td><span class='p-2 badge badge-pill badge-<?php echo $ticket_status_color; ?>'><?php echo $ticket_status; ?></span></td> <td>
<td><a href="#" data-toggle="modal" data-target="#assignTicketModal<?php echo $ticket_id; ?>"><?php echo $ticket_assigned_to_display; ?></a></td> <a href="#" data-toggle="modal" data-target="#editTicketPriorityModal<?php echo $ticket_id; ?>"><?php echo $ticket_priority_display; ?></a>
</td>
<!-- Ticket Status -->
<td>
<span class='p-2 badge badge-pill badge-<?php echo $ticket_status_color; ?>'><?php echo $ticket_status; ?></span>
</td>
<!-- Ticket Assigned agent -->
<td>
<a href="#" data-toggle="modal" data-target="#assignTicketModal<?php echo $ticket_id; ?>"><?php echo $ticket_assigned_to_display; ?></a>
</td>
<!-- Ticket Last Response -->
<td> <td>
<div><?php echo $ticket_updated_at_display; ?></div> <div><?php echo $ticket_updated_at_display; ?></div>
<div><?php echo $ticket_reply_by_display; ?></div> <div><?php echo $ticket_reply_by_display; ?></div>
</td> </td>
<!-- Ticket Created At -->
<td> <td>
<?php echo $ticket_created_at_time_ago; ?> <?php echo $ticket_created_at_time_ago; ?>
<br> <br>
<small class="text-secondary"><?php echo $ticket_created_at; ?></small> <small class="text-secondary"><?php echo $ticket_created_at; ?></small>
</td> </td>
</tr> </tr>
<?php <?php
// Edit actions, for open tickets
if ($ticket_status !== "Closed") { if ($ticket_status !== "Closed") {
// Temp performance boost for closed tickets, until we move to dynamic modals
require "ticket_assign_modal.php"; require "ticket_assign_modal.php";
@@ -288,7 +299,9 @@ $total_scheduled_tickets = intval($row['total_scheduled_tickets']);
require "ticket_edit_contact_modal.php"; require "ticket_edit_contact_modal.php";
if ($config_module_enable_accounting) {
require "ticket_edit_billable_modal.php"; require "ticket_edit_billable_modal.php";
}
} }
@@ -299,8 +312,7 @@ $total_scheduled_tickets = intval($row['total_scheduled_tickets']);
</tbody> </tbody>
</table> </table>
</div> </div>
<?php require_once "pagination.php"; <?php require_once "pagination.php"; ?>
?>
</div> </div>
</div> </div>
@@ -311,4 +323,3 @@ require_once "client_ticket_export_modal.php";
require_once "footer.php"; require_once "footer.php";
?>
+9 -2
View File
@@ -19,9 +19,11 @@ if (isset($_GET['id']) && intval($_GET['id'])) {
$ticket_id = intval($_GET['id']); $ticket_id = intval($_GET['id']);
if ($session_contact_primary == 1 || $session_contact_is_technical_contact) { if ($session_contact_primary == 1 || $session_contact_is_technical_contact) {
$ticket_sql = mysqli_query($mysqli, "SELECT * FROM tickets WHERE ticket_id = $ticket_id AND ticket_client_id = $session_client_id"); // For a primary / technical contact viewing all tickets
$ticket_sql = mysqli_query($mysqli, "SELECT * FROM tickets LEFT JOIN users on ticket_assigned_to = user_id WHERE ticket_id = $ticket_id AND ticket_client_id = $session_client_id");
} else { } else {
$ticket_sql = mysqli_query($mysqli, "SELECT * FROM tickets WHERE ticket_id = $ticket_id AND ticket_client_id = $session_client_id AND ticket_contact_id = $session_contact_id"); // For a user viewing their own ticket
$ticket_sql = mysqli_query($mysqli, "SELECT * FROM tickets LEFT JOIN users on ticket_assigned_to = user_id WHERE ticket_id = $ticket_id AND ticket_client_id = $session_client_id AND ticket_contact_id = $session_contact_id");
} }
$ticket_row = mysqli_fetch_array($ticket_sql); $ticket_row = mysqli_fetch_array($ticket_sql);
@@ -34,6 +36,7 @@ if (isset($_GET['id']) && intval($_GET['id'])) {
$ticket_priority = nullable_htmlentities($ticket_row['ticket_priority']); $ticket_priority = nullable_htmlentities($ticket_row['ticket_priority']);
$ticket_subject = nullable_htmlentities($ticket_row['ticket_subject']); $ticket_subject = nullable_htmlentities($ticket_row['ticket_subject']);
$ticket_details = $purifier->purify($ticket_row['ticket_details']); $ticket_details = $purifier->purify($ticket_row['ticket_details']);
$ticket_assigned_to = nullable_htmlentities($ticket_row['user_name']);
$ticket_feedback = nullable_htmlentities($ticket_row['ticket_feedback']); $ticket_feedback = nullable_htmlentities($ticket_row['ticket_feedback']);
?> ?>
@@ -66,6 +69,10 @@ if (isset($_GET['id']) && intval($_GET['id'])) {
<strong>State:</strong> <?php echo $ticket_status ?> <strong>State:</strong> <?php echo $ticket_status ?>
<br> <br>
<strong>Priority:</strong> <?php echo $ticket_priority ?> <strong>Priority:</strong> <?php echo $ticket_priority ?>
<br>
<?php if (!empty($ticket_assigned_to) && $ticket_status !== "Closed") { ?>
<strong>Assigned to: </strong> <?php echo $ticket_assigned_to ?>
<?php } ?>
</p> </p>
<?php echo $ticket_details ?> <?php echo $ticket_details ?>
</div> </div>
+44 -35
View File
@@ -96,12 +96,12 @@ $row = mysqli_fetch_array($sql_total_tickets_assigned);
$user_active_assigned_tickets = intval($row['total_tickets_assigned']); $user_active_assigned_tickets = intval($row['total_tickets_assigned']);
?> ?>
<style> <style>
.popover { .popover {
max-width: 600px; max-width: 600px;
} }
</style> </style>
<div class="card card-dark"> <div class="card card-dark">
<div class="card-header py-2"> <div class="card-header py-2">
<h3 class="card-title mt-2"><i class="fa fa-fw fa-life-ring mr-2"></i>Support Tickets <h3 class="card-title mt-2"><i class="fa fa-fw fa-life-ring mr-2"></i>Support Tickets
<small class="ml-3"> <small class="ml-3">
@@ -314,7 +314,6 @@ $user_active_assigned_tickets = intval($row['total_tickets_assigned']);
$ticket_status = nullable_htmlentities($row['ticket_status']); $ticket_status = nullable_htmlentities($row['ticket_status']);
$ticket_billable = intval($row['ticket_billable']); $ticket_billable = intval($row['ticket_billable']);
$ticket_scheduled_for = nullable_htmlentities($row['ticket_schedule']); $ticket_scheduled_for = nullable_htmlentities($row['ticket_schedule']);
$ticket_vendor_ticket_number = nullable_htmlentities($row['ticket_vendor_ticket_number']);
$ticket_created_at = nullable_htmlentities($row['ticket_created_at']); $ticket_created_at = nullable_htmlentities($row['ticket_created_at']);
$ticket_created_at_time_ago = timeAgo($row['ticket_created_at']); $ticket_created_at_time_ago = timeAgo($row['ticket_created_at']);
$ticket_updated_at = nullable_htmlentities($row['ticket_updated_at']); $ticket_updated_at = nullable_htmlentities($row['ticket_updated_at']);
@@ -331,13 +330,8 @@ $user_active_assigned_tickets = intval($row['total_tickets_assigned']);
$ticket_closed_at = nullable_htmlentities($row['ticket_closed_at']); $ticket_closed_at = nullable_htmlentities($row['ticket_closed_at']);
$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']);
$contact_id = intval($row['ticket_contact_id']);
$contact_name = nullable_htmlentities($row['contact_name']); $contact_name = nullable_htmlentities($row['contact_name']);
$contact_title = nullable_htmlentities($row['contact_title']);
$contact_email = nullable_htmlentities($row['contact_email']); $contact_email = nullable_htmlentities($row['contact_email']);
$contact_phone = formatPhoneNumber($row['contact_phone']);
$contact_extension = nullable_htmlentities($row['contact_extension']);
$contact_mobile = formatPhoneNumber($row['contact_mobile']);
if ($ticket_status == "New") { if ($ticket_status == "New") {
$ticket_status_color = "danger"; $ticket_status_color = "danger";
@@ -376,12 +370,10 @@ $user_active_assigned_tickets = intval($row['total_tickets_assigned']);
$contact_display = "$contact_name<br><small class='text-secondary'>$contact_email</small>"; $contact_display = "$contact_name<br><small class='text-secondary'>$contact_email</small>";
} }
$asset_id = intval($row['ticket_asset_id']); // Get who last updated the ticket - to be shown in the last Response column
$vendor_id = intval($row['ticket_vendor_id']); $ticket_reply_type = "Client"; // Default to client for unreplied tickets
$ticket_reply_by_display = ""; // Default none
$sql_ticket_reply = mysqli_query($mysqli, "SELECT ticket_reply_type, contact_name, user_name FROM ticket_replies
// 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 users ON ticket_reply_by = user_id
LEFT JOIN contacts ON ticket_reply_by = contact_id LEFT JOIN contacts ON ticket_reply_by = contact_id
WHERE ticket_reply_ticket_id = $ticket_id WHERE ticket_reply_ticket_id = $ticket_id
@@ -389,26 +381,22 @@ $user_active_assigned_tickets = intval($row['total_tickets_assigned']);
ORDER BY ticket_reply_id DESC LIMIT 1" ORDER BY ticket_reply_id DESC LIMIT 1"
); );
$row = mysqli_fetch_array($sql_ticket_reply); $row = mysqli_fetch_array($sql_ticket_reply);
if ($row) {
$ticket_reply_type = nullable_htmlentities($row['ticket_reply_type']); $ticket_reply_type = nullable_htmlentities($row['ticket_reply_type']);
$ticket_reply_by = intval($row['ticket_reply_by']);
if ($ticket_reply_type == "Client") { if ($ticket_reply_type == "Client") {
$ticket_reply_by_display = nullable_htmlentities($row['contact_name']); $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 { } else {
$ticket_reply_by_display = nullable_htmlentities($row['user_name']); $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)) { <tr class="<?php if(empty($ticket_updated_at)) { echo "text-bold"; }?> <?php if ($ticket_reply_type == "Client") { echo "table-warning"; } ?>">
echo "text-bold";
} ?>"> <!-- Ticket Bulk Select -->
<td> <td>
<?php if ($ticket_status !== "Closed") { ?> <?php if ($ticket_status !== "Closed") { ?>
<div class="form-check"> <div class="form-check">
@@ -416,20 +404,27 @@ $user_active_assigned_tickets = intval($row['total_tickets_assigned']);
</div> </div>
<?php } ?> <?php } ?>
</td> </td>
<!-- Ticket Number -->
<td> <td>
<a href="ticket.php?ticket_id=<?php echo $ticket_id; ?>"> <a href="ticket.php?ticket_id=<?php echo $ticket_id; ?>">
<span class="badge badge-pill badge-secondary p-3"><?php echo "$ticket_prefix$ticket_number"; ?></span> <span class="badge badge-pill badge-secondary p-3"><?php echo "$ticket_prefix$ticket_number"; ?></span>
</a> </a>
</td> </td>
<!-- Ticket Subject -->
<td> <td>
<a href="ticket.php?ticket_id=<?php echo $ticket_id; ?>"><?php echo $ticket_subject; ?></a> <a href="ticket.php?ticket_id=<?php echo $ticket_id; ?>"><?php echo $ticket_subject; ?></a>
</td> </td>
<!-- Ticket Contact -->
<td> <td>
<a href="client_tickets.php?client_id=<?php echo $client_id; ?>"><strong><?php echo $client_name; ?></strong></a> <a href="client_tickets.php?client_id=<?php echo $client_id; ?>"><strong><?php echo $client_name; ?></strong></a>
<div class="mt-1"><?php echo $contact_display; ?></div> <div class="mt-1"><?php echo $contact_display; ?></div>
</td> </td>
<!-- Ticket Billable (if accounting enabled -->
<?php if ($config_module_enable_accounting) { ?> <?php if ($config_module_enable_accounting) { ?>
<td class="text-center"> <td class="text-center">
<a href="#" data-toggle="modal" data-target="#editTicketBillableModal<?php echo $ticket_id; ?>"> <a href="#" data-toggle="modal" data-target="#editTicketBillableModal<?php echo $ticket_id; ?>">
@@ -443,24 +438,39 @@ $user_active_assigned_tickets = intval($row['total_tickets_assigned']);
</td> </td>
<?php } ?> <?php } ?>
<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> <!-- Ticket Priority -->
<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>
<td><a href="#" data-toggle="modal" data-target="#assignTicketModal<?php echo $ticket_id; ?>"><?php echo $ticket_assigned_to_display; ?></a></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>
<!-- Ticket Status -->
<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>
<!-- Ticket Assigned agent -->
<td>
<a href="#" data-toggle="modal" data-target="#assignTicketModal<?php echo $ticket_id; ?>"><?php echo $ticket_assigned_to_display; ?></a>
</td>
<!-- Ticket Last Response -->
<td> <td>
<div><?php echo $ticket_updated_at_display; ?></div> <div><?php echo $ticket_updated_at_display; ?></div>
<div><?php echo $ticket_reply_by_display; ?></div> <div><?php echo $ticket_reply_by_display; ?></div>
</td> </td>
<!-- Ticket Created At -->
<td> <td>
<?php echo $ticket_created_at_time_ago; ?> <?php echo $ticket_created_at_time_ago; ?>
<br> <br>
<small class="text-secondary"><?php echo $ticket_created_at; ?></small> <small class="text-secondary"><?php echo $ticket_created_at; ?></small>
</td> </td>
</tr> </tr>
<?php <?php
// Edit actions, for open tickets
if ($ticket_status !== "Closed") { if ($ticket_status !== "Closed") {
// Temp performance boost for closed tickets, until we move to dynamic modals
require "ticket_assign_modal.php"; require "ticket_assign_modal.php";
@@ -482,12 +492,11 @@ $user_active_assigned_tickets = intval($row['total_tickets_assigned']);
<?php require_once "ticket_bulk_close_modal.php"; ?> <?php require_once "ticket_bulk_close_modal.php"; ?>
<?php require_once "ticket_bulk_reply_modal.php"; ?> <?php require_once "ticket_bulk_reply_modal.php"; ?>
</form> </form>
<?php require_once "pagination.php"; <?php require_once "pagination.php"; ?>
?> </div>
</div> </div>
</div>
<script src="js/bulk_actions.js"></script> <script src="js/bulk_actions.js"></script>
<?php <?php
require_once "ticket_add_modal.php"; require_once "ticket_add_modal.php";