mirror of https://github.com/itflow-org/itflow
Merge pull request #835 from twetech/ticket_notifications
Notifications for technicians in tickets
This commit is contained in:
commit
a35a6f3ea0
|
|
@ -19,4 +19,5 @@ plugins/htmlpurifier/standalone/HTMLPurifier/DefinitionCache/Serializer/HTML/*
|
|||
plugins/htmlpurifier/standalone/HTMLPurifier/DefinitionCache/Serializer/URI/*
|
||||
!plugins/htmlpurifier/standalone/HTMLPurifier/DefinitionCache/Serializer/URI/.gitkeep
|
||||
plugins/htmlpurifier/standalone/HTMLPurifier/DefinitionCache/Serializer/CSS/*
|
||||
!plugins/htmlpurifier/standalone/HTMLPurifier/DefinitionCache/Serializer/CSS/.gitkeep
|
||||
!plugins/htmlpurifier/standalone/HTMLPurifier/DefinitionCache/Serializer/CSS/.gitkeep
|
||||
.vscode/settings.json
|
||||
|
|
|
|||
14
ajax.php
14
ajax.php
|
|
@ -312,10 +312,16 @@ if (isset($_GET['share_generate_link'])) {
|
|||
}
|
||||
$body = "Hello,<br><br>$session_name from $session_company_name sent you a time sensitive secure link regarding '$item_name'.<br><br>The link will expire in <strong>$item_expires_friendly</strong> and may only be viewed <strong>$item_view_limit</strong> times, before the link is destroyed. <br><br><strong><a href='$url'>Click here to access your secure content</a></strong><br><br>~<br>$session_company_name<br>Support Department<br>$config_ticket_from_email";
|
||||
|
||||
$mail = sendSingleEmail($config_smtp_host, $config_smtp_username, $config_smtp_password, $config_smtp_encryption, $config_smtp_port,
|
||||
$config_mail_from_email, $config_mail_from_name,
|
||||
$item_email, $item_email,
|
||||
$subject, $body);
|
||||
$data = [
|
||||
[
|
||||
'recipient' => $item_email,
|
||||
'recipient_name' => $item_email,
|
||||
'subject' => $subject,
|
||||
'body' => $body,
|
||||
]
|
||||
];
|
||||
|
||||
$mail = addToMailQueue($mysqli, $data);
|
||||
|
||||
if ($mail !== true) {
|
||||
mysqli_query($mysqli,"INSERT INTO notifications SET notification_type = 'Mail', notification = 'Failed to send email to $item_email'");
|
||||
|
|
|
|||
92
cron.php
92
cron.php
|
|
@ -297,6 +297,7 @@ if (mysqli_num_rows($sql_scheduled_tickets) > 0) {
|
|||
$ticket_subject = $row['ticket_subject'];
|
||||
$ticket_details = $row['ticket_details']; // Output on settings_mail_queue.php is sanitized through HTML Purifier
|
||||
|
||||
$data = [];
|
||||
|
||||
// Notify client by email their ticket has been raised, if general notifications are turned on & there is a valid contact email
|
||||
if (!empty($config_smtp_host) && $config_ticket_client_general_notifications == 1 && filter_var($contact_email, FILTER_VALIDATE_EMAIL)) {
|
||||
|
|
@ -304,7 +305,15 @@ if (mysqli_num_rows($sql_scheduled_tickets) > 0) {
|
|||
$email_subject = mysqli_real_escape_string($mysqli, "Ticket created - [$ticket_prefix$ticket_number] - $ticket_subject (scheduled)");
|
||||
$email_body = mysqli_real_escape_string($mysqli, "<i style='color: #808080'>##- Please type your reply above this line -##</i><br><br>Hello, $contact_name<br><br>A ticket regarding \"$ticket_subject\" has been automatically created for you.<br><br>--------------------------------<br>$details--------------------------------<br><br>Ticket: $ticket_prefix$ticket_number<br>Subject: $ticket_subject<br>Status: Open<br>Portal: https://$config_base_url/portal/ticket.php?id=$id<br><br>~<br>$company_name<br>Support Department<br>$config_ticket_from_email<br>$company_phone");
|
||||
|
||||
mysqli_query($mysqli, "INSERT INTO email_queue SET email_recipient = '$contact_email_escaped', email_recipient_name = '$contact_name_escaped', email_from = '$config_ticket_from_email_escaped', email_from_name = '$config_ticket_from_name_escaped', email_subject = '$email_subject', email_content = '$email_body'");
|
||||
$email = [
|
||||
'recipient' => $contact_email_escaped,
|
||||
'recipient_name' => $contact_name_escaped,
|
||||
'subject' => $email_subject,
|
||||
'body' => $email_body
|
||||
];
|
||||
|
||||
$data[] = $email;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -314,9 +323,19 @@ if (mysqli_num_rows($sql_scheduled_tickets) > 0) {
|
|||
$email_subject = mysqli_real_escape_string($mysqli, "ITFlow - New Scheduled Ticket - $client_name: $ticket_subject");
|
||||
$email_body = mysqli_real_escape_string($mysqli, "Hello, <br><br>This is a notification that a new 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");
|
||||
|
||||
mysqli_query($mysqli, "INSERT INTO email_queue SET email_recipient = '$config_ticket_new_ticket_notification_email', email_recipient_name = 'ITFlow Agents', email_from = '$config_ticket_from_email', email_from_name = '$config_ticket_from_name', email_subject = '$email_subject', email_content = '$email_body'");
|
||||
$email = [
|
||||
'recipient' => $config_ticket_new_ticket_notification_email,
|
||||
'recipient_name' => $config_ticket_from_name_escaped,
|
||||
'subject' => $email_subject,
|
||||
'body' => $email_body
|
||||
];
|
||||
|
||||
$data[] = $email;
|
||||
}
|
||||
|
||||
// Add to the mail queue
|
||||
addToMailQueue($mysqli, $data);
|
||||
|
||||
|
||||
// Set the next run date
|
||||
if ($frequency == "weekly") {
|
||||
|
|
@ -407,10 +426,15 @@ if ($config_ticket_autoclose == 1) {
|
|||
$subject = "Ticket pending closure - [$ticket_prefix$ticket_number] - $ticket_subject";
|
||||
$body = "<i style='color: #808080'>##- Please type your reply above this line -##</i><br><br>Hello, $contact_name<br><br>This is an automatic friendly reminder that your ticket regarding \"$ticket_subject\" will be closed, unless you respond.<br><br>--------------------------------<br>$ticket_reply--------------------------------<br><br>If your issue is resolved, you can ignore this email - the ticket will automatically close. If you need further assistance, please respond to this email. <br><br>Ticket: $ticket_prefix$ticket_number<br>Subject: $ticket_subject<br>Status: $ticket_status<br>Portal: https://$config_base_url/portal/ticket.php?id=$ticket_id<br><br>~<br>$company_name<br>Support Department<br>$config_ticket_from_email<br>$company_phone";
|
||||
|
||||
$mail = sendSingleEmail($config_smtp_host, $config_smtp_username, $config_smtp_password, $config_smtp_encryption, $config_smtp_port,
|
||||
$config_ticket_from_email, $config_ticket_from_name,
|
||||
$contact_email, $contact_name,
|
||||
$subject, $body);
|
||||
$data = [
|
||||
[
|
||||
'recipient' => $contact_email,
|
||||
'recipient_name' => $contact_name,
|
||||
'subject' => $subject,
|
||||
'body' => $body
|
||||
]
|
||||
];
|
||||
$mail = addToMailQueue($mysqli, $data);
|
||||
|
||||
if ($mail !== true) {
|
||||
mysqli_query($mysqli,"INSERT INTO notifications SET notification_type = 'Mail', notification = 'Failed to send email to $contact_email'");
|
||||
|
|
@ -483,19 +507,14 @@ if ($config_send_invoice_reminders == 1) {
|
|||
<br><br>
|
||||
Kindly review the invoice details mentioned below.<br><br>Invoice: $invoice_prefix$invoice_number<br>Issue Date: $invoice_date<br>Total: " . numfmt_format_currency($currency_format, $invoice_amount, $invoice_currency_code) . "<br>Due Date: $invoice_due<br><br><br>To view your invoice click <a href='https://$config_base_url/guest_view_invoice.php?invoice_id=$invoice_id&url_key=$invoice_url_key'>here</a><br><br><br>~<br>$company_name<br>Billing Department<br>$config_invoice_from_email<br>$company_phone";
|
||||
|
||||
$mail = sendSingleEmail(
|
||||
$config_smtp_host,
|
||||
$config_smtp_username,
|
||||
$config_smtp_password,
|
||||
$config_smtp_encryption,
|
||||
$config_smtp_port,
|
||||
$config_invoice_from_email,
|
||||
$config_invoice_from_name,
|
||||
$contact_email,
|
||||
$contact_name,
|
||||
$subject,
|
||||
$body
|
||||
);
|
||||
$mail = addToMailQueue($mysqli, [
|
||||
[
|
||||
'recipient' => $contact_email,
|
||||
'recipient_name' => $contact_name,
|
||||
'subject' => $subject,
|
||||
'body' => $body
|
||||
]
|
||||
]);
|
||||
|
||||
if ($mail === true) {
|
||||
mysqli_query($mysqli, "INSERT INTO history SET history_status = 'Sent', history_description = 'Cron Emailed Overdue Invoice', history_invoice_id = $invoice_id");
|
||||
|
|
@ -603,19 +622,14 @@ while ($row = mysqli_fetch_array($sql_recurring)) {
|
|||
$subject = "Invoice $invoice_prefix$invoice_number";
|
||||
$body = "Hello $contact_name,<br><br>Kindly review the invoice details mentioned below.<br><br>Invoice: $invoice_prefix$invoice_number<br>Issue Date: $invoice_date<br>Total: " . numfmt_format_currency($currency_format, $invoice_amount, $recurring_currency_code) . "<br>Due Date: $invoice_due<br><br><br>To view your invoice click <a href='https://$config_base_url/guest_view_invoice.php?invoice_id=$new_invoice_id&url_key=$invoice_url_key'>here</a><br><br><br>~<br>$company_name<br>Billing Department<br>$config_invoice_from_email<br>$company_phone";
|
||||
|
||||
$mail = sendSingleEmail(
|
||||
$config_smtp_host,
|
||||
$config_smtp_username,
|
||||
$config_smtp_password,
|
||||
$config_smtp_encryption,
|
||||
$config_smtp_port,
|
||||
$config_invoice_from_email,
|
||||
$config_invoice_from_name,
|
||||
$contact_email,
|
||||
$contact_name,
|
||||
$subject,
|
||||
$body
|
||||
);
|
||||
$mail = addToMailQueue($mysqli, [
|
||||
[
|
||||
'recipient' => $contact_email,
|
||||
'recipient_name' => $contact_name,
|
||||
'subject' => $subject,
|
||||
'body' => $body
|
||||
]
|
||||
]);
|
||||
|
||||
if ($mail === true) {
|
||||
mysqli_query($mysqli, "INSERT INTO history SET history_status = 'Sent', history_description = 'Cron Emailed Invoice!', history_invoice_id = $new_invoice_id");
|
||||
|
|
@ -641,10 +655,16 @@ while ($row = mysqli_fetch_array($sql_recurring)) {
|
|||
$billing_contact_name = $billing_contact['contact_name'];
|
||||
$billing_contact_email = $billing_contact['contact_email'];
|
||||
|
||||
sendSingleEmail($config_smtp_host, $config_smtp_username, $config_smtp_password, $config_smtp_encryption, $config_smtp_port,
|
||||
$config_invoice_from_email, $config_invoice_from_name,
|
||||
$billing_contact_email, $billing_contact_name,
|
||||
$subject, $body);
|
||||
$data = [
|
||||
[
|
||||
'recipient' => $billing_contact_email,
|
||||
'recipient_name' => $billing_contact_name,
|
||||
'subject' => $subject,
|
||||
'body' => $body
|
||||
]
|
||||
];
|
||||
|
||||
addToMailQueue($mysqli, $data);
|
||||
}
|
||||
|
||||
} //End if Autosend is on
|
||||
|
|
|
|||
|
|
@ -157,21 +157,23 @@ function addTicket($contact_id, $contact_name, $contact_email, $client_id, $date
|
|||
|
||||
}
|
||||
|
||||
|
||||
$data = [];
|
||||
// E-mail client notification that ticket has been created
|
||||
if ($config_ticket_client_general_notifications == 1) {
|
||||
|
||||
// Insert email into queue (first, escape vars)
|
||||
$contact_email_escaped = sanitizeInput($contact_email);
|
||||
$contact_name_escaped = sanitizeInput($contact_name);
|
||||
$config_ticket_from_email_escaped = sanitizeInput($config_ticket_from_email);
|
||||
$config_ticket_from_name_escaped = sanitizeInput($config_ticket_from_name);
|
||||
|
||||
$subject_escaped = mysqli_escape_string($mysqli, "Ticket created - [$config_ticket_prefix$ticket_number] - $subject");
|
||||
$body_escaped = mysqli_escape_string($mysqli, "<i style='color: #808080'>##- Please type your reply above this line -##</i><br><br>Hello, $contact_name<br><br>Thank you for your email. A ticket regarding \"$subject\" has been automatically created for you.<br><br>Ticket: $config_ticket_prefix$ticket_number<br>Subject: $subject<br>Status: Open<br>https://$config_base_url/portal/ticket.php?id=$id<br><br>~<br>$company_name<br>Support Department<br>$config_ticket_from_email<br>$company_phone");
|
||||
|
||||
mysqli_query($mysqli, "INSERT INTO email_queue SET email_recipient = '$contact_email_escaped', email_recipient_name = '$contact_name_escaped', email_from = '$config_ticket_from_email_escaped', email_from_name = '$config_ticket_from_name_escaped', email_subject = '$subject_escaped', email_content = '$body_escaped'");
|
||||
|
||||
$data[] = [
|
||||
'recipient' => $contact_email_escaped,
|
||||
'recipient_name' => $contact_name_escaped,
|
||||
'subject' => $subject_escaped,
|
||||
'body' => $body_escaped
|
||||
];
|
||||
}
|
||||
|
||||
// Notify agent DL of the new ticket, if populated with a valid email
|
||||
|
|
@ -188,9 +190,16 @@ function addTicket($contact_id, $contact_name, $contact_email, $client_id, $date
|
|||
$email_subject = mysqli_escape_string($mysqli, "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: Low (email parsed)<br>Link: https://$config_base_url/ticket.php?ticket_id=$id <br><br>--------------------------------<br><br><b>$subject</b><br>$details";
|
||||
|
||||
mysqli_query($mysqli, "INSERT INTO email_queue SET email_recipient = '$config_ticket_new_ticket_notification_email', email_recipient_name = 'ITFlow Agents', email_from = '$config_ticket_from_email', email_from_name = '$config_ticket_from_name', email_subject = '$email_subject', email_content = '$email_body'");
|
||||
$data[] = [
|
||||
'recipient' => $config_ticket_new_ticket_notification_email,
|
||||
'recipient_name' => $config_ticket_from_name,
|
||||
'subject' => $email_subject,
|
||||
'body' => $email_body
|
||||
];
|
||||
}
|
||||
|
||||
addToMailQueue($mysqli, $data);
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
|
@ -231,20 +240,17 @@ function addReply($from_email, $date, $subject, $ticket_number, $message, $attac
|
|||
|
||||
$email_subject = "Action required: This ticket is already closed";
|
||||
$email_body = "Hi there, <br><br>You've tried to reply to a ticket that is closed - we won't see your response. <br><br>Please raise a new ticket by sending a fresh e-mail to our support address. <br><br>~<br>$company_name<br>Support Department<br>$config_ticket_from_email<br>$company_phone";
|
||||
|
||||
sendSingleEmail(
|
||||
$config_smtp_host,
|
||||
$config_smtp_username,
|
||||
$config_smtp_password,
|
||||
$config_smtp_encryption,
|
||||
$config_smtp_port,
|
||||
$config_ticket_from_email,
|
||||
$config_ticket_from_name,
|
||||
$from_email,
|
||||
$from_email,
|
||||
$email_subject,
|
||||
$email_body
|
||||
);
|
||||
|
||||
$data = [
|
||||
[
|
||||
'recipient' => $from_email,
|
||||
'recipient_name' => $from_email,
|
||||
'subject' => $email_subject,
|
||||
'body' => $email_body
|
||||
]
|
||||
];
|
||||
|
||||
addToMailQueue($mysqli, $data);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
@ -310,6 +316,44 @@ function addReply($from_email, $date, $subject, $ticket_number, $message, $attac
|
|||
|
||||
}
|
||||
|
||||
// E-mail techs assigned to the ticket to notify them of the reply
|
||||
$ticket_assigned_to = mysqli_query($mysqli, "SELECT ticket_assigned_to FROM tickets WHERE ticket_id = $ticket_id LIMIT 1");
|
||||
|
||||
if ($ticket_assigned_to) {
|
||||
|
||||
$row = mysqli_fetch_array($ticket_assigned_to);
|
||||
$ticket_assigned_to = $row['ticket_assigned_to'];
|
||||
|
||||
if ($ticket_assigned_to) {
|
||||
|
||||
// Get tech details
|
||||
$tech_sql = mysqli_query($mysqli, "SELECT user_email, user_name FROM users WHERE user_id = $ticket_assigned_to LIMIT 1");
|
||||
$tech_row = mysqli_fetch_array($tech_sql);
|
||||
$tech_email = $tech_row['user_email'];
|
||||
$tech_name = $tech_row['user_name'];
|
||||
|
||||
// Insert email into queue (first, escape vars)
|
||||
$tech_email_escaped = sanitizeInput($tech_email);
|
||||
$tech_name_escaped = sanitizeInput($tech_name);
|
||||
|
||||
$subject_escaped = mysqli_escape_string($mysqli, "Ticket updated - [$config_ticket_prefix$ticket_number] - $subject");
|
||||
$body_escaped = mysqli_escape_string($mysqli, "<i style='color: #808080'>##- Please type your reply above this line -##</i><br><br>Hello, $tech_name<br><br>A new reply has been added to the ticket \"$subject\".<br><br>Ticket: $config_ticket_prefix$ticket_number<br>Subject: $subject<br>Status: Open<br>https://$config_base_url/portal/ticket.php?id=$ticket_id<br><br>~<br>$company_name<br>Support Department<br>$config_ticket_from_email<br>$company_phone");
|
||||
|
||||
$data = [
|
||||
[
|
||||
'recipient' => $tech_email_escaped,
|
||||
'recipient_name' => $tech_name_escaped,
|
||||
'subject' => $subject_escaped,
|
||||
'body' => $body_escaped
|
||||
]
|
||||
];
|
||||
|
||||
addToMailQueue($mysqli, $data);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Update Ticket Last Response Field & set ticket to open as client has replied
|
||||
mysqli_query($mysqli, "UPDATE tickets SET ticket_status = 'Client-Replied' WHERE ticket_id = $ticket_id AND ticket_client_id = $client_id LIMIT 1");
|
||||
|
||||
|
|
|
|||
|
|
@ -873,6 +873,24 @@ function calculateAccountBalance($mysqli, $account_id) {
|
|||
return $balance;
|
||||
}
|
||||
|
||||
|
||||
function addToMailQueue($mysqli, $data) {
|
||||
$config_invoice_from_email = strval(getSettingValue($mysqli, 'config_invoice_from_email'));
|
||||
$config_invoice_from_name = strval(getSettingValue($mysqli, 'config_invoice_from_name'));
|
||||
|
||||
foreach ($data as $email) {
|
||||
$recipient = strval($email['email']);
|
||||
$recipient_name = strval($email['name']);
|
||||
$subject = strval($email['subject']);
|
||||
$body = strval($email['body']);
|
||||
|
||||
mysqli_query($mysqli, "INSERT INTO email_queue SET email_recipient = '$recipient', email_recipient_name = '$recipient_name', email_from = '$config_invoice_from_email', email_from_name = '$config_invoice_from_name', email_subject = '$subject', email_content = '$body'");
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
function calculateInvoiceBalance($mysqli, $invoice_id) {
|
||||
$sql_invoice = mysqli_query($mysqli, "SELECT * FROM invoices WHERE invoice_id = $invoice_id");
|
||||
$row = mysqli_fetch_array($sql_invoice);
|
||||
|
|
@ -890,4 +908,5 @@ function calculateInvoiceBalance($mysqli, $invoice_id) {
|
|||
}
|
||||
|
||||
return $balance;
|
||||
|
||||
}
|
||||
|
|
@ -344,19 +344,15 @@ if (isset($_GET['invoice_id'], $_GET['url_key']) && !isset($_GET['payment_intent
|
|||
$subject = "Payment Received - Invoice $invoice_prefix$invoice_number";
|
||||
$body = "Hello $contact_name,<br><br>We have received your payment in the amount of " . $pi_currency . $pi_amount_paid . " for 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>. Please keep this email as a receipt for your records.<br><br>Amount: " . numfmt_format_currency($currency_format, $pi_amount_paid, $invoice_currency_code) . "<br>Balance: " . numfmt_format_currency($currency_format, '0', $invoice_currency_code) . "<br><br>Thank you for your business!<br><br><br>~<br>$company_name<br>Billing Department<br>$config_invoice_from_email<br>$company_phone";
|
||||
|
||||
$mail = sendSingleEmail(
|
||||
$config_smtp_host,
|
||||
$config_smtp_username,
|
||||
$config_smtp_password,
|
||||
$config_smtp_encryption,
|
||||
$config_smtp_port,
|
||||
$config_invoice_from_email,
|
||||
$config_invoice_from_name,
|
||||
$contact_email,
|
||||
$contact_name,
|
||||
$subject,
|
||||
$body
|
||||
);
|
||||
$data = [
|
||||
[
|
||||
'recipient' => $contact_email,
|
||||
'recipient_name' => $contact_name,
|
||||
'subject' => $subject,
|
||||
'body' => $body,
|
||||
]
|
||||
];
|
||||
$mail = addToMailQueue($mysqli, $data);
|
||||
|
||||
// Email Logging
|
||||
if ($mail === true) {
|
||||
|
|
|
|||
45
login.php
45
login.php
|
|
@ -145,19 +145,15 @@ if (isset($_POST['login'])) {
|
|||
$subject = "$config_app_name new login for $user_name";
|
||||
$body = "Hi $user_name, <br><br>A recent successful login to your $config_app_name account was considered a little unusual. If this was you, you can safely ignore this email!<br><br>IP Address: $ip<br> User Agent: $user_agent <br><br>If you did not perform this login, your credentials may be compromised. <br><br>Thanks, <br>ITFlow";
|
||||
|
||||
$mail = sendSingleEmail(
|
||||
$config_smtp_host,
|
||||
$config_smtp_username,
|
||||
$config_smtp_password,
|
||||
$config_smtp_encryption,
|
||||
$config_smtp_port,
|
||||
$config_mail_from_email,
|
||||
$config_mail_from_name,
|
||||
$user_email,
|
||||
$user_name,
|
||||
$subject,
|
||||
$body
|
||||
);
|
||||
$data = [
|
||||
[
|
||||
'recipient' => $user_email,
|
||||
'recipient_name' => $user_name,
|
||||
'subject' => $subject,
|
||||
'body' => $body
|
||||
]
|
||||
];
|
||||
addToMailQueue($mysqli, $data);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -222,20 +218,15 @@ if (isset($_POST['login'])) {
|
|||
if (!empty($config_smtp_host)) {
|
||||
$subject = "Important: $config_app_name failed 2FA login attempt for $user_name";
|
||||
$body = "Hi $user_name, <br><br>A recent login to your $config_app_name account was unsuccessful due to an incorrect 2FA code. If you did not attempt this login, your credentials may be compromised. <br><br>Thanks, <br>ITFlow";
|
||||
|
||||
$mail = sendSingleEmail(
|
||||
$config_smtp_host,
|
||||
$config_smtp_username,
|
||||
$config_smtp_password,
|
||||
$config_smtp_encryption,
|
||||
$config_smtp_port,
|
||||
$config_mail_from_email,
|
||||
$config_mail_from_name,
|
||||
$user_email,
|
||||
$user_name,
|
||||
$subject,
|
||||
$body
|
||||
);
|
||||
$data = [
|
||||
[
|
||||
'recipient' => $user_email,
|
||||
'recipient_name' => $user_name,
|
||||
'subject' => $subject,
|
||||
'body' => $body
|
||||
]
|
||||
];
|
||||
$mail = addToMailQueue($mysqli, $data);
|
||||
}
|
||||
|
||||
// HTML feedback for incorrect 2FA code
|
||||
|
|
|
|||
|
|
@ -71,19 +71,15 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
|
|||
$subject = "Password reset for $company_name ITFlow Portal";
|
||||
$body = "Hello, $name<br><br>Someone (probably you) has requested a new password for your account on $company_name's ITFlow Client Portal. <br><br><b>Please <a href='$url'>click here</a> to reset your password.</b> <br><br>Alternatively, copy and paste this URL into your browser:<br> $url<br><br><i>If you didn't request this change, you can safely ignore this email.</i><br><br>~<br>$company_name<br>Support Department<br>$config_mail_from_email";
|
||||
|
||||
$mail = sendSingleEmail(
|
||||
$config_smtp_host,
|
||||
$config_smtp_username,
|
||||
$config_smtp_password,
|
||||
$config_smtp_encryption,
|
||||
$config_smtp_port,
|
||||
$config_mail_from_email,
|
||||
$config_mail_from_name,
|
||||
$email,
|
||||
$name,
|
||||
$subject,
|
||||
$body
|
||||
);
|
||||
$data = [
|
||||
[
|
||||
'recipient' => $email,
|
||||
'recipient_name' => $name,
|
||||
'subject' => $subject,
|
||||
'body' => $body
|
||||
]
|
||||
];
|
||||
$mail = addToMailQueue($mysqli, $data);
|
||||
|
||||
// Error handling
|
||||
if ($mail !== true) {
|
||||
|
|
@ -130,19 +126,16 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
|
|||
$body = "Hello, $name<br><br>Your password for your account on $company_name's ITFlow Client Portal was successfully reset. You should be all set! <br><br><b>If you didn't reset your password, please get in touch ASAP.</b><br><br>~<br>$company_name<br>Support Department<br>$config_mail_from_email";
|
||||
|
||||
|
||||
$mail = sendSingleEmail(
|
||||
$config_smtp_host,
|
||||
$config_smtp_username,
|
||||
$config_smtp_password,
|
||||
$config_smtp_encryption,
|
||||
$config_smtp_port,
|
||||
$config_mail_from_email,
|
||||
$config_mail_from_name,
|
||||
$email,
|
||||
$name,
|
||||
$subject,
|
||||
$body
|
||||
);
|
||||
$data = [
|
||||
[
|
||||
'recipient' => $email,
|
||||
'recipient_name' => $name,
|
||||
'subject' => $subject,
|
||||
'body' => $body
|
||||
]
|
||||
];
|
||||
|
||||
$mail = addToMailQueue($mysqli, $data);
|
||||
|
||||
// Error handling
|
||||
if ($mail !== true) {
|
||||
|
|
|
|||
|
|
@ -50,8 +50,17 @@ if (isset($_POST['add_ticket'])) {
|
|||
$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";
|
||||
|
||||
mysqli_query($mysqli, "INSERT INTO email_queue SET email_recipient = '$config_ticket_new_ticket_notification_email', email_recipient_name = 'ITFlow Agents', email_from = '$config_ticket_from_email', email_from_name = '$config_ticket_from_name', email_subject = '$email_subject', email_content = '$email_body'");
|
||||
}
|
||||
// Queue Mail
|
||||
$data = [
|
||||
[
|
||||
'recipient' => $config_ticket_new_ticket_notification_email,
|
||||
'recipient_name' => $config_ticket_from_name,
|
||||
'subject' => $email_subject,
|
||||
'body' => $email_body,
|
||||
]
|
||||
];
|
||||
addToMailQueue($mysqli, $data);
|
||||
}
|
||||
|
||||
// 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");
|
||||
|
|
|
|||
|
|
@ -119,8 +119,15 @@ if (isset($_POST['edit_contact'])) {
|
|||
$body = mysqli_real_escape_string($mysqli, "Hello, $contact_name<br><br>$session_company_name has created a support portal account for you. <br><br>Username: $email<br>Password: $password_info<br><br>Login URL: https://$config_base_url/portal/<br><br>~<br>$session_company_name<br>Support Department<br>$config_ticket_from_email");
|
||||
|
||||
// Queue Mail
|
||||
mysqli_query($mysqli, "INSERT INTO email_queue SET email_recipient = '$email', email_recipient_name = '$name', email_from = '$config_ticket_from_email_escaped', email_from_name = '$config_ticket_from_name_escaped', email_subject = '$subject', email_content = '$body'");
|
||||
|
||||
$data = [
|
||||
[
|
||||
'recipient' => $email,
|
||||
'recipient_name' => $contact_name,
|
||||
'subject' => $subject,
|
||||
'body' => $body,
|
||||
]
|
||||
];
|
||||
addToMailQueue($mysqli, $data);
|
||||
// Get Email ID for reference
|
||||
$email_id = mysqli_insert_id($mysqli);
|
||||
|
||||
|
|
|
|||
|
|
@ -61,10 +61,15 @@ if (isset($_POST['add_event'])) {
|
|||
$subject = "New Calendar Event";
|
||||
$body = "Hello $contact_name,<br><br>A calendar event has been scheduled: $title at $start<br><br><br>~<br>$company_name<br>$company_phone";
|
||||
|
||||
$mail = sendSingleEmail($config_smtp_host, $config_smtp_username, $config_smtp_password, $config_smtp_encryption, $config_smtp_port,
|
||||
$config_mail_from_email, $config_mail_from_name,
|
||||
$contact_email, $contact_name,
|
||||
$subject, $body);
|
||||
$data = [
|
||||
[
|
||||
'recipient' => $contact_email,
|
||||
'recipient_name' => $contact_name,
|
||||
'subject' => $subject,
|
||||
'body' => $body
|
||||
]
|
||||
];
|
||||
$mail = addToMailQueue($mysqli, $data);
|
||||
|
||||
// Logging for email (success/fail)
|
||||
if ($mail === true) {
|
||||
|
|
@ -120,11 +125,15 @@ if (isset($_POST['edit_event'])) {
|
|||
$subject = "Calendar Event Rescheduled";
|
||||
$body = "Hello $contact_name,<br><br>A calendar event has been rescheduled: $title at $start<br><br><br>~<br>$company_name<br>$company_phone";
|
||||
|
||||
$mail = sendSingleEmail($config_smtp_host, $config_smtp_username, $config_smtp_password, $config_smtp_encryption, $config_smtp_port,
|
||||
$config_mail_from_email, $config_mail_from_name,
|
||||
$contact_email, $contact_name,
|
||||
$subject, $body);
|
||||
|
||||
$data = [
|
||||
[
|
||||
'recipient' => $contact_email,
|
||||
'recipient_name' => $contact_name,
|
||||
'subject' => $subject,
|
||||
'body' => $body
|
||||
]
|
||||
];
|
||||
$mail = addToMailQueue($mysqli, $data);
|
||||
// Logging for email (success/fail)
|
||||
if ($mail === true) {
|
||||
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Calendar_Event', log_action = 'Email', log_description = '$session_name Emailed modified event $title to $client_name email $client_email', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_user_id = $session_user_id");
|
||||
|
|
|
|||
|
|
@ -666,6 +666,8 @@ if (isset($_POST['add_payment'])) {
|
|||
//Calculate the Invoice balance
|
||||
$invoice_balance = $invoice_amount - $total_payments_amount;
|
||||
|
||||
$email_data = [];
|
||||
|
||||
//Determine if invoice has been paid then set the status accordingly
|
||||
if ($invoice_balance == 0) {
|
||||
|
||||
|
|
@ -677,7 +679,14 @@ if (isset($_POST['add_payment'])) {
|
|||
$body = mysqli_real_escape_string($mysqli, "Hello $contact_name,<br><br>We have received your payment in the amount of " . numfmt_format_currency($currency_format, $amount, $invoice_currency_code) . " for 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>. Please keep this email as a receipt for your records.<br><br>Amount: " . numfmt_format_currency($currency_format, $amount, $invoice_currency_code) . "<br>Balance: " . numfmt_format_currency($currency_format, $invoice_balance, $invoice_currency_code) . "<br><br>Thank you for your business!<br><br><br>~<br>$company_name<br>Billing Department<br>$config_invoice_from_email<br>$company_phone");
|
||||
|
||||
// Queue Mail
|
||||
mysqli_query($mysqli, "INSERT INTO email_queue SET email_recipient = '$contact_email_escaped', email_recipient_name = '$contact_name_escaped', email_from = '$config_invoice_from_email_escaped', email_from_name = '$config_invoice_from_name_escaped', email_subject = '$subject', email_content = '$body'");
|
||||
$email = [
|
||||
'recipient' => $contact_email_escaped,
|
||||
'recipient_name' => $contact_name_escaped,
|
||||
'subject' => $subject,
|
||||
'body' => $body
|
||||
];
|
||||
|
||||
$email_data = $email;
|
||||
|
||||
// Get Email ID for reference
|
||||
$email_id = mysqli_insert_id($mysqli);
|
||||
|
|
@ -701,7 +710,14 @@ if (isset($_POST['add_payment'])) {
|
|||
$body = mysqli_real_escape_string($mysqli, "Hello $contact_name,<br><br>We have recieved partial payment in the amount of " . numfmt_format_currency($currency_format, $amount, $invoice_currency_code) . " and it has been applied to 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>. Please keep this email as a receipt for your records.<br><br>Amount: " . numfmt_format_currency($currency_format, $amount, $invoice_currency_code) . "<br>Balance: " . numfmt_format_currency($currency_format, $invoice_balance, $invoice_currency_code) . "<br><br>Thank you for your business!<br><br><br>~<br>$company_name<br>Billing Department<br>$config_invoice_from_email<br>$company_phone");
|
||||
|
||||
// Queue Mail
|
||||
mysqli_query($mysqli, "INSERT INTO email_queue SET email_recipient = '$contact_email_escaped', email_recipient_name = '$contact_name_escaped', email_from = '$config_invoice_from_email_escaped', email_from_name = '$config_invoice_from_name_escaped', email_subject = '$subject', email_content = '$body'");
|
||||
$email = [
|
||||
'recipient' => $contact_email_escaped,
|
||||
'recipient_name' => $contact_name_escaped,
|
||||
'subject' => $subject,
|
||||
'body' => $body
|
||||
];
|
||||
|
||||
$email_data = $email;
|
||||
|
||||
// Get Email ID for reference
|
||||
$email_id = mysqli_insert_id($mysqli);
|
||||
|
|
@ -716,6 +732,11 @@ if (isset($_POST['add_payment'])) {
|
|||
|
||||
}
|
||||
|
||||
// Add emails to queue
|
||||
if (!empty($email)) {
|
||||
addToMailQueue($mysqli, $email);
|
||||
}
|
||||
|
||||
//Update Invoice Status
|
||||
mysqli_query($mysqli,"UPDATE invoices SET invoice_status = '$invoice_status' WHERE invoice_id = $invoice_id");
|
||||
|
||||
|
|
@ -979,7 +1000,16 @@ if (isset($_GET['email_invoice'])) {
|
|||
}
|
||||
|
||||
// Queue Mail
|
||||
mysqli_query($mysqli, "INSERT INTO email_queue SET email_recipient = '$contact_email_escaped', email_recipient_name = '$contact_name_escaped', email_from = '$config_invoice_from_email_escaped', email_from_name = '$config_invoice_from_name_escaped', email_subject = '$subject', email_content = '$body'");
|
||||
$data = [
|
||||
[
|
||||
'email' => $contact_email_escaped,
|
||||
'name' => $contact_name_escaped,
|
||||
'subject' => $subject,
|
||||
'body' => $body
|
||||
]
|
||||
];
|
||||
|
||||
addToMailQueue($mysqli, $data);
|
||||
|
||||
// Get Email ID for reference
|
||||
$email_id = mysqli_insert_id($mysqli);
|
||||
|
|
@ -1004,21 +1034,28 @@ if (isset($_GET['email_invoice'])) {
|
|||
AND contact_email != ''
|
||||
AND contact_client_id = $client_id"
|
||||
);
|
||||
|
||||
$data = [];
|
||||
|
||||
while ($billing_contact = mysqli_fetch_array($sql_billing_contacts)) {
|
||||
$billing_contact_name = sanitizeInput($billing_contact['contact_name']);
|
||||
$billing_contact_email = sanitizeInput($billing_contact['contact_email']);
|
||||
|
||||
// Queue Mail
|
||||
mysqli_query($mysqli, "INSERT INTO email_queue SET email_recipient = '$billing_contact_email', email_recipient_name = '$billing_contact_name', email_from = '$config_invoice_from_email', email_from_name = '$config_invoice_from_name', email_subject = '$subject', email_content = '$body'");
|
||||
|
||||
// Get Email ID for reference
|
||||
$email_id = mysqli_insert_id($mysqli);
|
||||
$data = [
|
||||
[
|
||||
'email' => $billing_contact_email,
|
||||
'name' => $billing_contact_name,
|
||||
'subject' => $subject,
|
||||
'body' => $body
|
||||
]
|
||||
];
|
||||
|
||||
// Logging
|
||||
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Invoice', log_action = 'Email', log_description = 'Invoice $invoice_prefix_escaped$invoice_number queued to $billing_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 = $invoice_id");
|
||||
|
||||
}
|
||||
|
||||
addToMailQueue($mysqli, $data);
|
||||
|
||||
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||
|
||||
}
|
||||
|
|
@ -1132,10 +1169,16 @@ if (isset($_GET['force_recurring'])) {
|
|||
$subject = "Invoice $invoice_prefix$invoice_number";
|
||||
$body = "Hello $contact_name,<br><br>Please view the details of the invoice below.<br><br>Invoice: $invoice_prefix$invoice_number<br>Issue Date: $invoice_date<br>Total: $$invoice_amount<br>Due Date: $invoice_due<br><br><br>To view your invoice click <a href='https://$config_base_url/guest_view_invoice.php?invoice_id=$new_invoice_id&url_key=$invoice_url_key'>here</a><br><br><br>~<br>$company_name<br>$company_phone";
|
||||
|
||||
$mail = sendSingleEmail($config_smtp_host, $config_smtp_username, $config_smtp_password, $config_smtp_encryption, $config_smtp_port,
|
||||
$config_invoice_from_email, $config_invoice_from_name,
|
||||
$contact_email, $contact_name,
|
||||
$subject, $body);
|
||||
|
||||
$data = [
|
||||
[
|
||||
'email' => $contact_email,
|
||||
'name' => $contact_name,
|
||||
'subject' => $subject,
|
||||
'body' => $body
|
||||
]
|
||||
];
|
||||
$mail = addToMailQueue($mysqli, $data);
|
||||
|
||||
if ($mail === true) {
|
||||
// Add send history
|
||||
|
|
|
|||
|
|
@ -41,10 +41,15 @@ if (isset($_POST['edit_profile'])) {
|
|||
$subject = "$config_app_name account update confirmation for $name";
|
||||
$body = "Hi $name, <br><br>Your $config_app_name account has been updated, details below: <br><br> <b>$details</b> <br><br> If you did not perform this change, contact your $config_app_name administrator immediately. <br><br>Thanks, <br>ITFlow<br>$session_company_name";
|
||||
|
||||
$mail = sendSingleEmail($config_smtp_host, $config_smtp_username, $config_smtp_password, $config_smtp_encryption, $config_smtp_port,
|
||||
$config_mail_from_email, $config_mail_from_name,
|
||||
$user_old_email, $name,
|
||||
$subject, $body);
|
||||
$data = [
|
||||
[
|
||||
'recipient' => $user_old_email,
|
||||
'recipient_name' => $name,
|
||||
'subject' => $subject,
|
||||
'body' => $body
|
||||
]
|
||||
];
|
||||
$mail = addToMailQueue($mysqli, $data);
|
||||
}
|
||||
|
||||
// Check to see if a file is attached
|
||||
|
|
@ -166,10 +171,15 @@ if(isset($_POST['disable_2fa'])){
|
|||
$subject = "$config_app_name account update confirmation for $session_name";
|
||||
$body = "Hi $session_name, <br><br>Your $config_app_name account has been updated, details below: <br><br> <b>2FA was disabled.</b> <br><br> If you did not perform this change, contact your $config_app_name administrator immediately. <br><br>Thanks, <br>ITFlow<br>$session_company_name";
|
||||
|
||||
$mail = sendSingleEmail($config_smtp_host, $config_smtp_username, $config_smtp_password, $config_smtp_encryption, $config_smtp_port,
|
||||
$config_mail_from_email, $config_mail_from_name,
|
||||
$session_email, $session_name,
|
||||
$subject, $body);
|
||||
$data = [
|
||||
[
|
||||
'recipient' => $session_email,
|
||||
'recipient_name' => $session_name,
|
||||
'subject' => $subject,
|
||||
'body' => $body
|
||||
]
|
||||
];
|
||||
$mail = addToMailQueue($mysqli, $data);
|
||||
}
|
||||
|
||||
$_SESSION['alert_type'] = "error";
|
||||
|
|
|
|||
|
|
@ -395,10 +395,15 @@ if (isset($_GET['email_quote'])) {
|
|||
$body = mysqli_escape_string($mysqli, "Hello $contact_name,<br><br>Thank you for your inquiry, we are pleased to provide you with the following estimate.<br><br><br>$quote_scope<br>Total Cost: " . numfmt_format_currency($currency_format, $quote_amount, $quote_currency_code) . "<br><br><br>View and accept your estimate online <a href='https://$config_base_url/guest_view_quote.php?quote_id=$quote_id&url_key=$quote_url_key'>here</a><br><br><br>~<br>$company_name<br>Sales<br>$config_quote_from_email<br>$company_phone");
|
||||
|
||||
// Queue Mail
|
||||
mysqli_query($mysqli, "INSERT INTO email_queue SET email_recipient = '$contact_email_escaped', email_recipient_name = '$contact_name_escaped', email_from = '$config_quote_from_email_escaped', email_from_name = '$config_quote_from_name_escaped', email_subject = '$subject', email_content = '$body'");
|
||||
|
||||
// Get Email ID for reference
|
||||
$email_id = mysqli_insert_id($mysqli);
|
||||
$data = [
|
||||
[
|
||||
'recipient' => $contact_email_escaped,
|
||||
'recipient_name' => $contact_name_escaped,
|
||||
'subject' => $subject,
|
||||
'body' => $body,
|
||||
]
|
||||
];
|
||||
addToMailQueue($mysqli, $data);
|
||||
|
||||
// Logging
|
||||
mysqli_query($mysqli,"INSERT INTO history SET history_status = 'Sent', history_description = 'Emailed Quote!', history_quote_id = $quote_id");
|
||||
|
|
|
|||
|
|
@ -153,13 +153,18 @@ if (isset($_POST['test_email_smtp'])) {
|
|||
validateAdminRole();
|
||||
$email_from = sanitizeInput($_POST['email_from']);
|
||||
$email_to = sanitizeInput($_POST['email_to']);
|
||||
$subject = "Hi'ya there Chap";
|
||||
$body = "Hello there Chap ;) Don't worry this won't hurt a bit, it's just a test";
|
||||
$subject = "Test email from ITFlow";
|
||||
$body = "This is a test email from ITFlow. If you are reading this, it worked!";
|
||||
|
||||
$mail = sendSingleEmail($config_smtp_host, $config_smtp_username, $config_smtp_password, $config_smtp_encryption, $config_smtp_port,
|
||||
$email_from, $config_mail_from_name,
|
||||
$email_to, $email_to,
|
||||
$subject, $body);
|
||||
$data = [
|
||||
[
|
||||
'recipient' => $email_to,
|
||||
'recipient_name' => 'Chap',
|
||||
'subject' => $subject,
|
||||
'body' => $body
|
||||
]
|
||||
];
|
||||
$mail = addToMailQueue($mysqli, $data);
|
||||
|
||||
if ($mail === true) {
|
||||
$_SESSION['alert_message'] = "Test email sent successfully";
|
||||
|
|
|
|||
|
|
@ -119,10 +119,13 @@ if (isset($_POST['add_ticket'])) {
|
|||
|
||||
// Email Ticket Contact
|
||||
// Queue Mail
|
||||
mysqli_query($mysqli, "INSERT INTO email_queue SET email_recipient = '$contact_email_escaped', email_recipient_name = '$contact_name_escaped', email_from = '$config_ticket_from_email_escaped', email_from_name = '$config_ticket_from_name_escaped', email_subject = '$subject_escaped', email_content = '$body_escaped'");
|
||||
|
||||
// Get Email ID for reference
|
||||
$email_id = mysqli_insert_id($mysqli);
|
||||
$data = [];
|
||||
$data[] = [
|
||||
'recipient' => $contact_email_escaped,
|
||||
'recipient_name' => $contact_name_escaped,
|
||||
'subject' => $subject_escaped,
|
||||
'body' => $body_escaped,
|
||||
];
|
||||
|
||||
// Also Email all the watchers
|
||||
$sql_watchers = mysqli_query($mysqli, "SELECT watcher_email FROM ticket_watchers WHERE watcher_ticket_id = $ticket_id");
|
||||
|
|
@ -131,8 +134,14 @@ if (isset($_POST['add_ticket'])) {
|
|||
$watcher_email_escaped = sanitizeInput($row['watcher_email']);
|
||||
|
||||
// Queue Mail
|
||||
mysqli_query($mysqli, "INSERT INTO email_queue SET email_recipient = '$watcher_email_escaped', email_recipient_name = '$contact_name_escaped', email_from = '$config_ticket_from_email_escaped', email_from_name = '$config_ticket_from_name_escaped', email_subject = '$subject_escaped', email_content = '$body_escaped'");
|
||||
$data[] = [
|
||||
'recipient' => $watcher_email_escaped,
|
||||
'recipient_name' => $watcher_email_escaped,
|
||||
'subject' => $subject_escaped,
|
||||
'body' => $body_escaped,
|
||||
];
|
||||
}
|
||||
addToMailQueue($mysqli, $data);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -410,10 +419,15 @@ if (isset($_POST['assign_ticket'])) {
|
|||
|
||||
// Email Ticket Agent
|
||||
// Queue Mail
|
||||
mysqli_query($mysqli, "INSERT INTO email_queue SET email_recipient = '$agent_email_escaped', email_recipient_name = '$agent_name_escaped', email_from = '$config_ticket_from_email_escaped', email_from_name = '$config_ticket_from_name_escaped', email_subject = '$subject_escaped', email_content = '$body_escaped'");
|
||||
|
||||
// Get Email ID for reference
|
||||
$email_id = mysqli_insert_id($mysqli);
|
||||
$data = [
|
||||
[
|
||||
'recipient' => $agent_email_escaped,
|
||||
'recipient_name' => $agent_name_escaped,
|
||||
'subject' => $subject_escaped,
|
||||
'body' => $body_escaped,
|
||||
]
|
||||
];
|
||||
addToMailQueue($mysqli, $data);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -554,12 +568,16 @@ if (isset($_POST['add_ticket_reply'])) {
|
|||
|
||||
}
|
||||
|
||||
$data = [];
|
||||
|
||||
// Email Ticket Contact
|
||||
// Queue Mail
|
||||
mysqli_query($mysqli, "INSERT INTO email_queue SET email_recipient = '$contact_email_escaped', email_recipient_name = '$contact_name_escaped', email_from = '$config_ticket_from_email_escaped', email_from_name = '$config_ticket_from_name_escaped', email_subject = '$subject_escaped', email_content = '$body_escaped'");
|
||||
|
||||
// Get Email ID for reference
|
||||
$email_id = mysqli_insert_id($mysqli);
|
||||
$data[] = [
|
||||
'recipient' => $contact_email_escaped,
|
||||
'recipient_name' => $contact_name_escaped,
|
||||
'subject' => $subject_escaped,
|
||||
'body' => $body_escaped,
|
||||
];
|
||||
|
||||
// Also Email all the watchers
|
||||
$sql_watchers = mysqli_query($mysqli, "SELECT watcher_email FROM ticket_watchers WHERE watcher_ticket_id = $ticket_id");
|
||||
|
|
@ -568,9 +586,14 @@ if (isset($_POST['add_ticket_reply'])) {
|
|||
$watcher_email_escaped = sanitizeInput($row['watcher_email']);
|
||||
|
||||
// Queue Mail
|
||||
mysqli_query($mysqli, "INSERT INTO email_queue SET email_recipient = '$watcher_email_escaped', email_recipient_name = '$contact_name_escaped', email_from = '$config_ticket_from_email_escaped', email_from_name = '$config_ticket_from_name_escaped', email_subject = '$subject_escaped', email_content = '$body_escaped'");
|
||||
$data[] = [
|
||||
'recipient' => $watcher_email_escaped,
|
||||
'recipient_name' => $watcher_email_escaped,
|
||||
'subject' => $subject_escaped,
|
||||
'body' => $body_escaped,
|
||||
];
|
||||
}
|
||||
|
||||
addToMailQueue($mysqli, $data);
|
||||
}
|
||||
}
|
||||
//End Mail IF
|
||||
|
|
@ -763,15 +786,20 @@ if (isset($_GET['close_ticket'])) {
|
|||
// Check email valid
|
||||
if (filter_var($contact_email_escaped, FILTER_VALIDATE_EMAIL)) {
|
||||
|
||||
$data = [];
|
||||
|
||||
$subject_escaped = mysqli_escape_string($mysqli, "Ticket closed - [$ticket_prefix$ticket_number] - $ticket_subject | (do not reply)");
|
||||
$body_escaped = mysqli_escape_string($mysqli, "Hello, $contact_name<br><br>Your ticket regarding \"$ticket_subject\" has been closed. <br><br> We hope the issue was resolved to your satisfaction. If you need further assistance, please raise a new ticket using the below details. Please do not reply to this email. <br><br>Ticket: $ticket_prefix$ticket_number<br>Subject: $ticket_subject<br>Portal: https://$config_base_url/portal/ticket.php?id=$ticket_id<br><br>~<br>$session_company_name<br>Support Department<br>$config_ticket_from_email<br>$company_phone");
|
||||
|
||||
// Email Ticket Contact
|
||||
// Queue Mail
|
||||
mysqli_query($mysqli, "INSERT INTO email_queue SET email_recipient = '$contact_email_escaped', email_recipient_name = '$contact_name_escaped', email_from = '$config_ticket_from_email_escaped', email_from_name = '$config_ticket_from_name_escaped', email_subject = '$subject_escaped', email_content = '$body_escaped'");
|
||||
|
||||
// Get Email ID for reference
|
||||
$email_queue_id = mysqli_insert_id($mysqli);
|
||||
$data[] = [
|
||||
'recipient' => $contact_email_escaped,
|
||||
'recipient_name' => $contact_name_escaped,
|
||||
'subject' => $subject_escaped,
|
||||
'body' => $body_escaped,
|
||||
];
|
||||
|
||||
// Also Email all the watchers
|
||||
$sql_watchers = mysqli_query($mysqli, "SELECT watcher_email FROM ticket_watchers WHERE watcher_ticket_id = $ticket_id");
|
||||
|
|
@ -780,9 +808,16 @@ if (isset($_GET['close_ticket'])) {
|
|||
$watcher_email_escaped = sanitizeInput($row['watcher_email']);
|
||||
|
||||
// Queue Mail
|
||||
mysqli_query($mysqli, "INSERT INTO email_queue SET email_recipient = '$watcher_email_escaped', email_recipient_name = '$contact_name_escaped', email_from = '$config_ticket_from_email_escaped', email_from_name = '$config_ticket_from_name_escaped', email_subject = '$subject_escaped', email_content = '$body_escaped'");
|
||||
$data[] = [
|
||||
'recipient' => $watcher_email_escaped,
|
||||
'recipient_name' => $watcher_email_escaped,
|
||||
'subject' => $subject_escaped,
|
||||
'body' => $body_escaped,
|
||||
];
|
||||
}
|
||||
|
||||
addToMailQueue($mysqli, $data);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,10 +53,15 @@ if (isset($_POST['add_user'])) {
|
|||
$subject = "Your new $session_company_name ITFlow account";
|
||||
$body = "Hello, $name<br><br>An ITFlow account has been setup for you. Please change your password upon login. <br><br>Username: $email <br>Password: $_POST[password]<br>Login URL: https://$config_base_url/login.php?key=$config_login_key_secret<br><br>~<br>$session_company_name<br>Support Department<br>$config_ticket_from_email";
|
||||
|
||||
$mail = sendSingleEmail($config_smtp_host, $config_smtp_username, $config_smtp_password, $config_smtp_encryption, $config_smtp_port,
|
||||
$config_ticket_from_email, $config_ticket_from_name,
|
||||
$email, $name,
|
||||
$subject, $body);
|
||||
$data = [
|
||||
[
|
||||
'recipient' => $email,
|
||||
'recipient_name' => $name,
|
||||
'subject' => $subject,
|
||||
'body' => $body
|
||||
]
|
||||
];
|
||||
$mail = addToMailQueue($mysqli, $data);
|
||||
|
||||
if ($mail !== true) {
|
||||
mysqli_query($mysqli, "INSERT INTO notifications SET notification_type = 'Mail', notification = 'Failed to send email to $email'");
|
||||
|
|
|
|||
26
temp.php
26
temp.php
|
|
@ -62,13 +62,19 @@ if(isset($_GET['email_invoice'])){
|
|||
}
|
||||
|
||||
// Queue Mail
|
||||
mysqli_query($mysqli, "INSERT INTO email_queue SET email_recipient = '$contact_email_escaped', email_recipient_name = '$contact_name_escaped', email_from = '$config_invoice_from_email_escaped', email_from_name = '$config_invoice_from_name_escaped', email_subject = '$subject', email_content = '$body'");
|
||||
$data = [
|
||||
[
|
||||
'recipient' => $contact_email_escaped,
|
||||
'recipient_name' => $contact_name_escaped,
|
||||
'subject' => $subject,
|
||||
'body' => $body,
|
||||
]
|
||||
];
|
||||
addToMailQueue($mysqli, $data);
|
||||
|
||||
// Get Email ID for reference
|
||||
$email_id = mysqli_insert_id($mysqli);
|
||||
|
||||
$_SESSION['alert_message'] = "Invoice has been sent";
|
||||
mysqli_query($mysqli,"INSERT INTO history SET history_status = 'Sent', history_description = 'Invoice sent to the mail queue ID: $email_id', history_invoice_id = $invoice_id");
|
||||
mysqli_query($mysqli,"INSERT INTO history SET history_status = 'Sent', history_description = 'Invoice sent to the mail queue.', history_invoice_id = $invoice_id");
|
||||
|
||||
// Don't change the status to sent if the status is anything but draft
|
||||
if($invoice_status == 'Draft'){
|
||||
|
|
@ -92,8 +98,16 @@ if(isset($_GET['email_invoice'])){
|
|||
$billing_contact_email = sanitizeInput($billing_contact['contact_email']);
|
||||
|
||||
// Queue Mail
|
||||
mysqli_query($mysqli, "INSERT INTO email_queue SET email_recipient = '$billing_contact_email', email_recipient_name = '$billing_contact_name', email_from = '$config_invoice_from_email', email_from_name = '$config_invoice_from_name', email_subject = '$subject', email_content = '$body'");
|
||||
|
||||
$data = [
|
||||
[
|
||||
'recipient' => $billing_contact_email,
|
||||
'recipient_name' => $billing_contact_name,
|
||||
'subject' => $subject,
|
||||
'body' => $body,
|
||||
]
|
||||
];
|
||||
addToMailQueue($mysqli, $data);
|
||||
|
||||
// Get Email ID for reference
|
||||
$email_id = mysqli_insert_id($mysqli);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue