diff --git a/api_key_add_modal.php b/api_key_add_modal.php index 903e8ea6..1eba6573 100644 --- a/api_key_add_modal.php +++ b/api_key_add_modal.php @@ -52,13 +52,12 @@ $key = randomString(156);
- +
@@ -103,7 +103,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()")); @@ -127,11 +127,11 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()")); - + Archive - + Delete @@ -164,7 +164,7 @@ require_once "client_certificate_export_modal.php"; ?> - +
-
-
- +
@@ -115,7 +115,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()")); @@ -134,13 +134,13 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()")); - + Archive - + Delete @@ -172,7 +172,7 @@ require_once "client_domain_export_modal.php"; ?> - +
-
-
- +
@@ -127,13 +127,12 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()")); @@ -153,11 +152,11 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()")); - + Archive - + Delete @@ -190,8 +189,7 @@ 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 mysqli_query($mysqli, "ALTER TABLE `tickets` ADD `ticket_schedule` DATETIME DEFAULT NULL AFTER `ticket_billable`"); // // 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'"); + + // if (CURRENT_DATABASE_VERSION == '1.0.5') { + // // Insert queries here required to update to DB version 1.0.6 + // // Then, update the database to the next sequential version + // mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '1.0.6'"); // } } 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 a64c5fd4..43f948b6 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, @@ -1761,4 +1765,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..74596116 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(); @@ -574,10 +601,11 @@ if (isset($_GET['download_database'])) { $sqlScript .= "\n"; } - if (!empty($sqlScript)) - { + if (!empty($sqlScript)) { + + $company_name = $session_company_name; // Save the SQL script to a backup file - $backup_file_name = date('Y-m-d') . '_' . $config_company_name . '_backup.sql'; + $backup_file_name = date('Y-m-d') . '_ITFlow_backup.sql'; $fileHandler = fopen($backup_file_name, 'w+'); $number_of_lines = fwrite($fileHandler, $sqlScript); fclose($fileHandler); 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

+
+
+ + + +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ + + + +
+
+ +
-
@@ -65,7 +67,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
-
+
- +
- - )" + )" data-target="#editNetworkModal">
@@ -107,7 +109,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()")); @@ -149,7 +151,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()")); - + Secret key
- +
diff --git a/settings_side_nav.php b/settings_side_nav.php index 36761570..9a7ea305 100644 --- a/settings_side_nav.php +++ b/settings_side_nav.php @@ -30,64 +30,12 @@ - - - - - - - - - - - - - - - - - - - @@ -105,13 +53,14 @@ --> + - + + + + + + + + + + + + + + + + + + + + + + + + + +
- +