Add more billable status functionality

This commit is contained in:
o-psi 2023-12-21 17:10:15 +00:00
parent f1516b06ee
commit 3eaaf73744
7 changed files with 123 additions and 2 deletions

View File

@ -1,7 +1,7 @@
<?php <?php
require_once "inc_all.php"; require_once "inc_all_client.php";
if (isset($_GET['client_id'])) { if (isset($_GET['client_id'])) {

View File

@ -1,5 +1,6 @@
<?php <?php
// Default Column Sortby Filter // Default Column Sortby Filter
$sort = "ticket_number"; $sort = "ticket_number";
$order = "DESC"; $order = "DESC";
@ -99,6 +100,7 @@ $total_tickets_closed = intval($row['total_tickets_closed']);
<th><a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=ticket_number&order=<?php echo $disp; ?>">Number</a></th> <th><a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=ticket_number&order=<?php echo $disp; ?>">Number</a></th>
<th><a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=ticket_subject&order=<?php echo $disp; ?>">Subject</a></th> <th><a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=ticket_subject&order=<?php echo $disp; ?>">Subject</a></th>
<th><a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=contact_name&order=<?php echo $disp; ?>">Contact</a></th> <th><a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=contact_name&order=<?php echo $disp; ?>">Contact</a></th>
<th><a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=ticket_billable&order=<?php echo $disp; ?>">Billable</a></th>
<th><a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=ticket_priority&order=<?php echo $disp; ?>">Priority</a></th> <th><a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=ticket_priority&order=<?php echo $disp; ?>">Priority</a></th>
<th><a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=ticket_status&order=<?php echo $disp; ?>">Status</a></th> <th><a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=ticket_status&order=<?php echo $disp; ?>">Status</a></th>
<th><a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=user_name&order=<?php echo $disp; ?>">Assigned</a></th> <th><a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=user_name&order=<?php echo $disp; ?>">Assigned</a></th>
@ -117,6 +119,7 @@ $total_tickets_closed = intval($row['total_tickets_closed']);
$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 = nullable_htmlentities($row['ticket_status']); $ticket_status = nullable_htmlentities($row['ticket_status']);
$ticket_billable = intval($row['ticket_billable']);
$ticket_vendor_ticket_number = nullable_htmlentities($row['ticket_vendor_ticket_number']); $ticket_vendor_ticket_number = nullable_htmlentities($row['ticket_vendor_ticket_number']);
$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']);
@ -195,6 +198,15 @@ $total_tickets_closed = intval($row['total_tickets_closed']);
<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 echo $ticket_subject; ?></a>
</td> </td>
<td><a href="#" data-toggle="modal" data-target="#editTicketContactModal<?php echo $ticket_id; ?>"><?php echo $contact_display; ?></a></td> <td><a href="#" data-toggle="modal" data-target="#editTicketContactModal<?php echo $ticket_id; ?>"><?php echo $contact_display; ?></a></td>
<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'>$</span>";
} else {
echo "<span class='badge badge-pill badge-secondary'>X</span>";
}
?></td>
<td><a href="#" data-toggle="modal" data-target="#editTicketPriorityModal<?php echo $ticket_id; ?>"><?php echo $ticket_priority_display; ?></a></td> <td><a href="#" data-toggle="modal" data-target="#editTicketPriorityModal<?php echo $ticket_id; ?>"><?php echo $ticket_priority_display; ?></a></td>
<td><span class='p-2 badge badge-pill badge-<?php echo $ticket_status_color; ?>'><?php echo $ticket_status; ?></span></td> <td><span class='p-2 badge badge-pill badge-<?php echo $ticket_status_color; ?>'><?php echo $ticket_status; ?></span></td>
<td><a href="#" data-toggle="modal" data-target="#assignTicketModal<?php echo $ticket_id; ?>"><?php echo $ticket_assigned_to_display; ?></a></td> <td><a href="#" data-toggle="modal" data-target="#assignTicketModal<?php echo $ticket_id; ?>"><?php echo $ticket_assigned_to_display; ?></a></td>
@ -217,6 +229,8 @@ $total_tickets_closed = intval($row['total_tickets_closed']);
require "ticket_edit_contact_modal.php"; require "ticket_edit_contact_modal.php";
require "ticket_edit_billable_modal.php";
} }
} }

