From 40434773c7b808725097f6ad767d3000b55bd814 Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Tue, 12 Mar 2024 18:22:59 +0100 Subject: [PATCH] New buttons for edit and delete pre_post prompt for each function --- htdocs/ai/admin/custom_prompt.php | 38 ++++++++++++++++++++++++++++++- htdocs/langs/en_US/help.lang | 1 + 2 files changed, 38 insertions(+), 1 deletion(-) 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 .= '
'; $out .= ''; $out .= ''; + $out .= ''; $out .= ''; $out .= ''; @@ -235,7 +268,10 @@ if ($action == 'edit' || $action == 'create') { $out .= ''; $out .= ''; - $out .= ''; + $out .= ''; $out .= ''; $out .= ''; $out .= ''; diff --git a/htdocs/langs/en_US/help.lang b/htdocs/langs/en_US/help.lang index 17a6104d59a..ccfb6d8468d 100644 --- a/htdocs/langs/en_US/help.lang +++ b/htdocs/langs/en_US/help.lang @@ -21,3 +21,4 @@ LinkToGoldMember=You can call one of the trainers preselected by Dolibarr for yo PossibleLanguages=Supported languages SubscribeToFoundation=Help the Dolibarr project, subscribe to the foundation SeeOfficalSupport=For official Dolibarr support in your language:
%s +ConfirmDeleteProperty=Are you sure you want to delete this property ? \ No newline at end of file
'.$arrayofaifeatures[$key]['picto'].' '.$langs->trans($arrayofaifeatures[$key]['label']).''.$arrayofaifeatures[$key]['picto'].' '.$langs->trans($arrayofaifeatures[$key]['label']); + $out .= ''.img_edit().''; + $out .= ''.img_delete().''; + $out .= '