Merged Global Tickets with Client Tickets seperated them with some header logic

This commit is contained in:
johnnyq
2025-02-19 13:45:44 -05:00
parent a5ff978a77
commit d228c30b03
11 changed files with 351 additions and 678 deletions
-372
View File
@@ -1,372 +0,0 @@
<?php
// Default Column Sortby Filter
$sort = "ticket_number";
$order = "DESC";
require_once "includes/inc_all_client.php";
// Perms
enforceUserPermission('module_support');
if (isset($_GET['status']) && ($_GET['status']) == 'Closed') {
$status = 'Closed';
$ticket_status_snippet = "ticket_resolved_at IS NOT NULL";
} else {
// Default - Show open tickets
$status = 'Open';
$ticket_status_snippet = "ticket_resolved_at IS NULL";
}
if (isset($_GET['billable']) && ($_GET['billable']) == '1') {
if (isset($_GET['unbilled'])) {
$billable = 1;
$ticket_billable_snippet = "ticket_billable = 1 AND ticket_invoice_id = 0";
$ticket_status_snippet = '1 = 1';
}
} else {
$billable = 0;
$ticket_billable_snippet = '1 = 1';
}
//Rebuild URL
$url_query_strings_sort = http_build_query($get_copy);
$sql = mysqli_query(
$mysqli,
"SELECT SQL_CALC_FOUND_ROWS * FROM tickets
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
WHERE ticket_client_id = $client_id
AND $ticket_status_snippet
AND $ticket_billable_snippet
AND (CONCAT(ticket_prefix,ticket_number) 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%')
ORDER BY
CASE
WHEN '$sort' = 'ticket_priority' THEN
CASE ticket_priority
WHEN 'High' THEN 1
WHEN 'Medium' THEN 2
WHEN 'Low' THEN 3
ELSE 4 -- Optional: for unexpected priority values
END
ELSE NULL
END $order,
$sort $order -- Apply normal sorting by $sort and $order
LIMIT $record_from, $record_to"
);
$num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
// Get Total tickets open
$sql_total_tickets_open = mysqli_query($mysqli, "SELECT COUNT(ticket_id) AS total_tickets_open FROM tickets WHERE ticket_client_id = $client_id AND ticket_resolved_at IS NULL");
$row = mysqli_fetch_array($sql_total_tickets_open);
$total_tickets_open = intval($row['total_tickets_open']);
// Get Total tickets closed
$sql_total_tickets_closed = mysqli_query($mysqli, "SELECT COUNT(ticket_id) AS total_tickets_closed FROM tickets WHERE ticket_client_id = $client_id AND ticket_resolved_at IS NOT NULL");
$row = mysqli_fetch_array($sql_total_tickets_closed);
$total_tickets_closed = intval($row['total_tickets_closed']);
?>
<div class="card card-dark">
<div class="card-header py-2">
<h3 class="card-title mt-2"><i class="fa fa-fw fa-life-ring mr-2"></i><?php if (isset($_GET['unbilled'])) { echo "Unbilled "; } ?> Tickets
<small class="ml-3">
<a href="?client_id=<?php echo $client_id?>&status=Open" class="text-light"><strong><?php echo $total_tickets_open; ?></strong> Open</a> |
<a href="?client_id=<?php echo $client_id?>&status=Closed" class="text-light"><strong><?php echo $total_tickets_closed; ?></strong> Closed</a>
</small>
</h3>
<div class="card-tools">
<div class="btn-group">
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#addTicketModal">
<i class="fas fa-plus mr-2"></i>New Ticket
</button>
<?php if ($num_rows[0] > 0) { ?>
<button type="button" class="btn btn-primary dropdown-toggle dropdown-toggle-split" data-toggle="dropdown"></button>
<div class="dropdown-menu">
<a class="dropdown-item text-dark" href="#" data-toggle="modal" data-target="#exportTicketModal">
<i class="fa fa-fw fa-download mr-2"></i>Export
</a>
</div>
<?php } ?>
</div>
</div>
</div>
<div class="card-body">
<form autocomplete="off">
<input type="hidden" name="client_id" value="<?php echo $client_id; ?>">
<input type="hidden" name="status" value="<?php echo $status; ?>">
<div class="row">
<div class="col-md-4">
<div class="input-group mb-3 mb-md-0">
<input type="search" class="form-control" name="q" value="<?php if (isset($q)) { echo stripslashes(nullable_htmlentities($q)); } ?>" placeholder="Search Tickets">
<div class="input-group-append">
<button class="btn btn-dark"><i class="fa fa-search"></i></button>
</div>
</div>
</div>
<div class="col-md-8">
</div>
</div>
</form>
<hr>
<div class="table-responsive-sm">
<table class="table table-striped table-borderless table-hover">
<thead class="text-dark <?php if ($num_rows[0] == 0) { echo "d-none"; } ?>">
<tr>
<th>
<a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=ticket_number&order=<?php echo $disp; ?>">
Number <?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=contact_name&order=<?php echo $disp; ?>">
Contact <?php if ($sort == 'contact_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 = nullable_htmlentities($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_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']);
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>";
}
$ticket_closed_at = nullable_htmlentities($row['ticket_closed_at']);
if ($ticket_priority == "High") {
$ticket_priority_display = "<span class='p-2 badge badge-pill badge-danger'>$ticket_priority</span>";
} elseif ($ticket_priority == "Medium") {
$ticket_priority_display = "<span class='p-2 badge badge-pill badge-warning'>$ticket_priority</span>";
} elseif ($ticket_priority == "Low") {
$ticket_priority_display = "<span class='p-2 badge badge-pill badge-info'>$ticket_priority</span>";
} else{
$ticket_priority_display = "-";
}
$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']);
}
$project_id = intval($row['ticket_project_id']);
$contact_name = nullable_htmlentities($row['contact_name']);
$contact_email = nullable_htmlentities($row['contact_email']);
$contact_archived_at = nullable_htmlentities($row['contact_archived_at']);
if (empty($contact_archived_at)) {
$contact_archived_display = "";
} else {
$contact_archived_display = "Archived - ";
}
if (empty($contact_name)) {
$contact_display = "-";
} else {
$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
$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, 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);
}
?>
<tr class="<?php if(empty($ticket_reply_created_at)) { echo "text-bold"; }?> <?php if (empty($ticket_closed_at) && $ticket_reply_type == "Client") { echo "table-warning"; } ?>">
<!-- Ticket Number -->
<td>
<a href="ticket.php?client_id=<?php echo $client_id; ?>&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?client_id=<?php echo $client_id; ?>&ticket_id=<?php echo $ticket_id; ?>"><?php echo $ticket_subject; ?></a>
</td>
<!-- Ticket Contact -->
<td>
<a href="#"
<?php if (empty($ticket_closed_at)) { ?>
data-toggle = "ajax-modal"
data-ajax-url = "ajax/ajax_ticket_contact.php"
data-ajax-id = "<?php echo $ticket_id; ?>"
<?php } ?>
>
<?php echo $contact_display; ?>
</a>
</td>
<!-- Ticket Billable (if accounting perms & enabled) -->
<?php if ($config_module_enable_accounting && lookupUserPermission("module_sales") >= 2) { ?>
<td class="text-center">
<a href="#"
data-toggle = "ajax-modal"
data-ajax-url = "ajax/ajax_ticket_billable.php"
data-ajax-id = "<?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>";
}
?>
</a>
</td>
<?php } ?>
<!-- Ticket Priority -->
<td>
<a href="#"
<?php if (lookupUserPermission("module_support") >= 2 && empty($ticket_closed_at)) { ?>
data-toggle = "ajax-modal"
data-ajax-url = "ajax/ajax_ticket_priority.php"
data-ajax-id = "<?php echo $ticket_id; ?>"
<?php } ?>
>
<?php echo $ticket_priority_display; ?>
</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>
</td>
<!-- Ticket Assigned agent -->
<td>
<a href="#"
<?php if (lookupUserPermission("module_support") >= 2 && empty($ticket_closed_at)) { ?>
data-toggle = "ajax-modal"
data-ajax-url = "ajax/ajax_ticket_assign.php"
data-ajax-id = "<?php echo $ticket_id; ?>"
<?php } ?>
>
<?php echo $ticket_assigned_to_display; ?>
</a>
</td>
<!-- Ticket Last Response -->
<td>
<?php if (!empty($ticket_reply_created_at)) { ?>
<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>
<?php } ?>
</td>
<!-- Ticket Created At -->
<td title="<?php echo $ticket_created_at; ?>">
<?php echo $ticket_created_at_time_ago; ?>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
<?php require_once "includes/filter_footer.php"; ?>
</div>
</div>
<?php
require_once "modals/ticket_add_modal.php";
require_once "modals/client_ticket_export_modal.php";
require_once "includes/footer.php";
+1 -1
View File
@@ -704,7 +704,7 @@ if ($user_config_dashboard_technical_enable == 1) {
<tr class="<?php echo empty($ticket_updated_at) ? 'text-bold' : ''; ?>"> <tr class="<?php echo empty($ticket_updated_at) ? 'text-bold' : ''; ?>">
<td><a class="text-dark" href="ticket.php?ticket_id=<?php echo $ticket_id; ?>"><?php echo "$ticket_prefix$ticket_number"; ?></a></td> <td><a class="text-dark" href="ticket.php?ticket_id=<?php echo $ticket_id; ?>"><?php echo "$ticket_prefix$ticket_number"; ?></a></td>
<td><a href="ticket.php?ticket_id=<?php echo $ticket_id; ?>"><?php echo $ticket_subject; ?></a></td> <td><a href="ticket.php?ticket_id=<?php echo $ticket_id; ?>"><?php echo $ticket_subject; ?></a></td>
<td><a href="client_tickets.php?client_id=<?php echo $client_id; ?>"><strong><?php echo $client_name; ?></strong></a></td> <td><a href="tickets.php?client_id=<?php echo $client_id; ?>"><strong><?php echo $client_name; ?></strong></a></td>
<td><?php echo $contact_display; ?></td> <td><?php echo $contact_display; ?></td>
<td><span class='p-2 badge badge-pill badge-<?php echo $ticket_priority_color; ?>'><?php echo $ticket_priority; ?></span></td> <td><span class='p-2 badge badge-pill badge-<?php echo $ticket_priority_color; ?>'><?php echo $ticket_priority; ?></span></td>
<td><span class='badge badge-pill text-light p-2' style="background-color: <?php echo $ticket_status_color; ?>"><?php echo $ticket_status_name; ?></span></td> <td><span class='badge badge-pill text-light p-2' style="background-color: <?php echo $ticket_status_color; ?>"><?php echo $ticket_status_name; ?></span></td>
+1 -1
View File
@@ -507,7 +507,7 @@ if (isset($_GET['query'])) {
<td><a href="ticket.php?ticket_id=<?php echo $ticket_id ?>"><?php echo $ticket_prefix . $ticket_number; ?></a></td> <td><a href="ticket.php?ticket_id=<?php echo $ticket_id ?>"><?php echo $ticket_prefix . $ticket_number; ?></a></td>
<td><?php echo $ticket_subject; ?></td> <td><?php echo $ticket_subject; ?></td>
<td><?php echo $ticket_status_name; ?></td> <td><?php echo $ticket_status_name; ?></td>
<td><a href="client_tickets.php?client_id=<?php echo $client_id ?>"><?php echo $client_name; ?></a></td> <td><a href="tickets.php?client_id=<?php echo $client_id ?>"><?php echo $client_name; ?></a></td>
</tr> </tr>
<?php } ?> <?php } ?>
+1 -1
View File
@@ -55,7 +55,7 @@
<li class="nav-header mt-3">SUPPORT</li> <li class="nav-header mt-3">SUPPORT</li>
<li class="nav-item"> <li class="nav-item">
<a href="client_tickets.php?client_id=<?php echo $client_id; ?>" class="nav-link <?php if (basename($_SERVER["PHP_SELF"]) == "client_tickets.php" || basename($_SERVER["PHP_SELF"]) == "ticket.php") { echo "active"; } ?>"> <a href="tickets.php?client_id=<?php echo $client_id; ?>" class="nav-link <?php if (basename($_SERVER["PHP_SELF"]) == "tickets.php" || basename($_SERVER["PHP_SELF"]) == "ticket.php") { echo "active"; } ?>">
<i class="nav-icon fas fa-life-ring"></i> <i class="nav-icon fas fa-life-ring"></i>
<p> <p>
Tickets Tickets
@@ -8,12 +8,14 @@
</button> </button>
</div> </div>
<form action="post.php" method="post" autocomplete="off"> <form action="post.php" method="post" autocomplete="off">
<?php if (isset($_GET['client_id'])) { ?>
<input type="hidden" name="client_id" value="<?php echo $client_id; ?>"> <input type="hidden" name="client_id" value="<?php echo $client_id; ?>">
<?php } ?>
<div class="modal-body bg-white"> <div class="modal-body bg-white">
</div> </div>
<div class="modal-footer bg-white"> <div class="modal-footer bg-white">
<button type="submit" name="export_client_tickets_csv" class="btn btn-primary text-bold"><i class="fas fa-fw fa-download mr-2"></i>Download CSV</button> <button type="submit" name="export_tickets_csv" class="btn btn-primary text-bold"><i class="fas fa-fw fa-download mr-2"></i>Download CSV</button>
<button type="button" class="btn btn-light" data-dismiss="modal"><i class="fas fa-times mr-2"></i>Cancel</button> <button type="button" class="btn btn-light" data-dismiss="modal"><i class="fas fa-times mr-2"></i>Cancel</button>
</div> </div>
</form> </form>
+9 -10
View File
@@ -1970,28 +1970,27 @@ if (isset($_POST['add_invoice_from_ticket'])) {
header("Location: invoice.php?invoice_id=$invoice_id"); header("Location: invoice.php?invoice_id=$invoice_id");
} }
if (isset($_POST['export_client_tickets_csv'])) { if (isset($_POST['export_tickets_csv'])) {
enforceUserPermission('module_support', 2); enforceUserPermission('module_support', 2);
$client_id = intval($_POST['client_id']); if (isset($_POST['client_id'])) {
$client_id = intval($_POST['client_id']);
//get records from database $client_query = "WHERE ticket_client_id = $client_id";
$sql = mysqli_query($mysqli, "SELECT * FROM clients WHERE client_id = $client_id"); } else {
$row = mysqli_fetch_array($sql); $client_query = '';
}
$client_name = $row['client_name'];
$sql = mysqli_query( $sql = mysqli_query(
$mysqli, $mysqli,
"SELECT * FROM tickets "SELECT * FROM tickets
LEFT JOIN ticket_statuses ON ticket_status = ticket_status_id LEFT JOIN ticket_statuses ON ticket_status = ticket_status_id
WHERE ticket_client_id = $client_id ORDER BY ticket_number ASC" $client_query ORDER BY ticket_number ASC"
); );
if ($sql->num_rows > 0) { if ($sql->num_rows > 0) {
$delimiter = ","; $delimiter = ",";
$filename = $client_name . "-Tickets-" . date('Y-m-d') . ".csv"; $filename = "Tickets-" . date('Y-m-d') . ".csv";
//create a file pointer //create a file pointer
$f = fopen('php://memory', 'w'); $f = fopen('php://memory', 'w');
+2 -2
View File
@@ -354,14 +354,14 @@ if (isset($_GET['ticket_id'])) {
<a href="client_overview.php?client_id=<?php echo $client_id; ?>"><?php echo $client_name; ?></a> <a href="client_overview.php?client_id=<?php echo $client_id; ?>"><?php echo $client_name; ?></a>
</li> </li>
<li class="breadcrumb-item"> <li class="breadcrumb-item">
<a href="client_tickets.php?client_id=<?php echo $client_id; ?>">Tickets</a> <a href="tickets.php?client_id=<?php echo $client_id; ?>">Tickets</a>
</li> </li>
<?php } else { ?> <?php } else { ?>
<li class="breadcrumb-item"> <li class="breadcrumb-item">
<a href="tickets.php">Tickets</a> <a href="tickets.php">Tickets</a>
</li> </li>
<li class="breadcrumb-item"> <li class="breadcrumb-item">
<a href="client_tickets.php?client_id=<?php echo $client_id; ?>"><?php echo $client_name; ?></a> <a href="tickets.php?client_id=<?php echo $client_id; ?>"><?php echo $client_name; ?></a>
</li> </li>
<?php } ?> <?php } ?>
<li class="breadcrumb-item active"><i class="fas fa-life-ring mr-1"></i><?php echo "$ticket_prefix$ticket_number";?></li> <li class="breadcrumb-item active"><i class="fas fa-life-ring mr-1"></i><?php echo "$ticket_prefix$ticket_number";?></li>
+31 -11
View File
@@ -5,7 +5,14 @@
$sort = "ticket_number"; $sort = "ticket_number";
$order = "DESC"; $order = "DESC";
require_once "includes/inc_all.php"; // If client_id is in URI then show client Side Bar and client header
if (isset($_GET['client_id'])) {
require_once "includes/inc_all_client.php";
$client_query = "AND ticket_client_id = $client_id";
} else {
require_once "includes/inc_all.php";
$client_query = '';
}
// Perms // Perms
enforceUserPermission('module_support'); enforceUserPermission('module_support');
@@ -90,6 +97,7 @@ $sql = mysqli_query(
AND DATE(ticket_created_at) BETWEEN '$dtf' AND '$dtt' 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%') 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 $ticket_permission_snippet
$client_query
ORDER BY ORDER BY
CASE CASE
WHEN '$sort' = 'ticket_priority' THEN WHEN '$sort' = 'ticket_priority' THEN
@@ -108,22 +116,22 @@ $sql = mysqli_query(
$num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()")); $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
//Get Total tickets open //Get Total tickets open
$sql_total_tickets_open = mysqli_query($mysqli, "SELECT COUNT(ticket_id) AS total_tickets_open FROM tickets WHERE ticket_resolved_at IS NULL $ticket_permission_snippet"); $sql_total_tickets_open = mysqli_query($mysqli, "SELECT COUNT(ticket_id) AS total_tickets_open FROM tickets WHERE ticket_resolved_at IS NULL $client_query $ticket_permission_snippet");
$row = mysqli_fetch_array($sql_total_tickets_open); $row = mysqli_fetch_array($sql_total_tickets_open);
$total_tickets_open = intval($row['total_tickets_open']); $total_tickets_open = intval($row['total_tickets_open']);
//Get Total tickets closed //Get Total tickets closed
$sql_total_tickets_closed = mysqli_query($mysqli, "SELECT COUNT(ticket_id) AS total_tickets_closed FROM tickets WHERE ticket_resolved_at IS NOT NULL $ticket_permission_snippet"); $sql_total_tickets_closed = mysqli_query($mysqli, "SELECT COUNT(ticket_id) AS total_tickets_closed FROM tickets WHERE ticket_resolved_at IS NOT NULL $client_query $ticket_permission_snippet");
$row = mysqli_fetch_array($sql_total_tickets_closed); $row = mysqli_fetch_array($sql_total_tickets_closed);
$total_tickets_closed = intval($row['total_tickets_closed']); $total_tickets_closed = intval($row['total_tickets_closed']);
//Get Unassigned tickets //Get Unassigned tickets
$sql_total_tickets_unassigned = mysqli_query($mysqli, "SELECT COUNT(ticket_id) AS total_tickets_unassigned FROM tickets WHERE ticket_assigned_to = '0' AND ticket_resolved_at IS NULL $ticket_permission_snippet"); $sql_total_tickets_unassigned = mysqli_query($mysqli, "SELECT COUNT(ticket_id) AS total_tickets_unassigned FROM tickets WHERE ticket_assigned_to = '0' AND ticket_resolved_at IS NULL $client_query $ticket_permission_snippet");
$row = mysqli_fetch_array($sql_total_tickets_unassigned); $row = mysqli_fetch_array($sql_total_tickets_unassigned);
$total_tickets_unassigned = intval($row['total_tickets_unassigned']); $total_tickets_unassigned = intval($row['total_tickets_unassigned']);
//Get Total tickets assigned to me //Get Total tickets assigned to me
$sql_total_tickets_assigned = mysqli_query($mysqli, "SELECT COUNT(ticket_id) AS total_tickets_assigned FROM tickets WHERE ticket_assigned_to = $session_user_id AND ticket_resolved_at IS NULL $ticket_permission_snippet"); $sql_total_tickets_assigned = mysqli_query($mysqli, "SELECT COUNT(ticket_id) AS total_tickets_assigned FROM tickets WHERE ticket_assigned_to = $session_user_id AND ticket_resolved_at IS NULL $client_query $ticket_permission_snippet");
$row = mysqli_fetch_array($sql_total_tickets_assigned); $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']);
@@ -146,20 +154,31 @@ $sql_categories = mysqli_query(
<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>Tickets <h3 class="card-title mt-2"><i class="fa fa-fw fa-life-ring mr-2"></i>Tickets
<small class="ml-3"> <small class="ml-3">
<a href="?status=Open" class="text-light"><strong><?php echo $total_tickets_open; ?></strong> Open</a> | <a href="?<?php if (isset($_GET['client_id'])) { echo "client_id=$client_id&"; } ?>status=Open" class="text-light"><strong><?php echo $total_tickets_open; ?></strong> Open</a> |
<a href="?status=Closed" class="text-light"><strong><?php echo $total_tickets_closed; ?></strong> Closed</a> <a href="?<?php if (isset($_GET['client_id'])) { echo "client_id=$client_id&"; } ?>status=Closed" class="text-light"><strong><?php echo $total_tickets_closed; ?></strong> Closed</a>
</small> </small>
</h3> </h3>
<div class='card-tools'> <div class="card-tools">
<div class="btn-group"> <div class="btn-group">
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#addTicketModal"> <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#addTicketModal">
<i class="fas fa-plus mr-2"></i>New Ticket <i class="fas fa-plus mr-2"></i>New Ticket
</button> </button>
<?php if ($num_rows[0] > 0) { ?>
<button type="button" class="btn btn-primary dropdown-toggle dropdown-toggle-split" data-toggle="dropdown"></button>
<div class="dropdown-menu">
<a class="dropdown-item text-dark" href="#" data-toggle="modal" data-target="#exportTicketModal">
<i class="fa fa-fw fa-download mr-2"></i>Export
</a>
</div>
<?php } ?>
</div> </div>
</div> </div>
</div> </div>
<div class="card-body"> <div class="card-body">
<form autocomplete="off"> <form autocomplete="off">
<?php if(isset($_GET['client_id'])) { ?>
<input type="hidden" name="client_id" value="<?php echo $client_id; ?>">
<?php } ?>
<div class="row"> <div class="row">
<div class="col-sm-4"> <div class="col-sm-4">
<div class="input-group"> <div class="input-group">
@@ -210,12 +229,12 @@ $sql_categories = mysqli_query(
<i class="fa fa-fw fa-envelope mr-2"></i>My Tickets <i class="fa fa-fw fa-envelope mr-2"></i>My Tickets
</button> </button>
<div class="dropdown-menu"> <div class="dropdown-menu">
<a class="dropdown-item" href="?status=Open&assigned=<?php echo $session_user_id ?>">Active tickets (<?php echo $user_active_assigned_tickets ?>)</a> <a class="dropdown-item" href="?<?php if (isset($_GET['client_id'])) { echo "client_id=$client_id&"; } ?>status=Open&assigned=<?php echo $session_user_id ?>">Active tickets (<?php echo $user_active_assigned_tickets ?>)</a>
<div class="dropdown-divider"></div> <div class="dropdown-divider"></div>
<a class="dropdown-item " href="?status=Closed&assigned=<?php echo $session_user_id ?>">Closed tickets</a> <a class="dropdown-item " href="<?php if (isset($_GET['client_id'])) { echo "client_id=$client_id&"; } ?>?status=Closed&assigned=<?php echo $session_user_id ?>">Closed tickets</a>
</div> </div>
</div> </div>
<a href="?assigned=unassigned" class="btn btn-outline-danger"> <a href="?<?php if (isset($_GET['client_id'])) { echo "client_id=$client_id&"; } ?>assigned=unassigned" class="btn btn-outline-danger">
<i class="fa fa-fw fa-exclamation-triangle mr-2"></i>Unassigned Tickets | <strong> <?php echo $total_tickets_unassigned; ?></strong> <i class="fa fa-fw fa-exclamation-triangle mr-2"></i>Unassigned Tickets | <strong> <?php echo $total_tickets_unassigned; ?></strong>
</a> </a>
@@ -402,4 +421,5 @@ if (isset($_GET["view"])) {
<?php <?php
require_once "modals/ticket_add_modal.php"; require_once "modals/ticket_add_modal.php";
require_once "modals/ticket_export_modal.php";
require_once "includes/footer.php"; require_once "includes/footer.php";
+273 -263
View File
@@ -1,288 +1,298 @@
<div class="card card-dark"> <div class="card card-dark">
<div class="card-body"> <div class="card-body">
<form id="bulkActions" action="post.php" method="post"> <form id="bulkActions" action="post.php" method="post">
<input type="hidden" name="csrf_token" value="<?php echo $_SESSION['csrf_token'] ?>"> <input type="hidden" name="csrf_token" value="<?php echo $_SESSION['csrf_token'] ?>">
<div class="table-responsive-sm"> <div class="table-responsive-sm">
<table class="table table-striped table-borderless table-hover"> <table class="table table-striped table-borderless table-hover">
<thead class="text-dark <?php if (!$num_rows[0]) { echo "d-none"; } ?>"> <thead class="text-dark <?php if (!$num_rows[0]) { echo "d-none"; } ?>">
<tr> <tr>
<td> <td>
<div class="form-check"> <div class="form-check">
<input class="form-check-input" id="selectAllCheckbox" type="checkbox" onclick="checkAll(this)" onKeyPress="checkAll(this)"> <input class="form-check-input" id="selectAllCheckbox" type="checkbox" onclick="checkAll(this)" onKeyPress="checkAll(this)">
</div> </div>
</td> </td>
<th scope="col"> <th scope="col">
<a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=ticket_subject&order=<?php echo $disp; ?>"> <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; } ?> Ticket <?php if ($sort == 'ticket_subject') { echo $order_icon; } ?>
</a> </a>
</th> </th>
<th scope="col"> <?php if (!isset($_GET['client_id'])) { ?>
<a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=client_name&order=<?php echo $disp; ?>"> <th scope="col">
Client <?php if ($sort == 'client_name') { echo $order_icon; } ?> <a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=client_name&order=<?php echo $disp; ?>">
</a> Client <?php if ($sort == 'client_name') { echo $order_icon; } ?>
</th> </a>
</th>
<?php } ?>
<?php if (isset($_GET['client_id'])) { ?>
<th scope="col">
<a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=client_name&order=<?php echo $disp; ?>">
Client <?php if ($sort == 'contact_name') { echo $order_icon; } ?>
</a>
</th>
<?php } ?>
<?php if ($config_module_enable_accounting && lookupUserPermission("module_sales") >= 2) { ?> <?php if ($config_module_enable_accounting && lookupUserPermission("module_sales") >= 2) { ?>
<th class="text-center" scope="col"> <th class="text-center" scope="col">
<a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=ticket_billable&order=<?php echo $disp; ?>"> <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; } ?> Billable <?php if ($sort == 'ticket_billable') { echo $order_icon; } ?>
</a> </a>
</th> </th>
<?php } ?> <?php } ?>
<th scope="col"> <th scope="col">
<a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=ticket_status&order=<?php echo $disp; ?>"> <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; } ?> Status <?php if ($sort == 'ticket_status') { echo $order_icon; } ?>
</a> </a>
</th> </th>
<th scope="col"> <th scope="col">
<a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=user_name&order=<?php echo $disp; ?>"> <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; } ?> Assigned <?php if ($sort == 'user_name') { echo $order_icon; } ?>
</a> </a>
</th> </th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php <?php
while ($row = mysqli_fetch_array($sql)) { while ($row = mysqli_fetch_array($sql)) {
$ticket_id = intval($row['ticket_id']); $ticket_id = intval($row['ticket_id']);
$ticket_prefix = nullable_htmlentities($row['ticket_prefix']); $ticket_prefix = nullable_htmlentities($row['ticket_prefix']);
$ticket_number = intval($row['ticket_number']); $ticket_number = intval($row['ticket_number']);
$ticket_subject = nullable_htmlentities($row['ticket_subject']); $ticket_subject = nullable_htmlentities($row['ticket_subject']);
$ticket_priority = nullable_htmlentities($row['ticket_priority']); $ticket_priority = nullable_htmlentities($row['ticket_priority']);
$ticket_status_id = intval($row['ticket_status_id']); $ticket_status_id = intval($row['ticket_status_id']);
$ticket_status_name = nullable_htmlentities($row['ticket_status_name']); $ticket_status_name = nullable_htmlentities($row['ticket_status_name']);
$ticket_status_color = nullable_htmlentities($row['ticket_status_color']); $ticket_status_color = nullable_htmlentities($row['ticket_status_color']);
$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_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']);
$ticket_updated_at_time_ago = timeAgo($row['ticket_updated_at']); $ticket_updated_at_time_ago = timeAgo($row['ticket_updated_at']);
$ticket_closed_at = nullable_htmlentities($row['ticket_closed_at']); $ticket_closed_at = nullable_htmlentities($row['ticket_closed_at']);
if (empty($ticket_updated_at)) { if (empty($ticket_updated_at)) {
if (!empty($ticket_closed_at)) { if (!empty($ticket_closed_at)) {
$ticket_updated_at_display = "<p>Never</p>"; $ticket_updated_at_display = "<p>Never</p>";
} else {
$ticket_updated_at_display = "<p class='text-danger'>Never</p>";
}
} else { } else {
$ticket_updated_at_display = "$ticket_updated_at_time_ago<br><small class='text-secondary'>$ticket_updated_at</small>"; $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']); $project_id = intval($row['ticket_project_id']);
$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_name = nullable_htmlentities($row['contact_name']); $contact_name = nullable_htmlentities($row['contact_name']);
$contact_email = nullable_htmlentities($row['contact_email']); $contact_email = nullable_htmlentities($row['contact_email']);
$asset_name = nullable_htmlentities($row['asset_name']); $asset_name = nullable_htmlentities($row['asset_name']);
if ($ticket_priority == "High") { if ($ticket_priority == "High") {
$ticket_priority_color = "danger"; $ticket_priority_color = "danger";
} elseif ($ticket_priority == "Medium") { } elseif ($ticket_priority == "Medium") {
$ticket_priority_color = "warning"; $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 { } else {
$ticket_priority_color = "info"; $ticket_assigned_to_display = "<p class='text-danger'>Not Assigned</p>";
} }
} else {
$ticket_assigned_to_display = nullable_htmlentities($row['user_name']);
}
$ticket_assigned_to = intval($row['ticket_assigned_to']); if (empty($contact_name)) {
if (empty($ticket_assigned_to)) { $contact_display = "-";
if (!empty($ticket_closed_at)) { } else {
$ticket_assigned_to_display = "<p>Not Assigned</p>"; $contact_display = "$contact_name<br><small class='text-secondary'>$contact_email</small>";
} else { }
$ticket_assigned_to_display = "<p class='text-danger'>Not Assigned</p>";
} // 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 { } else {
$ticket_assigned_to_display = nullable_htmlentities($row['user_name']); $ticket_reply_by_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);
} }
$ticket_reply_created_at = nullable_htmlentities($row['ticket_reply_created_at']);
$ticket_reply_created_at_time_ago = timeAgo($ticket_reply_created_at);
}
// Get Tasks // Get Tasks
$sql_tasks = mysqli_query( $mysqli, "SELECT * FROM tasks WHERE task_ticket_id = $ticket_id ORDER BY task_created_at ASC"); $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); $task_count = mysqli_num_rows($sql_tasks);
// Get Completed Task Count // Get Completed Task Count
$sql_tasks_completed = mysqli_query($mysqli, $sql_tasks_completed = mysqli_query($mysqli,
"SELECT * FROM tasks "SELECT * FROM tasks
WHERE task_ticket_id = $ticket_id WHERE task_ticket_id = $ticket_id
AND task_completed_at IS NOT NULL" AND task_completed_at IS NOT NULL"
); );
$completed_task_count = mysqli_num_rows($sql_tasks_completed); $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="#"
<?php if (empty($ticket_closed_at)) { ?>
data-toggle = "ajax-modal"
data-ajax-url = "ajax/ajax_ticket_priority.php"
data-ajax-id = "<?php echo $ticket_id; ?>"
<?php } ?>
>
<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 ($config_module_enable_accounting && lookupUserPermission("module_sales") >= 2) { ?>
<td class="text-center">
<a href="#"
data-toggle = "ajax-modal"
data-ajax-url = "ajax/ajax_ticket_billable.php"
data-ajax-id = "<?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>";
}
?>
</a>
</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="#"
<?php if (lookupUserPermission("module_support") >= 2 && empty($ticket_closed_at)) { ?>
data-toggle = "ajax-modal"
data-ajax-url = "ajax/ajax_ticket_assign.php"
data-ajax-id = "<?php echo $ticket_id; ?>"
<?php } ?>
>
<?php echo $ticket_assigned_to_display; ?>
</a>
</td>
</tr>
<?php
// Tasks Completed Percent
if($task_count) {
$tasks_completed_percent = round(($completed_task_count / $task_count) * 100);
} }
?> ?>
</tbody> <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"; } ?>">
</table>
</div> <!-- Ticket Bulk Select (for open tickets) -->
<?php require_once "modals/ticket_bulk_assign_modal.php"; ?> <td>
<?php require_once "modals/ticket_bulk_edit_category_modal.php"; ?> <?php if (empty($ticket_closed_at)) { ?>
<?php require_once "modals/ticket_bulk_edit_priority_modal.php"; ?> <div class="form-check">
<?php require_once "modals/ticket_bulk_add_project_modal.php"; ?> <input class="form-check-input bulk-select" type="checkbox" name="ticket_ids[]" value="<?php echo $ticket_id ?>">
<?php require_once "modals/ticket_bulk_reply_modal.php"; ?> </div>
<?php require_once "modals/ticket_bulk_merge_modal.php"; ?> <?php } ?>
<?php require_once "modals/ticket_bulk_resolve_modal.php"; ?> </td>
</form>
<?php require_once "includes/filter_footer.php"; ?>
</div>
<!-- Ticket Subject -->
<td>
<div class="mt-1">
<a href="#"
<?php if (empty($ticket_closed_at)) { ?>
data-toggle = "ajax-modal"
data-ajax-url = "ajax/ajax_ticket_priority.php"
data-ajax-id = "<?php echo $ticket_id; ?>"
<?php } ?>
>
<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 (isset($_GET['client_id'])) { echo "&client_id=$client_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>
<?php if (!isset($_GET['client_id'])) { ?>
<a href="tickets.php?client_id=<?php echo $client_id; ?>"><strong><?php echo $client_name; ?></strong></a>
<?php } ?>
<div><?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 = "ajax-modal"
data-ajax-url = "ajax/ajax_ticket_billable.php"
data-ajax-id = "<?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>";
}
?>
</a>
</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="#"
<?php if (lookupUserPermission("module_support") >= 2 && empty($ticket_closed_at)) { ?>
data-toggle = "ajax-modal"
data-ajax-url = "ajax/ajax_ticket_assign.php"
data-ajax-id = "<?php echo $ticket_id; ?>"
<?php } ?>
>
<?php echo $ticket_assigned_to_display; ?>
</a>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
<?php require_once "modals/ticket_bulk_assign_modal.php"; ?>
<?php require_once "modals/ticket_bulk_edit_category_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>
</div>
+9 -4
View File
@@ -2,8 +2,8 @@
<link rel="stylesheet" href="/css/tickets_kanban.css"> <link rel="stylesheet" href="/css/tickets_kanban.css">
<?php <?php
$kanban = [];
$kanban = [];
// Fetch all statuses // Fetch all statuses
$status_sql = mysqli_query($mysqli, "SELECT * FROM ticket_statuses where ticket_status_active = 1 AND ticket_status_id != 5 ORDER BY ticket_status_order"); $status_sql = mysqli_query($mysqli, "SELECT * FROM ticket_statuses where ticket_status_active = 1 AND ticket_status_id != 5 ORDER BY ticket_status_order");
@@ -47,6 +47,7 @@ $sql = mysqli_query(
LEFT JOIN categories ON ticket_category = category_id LEFT JOIN categories ON ticket_category = category_id
WHERE $ticket_status_snippet " . $ticket_assigned_query . " WHERE $ticket_status_snippet " . $ticket_assigned_query . "
$category_snippet $category_snippet
$client_query
AND DATE(ticket_created_at) BETWEEN '$dtf' AND '$dtt' 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%') 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 $ticket_permission_snippet
@@ -110,10 +111,14 @@ $kanban = array_values($statuses);
<b> <b>
<?php <?php
if ($item['contact_name'] != ""){ if (!isset($_GET['client_id'])) {
echo $item['client_name'] . ' - ' . $item['contact_name']; if ($item['contact_name'] != ""){
echo $item['client_name'] . ' - ' . $item['contact_name'];
} else {
echo $item['client_name'];
}
} else { } else {
echo $item['client_name']; echo $item['contact_name'];
} }
?> ?>
</b> </b>
+15 -6
View File
@@ -22,12 +22,20 @@
Subject <?php if ($sort == 'ticket_subject') { echo $order_icon; } ?> Subject <?php if ($sort == 'ticket_subject') { echo $order_icon; } ?>
</a> </a>
</th> </th>
<?php if (!isset($_GET['client_id'])) { ?>
<th> <th>
<a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=client_name&order=<?php echo $disp; ?>"> <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; } ?> Client / <span class="text-secondary">Contact</span> <?php if ($sort == 'client_name') { echo $order_icon; } ?>
</a> </a>
</th> </th>
<?php } ?>
<?php if (isset($_GET['client_id'])) { ?>
<th>
<a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=contact_name&order=<?php echo $disp; ?>">
Contact <?php if ($sort == 'contact_name') { echo $order_icon; } ?>
</a>
</th>
<?php } ?>
<?php if ($config_module_enable_accounting && lookupUserPermission("module_sales") >= 2) { ?> <?php if ($config_module_enable_accounting && lookupUserPermission("module_sales") >= 2) { ?>
<th class="text-center"> <th class="text-center">
<a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=ticket_billable&order=<?php echo $disp; ?>"> <a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=ticket_billable&order=<?php echo $disp; ?>">
@@ -185,14 +193,14 @@
<!-- Ticket Number --> <!-- Ticket Number -->
<td> <td>
<a href="ticket.php?ticket_id=<?php echo $ticket_id; ?>"> <a href="ticket.php?ticket_id=<?php echo $ticket_id; ?><?php if (isset($_GET['client_id'])) { echo "&client_id=$client_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 --> <!-- 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 if (isset($_GET['client_id'])) { echo "&client_id=$client_id"; } ?>"><?php echo $ticket_subject; ?></a>
<?php if($task_count && $completed_task_count > 0) { ?> <?php if($task_count && $completed_task_count > 0) { ?>
<div class="progress mt-2" style="height: 20px;"> <div class="progress mt-2" style="height: 20px;">
@@ -208,9 +216,10 @@
<!-- Ticket Contact --> <!-- Ticket Contact -->
<td> <td>
<a href="client_tickets.php?client_id=<?php echo $client_id; ?>"><strong><?php echo $client_name; ?></strong></a> <?php if (!isset($_GET['client_id'])) { ?>
<a href="tickets.php?client_id=<?php echo $client_id; ?>"><strong><?php echo $client_name; ?></strong></a>
<div class="mt-1"><?php echo $contact_display; ?></div> <?php } ?>
<div><?php echo $contact_display; ?></div>
</td> </td>
<!-- Ticket Billable (if accounting enabled --> <!-- Ticket Billable (if accounting enabled -->