mirror of https://github.com/itflow-org/itflow
parent
6cbd4ffebe
commit
bb787cdc70
362
tickets.php
362
tickets.php
|
|
@ -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";
|
||||
|
|
@ -0,0 +1,280 @@
|
|||
<div class="card card-dark">
|
||||
<div class="card-body">
|
||||
<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_subject&order=<?php echo $disp; ?>">
|
||||
Ticket <?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 <?php if ($sort == 'client_name') { echo $order_icon; } ?>
|
||||
</a>
|
||||
</th>
|
||||
|
||||
<?php if (1==2 && $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_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>
|
||||
|
||||
</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']);
|
||||
$asset_name = nullable_htmlentities($row['asset_name']);
|
||||
|
||||
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<br><small class='text-secondary'>$contact_email</small>";
|
||||
}
|
||||
|
||||
// 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-warning1"; } ?>">
|
||||
|
||||
<!-- 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 Subject -->
|
||||
<td>
|
||||
|
||||
|
||||
<div class="mt-1">
|
||||
<a href="#" data-toggle="modal" data-target="#editTicketPriorityModal<?php echo $ticket_id; ?>">
|
||||
<span class='badge badge-<?php echo $ticket_priority_color; ?>'>
|
||||
<?php echo $ticket_priority; ?>
|
||||
</span>
|
||||
</a>
|
||||
<?php if($asset_name !== "") { ?>
|
||||
<small class="text-secondary">
|
||||
<i class="fa fa-fw fa-desktop text-secondary mr-2"></i><?php echo $asset_name; ?>
|
||||
</small>
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
||||
|
||||
<a href="ticket.php?ticket_id=<?php echo $ticket_id; ?>">
|
||||
<?php
|
||||
if (empty($ticket_closed_at) && $ticket_reply_type == "Client") {
|
||||
echo "<strong>$ticket_subject</strong>";
|
||||
} else {
|
||||
echo $ticket_subject;
|
||||
} ?>
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<?php if($task_count && $completed_task_count > 0) { ?>
|
||||
<div class="progress mt-2" style="height: 15px; font-size: 11px; width: 150px;">
|
||||
<div class="progress-bar progress-bar-striped" 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; width: 150px;">
|
||||
<p class="text-center small" >
|
||||
<?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 (1==2&&$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 Status -->
|
||||
<td>
|
||||
<span class='badge 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>
|
||||
|
||||
|
||||
|
||||
</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>
|
||||
|
|
@ -0,0 +1,305 @@
|
|||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/dragula/3.7.3/dragula.min.css">
|
||||
<style>
|
||||
.popover {
|
||||
max-width: 600px;
|
||||
}
|
||||
#kanban-board {
|
||||
display: flex;
|
||||
box-sizing: border-box;
|
||||
overflow-x: auto;
|
||||
min-width: 400px;
|
||||
height: calc(100vh - 210px);
|
||||
}
|
||||
|
||||
.kanban-column {
|
||||
flex: 1; /* Allows columns to grow equally */
|
||||
margin: 0 10px; /* Space between columns */
|
||||
min-width: 300px;
|
||||
max-width: 300px;
|
||||
background: #f4f4f4;
|
||||
padding: 10px;
|
||||
border: 1px solid #ccc;
|
||||
min-height: calc(100vh - 230px);
|
||||
max-height: calc(100vh - 230px);
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.kanban-column div {
|
||||
max-height: calc(100vh - 280px); /* Set your desired max height */
|
||||
overflow-y: auto; /* Adds a scrollbar when content exceeds max height */
|
||||
}
|
||||
|
||||
.task {
|
||||
background: #fff;
|
||||
margin: 5px 0;
|
||||
padding: 10px;
|
||||
border: 1px solid #ddd;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
<?php
|
||||
$kanban = [];
|
||||
|
||||
|
||||
// Fetch all statuses
|
||||
$status_sql = mysqli_query($mysqli, "SELECT * FROM ticket_statuses");
|
||||
$statuses = [];
|
||||
while ($status_row = mysqli_fetch_array($status_sql)) {
|
||||
$id = $status_row['ticket_status_id'];
|
||||
$name = $status_row['ticket_status_name'];
|
||||
$kanban_order = $status_row['ticket_status_kanban'];
|
||||
|
||||
$statuses[$id] = new stdClass();
|
||||
$statuses[$id]->id = $id;
|
||||
$statuses[$id]->name = $name;
|
||||
$statuses[$id]->tickets = [];
|
||||
$statuses[$id]->order = $kanban_order; // Store the order
|
||||
}
|
||||
|
||||
// Fetch tickets and merge into statuses
|
||||
$sql = mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT SQL_CALC_FOUND_ROWS * FROM tickets
|
||||
LEFT JOIN clients ON ticket_client_id = client_id
|
||||
LEFT JOIN contacts ON ticket_contact_id = contact_id
|
||||
LEFT JOIN users ON ticket_assigned_to = user_id
|
||||
LEFT JOIN assets ON ticket_asset_id = asset_id
|
||||
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
|
||||
ORDER BY $sort $order"
|
||||
);
|
||||
|
||||
while ($row = mysqli_fetch_array($sql)) {
|
||||
$id = $row['ticket_status_id'];
|
||||
$ticket_order = $row['ticket_kanban'];
|
||||
$row['ticket_order'] = $ticket_order; // Store the ticket order
|
||||
|
||||
if (isset($statuses[$id])) {
|
||||
$statuses[$id]->tickets[] = $row;
|
||||
}
|
||||
}
|
||||
|
||||
// Convert associative array to indexed array for sorting
|
||||
$kanban_array = array_values($statuses);
|
||||
|
||||
// Sort the array by the 'order' field, moving null values to the end
|
||||
usort($kanban_array, function($a, $b) {
|
||||
if ($a->order === null) return 1;
|
||||
if ($b->order === null) return -1;
|
||||
return $a->order - $b->order;
|
||||
});
|
||||
|
||||
// Sort tickets within each column by 'ticket_kanban'
|
||||
foreach ($kanban_array as $kanban_column) {
|
||||
usort($kanban_column->tickets, function($a, $b) {
|
||||
return $a['ticket_order'] - $b['ticket_order'];
|
||||
});
|
||||
}
|
||||
|
||||
// Re-index the sorted array back to associative array if needed
|
||||
$ordered_kanban = [];
|
||||
foreach ($kanban_array as $item) {
|
||||
$ordered_kanban[$item->id] = $item;
|
||||
}
|
||||
|
||||
$kanban = $ordered_kanban;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
|
||||
<div class="container-fluid" id="kanban-board">
|
||||
<?php
|
||||
foreach($kanban as $kanban_column){
|
||||
|
||||
?>
|
||||
<div class="kanban-column card card-dark" data-status-id="<?=htmlspecialchars($kanban_column->id); ?>">
|
||||
<h6 class="panel-title"><?=htmlspecialchars($kanban_column->name); ?></h6>
|
||||
<div id="status_<?=htmlspecialchars($kanban_column->id); ?>" data-column-name="<?=$kanban_column->name?>" data-status-id="<?=htmlspecialchars($kanban_column->id); ?>" style="height: 100%;" >
|
||||
<?php
|
||||
foreach($kanban_column->tickets as $item){
|
||||
if ($item['ticket_priority'] == "High") {
|
||||
$ticket_priority_color = "danger";
|
||||
} elseif ($item['ticket_priority'] == "Medium") {
|
||||
$ticket_priority_color = "warning";
|
||||
} else {
|
||||
$ticket_priority_color = "info";
|
||||
}
|
||||
?>
|
||||
|
||||
<div
|
||||
class="task"
|
||||
data-ticket-id= "<?=$item['ticket_id']?>"
|
||||
data-ticket-status-id= "<?=$item['ticket_status_id']?>"
|
||||
ondblclick="window.location.href='ticket.php?ticket_id=<?php echo $item['ticket_id']; ?>'"
|
||||
style="cursor: grabbing;"
|
||||
>
|
||||
<span class='badge badge-<?php echo $ticket_priority_color; ?>'>
|
||||
<?php echo $item['ticket_priority']; ?>
|
||||
</span>
|
||||
<span class='badge badge-secondary'>
|
||||
<?php echo $item['category_name']; ?>
|
||||
</span>
|
||||
<br>
|
||||
|
||||
<b>
|
||||
<?php
|
||||
if ($item['contact_name'] != ""){
|
||||
echo $item['client_name'] . ' - ' . $item['contact_name'];
|
||||
} else {
|
||||
echo $item['client_name'];
|
||||
}
|
||||
?>
|
||||
</b>
|
||||
<br>
|
||||
<?php if ($item['asset_name'] != "") {?>
|
||||
<i class="fa fa-fw fa-desktop text-secondary mr-2"></i><?=$item['asset_name']?>
|
||||
<br>
|
||||
<?php } ?>
|
||||
<i class="fa fa-fw fa fa-life-ring text-secondary mr-2"></i><?=$item['ticket_subject']?>
|
||||
<br>
|
||||
<i class="fas fa-fw fa-user mr-2 text-secondary"></i><?=$item['user_name']?>
|
||||
<br>
|
||||
<?php if ($item['ticket_schedule'] != "") {?>
|
||||
<i class="fa fa-fw fa-calendar-check text-secondary mr-2"></i><span class="badge badge-warning"><?=$item['ticket_schedule']?></span>
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/dragula/3.7.3/dragula.min.js"></script>
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
// Initialize Dragula for the Kanban board
|
||||
var boardDrake = dragula([
|
||||
document.querySelector('#kanban-board')
|
||||
], {
|
||||
moves: function(el, container, handle) {
|
||||
return handle.classList.contains('panel-title');
|
||||
}
|
||||
});
|
||||
|
||||
// Log the event of moving the column panel-title
|
||||
boardDrake.on('drag', function(el) {
|
||||
console.log('Dragging column:', el.querySelector('.panel-title').innerText);
|
||||
});
|
||||
|
||||
boardDrake.on('drop', function(el, target, source, sibling) {
|
||||
console.log('Dropped column:', el.querySelector('.panel-title').innerText);
|
||||
|
||||
// Get all columns and their positions
|
||||
var columns = document.querySelectorAll('#kanban-board .kanban-column');
|
||||
var columnPositions = [];
|
||||
|
||||
columns.forEach(function(column, index) {
|
||||
var statusId = $(column).data('status-id'); // Assuming you have a data attribute for status ID
|
||||
columnPositions.push({
|
||||
status_id: statusId,
|
||||
status_kanban: index
|
||||
});
|
||||
});
|
||||
|
||||
// Send AJAX request to update all column positions
|
||||
$.ajax({
|
||||
url: 'post.php',
|
||||
type: 'POST',
|
||||
data: {
|
||||
update_kanban_status_position: true,
|
||||
positions: columnPositions
|
||||
},
|
||||
success: function(response) {
|
||||
console.log('Ticket status kanban orders updated successfully.');
|
||||
// Optionally, you can refresh the page or update the UI here
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error('Error updating ticket status kanban orders:', error);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Initialize Dragula for the Kanban Cards
|
||||
var drake = dragula([
|
||||
<?php
|
||||
$kanban_columns = [];
|
||||
foreach($kanban as $kanban_column) {
|
||||
$kanban_columns[] = "document.querySelector('#status_" . htmlspecialchars($kanban_column->id) . "')";
|
||||
}
|
||||
echo implode(", ", $kanban_columns);
|
||||
?>
|
||||
]);
|
||||
|
||||
// Add event listener for the drop event
|
||||
drake.on('drop', function (el, target, source, sibling) {
|
||||
// Log the target ID to the console
|
||||
//console.log('Dropped into:', target.getAttribute('data-column-name'));
|
||||
|
||||
// Get all cards in the target column and their positions
|
||||
var cards = $(target).children('.task');
|
||||
var positions = [];
|
||||
|
||||
//id of current status / column
|
||||
var columnId = $(target).data('status-id');
|
||||
|
||||
cards.each(function(index, card) {
|
||||
ticketId = $(card).data('ticket-id');
|
||||
statusId = $(card).data('ticket-status-id');
|
||||
|
||||
//update the status id of the card if needed
|
||||
if (statusId != columnId) {
|
||||
$(card).data('ticket-status-id', columnId);
|
||||
}
|
||||
positions.push({
|
||||
ticket_id: ticketId,
|
||||
ticket_kanban: index,
|
||||
ticket_status: statusId ?? null// Get the new status ID from the target column
|
||||
});
|
||||
});
|
||||
|
||||
//console.log(positions);
|
||||
// Send AJAX request to update all ticket kanban orders and statuses
|
||||
$.ajax({
|
||||
url: 'post.php',
|
||||
type: 'POST',
|
||||
data: {
|
||||
update_kanban_ticket: true,
|
||||
positions: positions
|
||||
},
|
||||
success: function(response) {
|
||||
//console.log('Ticket kanban orders and statuses updated successfully.');
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error('Error updating ticket kanban orders and statuses:', error);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,290 @@
|
|||
<div class="card card-dark">
|
||||
<div class="card-body">
|
||||
<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 / Tasks <?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 / Contact <?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<br><small class='text-secondary'>$contact_email</small>";
|
||||
}
|
||||
|
||||
// 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>
|
||||
|
||||
Loading…
Reference in New Issue