tickets initial idea of views

Kanban view
Compact view
This commit is contained in:
Hugo Sampaio
2025-01-29 11:01:53 -03:00
parent 6cbd4ffebe
commit bb787cdc70
4 changed files with 948 additions and 289 deletions

View File

@@ -36,6 +36,17 @@ if (isset($_GET['status']) && is_array($_GET['status']) && !empty($_GET['status'
}
}
if (isset($_GET['category'])) {
if ($_GET['category'] == 'empty') {
$category_snippet = "AND ticket_category = 0 ";
} elseif ($_GET['category'] == 'all') {
$category_snippet = "";
} else {
$category_snippet = "AND ticket_category = " . $_GET['category'];
}
}
// Ticket assignment status filter
// Default - any
$ticket_assigned_query = '';
@@ -48,7 +59,7 @@ if (isset($_GET['assigned']) & !empty($_GET['assigned'])) {
$ticket_assigned_query = 'AND ticket_assigned_to = ' . intval($_GET['assigned']);
$ticket_assigned_filter_id = intval($_GET['assigned']);
}
}
}
//Rebuild URL
$url_query_strings_sort = http_build_query(array_merge($_GET, array('sort' => $sort, 'order' => $order, 'status' => $status, 'assigned' => $ticket_assigned_filter_id)));
@@ -70,7 +81,9 @@ $sql = mysqli_query(
LEFT JOIN locations ON ticket_location_id = location_id
LEFT JOIN vendors ON ticket_vendor_id = vendor_id
LEFT JOIN ticket_statuses ON ticket_status = ticket_status_id
LEFT JOIN categories ON ticket_category = category_id
WHERE $ticket_status_snippet " . $ticket_assigned_query . "
$category_snippet
AND DATE(ticket_created_at) BETWEEN '$dtf' AND '$dtt'
AND (CONCAT(ticket_prefix,ticket_number) LIKE '%$q%' OR client_name LIKE '%$q%' OR ticket_subject LIKE '%$q%' OR ticket_status_name LIKE '%$q%' OR ticket_priority LIKE '%$q%' OR user_name LIKE '%$q%' OR contact_name LIKE '%$q%' OR asset_name LIKE '%$q%' OR vendor_name LIKE '%$q%' OR ticket_vendor_ticket_number LIKE '%q%')
$ticket_permission_snippet
@@ -99,6 +112,15 @@ $sql_total_tickets_assigned = mysqli_query($mysqli, "SELECT COUNT(ticket_id) AS
$row = mysqli_fetch_array($sql_total_tickets_assigned);
$user_active_assigned_tickets = intval($row['total_tickets_assigned']);
$sql_categories = mysqli_query(
$mysqli,
"SELECT * FROM categories
WHERE category_type = 'Ticket'
ORDER BY category_name"
);
?>
<style>
.popover {
@@ -137,6 +159,37 @@ $user_active_assigned_tickets = intval($row['total_tickets_assigned']);
<div class="btn-group float-right">
<div class="btn-group">
<button class="btn btn-outline-dark dropdown-toggle" id="dropdownMenuButton" data-toggle="dropdown">
<i class="fa fa-fw fa-eye mr-2"></i>View
</button>
<div class="dropdown-menu">
<a class="dropdown-item " href="<?=htmlspecialchars('?' . http_build_query(array_merge($_GET, ['view' => 'list']))); ?>">List</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item " href="<?=htmlspecialchars('?' . http_build_query(array_merge($_GET, ['view' => 'compact']))); ?>">Compact List</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item " href="<?=htmlspecialchars('?' . http_build_query(array_merge($_GET, ['view' => 'kanban']))); ?>">Kanban</a>
</div>
</div>
<div class="btn-group">
<button class="btn btn-outline-dark dropdown-toggle" id="dropdownMenuButton" data-toggle="dropdown">
<i class="fa fa-fw fa-layer-group mr-2"></i>Categories
</button>
<div class="dropdown-menu">
<a class="dropdown-item " href="<?=htmlspecialchars('?' . http_build_query(array_merge($_GET, ['category' => 'all']))); ?>">All</a>
<div class="dropdown-divider"></div>
<?php
while ($row = mysqli_fetch_array($sql_categories)) {
$category_id = intval($row['category_id']);
$category_name = nullable_htmlentities($row['category_name']);
$category_color = nullable_htmlentities($row['category_color']);
?>
<a class="dropdown-item" href="<?=htmlspecialchars('?' . http_build_query(array_merge($_GET, ['category' => $category_id]))); ?>"><?php echo $category_name ?></a>
<div class="dropdown-divider"></div>
<?php } ?>
<a class="dropdown-item " href="<?=htmlspecialchars('?' . http_build_query(array_merge($_GET, ['category' => 'empty']))); ?>">No Category</a>
</div>
</div>
<div class="btn-group">
<button class="btn btn-outline-dark dropdown-toggle" id="categoriesDropdownMenuButton" data-toggle="dropdown">
<i class="fa fa-fw fa-envelope mr-2"></i>My Tickets
</button>
<div class="dropdown-menu">
@@ -296,298 +349,29 @@ $user_active_assigned_tickets = intval($row['total_tickets_assigned']);
</div>
</div>
</form>
<hr>
<form id="bulkActions" action="post.php" method="post">
<input type="hidden" name="csrf_token" value="<?php echo $_SESSION['csrf_token'] ?>">
<div class="table-responsive-sm">
<table class="table table-striped table-borderless table-hover">
<thead class="text-dark <?php if (!$num_rows[0]) { echo "d-none"; } ?>">
<tr>
<td>
<div class="form-check">
<input class="form-check-input" id="selectAllCheckbox" type="checkbox" onclick="checkAll(this)">
</div>
</td>
<th>
<a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=ticket_number&order=<?php echo $disp; ?>">
Ticket <?php if ($sort == 'ticket_number') { echo $order_icon; } ?>
</a>
</th>
<th>
<a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=ticket_subject&order=<?php echo $disp; ?>">
Subject <?php if ($sort == 'ticket_subject') { echo $order_icon; } ?>
</a>
</th>
<th>
<a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=client_name&order=<?php echo $disp; ?>">
Client / <span class="text-secondary">Contact</span> <?php if ($sort == 'client_name') { echo $order_icon; } ?>
</a>
</th>
<?php if ($config_module_enable_accounting && lookupUserPermission("module_sales") >= 2) { ?>
<th class="text-center">
<a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=ticket_billable&order=<?php echo $disp; ?>">
Billable <?php if ($sort == 'ticket_billable') { echo $order_icon; } ?>
</a>
</th>
<?php } ?>
<th>
<a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=ticket_priority&order=<?php echo $disp; ?>">
Priority <?php if ($sort == 'ticket_priority') { echo $order_icon; } ?>
</a>
</th>
<th>
<a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=ticket_status&order=<?php echo $disp; ?>">
Status <?php if ($sort == 'ticket_status') { echo $order_icon; } ?>
</a>
</th>
<th>
<a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=user_name&order=<?php echo $disp; ?>">
Assigned <?php if ($sort == 'user_name') { echo $order_icon; } ?>
</a>
</th>
<th>
<a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=ticket_updated_at&order=<?php echo $disp; ?>">
Last Response <?php if ($sort == 'ticket_updated_at') { echo $order_icon; } ?>
</a>
</th>
<th>
<a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=ticket_created_at&order=<?php echo $disp; ?>">
Created <?php if ($sort == 'ticket_created_at') { echo $order_icon; } ?>
</a>
</th>
</tr>
</thead>
<tbody>
<?php
while ($row = mysqli_fetch_array($sql)) {
$ticket_id = intval($row['ticket_id']);
$ticket_prefix = nullable_htmlentities($row['ticket_prefix']);
$ticket_number = intval($row['ticket_number']);
$ticket_subject = nullable_htmlentities($row['ticket_subject']);
$ticket_priority = nullable_htmlentities($row['ticket_priority']);
$ticket_status_id = intval($row['ticket_status_id']);
$ticket_status_name = nullable_htmlentities($row['ticket_status_name']);
$ticket_status_color = nullable_htmlentities($row['ticket_status_color']);
$ticket_billable = intval($row['ticket_billable']);
$ticket_scheduled_for = nullable_htmlentities($row['ticket_schedule']);
$ticket_created_at = nullable_htmlentities($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_time_ago = timeAgo($row['ticket_updated_at']);
$ticket_closed_at = nullable_htmlentities($row['ticket_closed_at']);
if (empty($ticket_updated_at)) {
if (!empty($ticket_closed_at)) {
$ticket_updated_at_display = "<p>Never</p>";
} else {
$ticket_updated_at_display = "<p class='text-danger'>Never</p>";
}
} else {
$ticket_updated_at_display = "$ticket_updated_at_time_ago<br><small class='text-secondary'>$ticket_updated_at</small>";
}
$project_id = intval($row['ticket_project_id']);
$client_id = intval($row['ticket_client_id']);
$client_name = nullable_htmlentities($row['client_name']);
$contact_name = nullable_htmlentities($row['contact_name']);
$contact_email = nullable_htmlentities($row['contact_email']);
if ($ticket_priority == "High") {
$ticket_priority_color = "danger";
} elseif ($ticket_priority == "Medium") {
$ticket_priority_color = "warning";
} else {
$ticket_priority_color = "info";
}
$ticket_assigned_to = intval($row['ticket_assigned_to']);
if (empty($ticket_assigned_to)) {
if (!empty($ticket_closed_at)) {
$ticket_assigned_to_display = "<p>Not Assigned</p>";
} else {
$ticket_assigned_to_display = "<p class='text-danger'>Not Assigned</p>";
}
} else {
$ticket_assigned_to_display = nullable_htmlentities($row['user_name']);
}
if (empty($contact_name)) {
$contact_display = "-";
} else {
$contact_display = "$contact_name";
}
// Get who last updated the ticket - to be shown in the last Response column
// Defaults to prevent undefined errors
$ticket_reply_created_at = "";
$ticket_reply_created_at_time_ago = "Never";
$ticket_reply_by_display = "";
$ticket_reply_type = "Client"; // Default to client for un-replied tickets
$sql_ticket_reply = mysqli_query($mysqli,
"SELECT ticket_reply_type, ticket_reply_created_at, contact_name, user_name 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);
if ($row) {
$ticket_reply_type = nullable_htmlentities($row['ticket_reply_type']);
if ($ticket_reply_type == "Client") {
$ticket_reply_by_display = nullable_htmlentities($row['contact_name']);
} else {
$ticket_reply_by_display = nullable_htmlentities($row['user_name']);
}
$ticket_reply_created_at = nullable_htmlentities($row['ticket_reply_created_at']);
$ticket_reply_created_at_time_ago = timeAgo($ticket_reply_created_at);
}
// Get Tasks
$sql_tasks = mysqli_query( $mysqli, "SELECT * FROM tasks WHERE task_ticket_id = $ticket_id ORDER BY task_created_at ASC");
$task_count = mysqli_num_rows($sql_tasks);
// Get Completed Task Count
$sql_tasks_completed = mysqli_query($mysqli,
"SELECT * FROM tasks
WHERE task_ticket_id = $ticket_id
AND task_completed_at IS NOT NULL"
);
$completed_task_count = mysqli_num_rows($sql_tasks_completed);
// Tasks Completed Percent
if($task_count) {
$tasks_completed_percent = round(($completed_task_count / $task_count) * 100);
}
?>
<tr class="<?php if(empty($ticket_closed_at) && empty($ticket_updated_at)) { echo "text-bold"; }?> <?php if (empty($ticket_closed_at) && $ticket_reply_type == "Client") { echo "table-warning"; } ?>">
<!-- Ticket Bulk Select (for open tickets) -->
<td>
<?php if (empty($ticket_closed_at)) { ?>
<div class="form-check">
<input class="form-check-input bulk-select" type="checkbox" name="ticket_ids[]" value="<?php echo $ticket_id ?>">
</div>
<?php } ?>
</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>
<a href="ticket.php?ticket_id=<?php echo $ticket_id; ?>"><?php echo $ticket_subject; ?></a>
<?php if($task_count && $completed_task_count > 0) { ?>
<div class="progress mt-2" style="height: 20px;">
<div class="progress-bar" style="width: <?php echo $tasks_completed_percent; ?>%;"><?php echo $completed_task_count.' / '.$task_count; ?></div>
</div>
<?php } ?>
<?php if($task_count && $completed_task_count == 0) { ?>
<div class="mt-2" style="height: 20px; background-color:#e9ecef;">
<p class="text-center" ><?php echo $completed_task_count.' / '.$task_count; ?></p>
</div>
<?php } ?>
</td>
<!-- Ticket Contact -->
<td>
<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>
</td>
<!-- Ticket Billable (if accounting enabled -->
<?php if ($config_module_enable_accounting && lookupUserPermission("module_sales") >= 2) { ?>
<td class="text-center">
<a href="#" data-toggle="modal" data-target="#editTicketBillableModal<?php echo $ticket_id; ?>">
<?php
if ($ticket_billable == 1) {
echo "<span class='badge badge-pill badge-success p-2'>Yes</span>";
} else {
echo "<span class='badge badge-pill badge-secondary p-2'>No</span>";
}
?>
</td>
<?php } ?>
<!-- Ticket Priority -->
<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='badge badge-pill text-light p-2' style="background-color: <?php echo $ticket_status_color; ?>"><?php echo $ticket_status_name; ?></span>
<?php if (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>
<div title="<?php echo $ticket_reply_created_at; ?>">
<?php echo $ticket_reply_created_at_time_ago; ?>
</div>
<div><?php echo $ticket_reply_by_display; ?></div>
</td>
<!-- Ticket Created At -->
<td title="<?php echo $ticket_created_at; ?>">
<?php echo $ticket_created_at_time_ago; ?>
</td>
</tr>
<?php
// Edit actions, for open tickets
if (empty($ticket_closed_at)) {
require "modals/ticket_assign_modal.php";
require "modals/ticket_edit_priority_modal.php";
if ($config_module_enable_accounting) {
require "modals/ticket_edit_billable_modal.php";
}
}
}
?>
</tbody>
</table>
</div>
<?php require_once "modals/ticket_bulk_assign_modal.php"; ?>
<?php require_once "modals/ticket_bulk_edit_priority_modal.php"; ?>
<?php require_once "modals/ticket_bulk_add_project_modal.php"; ?>
<?php require_once "modals/ticket_bulk_reply_modal.php"; ?>
<?php require_once "modals/ticket_bulk_merge_modal.php"; ?>
<?php require_once "modals/ticket_bulk_resolve_modal.php"; ?>
</form>
<?php require_once "includes/filter_footer.php"; ?>
</div>
</div>
<script src="js/bulk_actions.js"></script>
<?php
if ($_GET["view"]) {
if ($_GET["view"] == "list") {
require_once "tickets_list.php";
} elseif ($_GET["view"] == "compact") {
require_once "tickets_compact.php";
} elseif ($_GET["view"] == "kanban") {
require_once "tickets_kanban.php";
}
} else {
// here we have to get default view setting
require_once "tickets_list.php";
}
?>
<script src="js/bulk_actions.js"></script>
<?php
require_once "modals/ticket_add_modal.php";
require_once "includes/footer.php";
require_once "includes/footer.php";