diff --git a/htdocs/ai/admin/custom_prompt.php b/htdocs/ai/admin/custom_prompt.php index c784e9ae3b8..8f93431e363 100644 --- a/htdocs/ai/admin/custom_prompt.php +++ b/htdocs/ai/admin/custom_prompt.php @@ -126,6 +126,25 @@ if ($action == 'update' && !GETPOST('cancel')) { $action = 'edit'; } +if ($action == 'confirm_deleteproperty') { + $key = GETPOST('key', 'alpha'); + + //var_dump($currentConfigurations[$key]);exit; + if (isset($currentConfigurations[$key])) { + unset($currentConfigurations[$key]); + + $newConfigurationsJson = json_encode($currentConfigurations, JSON_UNESCAPED_UNICODE); + $res = dolibarr_set_const($db, 'AI_CONFIGURATIONS_PROMPT', $newConfigurationsJson, 'chaine', 0, '', $conf->entity); + if ($res) { + header("Location: ".$_SERVER['PHP_SELF']); + setEventMessages($langs->trans("SetupDeleted"), null, 'mesgs'); + exit; + } else { + setEventMessages($langs->trans("ErrorDeleting"), null, 'errors'); + } + } +} + /* * View @@ -152,11 +171,25 @@ $newbutton = ''; print load_fiche_titre($langs->trans("AIPromptForFeatures"), $newbutton, ''); +if ($action == 'deleteproperty') { + $formconfirm = $form->formconfirm( + $_SERVER["PHP_SELF"].'?key='.urlencode(GETPOST('key', 'alpha')), + $langs->trans('Delete'), + $langs->trans('ConfirmDeleteProperty', GETPOST('key', 'alpha')), + 'confirm_deleteproperty', + '', + 0, + 1 + ); + print $formconfirm; +} + if ($action == 'edit') { $out .= '