diff --git a/admin_settings_invoice.php b/admin_settings_invoice.php index 991e60fd4..d2b68f267 100644 --- a/admin_settings_invoice.php +++ b/admin_settings_invoice.php @@ -57,6 +57,16 @@ We recommend updating the invoice footer to include policies on your late charges. This will be applied every 30 days after the invoice Due Date. +
+ +
+
+ +
+ +
+
+

Recurring Invoice

diff --git a/database_updates.php b/database_updates.php index 1f9d22e77..6cbcd519c 100644 --- a/database_updates.php +++ b/database_updates.php @@ -2231,10 +2231,16 @@ mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '1.5.2'"); } - // if (CURRENT_DATABASE_VERSION == '1.5.2') { - // // Insert queries here required to update to DB version 1.5.3 + if (CURRENT_DATABASE_VERSION == '1.5.2') { + mysqli_query($mysqli, "ALTER TABLE `settings` ADD `config_invoice_paid_notification_email` VARCHAR(200) DEFAULT NULL AFTER `config_invoice_late_fee_percent`"); + + mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '1.5.3'"); + } + + // if (CURRENT_DATABASE_VERSION == '1.5.3') { + // // Insert queries here required to update to DB version 1.5.4 // // Then, update the database to the next sequential version - // mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '1.5.3'"); + // mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '1.5.4'"); // } } else { diff --git a/database_version.php b/database_version.php index f61c2d695..16310497e 100644 --- a/database_version.php +++ b/database_version.php @@ -5,4 +5,4 @@ * It is used in conjunction with database_updates.php */ -DEFINE("LATEST_DATABASE_VERSION", "1.5.2"); +DEFINE("LATEST_DATABASE_VERSION", "1.5.3"); diff --git a/db.sql b/db.sql index 6686b3365..04568ef9f 100644 --- a/db.sql +++ b/db.sql @@ -1477,6 +1477,7 @@ CREATE TABLE `settings` ( `config_invoice_from_email` varchar(200) DEFAULT NULL, `config_invoice_late_fee_enable` tinyint(1) NOT NULL DEFAULT 0, `config_invoice_late_fee_percent` decimal(5,2) NOT NULL DEFAULT 0.00, + `config_invoice_paid_notification_email` varchar(200) DEFAULT NULL, `config_recurring_prefix` varchar(200) DEFAULT NULL, `config_recurring_next_number` int(11) NOT NULL, `config_quote_prefix` varchar(200) DEFAULT NULL, diff --git a/get_settings.php b/get_settings.php index eda76869d..40f4cd35a 100644 --- a/get_settings.php +++ b/get_settings.php @@ -46,6 +46,7 @@ $config_invoice_from_email = $row['config_invoice_from_email']; $config_invoice_late_fee_enable = intval($row['config_invoice_late_fee_enable']); $config_invoice_late_fee_percent = floatval($row['config_invoice_late_fee_percent']); +$config_invoice_paid_notification_email = $row['config_invoice_paid_notification_email']; // Recurring Invoices $config_recurring_prefix = $row['config_recurring_prefix']; diff --git a/guest_pay_invoice_stripe.php b/guest_pay_invoice_stripe.php index c0a1b3079..0740e6b5e 100644 --- a/guest_pay_invoice_stripe.php +++ b/guest_pay_invoice_stripe.php @@ -306,6 +306,7 @@ $config_smtp_password = $row['config_smtp_password']; $config_invoice_from_name = sanitizeInput($row['config_invoice_from_name']); $config_invoice_from_email = sanitizeInput($row['config_invoice_from_email']); + $config_invoice_paid_notification_email = sanitizeInput($row['config_invoice_paid_notification_email']); $config_base_url = sanitizeInput($config_base_url); @@ -313,16 +314,33 @@ $subject = "Payment Received - Invoice $invoice_prefix$invoice_number"; $body = "Hello $contact_name,

We have received your payment in the amount of " . $pi_currency . $pi_amount_paid . " for invoice $invoice_prefix$invoice_number. Please keep this email as a receipt for your records.

Amount: " . numfmt_format_currency($currency_format, $pi_amount_paid, $invoice_currency_code) . "
Balance: " . numfmt_format_currency($currency_format, '0', $invoice_currency_code) . "

Thank you for your business!


~
$company_name - Billing
$config_invoice_from_email
$company_phone"; - $data = [ - [ - 'from' => $config_invoice_from_email, - 'from_name' => $config_invoice_from_name, - 'recipient' => $contact_email, - 'recipient_name' => $contact_name, - 'subject' => $subject, - 'body' => $body, - ] + $data = [ + [ + 'from' => $config_invoice_from_email, + 'from_name' => $config_invoice_from_name, + 'recipient' => $contact_email, + 'recipient_name' => $contact_name, + 'subject' => $subject, + 'body' => $body, + ] + ]; + + + // Email the internal notification address too + if (!empty($config_invoice_paid_notification_email)) { + $subject = "Payment Received - $client_name - Invoice $invoice_prefix$invoice_number"; + $body = "Hello,

