Merge pull request #1079 from itflow-org/custom-actions

Add custom event handler
This commit is contained in:
Johnny 2024-10-02 12:34:45 -04:00 committed by GitHub
commit 11230d655f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 160 additions and 17 deletions

View File

@ -152,7 +152,7 @@ if ($config_whitelabel_enabled && !validateWhitelabelKey($config_whitelabel_key)
// DOMAINS EXPIRING
if($config_enable_alert_domain_expire == 1){
if ($config_enable_alert_domain_expire == 1) {
$domainAlertArray = [1,7,14,30,90];
@ -247,7 +247,7 @@ $sql_tickets_pending_assignment = mysqli_query($mysqli,"SELECT ticket_id FROM ti
$tickets_pending_assignment = mysqli_num_rows($sql_tickets_pending_assignment);
if($tickets_pending_assignment > 0){
if ($tickets_pending_assignment > 0) {
mysqli_query($mysqli, "INSERT INTO notifications SET notification_type = 'Pending Tickets', notification = 'There are $tickets_pending_assignment new tickets pending assignment', notification_action = 'tickets.php?status=New'");
@ -295,6 +295,8 @@ if (mysqli_num_rows($sql_scheduled_tickets) > 0) {
// Logging
mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Ticket', log_action = 'Create', log_description = 'System created recurring scheduled $frequency ticket - $subject', log_client_id = $client_id, log_user_id = $created_id");
customAction('ticket_create', $id);
// Notifications
// Get client/contact/ticket details
@ -415,6 +417,8 @@ while ($row = mysqli_fetch_array($sql_resolved_tickets_to_close)) {
//Logging
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Ticket', log_action = 'Closed', log_description = '$ticket_prefix$ticket_number auto closed', log_entity_id = $ticket_id");
customAction('ticket_close', $ticket_id);
//TODO: Add client notifs if $config_ticket_client_general_notifications is on
}
@ -569,6 +573,8 @@ while ($row = mysqli_fetch_array($sql_recurring)) {
mysqli_query($mysqli, "INSERT INTO notifications SET notification_type = 'Recurring Sent', notification = 'Recurring Invoice $config_invoice_prefix$new_invoice_number for $client_name Sent', notification_action = 'invoice.php?invoice_id=$new_invoice_id', notification_client_id = $client_id, notification_entity_id = $new_invoice_id");
customAction('invoice_create', $new_invoice_id);
//Update recurring dates
mysqli_query($mysqli, "UPDATE recurring SET recurring_last_sent = CURDATE(), recurring_next_date = DATE_ADD(CURDATE(), INTERVAL 1 $recurring_frequency) WHERE recurring_id = $recurring_id");

View File

@ -101,7 +101,6 @@ function addTicket($contact_id, $contact_name, $contact_email, $client_id, $date
mysqli_query($mysqli, "INSERT INTO tickets SET ticket_prefix = '$ticket_prefix_esc', ticket_number = $ticket_number, ticket_subject = '$subject_esc', ticket_details = '$message_esc', ticket_priority = 'Low', ticket_status = 1, ticket_created_by = 0, ticket_contact_id = $contact_id, ticket_url_key = '$url_key', ticket_client_id = $client_id_esc");
$id = mysqli_insert_id($mysqli);
echo "Created new ticket.<br>";
mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Ticket', log_action = 'Create', log_description = 'Email parser: Client contact $contact_email_esc created ticket $ticket_prefix_esc$ticket_number ($subject_esc) ($id)', log_client_id = $client_id_esc");
mkdirMissing('uploads/tickets/');
@ -172,6 +171,9 @@ function addTicket($contact_id, $contact_name, $contact_email, $client_id, $date
addToMailQueue($mysqli, $data);
// Custom action/notif handler
customAction('ticket_create', $id);
return true;
}
@ -308,10 +310,12 @@ function addReply($from_email, $date, $subject, $ticket_number, $message, $attac
mysqli_query($mysqli, "UPDATE tickets SET ticket_status = 2, ticket_resolved_at = NULL WHERE ticket_id = $ticket_id AND ticket_client_id = $client_id LIMIT 1");
echo "Updated existing ticket.<br>";
mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Ticket', log_action = 'Update', log_description = 'Email parser: Client contact $from_email_esc updated ticket $config_ticket_prefix$ticket_number_esc ($subject)', log_client_id = $client_id");
customAction('ticket_reply_client', $ticket_id);
return true;
} else {
return false;
}
@ -469,8 +473,8 @@ if ($messages->count() > 0) {
mysqli_query($mysqli, "INSERT INTO contacts SET contact_name = '".mysqli_real_escape_string($mysqli, $contact_name)."', contact_email = '".mysqli_real_escape_string($mysqli, $contact_email)."', contact_notes = 'Added automatically via email parsing.', contact_password_hash = '$password', contact_client_id = $client_id");
$contact_id = mysqli_insert_id($mysqli);
echo "Created new contact.<br>";
mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Contact', log_action = 'Create', log_description = 'Email parser: created contact ".mysqli_real_escape_string($mysqli, $contact_name)."', log_client_id = $client_id");
customAction('contact_create', $ticket_id);
if (addTicket($contact_id, $contact_name, $contact_email, $client_id, $date, $subject, $message_body, $message->getAttachments(), $original_message_file)) {
$email_processed = true;

View File

@ -1304,6 +1304,7 @@ function enforceUserPermission($module, $check_access_level = 1) {
}
}
// TODO: Probably remove this
function enforceAdminPermission() {
global $session_is_admin;
if (!isset($session_is_admin) || !$session_is_admin) {
@ -1311,3 +1312,10 @@ function enforceAdminPermission() {
}
return true;
}
function customAction($trigger, $entity) {
chdir(dirname(__FILE__));
if (file_exists(__DIR__ . "/xcustom/xcustom_action_handler.php")) {
include_once __DIR__ . "/xcustom/xcustom_action_handler.php";
}
}

View File

@ -283,6 +283,7 @@ if (isset($_GET['invoice_id'], $_GET['url_key']) && !isset($_GET['payment_intent
// Notify
mysqli_query($mysqli, "INSERT INTO notifications SET notification_type = 'Invoice Paid', notification = 'Invoice $invoice_prefix$invoice_number has been paid by $client_name - $ip - $os - $browser', notification_action = 'invoice.php?invoice_id=$invoice_id', notification_client_id = $pi_client_id");
customAction('invoice_pay', $invoice_id);
// Logging
$extended_log_desc = '';

View File

@ -23,6 +23,8 @@ if (isset($_GET['accept_quote'], $_GET['url_key'])) {
mysqli_query($mysqli, "INSERT INTO history SET history_status = 'Accepted', history_description = 'Client accepted Quote!', history_quote_id = $quote_id");
customAction('quote_accept', $quote_id);
$_SESSION['alert_message'] = "Quote Accepted";
header("Location: " . $_SERVER["HTTP_REFERER"]);
@ -45,6 +47,8 @@ if (isset($_GET['decline_quote'], $_GET['url_key'])) {
mysqli_query($mysqli, "INSERT INTO history SET history_status = 'Declined', history_description = 'Client declined Quote!', history_quote_id = $quote_id");
customAction('quote_decline', $quote_id);
$_SESSION['alert_type'] = "danger";
$_SESSION['alert_message'] = "Quote Declined";
@ -73,6 +77,8 @@ if (isset($_GET['reopen_ticket'], $_GET['url_key'])) {
//Logging
mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Ticket', log_action = 'Replied', log_description = '$ticket_id reopened by client (guest)', log_ip = '$session_ip', log_user_agent = '$session_user_agent'");
customAction('ticket_update', $ticket_id);
$_SESSION['alert_message'] = "Ticket reopened";
header("Location: " . $_SERVER["HTTP_REFERER"]);
@ -100,6 +106,8 @@ if (isset($_GET['close_ticket'], $_GET['url_key'])) {
//Logging
mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Ticket', log_action = 'Replied', log_description = '$ticket_id closed by client (guest)', log_ip = '$session_ip', log_user_agent = '$session_user_agent'");
customAction('ticket_close', $ticket_id);
$_SESSION['alert_message'] = "Ticket closed";
header("Location: " . $_SERVER["HTTP_REFERER"]);
@ -130,6 +138,8 @@ if (isset($_GET['add_ticket_feedback'], $_GET['url_key'])) {
$_SESSION['alert_message'] = "Feedback recorded - thank you";
header("Location: " . $_SERVER["HTTP_REFERER"]);
customAction('ticket_feedback', $ticket_id);
} else {
echo "Invalid!!";
}

View File

@ -37,7 +37,7 @@ if (isset($_POST['add_ticket'])) {
mysqli_query($mysqli, "UPDATE settings SET config_ticket_next_number = $new_config_ticket_next_number WHERE company_id = 1");
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 = 1, ticket_created_by = 0, ticket_contact_id = $contact, ticket_url_key = '$url_key', ticket_client_id = $client_id");
$id = mysqli_insert_id($mysqli);
$ticket_id = mysqli_insert_id($mysqli);
// Notify agent DL of the new ticket, if populated with a valid email
if ($config_ticket_new_ticket_notification_email) {
@ -46,7 +46,7 @@ if (isset($_POST['add_ticket'])) {
$details = removeEmoji($details);
$email_subject = "ITFlow - New Ticket - $client_name: $subject";
$email_body = "Hello, <br><br>This is a notification that a new ticket has been raised in ITFlow. <br>Client: $client_name<br>Priority: $priority<br>Link: https://$config_base_url/ticket.php?ticket_id=$id <br><br><b>$subject</b><br>$details";
$email_body = "Hello, <br><br>This is a notification that a new ticket has been raised in ITFlow. <br>Client: $client_name<br>Priority: $priority<br>Link: https://$config_base_url/ticket.php?ticket_id=$ticket_id <br><br><b>$subject</b><br>$details";
// Queue Mail
$data = [
@ -62,10 +62,13 @@ if (isset($_POST['add_ticket'])) {
addToMailQueue($mysqli, $data);
}
// Custom action/notif handler
customAction('ticket_create', $ticket_id);
// Logging
mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Ticket', log_action = 'Create', log_description = 'Client contact $session_contact_name created ticket $subject', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_client_id = $client_id");
header("Location: ticket.php?id=" . $id);
header("Location: ticket.php?id=" . $ticket_id);
}
@ -162,6 +165,9 @@ if (isset($_POST['add_ticket_comment'])) {
}
}
// Custom action/notif handler
customAction('ticket_reply_client', $ticket_id);
// Redirect back to original page
header("Location: " . $_SERVER["HTTP_REFERER"]);
@ -187,6 +193,9 @@ if (isset($_POST['add_ticket_feedback'])) {
mysqli_query($mysqli, "INSERT INTO notifications SET notification_type = 'Feedback', notification = '$session_contact_name rated ticket ID $ticket_id as bad', notification_client_id = $session_client_id");
}
// Custom action/notif handler
customAction('ticket_feedback', $ticket_id);
// Redirect
header("Location: " . $_SERVER["HTTP_REFERER"]);
} else {
@ -212,7 +221,11 @@ if (isset($_GET['resolve_ticket'])) {
//Logging
mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Ticket', log_action = 'Resolved', log_description = '$ticket_id resolved by client', log_ip = '$session_ip', log_user_agent = '$session_user_agent'");
// Custom action/notif handler
customAction('ticket_resolve', $ticket_id);
header("Location: ticket.php?id=" . $ticket_id);
} else {
// The client does not have access to this ticket - send them home
header("Location: index.php");
@ -235,7 +248,11 @@ if (isset($_GET['reopen_ticket'])) {
//Logging
mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Ticket', log_action = 'Replied', log_description = '$ticket_id reopened by client', log_ip = '$session_ip', log_user_agent = '$session_user_agent'");
// Custom action/notif handler
customAction('ticket_update', $ticket_id);
header("Location: ticket.php?id=" . $ticket_id);
} else {
// The client does not have access to this ticket - send them home
header("Location: index.php");
@ -258,6 +275,9 @@ if (isset($_GET['close_ticket'])) {
//Logging
mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Ticket', log_action = 'Closed', log_description = '$ticket_id closed by client', log_ip = '$session_ip', log_user_agent = '$session_user_agent'");
// Custom action/notif handler
customAction('ticket_close', $ticket_id);
header("Location: ticket.php?id=" . $ticket_id);
} else {
// The client does not have access to this ticket - send them home
@ -303,6 +323,8 @@ if (isset($_POST['edit_contact'])) {
$_SESSION['alert_message'] = "Contact updated";
header('Location: contacts.php');
customAction('contact_update', $ticket_id);
}
if (isset($_POST['add_contact'])) {
@ -317,6 +339,8 @@ if (isset($_POST['add_contact'])) {
// Logging
mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Contact', log_action = 'Create', log_description = 'Client $session_contact_name created contact $contact_name', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_client_id = $session_client_id");
customAction('contact_create', $ticket_id);
$_SESSION['alert_message'] = "Contact created";
header('Location: contacts.php');
}

View File

@ -10,7 +10,6 @@ if (isset($_POST['add_contact'])) {
require_once 'post/user/contact_model.php';
// Set password
if (!empty($_POST['contact_password'])) {
$password_hash = password_hash(trim($_POST['contact_password']), PASSWORD_DEFAULT);
@ -58,6 +57,8 @@ if (isset($_POST['add_contact'])) {
//Logging
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Contact', log_action = 'Create', log_description = '$session_name created contact $name', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_client_id = $client_id, log_user_id = $session_user_id, log_entity_id = $contact_id");
customAction('contact_create', $contact_id);
$_SESSION['alert_message'] = "Contact <strong>$name</strong> created";
header("Location: " . $_SERVER["HTTP_REFERER"]);
@ -173,6 +174,8 @@ if (isset($_POST['edit_contact'])) {
//Logging
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Contact', log_action = 'Modify', log_description = '$session_name modified contact $name', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_client_id = $client_id, log_user_id = $session_user_id, log_entity_id = $contact_id");
customAction('contact_update', $contact_id);
$_SESSION['alert_message'] = "Contact <strong>$name</strong> updated";
header("Location: " . $_SERVER["HTTP_REFERER"]);
@ -313,6 +316,8 @@ if (isset($_POST['bulk_edit_contact_role'])) {
//Logging
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Contact', log_action = 'Modify', log_description = '$session_name updated $contact_name role', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_client_id = $client_id, log_user_id = $session_user_id, log_entity_id = $contact_id");
customAction('contact_update', $contact_id);
} // End Assign Location Loop
$_SESSION['alert_message'] = "You updated roles for <b>$contact_count</b> contacts";

View File

@ -31,6 +31,8 @@ if (isset($_POST['add_invoice'])) {
//Logging
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Invoice', log_action = 'Create', log_description = '$config_invoice_prefix$invoice_number', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_user_id = $session_user_id");
customAction('invoice_create', $invoice_id);
$_SESSION['alert_message'] = "Invoice added";
header("Location: invoice.php?invoice_id=$invoice_id");
@ -117,6 +119,8 @@ if (isset($_POST['add_invoice_copy'])) {
//Logging
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Invoice', log_action = 'Create', log_description = 'Copied Invoice', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_user_id = $session_user_id");
customAction('invoice_create', $new_invoice_id);
$_SESSION['alert_message'] = "Invoice copied";
header("Location: invoice.php?invoice_id=$new_invoice_id");
@ -748,6 +752,8 @@ if (isset($_POST['add_payment'])) {
//Logging
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Payment', log_action = 'Create', log_description = '$payment_amount', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_client_id = $client_id, log_user_id = $session_user_id, log_entity_id = $payment_id");
customAction('invoice_pay', $invoice_id);
if ($email_receipt == 1) {
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Payment', log_action = 'Email', log_description = 'Payment receipt for invoice $invoice_prefix$invoice_number queued to $contact_email Email ID: $email_id', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_client_id = $client_id, log_user_id = $session_user_id, log_entity_id = $payment_id");
}
@ -834,9 +840,9 @@ if (isset($_POST['add_bulk_payment'])) {
mysqli_query($mysqli, $add_history_query);
// Add to Email Body Invoice Portion
$email_body_invoices .= "<br>Invoice <a href=\'https://$config_base_url/guest_view_invoice.php?invoice_id=$invoice_id&url_key=$invoice_url_key\'>$invoice_prefix$invoice_number</a> - Outstanding Amount: " . numfmt_format_currency($currency_format, $invoice_balance, $currency_code) . " - Payment Applied: " . numfmt_format_currency($currency_format, $payment_amount, $currency_code) . " - New Balance: " . numfmt_format_currency($currency_format, $remaining_invoice_balance, $currency_code);
customAction('invoice_pay', $invoice_id);
} // End Invoice Loop
@ -1209,6 +1215,8 @@ if (isset($_GET['force_recurring'])) {
//Logging
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Invoice', log_action = 'Create', log_description = '$session_name forced recurring invoice into an invoice', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_client_id = $client_id, log_user_id = $session_user_id, log_entity_id = $new_invoice_id");
customAction('invoice_create', $new_invoice_id);
$_SESSION['alert_message'] = "Recurring Invoice Forced";
header("Location: " . $_SERVER["HTTP_REFERER"]);

View File

@ -29,6 +29,8 @@ if (isset($_POST['add_quote'])) {
//Logging
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Quote', log_action = 'Create', log_description = '$quote_prefix$quote_number', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_user_id = $session_user_id");
customAction('quote_create', $quote_id);
$_SESSION['alert_message'] = "Quote added";
header("Location: quote.php?quote_id=$quote_id");
@ -86,6 +88,8 @@ if (isset($_POST['add_quote_copy'])) {
//Logging
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Quote', log_action = 'Create', log_description = 'Copied Quote', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_client_id = $client_id, log_user_id = $session_user_id");
customAction('quote_create', $new_quote_id);
$_SESSION['alert_message'] = "Quote copied";
header("Location: quote.php?quote_id=$new_quote_id");
@ -145,6 +149,8 @@ if (isset($_POST['add_quote_to_invoice'])) {
//Logging
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Quote', log_action = 'Create', log_description = 'Quote copied to Invoice', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_user_id = $session_user_id");
customAction('invoice_create', $new_invoice_id);
$_SESSION['alert_message'] = "Quote copied to Invoice";
header("Location: invoice.php?invoice_id=$new_invoice_id");
@ -345,6 +351,8 @@ if (isset($_GET['accept_quote'])) {
//Logging
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Quote', log_action = 'Modify', log_description = 'Accepted Quote $quote_id', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_user_id = $session_user_id");
customAction('quote_accept', $quote_id);
$_SESSION['alert_message'] = "Quote accepted";
header("Location: " . $_SERVER["HTTP_REFERER"]);
@ -361,6 +369,8 @@ if (isset($_GET['decline_quote'])) {
mysqli_query($mysqli,"INSERT INTO history SET history_status = 'Cancelled', history_description = 'Quote declined!', history_quote_id = $quote_id");
customAction('quote_decline', $quote_id);
//Logging
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Quote', log_action = 'Modify', log_description = 'Declined Quote $quote_id', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_user_id = $session_user_id");

View File

@ -176,6 +176,9 @@ if (isset($_POST['add_ticket'])) {
}
}
// Custom action/notif handler
customAction('ticket_create', $ticket_id);
// Logging
mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Ticket', log_action = 'Create', log_description = '$session_name created ticket $config_ticket_prefix$ticket_number - $ticket_subject', 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_id");
@ -259,6 +262,9 @@ if (isset($_POST['edit_ticket'])) {
addToMailQueue($mysqli, $data);
}
// Custom action/notif handler
customAction('ticket_update', $ticket_id);
//Logging
mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Ticket', log_action = 'Modify', log_description = '$session_name modified ticket $ticket_number - $subject', 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_id");
@ -280,6 +286,8 @@ if (isset($_POST['edit_ticket_priority'])) {
//Logging
mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Ticket', log_action = 'Modify', log_description = '$session_name edited ticket priority', 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_id");
customAction('ticket_update', $ticket_id);
$_SESSION['alert_message'] = "Ticket priority updated";
header("Location: " . $_SERVER["HTTP_REFERER"]);
@ -350,6 +358,9 @@ if (isset($_POST['edit_ticket_contact'])) {
addToMailQueue($mysqli, $data);
}
// Custom action/notif handler
customAction('ticket_update', $ticket_id);
//Logging
mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Ticket', log_action = 'Modify', log_description = '$session_name changed contact for ticket $ticket_number', 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_id");
@ -523,9 +534,14 @@ if (isset($_POST['edit_ticket_priority'])) {
//Logging
mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Ticket', log_action = 'Modify', log_description = '$session_name edited ticket priority', 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_id");
// Custom action/notif handler
customAction('ticket_update', $ticket_id);
$_SESSION['alert_message'] = "Ticket priority updated";
header("Location: " . $_SERVER["HTTP_REFERER"]);
customAction('ticket_update', $ticket_id);
}
if (isset($_POST['assign_ticket'])) {
@ -622,6 +638,8 @@ if (isset($_POST['assign_ticket'])) {
}
}
customAction('ticket_assign', $ticket_id);
$_SESSION['alert_message'] = "Ticket <strong>$ticket_prefix$ticket_number</strong> assigned to <strong>$agent_name</strong>";
header("Location: " . $_SERVER["HTTP_REFERER"]);
@ -661,6 +679,8 @@ if (isset($_GET['delete_ticket'])) {
$_SESSION['alert_type'] = "error";
$_SESSION['alert_message'] = "Ticket <strong>$ticket_prefix$ticket_number</strong> along with all replies deleted";
customAction('ticket_delete', $ticket_id);
header("Location: tickets.php");
}
}
@ -723,6 +743,8 @@ if (isset($_POST['bulk_assign_ticket'])) {
// Logging
mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Ticket', log_action = 'Edit', log_description = '$session_name reassigned ticket $ticket_prefix$ticket_number - $ticket_subject to $agent_name', 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_id");
customAction('ticket_assign', $ticket_id);
$tickets_assigned_body .= "$ticket_prefix$ticket_number - $ticket_subject<br>";
} // End For Each Ticket ID Loop
@ -796,6 +818,8 @@ if (isset($_POST['bulk_edit_ticket_priority'])) {
// Logging
mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Ticket', log_action = 'Edit', log_description = '$session_name updated the priority on ticket $ticket_prefix$ticket_number - $ticket_subject from $current_ticket_priority to $priority', 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_id");
customAction('ticket_update', $ticket_id);
} // End For Each Ticket ID Loop
}
@ -850,6 +874,9 @@ if (isset($_POST['bulk_merge_tickets'])) {
// Logging
mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Ticket', log_action = 'Merged', log_description = 'Merged ticket $ticket_prefix$ticket_number into $ticket_prefix$merge_into_ticket_number', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_user_id = $session_user_id");
// Custom action/notif handler
customAction('ticket_merge', $ticket_id);
}
} // End For Each Ticket ID Loop
}
@ -901,6 +928,8 @@ if (isset($_POST['bulk_resolve_tickets'])) {
// Logging
mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Ticket', log_action = 'Resolve', log_description = '$session_name resolved $ticket_prefix$ticket_number - $ticket_subject in a bulk action', 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_id");
customAction('ticket_resolve', $ticket_id);
// Client notification email
if (!empty($config_smtp_host) && $config_ticket_client_general_notifications == 1 && $private_note == 0) {
@ -1012,15 +1041,23 @@ if (isset($_POST['bulk_ticket_reply'])) {
// Update Ticket Status
mysqli_query($mysqli, "UPDATE tickets SET ticket_status = '$ticket_status' WHERE ticket_id = $ticket_id");
// 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");
// Custom action/notif handler
if ($ticket_reply_type == 'Internal') {
customAction('ticket_reply_agent_internal', $ticket_id);
} else {
customAction('reply_reply_agent_public', $ticket_id);
}
// Resolve the ticket, if set
if ($ticket_status == 4) {
mysqli_query($mysqli, "UPDATE tickets SET ticket_resolved_at = NOW() WHERE ticket_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");
customAction('ticket_resolve', $ticket_id);
}
// 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");
// Get Contact Details
$sql = mysqli_query(
$mysqli,
@ -1109,7 +1146,7 @@ if (isset($_POST['bulk_ticket_reply'])) {
}
// Currenly not UI Frontend for this
// Currently not UI Frontend for this
if (isset($_POST['bulk_add_ticket_project'])) {
enforceUserPermission('module_support', 2);
@ -1290,6 +1327,13 @@ if (isset($_POST['add_ticket_reply'])) {
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");
}
// Custom action/notif handler
if ($ticket_reply_type == 'Internal') {
customAction('ticket_reply_agent_internal', $ticket_id);
} else {
customAction('reply_reply_agent_public', $ticket_id);
}
// 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");
@ -1394,6 +1438,8 @@ if (isset($_POST['merge_ticket'])) {
// Logging
mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Ticket', log_action = 'Merged', log_description = 'Merged ticket $ticket_prefix$ticket_number into $ticket_prefix$merge_into_ticket_number', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_user_id = $session_user_id");
customAction('ticket_merge', $ticket_id);
$_SESSION['alert_message'] = "Ticket merged into $ticket_prefix$merge_into_ticket_number";
header("Location: " . $_SERVER["HTTP_REFERER"]);
@ -1416,6 +1462,8 @@ if (isset($_POST['change_client_ticket'])) {
//Logging
mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Ticket Reply', log_action = 'Modify', log_description = '$session_name modified ticket - client changed', 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_id");
customAction('ticket_update', $ticket_id);
$_SESSION['alert_message'] = "Ticket client updated";
header("Location: " . $_SERVER["HTTP_REFERER"]);
@ -1435,6 +1483,8 @@ if (isset($_GET['resolve_ticket'])) {
//Logging
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");
customAction('ticket_resolve', $ticket_id);
// Client notification email
if (!empty($config_smtp_host) && $config_ticket_client_general_notifications == 1) {
@ -1529,6 +1579,8 @@ if (isset($_GET['close_ticket'])) {
//Logging
mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Ticket', log_action = 'Closed', log_description = 'Ticket ID $ticket_id Closed', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_user_id = $session_user_id, log_entity_id = $ticket_id");
customAction('ticket_close', $ticket_id);
// Client notification email
if (!empty($config_smtp_host) && $config_ticket_client_general_notifications == 1) {
@ -1615,6 +1667,8 @@ if (isset($_GET['reopen_ticket'])) {
//Logging
mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Ticket', log_action = 'Reopened', log_description = 'Ticket ID $ticket_id reopened', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_user_id = $session_user_id, log_entity_id = $ticket_id");
customAction('ticket_update', $ticket_id);
$_SESSION['alert_message'] = "Ticket re-opened";
header("Location: " . $_SERVER["HTTP_REFERER"]);
}
@ -2079,6 +2133,8 @@ if (isset($_POST['edit_ticket_schedule'])) {
log_entity_id = $ticket_id"
);
customAction('ticket_schedule', $ticket_id);
if (empty($conflicting_tickets)) {
$_SESSION['alert_message'] = "Ticket scheduled for $email_datetime";
@ -2226,6 +2282,8 @@ if (isset($_GET['cancel_ticket_schedule'])) {
//Logging
mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Ticket', log_action = 'Modify', log_description = '$session_name cancelled ticket schedule', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_user_id = $session_user_id, log_entity_id = $ticket_id");
customAction('ticket_unschedule', $ticket_id);
$_SESSION['alert_message'] = "Ticket schedule cancelled";
header("Location: " . $_SERVER["HTTP_REFERER"]);

View File

@ -3,11 +3,11 @@
/*
- Custom Pages -
If you wish to add custom pages to ITFlow, add them to the root directory with the prefix "xcustom_"
e.g. If your page was called my_page_one, name it "xcustom_my_page_one.php"
If you wish to add custom pages to ITFlow, add them to the xcustom folder in the root directory with the prefix "xcustom_"
e.g. If your page was called my_page_one, name it "xcustom/xcustom_my_page_one.php"
Note: If required, you can use the Custom Links module to have the page show on the user sidebar.
To process POST data via your custom pages, create a file in this directory (post/xcustom) named after your page (e.g. xcustom_my_page_one.php).
The relevant file will be automatically loaded upon a POST request based on the referer - your form just needs to target the standard post.php.
The relevant file will be automatically loaded upon a POST request based on the referer - your form just needs to target the standard root/post.php.
*/

9
xcustom/readme.php Normal file
View File

@ -0,0 +1,9 @@
<?php
/*
- Custom Pages -
If you wish to add custom pages to ITFlow, add them to this directory with the prefix "xcustom_"
*/