View File

@ -1097,3 +1097,35 @@ if (isset($_POST['bulk_delete_scheduled_tickets'])) {
header("Location: " . $_SERVER["HTTP_REFERER"]); header("Location: " . $_SERVER["HTTP_REFERER"]);
} }
if(isset($_POST['set_billable_status'])) {
validateTechRole();
$ticket_id = intval($_POST['ticket_id']);
$billable_status = sanitizeInput($_POST['billable_status']);
mysqli_query($mysqli,
"UPDATE tickets SET
ticket_billable = '$billable_status'
WHERE ticket_id = $ticket_id"
);
//Logging
mysqli_query(
$mysqli,
"INSERT INTO logs SET
log_type = 'Ticket',
log_action = 'Modify',
log_description = '$session_name modified ticket billable status',
log_ip = '$session_ip',
log_user_agent = '$session_user_agent',
log_user_id = $session_user_id,
log_entity_id = $ticket_id"
);
$_SESSION['alert_message'] = "Ticket billable status updated";
header("Location: " . $_SERVER["HTTP_REFERER"]);
}

View File

@ -637,6 +637,21 @@ if (isset($_GET['ticket_id'])) {
<i class="far fa-fw fa-clock text-secondary ml-1 mr-2"></i>Total time worked: <?php echo $ticket_total_reply_time; ?> <i class="far fa-fw fa-clock text-secondary ml-1 mr-2"></i>Total time worked: <?php echo $ticket_total_reply_time; ?>
</div> </div>
<?php } ?> <?php } ?>
<?php if (!empty($ticket_billable)) { ?>
<div class="mt-1">
<i class="fa fa-fw fa-dollar-sign text-secondary ml-1 mr-2"></i>Billable:
<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'>$</span>";
} else {
echo "<span class='badge badge-pill badge-secondary p-2'>X</span>";
}
?>
</a>
</div>
<?php } ?>
</div> </div>
<!-- End Ticket details card --> <!-- End Ticket details card -->
@ -851,6 +866,8 @@ if (isset($_GET['ticket_id'])) {
require_once "ticket_invoice_add_modal.php"; require_once "ticket_invoice_add_modal.php";
require_once "ticket_edit_billable_modal.php";
} }

View File

@ -0,0 +1,42 @@
<div class="modal" id="editTicketBillableModal<?php echo $ticket_id; ?>" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content bg-dark">
<div class="modal-header">
<h5 class="modal-title">
<i class="fa fa-fw fa-user mr-2"></i>
Edit Billable Status for <strong><?php echo "$ticket_prefix$ticket_number"; ?></strong>
</h5>
<button type="button" class="close text-white" data-dismiss="modal">
<span>&times;</span>
</button>
</div>
<form action="post.php" method="post" autocomplete="off">
<div class="modal-body bg-white">
<input type="hidden" name="ticket_id" value="<?php echo $ticket_id; ?>">
<input type="hidden" name="set_billable_status" value="1">
<div class="form-group">
<label>Billable</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-money-bill"></i></span>
</div>
<select class="form-control" name="billable_status">
<option <?php if ($ticket_billable == 1) { echo "selected"; } ?> value="1">Yes</option>
<option <?php if ($ticket_billable == 0) { echo "selected"; } ?> value="0">No</option>
</select>
</div>
</div>
</div>
<div class="modal-footer bg-white">
<button type="submit" name="edit_ticket_billable" class="btn btn-primary text-bold"><i class="fa fa-check mr-2"></i>Save</button>
<button type="button" class="btn btn-light" data-dismiss="modal"><i class="fa fa-times mr-2"></i>Cancel</button>
</div>
</form>
</div>
</div>
</div>