This is a notification that an invoice has been paid in ITFlow. Below is a copy of the receipt sent to the client:-

--------

Hello $contact_name,

We have received your payment in the amount of " . $pi_currency . $pi_amount_paid . " for invoice $invoice_prefix$invoice_number. Please keep this email as a receipt for your records.

Amount: " . numfmt_format_currency($currency_format, $pi_amount_paid, $invoice_currency_code) . "
Balance: " . numfmt_format_currency($currency_format, '0', $invoice_currency_code) . "

Thank you for your business!


~
$company_name - Billing
$config_invoice_from_email
$company_phone"; + + $data[] = [ + 'from' => $config_invoice_from_email, + 'from_name' => $config_invoice_from_name, + 'recipient' => $config_invoice_paid_notification_email, + 'recipient_name' => $contact_name, + 'subject' => $subject, + 'body' => $body, ]; + } + $mail = addToMailQueue($mysqli, $data); // Email logging diff --git a/post/admin/admin_settings_invoice.php b/post/admin/admin_settings_invoice.php index fa3274d58..345017415 100644 --- a/post/admin/admin_settings_invoice.php +++ b/post/admin/admin_settings_invoice.php @@ -11,9 +11,13 @@ $config_invoice_late_fee_percent = floatval($_POST['config_invoice_late_fee_percent']); $config_recurring_prefix = sanitizeInput($_POST['config_recurring_prefix']); $config_recurring_next_number = intval($_POST['config_recurring_next_number']); + $config_invoice_paid_notification_email = ''; + if (filter_var($_POST['config_invoice_paid_notification_email'], FILTER_VALIDATE_EMAIL)) { + $config_invoice_paid_notification_email = sanitizeInput($_POST['config_invoice_paid_notification_email']); + } - mysqli_query($mysqli,"UPDATE settings SET config_invoice_prefix = '$config_invoice_prefix', config_invoice_next_number = $config_invoice_next_number, config_invoice_footer = '$config_invoice_footer', config_invoice_late_fee_enable = $config_invoice_late_fee_enable, config_invoice_late_fee_percent = $config_invoice_late_fee_percent, config_recurring_prefix = '$config_recurring_prefix', config_recurring_next_number = $config_recurring_next_number WHERE company_id = 1"); + mysqli_query($mysqli,"UPDATE settings SET config_invoice_prefix = '$config_invoice_prefix', config_invoice_next_number = $config_invoice_next_number, config_invoice_footer = '$config_invoice_footer', config_invoice_late_fee_enable = $config_invoice_late_fee_enable, config_invoice_late_fee_percent = $config_invoice_late_fee_percent, config_invoice_paid_notification_email = '$config_invoice_paid_notification_email', config_recurring_prefix = '$config_recurring_prefix', config_recurring_next_number = $config_recurring_next_number WHERE company_id = 1"); //Logging mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Settings', log_action = 'Edit', log_description = '$session_name edited invoice settings', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_user_id = $session_user_id"); diff --git a/post/admin/admin_settings_ticket.php b/post/admin/admin_settings_ticket.php index 88ad7a3fe..724921841 100644 --- a/post/admin/admin_settings_ticket.php +++ b/post/admin/admin_settings_ticket.php @@ -8,7 +8,10 @@ $config_ticket_email_parse_unknown_senders = intval($_POST['config_ticket_email_parse_unknown_senders']); $config_ticket_default_billable = intval($_POST['config_ticket_default_billable']); $config_ticket_autoclose_hours = intval($_POST['config_ticket_autoclose_hours']); - $config_ticket_new_ticket_notification_email = sanitizeInput($_POST['config_ticket_new_ticket_notification_email']); + $config_ticket_new_ticket_notification_email = ''; + if (filter_var($_POST['config_ticket_new_ticket_notification_email'], FILTER_VALIDATE_EMAIL)) { + $config_ticket_new_ticket_notification_email = sanitizeInput($_POST['config_ticket_new_ticket_notification_email']); + } mysqli_query($mysqli,"UPDATE settings SET config_ticket_prefix = '$config_ticket_prefix', config_ticket_next_number = $config_ticket_next_number, config_ticket_email_parse = $config_ticket_email_parse, config_ticket_email_parse_unknown_senders = $config_ticket_email_parse_unknown_senders, config_ticket_autoclose_hours = $config_ticket_autoclose_hours, config_ticket_new_ticket_notification_email = '$config_ticket_new_ticket_notification_email', config_ticket_default_billable = $config_ticket_default_billable WHERE company_id = 1");