diff --git a/admin_settings_quote.php b/admin_settings_quote.php index ea3c2763a..9473c7fbf 100644 --- a/admin_settings_quote.php +++ b/admin_settings_quote.php @@ -35,6 +35,16 @@ +
+ +
+
+ +
+ +
+
+
diff --git a/database_updates.php b/database_updates.php index 4751fe7b2..c9485e499 100644 --- a/database_updates.php +++ b/database_updates.php @@ -2232,10 +2232,16 @@ function processFile($file_path, $file_name, $mysqli) { mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '1.6.5'"); } - // if (CURRENT_DATABASE_VERSION == '1.6.5') { - // // Insert queries here required to update to DB version 1.6.6 + if (CURRENT_DATABASE_VERSION == '1.6.5') { + mysqli_query($mysqli, "ALTER TABLE `settings` ADD `config_quote_notification_email` VARCHAR(200) DEFAULT NULL AFTER `config_quote_from_email`"); + + mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '1.6.6'"); + } + + // if (CURRENT_DATABASE_VERSION == '1.6.6') { + // // Insert queries here required to update to DB version 1.6.7 // // Then, update the database to the next sequential version - // mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '1.6.6'"); + // mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '1.6.7'"); // } } else { diff --git a/database_version.php b/database_version.php index 856c91897..d8b464c45 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.6.5"); +DEFINE("LATEST_DATABASE_VERSION", "1.6.6"); diff --git a/db.sql b/db.sql index 223a86623..b6706f946 100644 --- a/db.sql +++ b/db.sql @@ -1517,6 +1517,7 @@ CREATE TABLE `settings` ( `config_quote_footer` text DEFAULT NULL, `config_quote_from_name` varchar(200) DEFAULT NULL, `config_quote_from_email` varchar(200) DEFAULT NULL, + `config_quote_notification_email` varchar(200) DEFAULT NULL, `config_ticket_prefix` varchar(200) DEFAULT NULL, `config_ticket_next_number` int(11) DEFAULT NULL, `config_ticket_from_name` varchar(200) DEFAULT NULL, diff --git a/get_settings.php b/get_settings.php index 40f4cd35a..b74f7a66c 100644 --- a/get_settings.php +++ b/get_settings.php @@ -58,6 +58,7 @@ $config_quote_footer = $row['config_quote_footer']; $config_quote_from_name = $row['config_quote_from_name']; $config_quote_from_email = $row['config_quote_from_email']; +$config_quote_notification_email = $row['config_quote_notification_email']; // Projects $config_project_prefix = $row['config_project_prefix']; diff --git a/guest_footer.php b/guest_footer.php index c11e4c882..c6e94e3ce 100644 --- a/guest_footer.php +++ b/guest_footer.php @@ -7,6 +7,7 @@ + @@ -23,5 +24,7 @@ + + diff --git a/guest_post.php b/guest_post.php index 410f63ddd..b2fd9ac72 100644 --- a/guest_post.php +++ b/guest_post.php @@ -23,11 +23,44 @@ mysqli_query($mysqli, "UPDATE quotes SET quote_status = 'Accepted' WHERE quote_id = $quote_id"); mysqli_query($mysqli, "INSERT INTO history SET history_status = 'Accepted', history_description = 'Client accepted Quote!', history_quote_id = $quote_id"); + // Notification appNotify("Quote Accepted", "Quote $quote_prefix$quote_number has been accepted by $client_name", "quote.php?quote_id=$quote_id", $client_id); + customAction('quote_accept', $quote_id); + // Internal email notification + + $sql_company = mysqli_query($mysqli, "SELECT company_name FROM companies WHERE company_id = 1"); + $row = mysqli_fetch_array($sql_company); + $company_name = sanitizeInput($row['company_name']); + + $sql_settings = mysqli_query($mysqli, "SELECT * FROM settings WHERE company_id = 1"); + $row = mysqli_fetch_array($sql_settings); + $config_smtp_host = $row['config_smtp_host']; + $config_smtp_port = intval($row['config_smtp_port']); + $config_smtp_encryption = $row['config_smtp_encryption']; + $config_smtp_username = $row['config_smtp_username']; + $config_smtp_password = $row['config_smtp_password']; + $config_quote_from_name = sanitizeInput($row['config_quote_from_name']); + $config_quote_from_email = sanitizeInput($row['config_quote_from_email']); + $config_quote_notification_email = sanitizeInput($row['config_quote_notification_email']); + $config_base_url = sanitizeInput($config_base_url); + + if (!empty($config_smtp_host) && !empty($config_quote_notification_email)) { + $subject = "Quote Accepted - $client_name - Quote $quote_prefix$quote_number"; + $body = "Hello,

