Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New buttons for edit and delete pre_post prompt for each function #28791

Merged
merged 1 commit into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 37 additions & 1 deletion htdocs/ai/admin/custom_prompt.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,25 @@
$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
Expand All @@ -152,11 +171,25 @@

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 .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
$out .= '<input type="hidden" name="token" value="'.newToken().'">';
$out .= '<input type="hidden" name="action" value="update">';


$out .= '<table class="noborder centpercent">';
$out .= '<thead>';
$out .= '<tr class="liste_titre">';
Expand Down Expand Up @@ -235,7 +268,10 @@

$out .= '<thead>';
$out .= '<tr class="liste_titre">';
$out .= '<td>'.$arrayofaifeatures[$key]['picto'].' '.$langs->trans($arrayofaifeatures[$key]['label']).'</td>';
$out .= '<td>'.$arrayofaifeatures[$key]['picto'].' '.$langs->trans($arrayofaifeatures[$key]['label']);
$out .= '<a class="editfielda reposition marginleftonly marginrighttonly " href="'.$_SERVER["PHP_SELF"].'?action=editproperty&token='.newToken().'&key='.urlencode($key).'">'.img_edit().'</a>';
$out .= '<a class="deletefielda marginleftonly right" href="'.$_SERVER["PHP_SELF"].'?action=deleteproperty&token='.newToken().'&key='.urlencode($key).'">'.img_delete().'</a>';
$out .= '</td>';
$out .= '<td></td>';
$out .= '</tr>';
$out .= '</thead>';
Expand Down
1 change: 1 addition & 0 deletions htdocs/langs/en_US/help.lang
Original file line number Diff line number Diff line change
Expand Up @@ -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: <br><b><a href="%s" target="_blank" rel="noopener noreferrer">%s</a></b>
ConfirmDeleteProperty=Are you sure you want to delete this property ?
Loading