mirror of
https://github.com/itflow-org/itflow
synced 2026-03-18 19:54:51 +00:00
Ticketing updates
- Allow changing ticket status without adding a reply (just leave the response blank) - Bugfix: Contact change email didn't include URL key - Make it clearer when nobody is assigned to a ticket
This commit is contained in:
@@ -286,7 +286,7 @@ if (isset($_POST['edit_ticket_contact'])) {
|
|||||||
if ($notify && !empty($config_smtp_host)) {
|
if ($notify && !empty($config_smtp_host)) {
|
||||||
|
|
||||||
// Get contact/ticket details
|
// Get contact/ticket details
|
||||||
$sql = mysqli_query($mysqli, "SELECT contact_name, contact_email, ticket_prefix, ticket_number, ticket_category, ticket_subject, ticket_details, ticket_priority, ticket_status_name, ticket_created_by, ticket_assigned_to, ticket_client_id FROM tickets
|
$sql = mysqli_query($mysqli, "SELECT contact_name, contact_email, ticket_prefix, ticket_number, ticket_category, ticket_subject, ticket_details, ticket_priority, ticket_status_name, ticket_url_key, ticket_created_by, ticket_assigned_to, ticket_client_id FROM tickets
|
||||||
LEFT JOIN clients ON ticket_client_id = client_id
|
LEFT JOIN clients ON ticket_client_id = client_id
|
||||||
LEFT JOIN contacts ON ticket_contact_id = contact_id
|
LEFT JOIN contacts ON ticket_contact_id = contact_id
|
||||||
LEFT JOIN ticket_statuses ON ticket_status = ticket_status_id
|
LEFT JOIN ticket_statuses ON ticket_status = ticket_status_id
|
||||||
@@ -306,6 +306,7 @@ if (isset($_POST['edit_ticket_contact'])) {
|
|||||||
$client_id = intval($row['ticket_client_id']);
|
$client_id = intval($row['ticket_client_id']);
|
||||||
$ticket_created_by = intval($row['ticket_created_by']);
|
$ticket_created_by = intval($row['ticket_created_by']);
|
||||||
$ticket_assigned_to = intval($row['ticket_assigned_to']);
|
$ticket_assigned_to = intval($row['ticket_assigned_to']);
|
||||||
|
$url_key = sanitizeInput($row['ticket_url_key']);
|
||||||
|
|
||||||
// Get Company Phone Number
|
// Get Company Phone Number
|
||||||
$sql = mysqli_query($mysqli, "SELECT company_name, company_phone FROM companies WHERE company_id = 1");
|
$sql = mysqli_query($mysqli, "SELECT company_name, company_phone FROM companies WHERE company_id = 1");
|
||||||
@@ -1291,18 +1292,17 @@ if (isset($_POST['add_ticket_reply'])) {
|
|||||||
$ticket_id = intval($_POST['ticket_id']);
|
$ticket_id = intval($_POST['ticket_id']);
|
||||||
$ticket_reply = mysqli_real_escape_string($mysqli, $_POST['ticket_reply']);
|
$ticket_reply = mysqli_real_escape_string($mysqli, $_POST['ticket_reply']);
|
||||||
$ticket_status = intval($_POST['status']);
|
$ticket_status = intval($_POST['status']);
|
||||||
// Handle the time inputs for hours, minutes, and seconds
|
$client_id = intval($_POST['client_id']);
|
||||||
|
|
||||||
|
// Time tracking, inputs & combine into string
|
||||||
$hours = intval($_POST['hours']);
|
$hours = intval($_POST['hours']);
|
||||||
$minutes = intval($_POST['minutes']);
|
$minutes = intval($_POST['minutes']);
|
||||||
$seconds = intval($_POST['seconds']);
|
$seconds = intval($_POST['seconds']);
|
||||||
|
|
||||||
// Combine into a single time string
|
|
||||||
$ticket_reply_time_worked = sanitizeInput(sprintf("%02d:%02d:%02d", $hours, $minutes, $seconds));
|
$ticket_reply_time_worked = sanitizeInput(sprintf("%02d:%02d:%02d", $hours, $minutes, $seconds));
|
||||||
|
|
||||||
$client_id = intval($_POST['client_id']);
|
// Defaults
|
||||||
|
|
||||||
$send_email = 0;
|
$send_email = 0;
|
||||||
|
$ticket_reply_id = 0;
|
||||||
if ($_POST['public_reply_type'] == 1 ){
|
if ($_POST['public_reply_type'] == 1 ){
|
||||||
$ticket_reply_type = 'Public';
|
$ticket_reply_type = 'Public';
|
||||||
} elseif ($_POST['public_reply_type'] == 2 ) {
|
} elseif ($_POST['public_reply_type'] == 2 ) {
|
||||||
@@ -1312,13 +1312,8 @@ if (isset($_POST['add_ticket_reply'])) {
|
|||||||
$ticket_reply_type = 'Internal';
|
$ticket_reply_type = 'Internal';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add reply
|
// Update Ticket Status & updated at (in case status didn't change)
|
||||||
mysqli_query($mysqli, "INSERT INTO ticket_replies SET ticket_reply = '$ticket_reply', ticket_reply_time_worked = '$ticket_reply_time_worked', ticket_reply_type = '$ticket_reply_type', ticket_reply_by = $session_user_id, ticket_reply_ticket_id = $ticket_id");
|
mysqli_query($mysqli, "UPDATE tickets SET ticket_status = $ticket_status, ticket_updated_at = NOW() WHERE ticket_id = $ticket_id");
|
||||||
|
|
||||||
$ticket_reply_id = mysqli_insert_id($mysqli);
|
|
||||||
|
|
||||||
// Update Ticket Status & Last Response Field
|
|
||||||
mysqli_query($mysqli, "UPDATE tickets SET ticket_status = $ticket_status WHERE ticket_id = $ticket_id");
|
|
||||||
|
|
||||||
// Resolve the ticket, if set
|
// Resolve the ticket, if set
|
||||||
if ($ticket_status == 4) {
|
if ($ticket_status == 4) {
|
||||||
@@ -1326,6 +1321,14 @@ if (isset($_POST['add_ticket_reply'])) {
|
|||||||
mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Ticket', log_action = 'Resolved', log_description = 'Ticket ID $ticket_id resolved', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_user_id = $session_user_id, log_entity_id = $ticket_id");
|
mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Ticket', log_action = 'Resolved', log_description = 'Ticket ID $ticket_id resolved', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_user_id = $session_user_id, log_entity_id = $ticket_id");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Process reply actions, if we have a reply to work with (e.g. we're not just editing the status)
|
||||||
|
if (!empty($ticket_reply)) {
|
||||||
|
|
||||||
|
// Add reply
|
||||||
|
mysqli_query($mysqli, "INSERT INTO ticket_replies SET ticket_reply = '$ticket_reply', ticket_reply_time_worked = '$ticket_reply_time_worked', ticket_reply_type = '$ticket_reply_type', ticket_reply_by = $session_user_id, ticket_reply_ticket_id = $ticket_id");
|
||||||
|
|
||||||
|
$ticket_reply_id = mysqli_insert_id($mysqli);
|
||||||
|
|
||||||
// Get Ticket Details
|
// Get Ticket Details
|
||||||
$ticket_sql = mysqli_query($mysqli, "SELECT contact_name, contact_email, ticket_prefix, ticket_number, ticket_subject, ticket_status, ticket_status_name, ticket_url_key, ticket_client_id, ticket_created_by, ticket_assigned_to
|
$ticket_sql = mysqli_query($mysqli, "SELECT contact_name, contact_email, ticket_prefix, ticket_number, ticket_subject, ticket_status, ticket_status_name, ticket_url_key, ticket_client_id, ticket_created_by, ticket_assigned_to
|
||||||
FROM tickets
|
FROM tickets
|
||||||
@@ -1411,13 +1414,11 @@ if (isset($_POST['add_ticket_reply'])) {
|
|||||||
|
|
||||||
// Notification for assigned ticket user
|
// Notification for assigned ticket user
|
||||||
if ($session_user_id != $ticket_assigned_to && $ticket_assigned_to != 0) {
|
if ($session_user_id != $ticket_assigned_to && $ticket_assigned_to != 0) {
|
||||||
|
|
||||||
mysqli_query($mysqli, "INSERT INTO notifications SET notification_type = 'Ticket', notification = '$session_name updated Ticket $ticket_prefix$ticket_number - Subject: $ticket_subject that is assigned to you', notification_action = 'ticket.php?ticket_id=$ticket_id', notification_client_id = $client_id, notification_user_id = $ticket_assigned_to");
|
mysqli_query($mysqli, "INSERT INTO notifications SET notification_type = 'Ticket', notification = '$session_name updated Ticket $ticket_prefix$ticket_number - Subject: $ticket_subject that is assigned to you', notification_action = 'ticket.php?ticket_id=$ticket_id', notification_client_id = $client_id, notification_user_id = $ticket_assigned_to");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Notification for user that opened the ticket
|
// Notification for user that opened the ticket
|
||||||
if ($session_user_id != $ticket_created_by && $ticket_created_by != 0) {
|
if ($session_user_id != $ticket_created_by && $ticket_created_by != 0) {
|
||||||
|
|
||||||
mysqli_query($mysqli, "INSERT INTO notifications SET notification_type = 'Ticket', notification = '$session_name updated Ticket $ticket_prefix$ticket_number - Subject: $ticket_subject that you opened', notification_action = 'ticket.php?ticket_id=$ticket_id', notification_client_id = $client_id, notification_user_id = $ticket_created_by");
|
mysqli_query($mysqli, "INSERT INTO notifications SET notification_type = 'Ticket', notification = '$session_name updated Ticket $ticket_prefix$ticket_number - Subject: $ticket_subject that you opened', notification_action = 'ticket.php?ticket_id=$ticket_id', notification_client_id = $client_id, notification_user_id = $ticket_created_by");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1428,11 +1429,15 @@ if (isset($_POST['add_ticket_reply'])) {
|
|||||||
customAction('reply_reply_agent_public', $ticket_id);
|
customAction('reply_reply_agent_public', $ticket_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$_SESSION['alert_message'] = "Ticket <strong>$ticket_prefix$ticket_number</strong> has been updated with your reply and was <strong>$ticket_reply_type</strong>";
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$_SESSION['alert_message'] = "Ticket updated";
|
||||||
|
}
|
||||||
|
|
||||||
// Logging
|
// Logging
|
||||||
mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Ticket Reply', log_action = 'Create', log_description = '$session_name replied to ticket $ticket_prefix$ticket_number - $ticket_subject and was a $ticket_reply_type reply', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_client_id = $client_id, log_user_id = $session_user_id, log_entity_id = $ticket_reply_id");
|
mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Ticket Reply', log_action = 'Create', log_description = '$session_name replied to ticket $ticket_prefix$ticket_number - $ticket_subject and was a $ticket_reply_type reply', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_client_id = $client_id, log_user_id = $session_user_id, log_entity_id = $ticket_reply_id");
|
||||||
|
|
||||||
$_SESSION['alert_message'] = "Ticket <strong>$ticket_prefix$ticket_number</strong> has been updated with your reply and was <strong>$ticket_reply_type</strong>";
|
|
||||||
|
|
||||||
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -876,6 +876,14 @@ if (isset($_GET['ticket_id'])) {
|
|||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
<?php } else { ?>
|
||||||
|
<div class="card card-body mb-3">
|
||||||
|
<h5 class="text-secondary">Contact</h5>
|
||||||
|
<div>
|
||||||
|
<i class="fa fa-fw fa-user text-secondary mr-2"></i><a href="#" data-toggle="modal" data-target="#editTicketContactModal<?php echo $ticket_id; ?>"><i>No One</i>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<!-- End contact card -->
|
<!-- End contact card -->
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user