diff --git a/client_networks.php b/client_networks.php index c11b9e77..85c439d5 100644 --- a/client_networks.php +++ b/client_networks.php @@ -193,4 +193,3 @@ require_once "client_network_export_modal.php"; CURRENT_DATABASE_VERSION) { mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '1.0.3'"); } + if (CURRENT_DATABASE_VERSION == '1.0.3') { + //Insert queries here required to update to DB version 1.0.4 + mysqli_query($mysqli, "ALTER TABLE `settings` ADD `config_ai_enable` TINYINT(1) DEFAULT 0 AFTER `config_stripe_percentage_fee`"); + mysqli_query($mysqli, "ALTER TABLE `settings` ADD `config_ai_provider` VARCHAR(250) DEFAULT NULL AFTER `config_ai_enable`"); + mysqli_query($mysqli, "ALTER TABLE `settings` ADD `config_ai_url` VARCHAR(250) DEFAULT NULL AFTER `config_ai_provider`"); + mysqli_query($mysqli, "ALTER TABLE `settings` ADD `config_ai_api_key` VARCHAR(250) DEFAULT NULL AFTER `config_ai_url`"); + + //Then, update the database to the next sequential version + mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '1.0.4'"); + } + // Be sure to change database_version.php to reflect the version you are updating to here // Please add this same comment block to the bottom of this file, and update the version number. // Uncomment Below Lines, to add additional database updates // - // if (CURRENT_DATABASE_VERSION == '1.0.3') { - // // Insert queries here required to update to DB version 1.0.4 + // if (CURRENT_DATABASE_VERSION == '1.0.4') { + // // Insert queries here required to update to DB version 1.0.5 // // Then, update the database to the next sequential version - // mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '1.0.4'"); + // mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '1.0.5'"); // } } else { diff --git a/database_version.php b/database_version.php index 6ede6e49..6fa7aaba 100644 --- a/database_version.php +++ b/database_version.php @@ -5,5 +5,5 @@ * It is used in conjunction with database_updates.php */ -DEFINE("LATEST_DATABASE_VERSION", "1.0.3"); +DEFINE("LATEST_DATABASE_VERSION", "1.0.4"); diff --git a/db.sql b/db.sql index 81e80bb1..4dfd81fc 100644 --- a/db.sql +++ b/db.sql @@ -1274,6 +1274,10 @@ CREATE TABLE `settings` ( `config_stripe_expense_vendor` int(11) NOT NULL DEFAULT 0, `config_stripe_expense_category` int(11) NOT NULL DEFAULT 0, `config_stripe_percentage_fee` decimal(4,4) NOT NULL DEFAULT 0.0290, + `config_ai_enable` tinyint(1) DEFAULT 0, + `config_ai_provider` varchar(250) DEFAULT NULL, + `config_ai_url` varchar(250) DEFAULT NULL, + `config_ai_api_key` varchar(250) DEFAULT NULL, `config_stripe_flat_fee` decimal(15,2) NOT NULL DEFAULT 0.30, `config_stripe_client_pays_fees` tinyint(1) NOT NULL DEFAULT 0, `config_azure_client_id` varchar(200) DEFAULT NULL, @@ -1760,4 +1764,4 @@ CREATE TABLE `vendors` ( /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2024-01-27 23:58:10 +-- Dump completed on 2024-02-05 21:00:37 diff --git a/get_settings.php b/get_settings.php index 51e098f1..69c3a781 100644 --- a/get_settings.php +++ b/get_settings.php @@ -90,6 +90,12 @@ $config_stripe_percentage_fee = floatval($row['config_stripe_percentage_fee']); $config_stripe_flat_fee = floatval($row['config_stripe_flat_fee']); $config_stripe_client_pays_fees = intval($row['config_stripe_client_pays_fees']); +// AI Provider Details +$config_ai_enable = intval($row['config_ai_enable']); +$config_ai_provider = $row['config_ai_provider']; +$config_ai_url = $row['config_ai_url']; +$config_ai_api_key = $row['config_ai_api_key']; + // Modules $config_module_enable_itdoc = intval($row['config_module_enable_itdoc']); $config_module_enable_ticketing = intval($row['config_module_enable_ticketing']); diff --git a/post/setting.php b/post/setting.php index 024e28c4..7639a0b6 100644 --- a/post/setting.php +++ b/post/setting.php @@ -448,6 +448,33 @@ if (isset($_POST['edit_integrations_settings'])) { } +if (isset($_POST['edit_ai_settings'])) { + + validateCSRFToken($_POST['csrf_token']); + + validateAdminRole(); + + $provider = sanitizeInput($_POST['provider']); + if($provider){ + $ai_enable = 1; + } else { + $ai_enable = 0; + } + + $url = sanitizeInput($_POST['url']); + $api_key = sanitizeInput($_POST['api_key']); + + mysqli_query($mysqli,"UPDATE settings SET config_ai_enable = $ai_enable, config_ai_provider = '$provider', config_ai_url = '$url', config_ai_api_key = '$api_key' WHERE company_id = 1"); + + //Logging + mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Settings', log_action = 'Edit', log_description = '$session_name edited AI settings', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_user_id = $session_user_id"); + + $_SESSION['alert_message'] = "You updated the AI Settings"; + + header("Location: " . $_SERVER["HTTP_REFERER"]); + +} + if (isset($_POST['edit_module_settings'])) { validateAdminRole(); diff --git a/settings_ai.php b/settings_ai.php new file mode 100644 index 00000000..adc634e1 --- /dev/null +++ b/settings_ai.php @@ -0,0 +1,58 @@ + + +
+
+

AI

+
+
+
+ + +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ + + +
+
+
+ + + +