Skip to content

Commit

Permalink
Ticket categories
Browse files Browse the repository at this point in the history
Add basic support for categorising tickets (e.g. Software/Network)
  • Loading branch information
wrongecho committed May 26, 2024
1 parent 5210fae commit 159c1d7
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 19 deletions.
10 changes: 8 additions & 2 deletions admin_categories.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ class="btn <?php if ($category == 'Payment Method') {
echo 'btn-default';
} ?>">Payment
Method</a>
<a href="?category=Ticket"
class="btn <?php if ($category == 'Ticket') {
echo 'btn-primary';
} else {
echo 'btn-default';
} ?>">Ticket</a>
<a href="?archived=1"
class="btn <?php if (isset($_GET['archived'])) {
echo 'btn-primary';
Expand Down Expand Up @@ -125,7 +131,7 @@ class="fas fa-fw fa-archive mr-2"></i>Archived</a>
$category_id = intval($row['category_id']);
$category_name = nullable_htmlentities($row['category_name']);
$category_color = nullable_htmlentities($row['category_color']);

?>
<tr>
<td><a class="text-dark" href="#" data-toggle="modal"
Expand Down Expand Up @@ -170,7 +176,7 @@ class="fas fa-fw fa-archive mr-2"></i>Archived</a>
</tr>

<?php

include "admin_category_edit_modal.php";

}
Expand Down
3 changes: 2 additions & 1 deletion post/ticket.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@
$ticket_id = intval($_POST['ticket_id']);
$contact_id = intval($_POST['contact']);
$notify = intval($_POST['contact_notify']);
$category = intval($_POST['category']);
$subject = sanitizeInput($_POST['subject']);
$billable = intval($_POST['billable']);
$priority = sanitizeInput($_POST['priority']);
Expand All @@ -200,7 +201,7 @@
$client_id = intval($_POST['client_id']);
$ticket_number = sanitizeInput($_POST['ticket_number']);

mysqli_query($mysqli, "UPDATE tickets SET ticket_subject = '$subject', ticket_priority = '$priority', ticket_billable = $billable, ticket_details = '$details', ticket_vendor_ticket_number = '$vendor_ticket_number', ticket_contact_id = $contact_id, ticket_vendor_id = $vendor_id, ticket_location_id = $location_id, ticket_asset_id = $asset_id, ticket_project_id = $project_id WHERE ticket_id = $ticket_id");
mysqli_query($mysqli, "UPDATE tickets SET ticket_category = $category, ticket_subject = '$subject', ticket_priority = '$priority', ticket_billable = $billable, ticket_details = '$details', ticket_vendor_ticket_number = '$vendor_ticket_number', ticket_contact_id = $contact_id, ticket_vendor_id = $vendor_id, ticket_location_id = $location_id, ticket_asset_id = $asset_id, ticket_project_id = $project_id WHERE ticket_id = $ticket_id");

// Notify new contact if selected
if ($notify && !empty($config_smtp_host)) {
Expand Down
21 changes: 15 additions & 6 deletions ticket.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
LEFT JOIN projects ON ticket_project_id = project_id
LEFT JOIN invoices ON ticket_invoice_id = invoice_id
LEFT JOIN ticket_statuses ON ticket_status = ticket_status_id
LEFT JOIN categories ON ticket_category = category_id
WHERE ticket_id = $ticket_id LIMIT 1"
);

Expand All @@ -54,7 +55,8 @@

$ticket_prefix = nullable_htmlentities($row['ticket_prefix']);
$ticket_number = intval($row['ticket_number']);
$ticket_category = nullable_htmlentities($row['ticket_category']);
$ticket_category = intval($row['ticket_category']);
$ticket_category_display = htmlentities($row['category_name']);
$ticket_subject = nullable_htmlentities($row['ticket_subject']);
$ticket_details = $purifier->purify($row['ticket_details']);
$ticket_priority = nullable_htmlentities($row['ticket_priority']);
Expand Down Expand Up @@ -404,18 +406,25 @@
</div>

