Ticketing updates

- Bugfix: Prevent tickets from being assigned to disabled techs
- Bugfix: Un-assign all open tickets when a tech account is disabled
- Allow auto-assignment of recurring/scheduled tickets to an agent/tech (#901)
- Rework layout of recurring/scheduled ticket modal
This commit is contained in:
Marcus Hill
2024-03-17 11:09:53 +00:00
parent cdd16bd460
commit f9a5ca1ef8
15 changed files with 438 additions and 223 deletions

View File

@@ -249,10 +249,16 @@ if (mysqli_num_rows($sql_scheduled_tickets) > 0) {
$priority = sanitizeInput($row['scheduled_ticket_priority']);
$frequency = sanitizeInput(strtolower($row['scheduled_ticket_frequency']));
$created_id = intval($row['scheduled_ticket_created_by']);
$assigned_id = intval($row['scheduled_ticket_assigned_to']);
$client_id = intval($row['scheduled_ticket_client_id']);
$contact_id = intval($row['scheduled_ticket_contact_id']);
$asset_id = intval($row['scheduled_ticket_asset_id']);
$ticket_status = 'New'; // Default
if ($assigned_id > 0) {
$ticket_status = 'Open'; // Set to open if we've auto-assigned an agent
}
// Assign this new ticket the next ticket number
$ticket_number_sql = mysqli_fetch_array(mysqli_query($mysqli, "SELECT config_ticket_next_number FROM settings WHERE company_id = 1"));
$ticket_number = intval($ticket_number_sql['config_ticket_next_number']);
@@ -262,7 +268,7 @@ if (mysqli_num_rows($sql_scheduled_tickets) > 0) {
mysqli_query($mysqli, "UPDATE settings SET config_ticket_next_number = $new_config_ticket_next_number WHERE company_id = 1");
// Raise the ticket
mysqli_query($mysqli, "INSERT INTO tickets SET ticket_prefix = '$config_ticket_prefix', ticket_number = $ticket_number, ticket_subject = '$subject', ticket_details = '$details', ticket_priority = '$priority', ticket_status = 'New', ticket_created_by = $created_id, ticket_contact_id = $contact_id, ticket_client_id = $client_id, ticket_asset_id = $asset_id");
mysqli_query($mysqli, "INSERT INTO tickets SET ticket_prefix = '$config_ticket_prefix', ticket_number = $ticket_number, ticket_subject = '$subject', ticket_details = '$details', ticket_priority = '$priority', ticket_status = '$ticket_status', ticket_created_by = $created_id, ticket_assigned_to = $assigned_id, ticket_contact_id = $contact_id, ticket_client_id = $client_id, ticket_asset_id = $asset_id");
$id = mysqli_insert_id($mysqli);
// Logging
@@ -316,7 +322,7 @@ if (mysqli_num_rows($sql_scheduled_tickets) > 0) {
if (filter_var($config_ticket_new_ticket_notification_email, FILTER_VALIDATE_EMAIL)) {
$email_subject = "ITFlow - New Recurring Ticket - $client_name: $ticket_subject";
$email_body = "Hello, <br><br>This is a notification that a recurring scheduled ticket has been raised in ITFlow. <br>Ticket: $ticket_prefix$ticket_number<br>Client: $client_name<br>Priority: $priority<br>Link: https://$config_base_url/ticket.php?ticket_id=$id <br><br>--------------------------------<br><br><b>$ticket_subject</b><br>$ticket_details";
$email_body = "Hello, <br><br>This is a notification that a recurring (scheduled) ticket has been raised in ITFlow. <br>Ticket: $ticket_prefix$ticket_number<br>Client: $client_name<br>Priority: $priority<br>Link: https://$config_base_url/ticket.php?ticket_id=$id <br><br>--------------------------------<br><br><b>$ticket_subject</b><br>$ticket_details";
$email = [
'from' => $config_ticket_from_email,