This is a notification that a quote has been accepted in ITFlow.

Client: $client_name
Quote: $quote_prefix$quote_number

~
$company_name - Billing
$config_quote_from_email"; + + $data[] = [ + 'from' => $config_quote_from_email, + 'from_name' => $config_quote_from_name, + 'recipient' => $config_quote_notification_email, + 'subject' => $subject, + 'body' => $body, + ]; + + $mail = addToMailQueue($mysqli, $data); + } - customAction('quote_accept', $quote_id); $_SESSION['alert_message'] = "Quote Accepted"; header("Location: " . $_SERVER["HTTP_REFERER"]); } else { @@ -51,10 +84,44 @@ mysqli_query($mysqli, "UPDATE quotes SET quote_status = 'Declined' WHERE quote_id = $quote_id"); mysqli_query($mysqli, "INSERT INTO history SET history_status = 'Declined', history_description = 'Client declined Quote!', history_quote_id = $quote_id"); + // Notification appNotify("Quote Declined", "Quote $quote_prefix$quote_number has been declined by $client_name", "quote.php?quote_id=$quote_id", $client_id); - customAction('quote_decline', $quote_id); + + // Internal email notification + + $sql_company = mysqli_query($mysqli, "SELECT company_name FROM companies WHERE company_id = 1"); + $row = mysqli_fetch_array($sql_company); + $company_name = sanitizeInput($row['company_name']); + + $sql_settings = mysqli_query($mysqli, "SELECT * FROM settings WHERE company_id = 1"); + $row = mysqli_fetch_array($sql_settings); + $config_smtp_host = $row['config_smtp_host']; + $config_smtp_port = intval($row['config_smtp_port']); + $config_smtp_encryption = $row['config_smtp_encryption']; + $config_smtp_username = $row['config_smtp_username']; + $config_smtp_password = $row['config_smtp_password']; + $config_quote_from_name = sanitizeInput($row['config_quote_from_name']); + $config_quote_from_email = sanitizeInput($row['config_quote_from_email']); + $config_quote_notification_email = sanitizeInput($row['config_quote_notification_email']); + $config_base_url = sanitizeInput($config_base_url); + + if (!empty($config_smtp_host) && !empty($config_quote_notification_email)) { + $subject = "Quote Declined - $client_name - Quote $quote_prefix$quote_number"; + $body = "Hello,

This is a notification that a quote has been declined in ITFlow.

Client: $client_name
Quote: $quote_prefix$quote_number

~
$company_name - Billing
$config_quote_from_email"; + + $data[] = [ + 'from' => $config_quote_from_email, + 'from_name' => $config_quote_from_name, + 'recipient' => $config_quote_notification_email, + 'subject' => $subject, + 'body' => $body, + ]; + + $mail = addToMailQueue($mysqli, $data); + } + $_SESSION['alert_type'] = "danger"; $_SESSION['alert_message'] = "Quote Declined"; header("Location: " . $_SERVER["HTTP_REFERER"]); diff --git a/guest_view_quote.php b/guest_view_quote.php index 2996c1bdf..b909b79ab 100644 --- a/guest_view_quote.php +++ b/guest_view_quote.php @@ -44,7 +44,6 @@ $quote_amount = floatval($row['quote_amount']); $quote_currency_code = nullable_htmlentities($row['quote_currency_code']); $quote_note = nullable_htmlentities($row['quote_note']); -$category_id = intval($row['category_id']); $client_id = intval($row['client_id']); $client_name = nullable_htmlentities($row['client_name']); $client_name_escaped = sanitizeInput($row['client_name']); @@ -273,10 +272,10 @@ strtotime("now")) { ?> - + Accept - + Decline @@ -712,7 +711,6 @@ } -