<div class="col-sm-3">
<?php if($task_count) { ?>
<?php if ($task_count) { ?>
Tasks Completed<span class="float-right text-bold"><?php echo $tasks_completed_percent; ?>%</span>
<div class="progress mt-2" style="height: 20px;">
<div class="progress-bar" style="width: <?php echo $tasks_completed_percent; ?>%;"><?php echo $completed_task_count; ?> / <?php echo $task_count; ?></div>
</div>
<?php } ?>

<?php if($ticket_collaborators) { ?>
<?php if ($ticket_collaborators) { ?>
<div class="mt-2">
<i class="fas fa-fw fa-users mr-2 text-secondary"></i><?php echo $ticket_collaborators; ?>
</div>
<?php } ?>

<?php if ($ticket_category > 0) { ?>
<div class="mt-2">
<i class="fas fa-fw fa-layer-group mr-2 text-secondary"></i><?php echo $ticket_category_display; ?>
</div>
<?php } ?>

</div>

<div class="col-sm-3">
Expand Down Expand Up @@ -451,7 +460,7 @@
<?php }

if (empty($ticket_closed_at)) { ?>
<?php if($task_count == $completed_task_count) { ?>
<?php if ($task_count == $completed_task_count) { ?>
<a href="post.php?close_ticket=<?php echo $ticket_id; ?>" class="btn btn-dark btn-sm confirm-link" id="ticket_close">
<i class="fas fa-fw fa-gavel mr-2"></i>Close
</a>
Expand Down Expand Up @@ -625,7 +634,7 @@
<!-- End IF for reply modal -->
<?php } ?>

<?php if($ticket_responses) { ?><h5 class="mb-4">Responses (<?php echo $ticket_responses; ?>)</h5><?php } ?>
<?php if ($ticket_responses) { ?><h5 class="mb-4">Responses (<?php echo $ticket_responses; ?>)</h5><?php } ?>

<!-- Ticket replies -->
<?php
Expand Down Expand Up @@ -837,7 +846,7 @@
?>
<tr>
<td>
<?php if($task_completed_at) { ?>
<?php if ($task_completed_at) { ?>
<i class="far fa-fw fa-check-square text-primary"></i>
<?php } else { ?>
<a href="post.php?complete_task=<?php echo $task_id; ?>">
Expand Down
48 changes: 38 additions & 10 deletions ticket_edit_modal.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,45 @@
<textarea class="form-control tinymce" rows="8" name="details"><?php echo $ticket_details; ?></textarea>
</div>

<div class="form-group">
<label>Priority <strong class="text-danger">*</strong></label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-thermometer-half"></i></span>
<div class="row">
<div class="col">
<div class="form-group">
<label>Priority <strong class="text-danger">*</strong></label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-thermometer-half"></i></span>
</div>
<select class="form-control select2" name="priority" required>
<option <?php if ($ticket_priority == 'Low') { echo "selected"; } ?> >Low</option>
<option <?php if ($ticket_priority == 'Medium') { echo "selected"; } ?> >Medium</option>
<option <?php if ($ticket_priority == 'High') { echo "selected"; } ?> >High</option>
</select>
</div>
</div>
</div>

<div class="col">
<div class="form-group">
<label>Category</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-layer-group"></i></span>
</div>
<select class="form-control select2" name="category">
<option value="">- Ticket Category -</option>
<?php
$sql_categories = mysqli_query($mysqli, "SELECT * FROM categories WHERE category_type = 'Ticket' AND categories.category_archived_at IS NULL");
while ($row = mysqli_fetch_array($sql_categories)) {
$category_id = intval($row['category_id']);
$category_name = nullable_htmlentities($row['category_name']);

?>
<option <?php if ($ticket_category == $category_id) {echo "selected";} ?> value="<?php echo $category_id; ?>"><?php echo $category_name; ?></option>
<?php } ?>

</select>
</div>
</div>
<select class="form-control select2" name="priority" required>
<option <?php if ($ticket_priority == 'Low') { echo "selected"; } ?> >Low</option>
<option <?php if ($ticket_priority == 'Medium') { echo "selected"; } ?> >Medium</option>
<option <?php if ($ticket_priority == 'High') { echo "selected"; } ?> >High</option>
</select>
</div>
</div>

Expand Down

0 comments on commit 159c1d7

Please sign in to comment.