- General reformatting
- Adjusted logic for open tickets to include tickets in working/on-hold states. - Added filter to advanced search for ticket state - Removed query string for the total/open/closed counts/filters - Hyperlinked the unassigned tickets button. -- Future work here would be to allow tickets to be filtered by assignee.
This commit is contained in:
+160
-50
@@ -37,7 +37,10 @@
|
||||
}
|
||||
|
||||
// Ticket status from GET
|
||||
if(isset($_GET['status']) && ($_GET['status']) == 'Open'){
|
||||
if (!isset($_GET['status'])) {
|
||||
// If nothing is set, assume we only want to see open tickets
|
||||
$status = 'Open';
|
||||
} elseif (isset($_GET['status']) && ($_GET['status']) == 'Open') {
|
||||
$status = 'Open';
|
||||
} elseif (isset($_GET['status']) && ($_GET['status']) == 'Closed') {
|
||||
$status = 'Closed';
|
||||
@@ -45,11 +48,13 @@
|
||||
$status = '%';
|
||||
}
|
||||
|
||||
//$url_query_strings_sb = http_build_query(array_merge($_GET,array('ticket_status' => $status)));
|
||||
|
||||
//if(isset($_GET['status'])){
|
||||
//unset($_GET['status']);
|
||||
//}
|
||||
// Unassigned ticket filter
|
||||
// TODO: Eventually use this as an "assigned" parameter allowing for the filtering of tickets by who they are assigned to - for use with "My tickets"
|
||||
if (isset($_GET['unassigned'])) {
|
||||
$view_unassigned_only = TRUE;
|
||||
} else {
|
||||
$view_unassigned_only = FALSE;
|
||||
}
|
||||
|
||||
//Date Filter
|
||||
|
||||
@@ -92,9 +97,39 @@
|
||||
}
|
||||
|
||||
//Rebuild URL
|
||||
$url_query_strings_sb = http_build_query(array_merge($_GET, array('sb' => $sb, 'o' => $o, 'status' => $status)));
|
||||
|
||||
$url_query_strings_sb = http_build_query(array_merge($_GET,array('sb' => $sb, 'o' => $o, 'ticket_status' => $status)));
|
||||
// Main ticket query:
|
||||
|
||||
// Separate queries for Unassigned, Open / Closed tickets as Open tickets need to include tickets in state "Working" and "On Hold" as well as "Open".
|
||||
if ($view_unassigned_only) {
|
||||
$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
|
||||
WHERE tickets.company_id = $session_company_id
|
||||
AND ticket_assigned_to = '0'
|
||||
AND ticket_status != 'Closed'
|
||||
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 user_name LIKE '%$q%')
|
||||
ORDER BY $sb $o LIMIT $record_from, $record_to");
|
||||
}
|
||||
elseif ($status == "Open") {
|
||||
$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
|
||||
WHERE tickets.company_id = $session_company_id
|
||||
AND ticket_status != 'Closed'
|
||||
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 user_name LIKE '%$q%')
|
||||
ORDER BY $sb $o LIMIT $record_from, $record_to");
|
||||
}
|
||||
else {
|
||||
$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
|
||||
@@ -104,20 +139,20 @@
|
||||
WHERE tickets.company_id = $session_company_id
|
||||
AND ticket_status LIKE '%$status%'
|
||||
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_priority LIKE '%$q%' OR user_name LIKE '%$q%')
|
||||
AND (CONCAT(ticket_prefix,ticket_number) LIKE '%$q%' OR client_name LIKE '%$q%' OR ticket_subject LIKE '%$q%' OR user_name LIKE '%$q%')
|
||||
ORDER BY $sb $o LIMIT $record_from, $record_to");
|
||||
}
|
||||
|
||||
$num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
||||
|
||||
|
||||
|
||||
//Get Total tickets
|
||||
$sql_total_tickets = mysqli_query($mysqli, "SELECT COUNT(ticket_id) AS total_tickets FROM tickets WHERE company_id = $session_company_id");
|
||||
$row = mysqli_fetch_array($sql_total_tickets);
|
||||
$total_tickets = $row['total_tickets'];
|
||||
|
||||
//Get Total tickets open
|
||||
$sql_total_tickets_open = mysqli_query($mysqli,"SELECT COUNT(ticket_id) AS total_tickets_open FROM tickets WHERE ticket_status = 'open' AND company_id = $session_company_id");
|
||||
$sql_total_tickets_open = mysqli_query($mysqli, "SELECT COUNT(ticket_id) AS total_tickets_open FROM tickets WHERE ticket_status != 'Closed' AND company_id = $session_company_id");
|
||||
$row = mysqli_fetch_array($sql_total_tickets_open);
|
||||
$total_tickets_open = $row['total_tickets_open'];
|
||||
|
||||
@@ -126,13 +161,13 @@ $sql_total_tickets_closed = mysqli_query($mysqli,"SELECT COUNT(DISTINCT 'ticket_
|
||||
$row = mysqli_fetch_array($sql_total_tickets_closed);
|
||||
$total_tickets_closed = $row['total_tickets_closed'];
|
||||
|
||||
//Get Unnassigned 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_status = 'open' AND company_id = $session_company_id");
|
||||
//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_status != 'Closed' AND company_id = $session_company_id");
|
||||
$row = mysqli_fetch_array($sql_total_tickets_unassigned);
|
||||
$total_tickets_unassigned = $row['total_tickets_unassigned'];
|
||||
|
||||
//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_status = 'open' AND company_id = $session_company_id");
|
||||
$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_status != 'Closed' AND company_id = $session_company_id");
|
||||
$row = mysqli_fetch_array($sql_total_tickets_assigned);
|
||||
$total_tickets_assigned = $row['total_tickets_assigned'];
|
||||
|
||||
@@ -141,64 +176,102 @@ $total_tickets_assigned = $row['total_tickets_assigned'];
|
||||
<div class="card-header py-2">
|
||||
<h3 class="card-title mt-2"><i class="fa fa-fw fa-tags"></i> Tickets
|
||||
<small class="ml-3">
|
||||
<a href="?<?php echo $url_query_strings_sb; ?>&status=%"><strong><?php echo $total_tickets; ?></strong> Total</a> |
|
||||
<a href="?<?php echo $url_query_strings_sb; ?>&status=Open"><strong><?php echo $total_tickets_open; ?></strong> Open</a> |
|
||||
<a href="?<?php echo $url_query_strings_sb; ?>&status=Closed"><strong><?php echo $total_tickets_closed; ?></strong> Closed</a>
|
||||
<a href="?status=%"><strong><?php echo $total_tickets; ?></strong> Total</a> |
|
||||
<a href="?status=Open"><strong><?php echo $total_tickets_open; ?></strong> Open</a> |
|
||||
<a href="?status=Closed"><strong><?php echo $total_tickets_closed; ?></strong> Closed</a>
|
||||
</small>
|
||||
</h3>
|
||||
|
||||
<div class='card-tools'>
|
||||
<div class="float-left">
|
||||
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#addTicketModal"><i class="fas fa-fw fa-plus"></i> New Ticket</button>
|
||||
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#addTicketModal"><i
|
||||
class="fas fa-fw fa-plus"></i> New Ticket
|
||||
</button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form class="mb-4" autocomplete="off">
|
||||
<input type="hidden" name="status" value="<?php echo $status; ?>">
|
||||
<div class="row">
|
||||
<div class="col-sm-4">
|
||||
<div class="input-group">
|
||||
<input type="search" class="form-control" name="q" value="<?php if(isset($q)){echo stripslashes($q);} ?>" placeholder="Search Tickets">
|
||||
<input type="search" class="form-control" name="q" value="<?php if (isset($q)) {
|
||||
echo htmlentities($q);
|
||||
} ?>" placeholder="Search Tickets">
|
||||
<div class="input-group-append">
|
||||
<button class="btn btn-secondary" type="button" data-toggle="collapse" data-target="#advancedFilter"><i class="fas fa-filter"></i></button>
|
||||
<button class="btn btn-secondary" type="button" data-toggle="collapse"
|
||||
data-target="#advancedFilter"><i class="fas fa-filter"></i></button>
|
||||
<button class="btn btn-primary"><i class="fa fa-search"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-8">
|
||||
<div class="btn-group btn-group-lg float-right">
|
||||
<button class="btn btn-outline-dark dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown">
|
||||
<i class="fa fa-fw fa-envelope"></i> My Tickets | <strong> <?php echo $total_tickets_assigned; ?></strong>
|
||||
<button class="btn btn-outline-dark dropdown-toggle" type="button" id="dropdownMenuButton"
|
||||
data-toggle="dropdown">
|
||||
<i class="fa fa-fw fa-envelope"></i> My Tickets |
|
||||
<strong> <?php echo $total_tickets_assigned; ?></strong>
|
||||
</button>
|
||||
<div class="dropdown-menu">
|
||||
<a class="dropdown-item" href="#"><strong> <?php echo $total_tickets_assigned; ?></strong> | Unanswered</a>
|
||||
<a class="dropdown-item" href="#"><strong> <?php echo $total_tickets_assigned; ?></strong> | Answered</a>
|
||||
<a class="dropdown-item"
|
||||
href="#"><strong> <?php echo $total_tickets_assigned; ?></strong> | Unanswered</a>
|
||||
<a class="dropdown-item"
|
||||
href="#"><strong> <?php echo $total_tickets_assigned; ?></strong> | Answered</a>
|
||||
<div class="dropdown-divider"></div>
|
||||
<a class="dropdown-item " href="#">Closed by me</a>
|
||||
</div>
|
||||
<a href="#" class="btn btn-outline-danger"><i class="fa fa-fw fa-exclamation-triangle"></i> Unassigned Tickets | <strong> <?php echo $total_tickets_unassigned; ?></strong></a>
|
||||
<a href="?unassigned" class="btn btn-outline-danger"><i class="fa fa-fw fa-exclamation-triangle"></i>
|
||||
Unassigned Tickets | <strong> <?php echo $total_tickets_unassigned; ?></strong></a>
|
||||
<a href="#" class="btn btn-outline-info"><i class="fa fa-fw fa-cogs"></i> Tasks</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="collapse mt-3 <?php if(!empty($_GET['dtf'])){ echo "show"; } ?>" id="advancedFilter">
|
||||
<div class="collapse mt-3 <?php if (!empty($_GET['dtf'])) {
|
||||
echo "show";
|
||||
} ?>" id="advancedFilter">
|
||||
<div class="row">
|
||||
<div class="col-md-2">
|
||||
<div class="form-group">
|
||||
<label>Canned Date</label>
|
||||
<select class="form-control select2" name="canned_date">
|
||||
<option <?php if($_GET['canned_date'] == "custom"){ echo "selected"; } ?> value="custom">Custom</option>
|
||||
<option <?php if($_GET['canned_date'] == "today"){ echo "selected"; } ?> value="today">Today</option>
|
||||
<option <?php if($_GET['canned_date'] == "yesterday"){ echo "selected"; } ?> value="yesterday">Yesterday</option>
|
||||
<option <?php if($_GET['canned_date'] == "thisweek"){ echo "selected"; } ?> value="thisweek">This Week</option>
|
||||
<option <?php if($_GET['canned_date'] == "lastweek"){ echo "selected"; } ?> value="lastweek">Last Week</option>
|
||||
<option <?php if($_GET['canned_date'] == "thismonth"){ echo "selected"; } ?> value="thismonth">This Month</option>
|
||||
<option <?php if($_GET['canned_date'] == "lastmonth"){ echo "selected"; } ?> value="lastmonth">Last Month</option>
|
||||
<option <?php if($_GET['canned_date'] == "thisyear"){ echo "selected"; } ?> value="thisyear">This Year</option>
|
||||
<option <?php if($_GET['canned_date'] == "lastyear"){ echo "selected"; } ?> value="lastyear">Last Year</option>
|
||||
<option <?php if ($_GET['canned_date'] == "custom") {
|
||||
echo "selected";
|
||||
} ?> value="custom">Custom
|
||||
</option>
|
||||
<option <?php if ($_GET['canned_date'] == "today") {
|
||||
echo "selected";
|
||||
} ?> value="today">Today
|
||||
</option>
|
||||
<option <?php if ($_GET['canned_date'] == "yesterday") {
|
||||
echo "selected";
|
||||
} ?> value="yesterday">Yesterday
|
||||
</option>
|
||||
<option <?php if ($_GET['canned_date'] == "thisweek") {
|
||||
echo "selected";
|
||||
} ?> value="thisweek">This Week
|
||||
</option>
|
||||
<option <?php if ($_GET['canned_date'] == "lastweek") {
|
||||
echo "selected";
|
||||
} ?> value="lastweek">Last Week
|
||||
</option>
|
||||
<option <?php if ($_GET['canned_date'] == "thismonth") {
|
||||
echo "selected";
|
||||
} ?> value="thismonth">This Month
|
||||
</option>
|
||||
<option <?php if ($_GET['canned_date'] == "lastmonth") {
|
||||
echo "selected";
|
||||
} ?> value="lastmonth">Last Month
|
||||
</option>
|
||||
<option <?php if ($_GET['canned_date'] == "thisyear") {
|
||||
echo "selected";
|
||||
} ?> value="thisyear">This Year
|
||||
</option>
|
||||
<option <?php if ($_GET['canned_date'] == "lastyear") {
|
||||
echo "selected";
|
||||
} ?> value="lastyear">Last Year
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
@@ -214,23 +287,52 @@ $total_tickets_assigned = $row['total_tickets_assigned'];
|
||||
<input type="date" class="form-control" name="dtt" value="<?php echo $dtt; ?>">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<div class="form-group">
|
||||
<label>Ticket Status</label>
|
||||
<select class="form-control" name="status">
|
||||
<option value="%" <?php if($status == "%"){echo "selected";}?> >Any</option>
|
||||
<option value="Open" <?php if($status == "Open"){echo "selected";}?> >Open</option>
|
||||
<option value="Closed" <?php if($status == "Closed"){echo "selected";}?> >Closed</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<hr>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-borderless table-hover">
|
||||
<thead class="text-dark <?php if($num_rows[0] == 0){ echo "d-none"; } ?>">
|
||||
<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_sb; ?>&sb=ticket_number&o=<?php echo $disp; ?>">Number</a></th>
|
||||
<th><a class="text-dark" href="?<?php echo $url_query_strings_sb; ?>&sb=ticket_subject&o=<?php echo $disp; ?>">Subject</a></th>
|
||||
<th><a class="text-dark" href="?<?php echo $url_query_strings_sb; ?>&sb=contact_name&o=<?php echo $disp; ?>">Contact</a></th>
|
||||
<th><a class="text-dark" href="?<?php echo $url_query_strings_sb; ?>&sb=client_name&o=<?php echo $disp; ?>">Client</a></th>
|
||||
<th><a class="text-dark" href="?<?php echo $url_query_strings_sb; ?>&sb=ticket_priority&o=<?php echo $disp; ?>">Priority</a></th>
|
||||
<th><a class="text-dark" href="?<?php echo $url_query_strings_sb; ?>&sb=ticket_status&o=<?php echo $disp; ?>">Status</a>
|
||||
<th><a class="text-dark" href="?<?php echo $url_query_strings_sb; ?>&sb=user_name&o=<?php echo $disp; ?>">Assigned</a></th>
|
||||
<th><a class="text-dark" href="?<?php echo $url_query_strings_sb; ?>&sb=ticket_updated_at&o=<?php echo $disp; ?>">Last Response</a></th>
|
||||
<th><a class="text-dark" href="?<?php echo $url_query_strings_sb; ?>&sb=ticket_created_at&o=<?php echo $disp; ?>">Created</a></th>
|
||||
<th><a class="text-dark"
|
||||
href="?<?php echo $url_query_strings_sb; ?>&sb=ticket_number&o=<?php echo $disp; ?>">Number</a>
|
||||
</th>
|
||||
<th><a class="text-dark"
|
||||
href="?<?php echo $url_query_strings_sb; ?>&sb=ticket_subject&o=<?php echo $disp; ?>">Subject</a>
|
||||
</th>
|
||||
<th><a class="text-dark"
|
||||
href="?<?php echo $url_query_strings_sb; ?>&sb=contact_name&o=<?php echo $disp; ?>">Contact</a>
|
||||
</th>
|
||||
<th><a class="text-dark"
|
||||
href="?<?php echo $url_query_strings_sb; ?>&sb=client_name&o=<?php echo $disp; ?>">Client</a>
|
||||
</th>
|
||||
<th><a class="text-dark"
|
||||
href="?<?php echo $url_query_strings_sb; ?>&sb=ticket_priority&o=<?php echo $disp; ?>">Priority</a>
|
||||
</th>
|
||||
<th><a class="text-dark"
|
||||
href="?<?php echo $url_query_strings_sb; ?>&sb=ticket_status&o=<?php echo $disp; ?>">Status</a>
|
||||
<th><a class="text-dark"
|
||||
href="?<?php echo $url_query_strings_sb; ?>&sb=user_name&o=<?php echo $disp; ?>">Assigned</a>
|
||||
</th>
|
||||
<th><a class="text-dark"
|
||||
href="?<?php echo $url_query_strings_sb; ?>&sb=ticket_updated_at&o=<?php echo $disp; ?>">Last
|
||||
Response</a></th>
|
||||
<th><a class="text-dark"
|
||||
href="?<?php echo $url_query_strings_sb; ?>&sb=ticket_created_at&o=<?php echo $disp; ?>">Created</a>
|
||||
</th>
|
||||
|
||||
<th class="text-center">Action</th>
|
||||
</tr>
|
||||
@@ -303,10 +405,16 @@ $total_tickets_assigned = $row['total_tickets_assigned'];
|
||||
?>
|
||||
|
||||
<tr>
|
||||
<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>
|
||||
<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; ?>"><span
|
||||
class="badge badge-pill badge-secondary p-3"><?php echo "$ticket_prefix$ticket_number"; ?></span></a>
|
||||
</td>
|
||||
<td>
|
||||
<a href="ticket.php?ticket_id=<?php echo $ticket_id; ?>"><?php echo $ticket_subject; ?></a>
|
||||
</td>
|
||||
<td><?php echo $contact_display; ?></td>
|
||||
<td><a href="client.php?client_id=<?php echo $client_id; ?>&tab=tickets"><?php echo $client_name; ?></a></td>
|
||||
<td>
|
||||
<a href="client.php?client_id=<?php echo $client_id; ?>&tab=tickets"><?php echo $client_name; ?></a>
|
||||
</td>
|
||||
<td><?php echo $ticket_priority_display; ?></td>
|
||||
<td><?php echo $ticket_status_display; ?></td>
|
||||
<td><?php echo $ticket_assigned_to_display; ?></td>
|
||||
@@ -318,9 +426,11 @@ $total_tickets_assigned = $row['total_tickets_assigned'];
|
||||
<i class="fas fa-ellipsis-h"></i>
|
||||
</button>
|
||||
<div class="dropdown-menu">
|
||||
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#editTicketModal<?php echo $ticket_id; ?>">Edit</a>
|
||||
<a class="dropdown-item" href="#" data-toggle="modal"
|
||||
data-target="#editTicketModal<?php echo $ticket_id; ?>">Edit</a>
|
||||
<div class="dropdown-divider"></div>
|
||||
<a class="dropdown-item text-danger" href="post.php?delete_ticket=<?php echo $ticket_id; ?>">Delete</a>
|
||||
<a class="dropdown-item text-danger"
|
||||
href="post.php?delete_ticket=<?php echo $ticket_id; ?>">Delete</a>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
|
||||
Reference in New Issue
Block a user