View File

@ -68,7 +68,7 @@
<div class="input-group-prepend"> <div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-money-bill"></i></span> <span class="input-group-text"><i class="fa fa-fw fa-money-bill"></i></span>
</div> </div>
<select class="form-control select2" name="billable"> <select class="form-control" name="billable">
<option <?php if ($ticket_billable == 1) { echo "selected"; } ?> value="1">Yes</option> <option <?php if ($ticket_billable == 1) { echo "selected"; } ?> value="1">Yes</option>
<option <?php if ($ticket_billable == 0) { echo "selected"; } ?> value="0">No</option> <option <?php if ($ticket_billable == 0) { echo "selected"; } ?> value="0">No</option>
</select> </select>

View File

@ -1,5 +1,6 @@
<?php <?php
// Default Column Sortby Filter // Default Column Sortby Filter
$sort = "ticket_number"; $sort = "ticket_number";
$order = "DESC"; $order = "DESC";
@ -250,6 +251,9 @@ $user_active_assigned_tickets = intval($row['total_tickets_assigned']);
<th><a class="text-dark" <th><a class="text-dark"
href="?<?php echo $url_query_strings_sort; ?>&sort=client_name&order=<?php echo $disp; ?>">Client / Contact</a> href="?<?php echo $url_query_strings_sort; ?>&sort=client_name&order=<?php echo $disp; ?>">Client / Contact</a>
</th> </th>
<th><a class="text-dark"
href="?<?php echo $url_query_strings_sort; ?>&sort=ticket_billable&order=<?php echo $disp; ?>">Billable</a>
</th>
<th><a class="text-dark" <th><a class="text-dark"
href="?<?php echo $url_query_strings_sort; ?>&sort=ticket_priority&order=<?php echo $disp; ?>">Priority</a> href="?<?php echo $url_query_strings_sort; ?>&sort=ticket_priority&order=<?php echo $disp; ?>">Priority</a>
</th> </th>
@ -277,6 +281,7 @@ $user_active_assigned_tickets = intval($row['total_tickets_assigned']);
$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 = nullable_htmlentities($row['ticket_status']); $ticket_status = nullable_htmlentities($row['ticket_status']);
$ticket_billable = intval($row['ticket_billable']);
$ticket_vendor_ticket_number = nullable_htmlentities($row['ticket_vendor_ticket_number']); $ticket_vendor_ticket_number = nullable_htmlentities($row['ticket_vendor_ticket_number']);
$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']);
@ -356,6 +361,15 @@ $user_active_assigned_tickets = intval($row['total_tickets_assigned']);
<div class="mt-1"><?php echo $contact_display; ?></div> <div class="mt-1"><?php echo $contact_display; ?></div>
</td> </td>
<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'>$</span>";
} else {
echo "<span class='badge badge-pill badge-secondary'>X</span>";
}
?></td>
<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> <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>
<td><span class='p-2 badge badge-pill badge-<?php echo $ticket_status_color; ?>'><?php echo $ticket_status; ?></span></td> <td><span class='p-2 badge badge-pill badge-<?php echo $ticket_status_color; ?>'><?php echo $ticket_status; ?></span></td>
<td><a href="#" data-toggle="modal" data-target="#assignTicketModal<?php echo $ticket_id; ?>"><?php echo $ticket_assigned_to_display; ?></a></td> <td><a href="#" data-toggle="modal" data-target="#assignTicketModal<?php echo $ticket_id; ?>"><?php echo $ticket_assigned_to_display; ?></a></td>
@ -376,6 +390,8 @@ $user_active_assigned_tickets = intval($row['total_tickets_assigned']);
require "ticket_edit_priority_modal.php"; require "ticket_edit_priority_modal.php";
require "ticket_edit_billable_modal.php";
} }
} }