mirror of
https://github.com/itflow-org/itflow
synced 2026-03-03 12:24:51 +00:00
[Feature] The Start of AI Integration within ITFlow
This commit is contained in:
@@ -193,4 +193,3 @@ require_once "client_network_export_modal.php";
|
|||||||
|
|
||||||
<?php
|
<?php
|
||||||
require_once "footer.php";
|
require_once "footer.php";
|
||||||
|
|
||||||
|
|||||||
@@ -1571,14 +1571,25 @@ if (LATEST_DATABASE_VERSION > CURRENT_DATABASE_VERSION) {
|
|||||||
mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '1.0.3'");
|
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
|
// 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.
|
// 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
|
// Uncomment Below Lines, to add additional database updates
|
||||||
//
|
//
|
||||||
// if (CURRENT_DATABASE_VERSION == '1.0.3') {
|
// if (CURRENT_DATABASE_VERSION == '1.0.4') {
|
||||||
// // Insert queries here required to update to DB 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
|
// // 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 {
|
} else {
|
||||||
|
|||||||
@@ -5,5 +5,5 @@
|
|||||||
* It is used in conjunction with database_updates.php
|
* It is used in conjunction with database_updates.php
|
||||||
*/
|
*/
|
||||||
|
|
||||||
DEFINE("LATEST_DATABASE_VERSION", "1.0.3");
|
DEFINE("LATEST_DATABASE_VERSION", "1.0.4");
|
||||||
|
|
||||||
|
|||||||
6
db.sql
6
db.sql
@@ -1274,6 +1274,10 @@ CREATE TABLE `settings` (
|
|||||||
`config_stripe_expense_vendor` int(11) NOT NULL DEFAULT 0,
|
`config_stripe_expense_vendor` int(11) NOT NULL DEFAULT 0,
|
||||||
`config_stripe_expense_category` 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_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_flat_fee` decimal(15,2) NOT NULL DEFAULT 0.30,
|
||||||
`config_stripe_client_pays_fees` tinyint(1) NOT NULL DEFAULT 0,
|
`config_stripe_client_pays_fees` tinyint(1) NOT NULL DEFAULT 0,
|
||||||
`config_azure_client_id` varchar(200) DEFAULT NULL,
|
`config_azure_client_id` varchar(200) DEFAULT NULL,
|
||||||
@@ -1760,4 +1764,4 @@ CREATE TABLE `vendors` (
|
|||||||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
||||||
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
/*!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
|
||||||
|
|||||||
@@ -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_flat_fee = floatval($row['config_stripe_flat_fee']);
|
||||||
$config_stripe_client_pays_fees = intval($row['config_stripe_client_pays_fees']);
|
$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
|
// Modules
|
||||||
$config_module_enable_itdoc = intval($row['config_module_enable_itdoc']);
|
$config_module_enable_itdoc = intval($row['config_module_enable_itdoc']);
|
||||||
$config_module_enable_ticketing = intval($row['config_module_enable_ticketing']);
|
$config_module_enable_ticketing = intval($row['config_module_enable_ticketing']);
|
||||||
|
|||||||
@@ -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'])) {
|
if (isset($_POST['edit_module_settings'])) {
|
||||||
|
|
||||||
validateAdminRole();
|
validateAdminRole();
|
||||||
|
|||||||
58
settings_ai.php
Normal file
58
settings_ai.php
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
require_once "inc_all_settings.php";
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div class="card card-dark">
|
||||||
|
<div class="card-header py-3">
|
||||||
|
<h3 class="card-title"><i class="fas fa-fw fa-robot mr-2"></i>AI</h3>
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<form action="post.php" method="post" autocomplete="off">
|
||||||
|
<input type="hidden" name="csrf_token" value="<?php echo $_SESSION['csrf_token'] ?>">
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label>AI Provider</label>
|
||||||
|
<div class="input-group">
|
||||||
|
<div class="input-group-prepend">
|
||||||
|
<span class="input-group-text"><i class="fa fa-fw fa-robot"></i></span>
|
||||||
|
</div>
|
||||||
|
<select class="form-control select2" name="provider">
|
||||||
|
<option value="" <?php if($config_ai_enable == 0) { echo "selected"; } ?> >Disabled</option>
|
||||||
|
<option <?php if($config_ai_provider == "Ollama") { echo "selected"; } ?> >Ollama</option>
|
||||||
|
<option <?php if($config_ai_provider == "OpenAI") { echo "selected"; } ?> >OpenAI</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label>URL</label>
|
||||||
|
<div class="input-group">
|
||||||
|
<div class="input-group-prepend">
|
||||||
|
<span class="input-group-text"><i class="fa fa-fw fa-globe"></i></span>
|
||||||
|
</div>
|
||||||
|
<input type="url" class="form-control" name="url" value="<?php echo nullable_htmlentities($config_ai_url); ?>" placeholder="ex https://ai.company.ext/api">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label>API Key</label>
|
||||||
|
<div class="input-group">
|
||||||
|
<div class="input-group-prepend">
|
||||||
|
<span class="input-group-text"><i class="fa fa-fw fa-key"></i></span>
|
||||||
|
</div>
|
||||||
|
<input type="text" class="form-control" name="api_key" value="<?php echo nullable_htmlentities($config_ai_api_key); ?>" placeholder="Enter API key here">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<button type="submit" name="edit_ai_settings" class="btn btn-primary text-bold"><i class="fa fa-check mr-2"></i>Save</button>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
require_once "footer.php";
|
||||||
|
|
||||||
@@ -228,6 +228,13 @@
|
|||||||
</li>
|
</li>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
|
<li class="nav-item">
|
||||||
|
<a href="settings_ai.php" class="nav-link <?php if (basename($_SERVER["PHP_SELF"]) == "settings_ai.php") { echo "active"; } ?>">
|
||||||
|
<i class="nav-icon fas fa-robot"></i>
|
||||||
|
<p>AI</p>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a href="settings_integrations.php" class="nav-link <?php if (basename($_SERVER["PHP_SELF"]) == "settings_integrations.php") { echo "active"; } ?>">
|
<a href="settings_integrations.php" class="nav-link <?php if (basename($_SERVER["PHP_SELF"]) == "settings_integrations.php") { echo "active"; } ?>">
|
||||||
<i class="nav-icon fas fa-plug"></i>
|
<i class="nav-icon fas fa-plug"></i>
|
||||||
|
|||||||
Reference in New Issue
Block a user