diff --git a/htdocs/ai/admin/setup.php b/htdocs/ai/admin/setup.php index 8df3b7bd9e2..cd3eec1c01b 100644 --- a/htdocs/ai/admin/setup.php +++ b/htdocs/ai/admin/setup.php @@ -28,7 +28,8 @@ // Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"; -require_once '../lib/ai.lib.php'; +require_once DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php"; +require_once DOL_DOCUMENT_ROOT."/ai/lib/ai.lib.php"; /** * @var Conf $conf @@ -38,7 +39,9 @@ require_once '../lib/ai.lib.php'; * @var User $user */ -$langs->loadLangs(array("admin")); +$langs->loadLangs(array("admin", "website", "other")); + +$arrayofaifeatures = getLitOfAIFeatures(); // Parameters $action = GETPOST('action', 'aZ09'); @@ -49,10 +52,7 @@ if (empty($action)) { $action = 'edit'; } -$value = GETPOST('value', 'alpha'); -$label = GETPOST('label', 'alpha'); -$scandir = GETPOST('scan_dir', 'alpha'); -$type = 'myobject'; +$content = GETPOST('content'); $error = 0; $setupnotempty = 0; @@ -163,5 +163,55 @@ if (empty($setupnotempty)) { // Page end print dol_get_fiche_end(); + +// Section to test +print '
'; +print ''; +print ''; +print ''; + +$functioncode = GETPOST('functioncode'); +$out = ''; + +if ($functioncode) { + $labeloffeature = empty($arrayofaifeatures[GETPOST('functioncode')]['label']) ? 'Undefined' : $arrayofaifeatures[GETPOST('functioncode')]['label']; + + $out .= $langs->trans("Test").' '.$labeloffeature.'...

'; + + if (GETPOST('functioncode') == 'textgenerationemail') { + $showlinktoai = 1; + $showlinktolayout = 0; + + + $neweditor = new DolEditor('aicontenttotest', $content); + $out .= $neweditor->Create(1); + + $out .= $form->buttonsSaveCancel("Test"); + } else { + $out .= $langs->trans("FeatureNotYetAvailable").'

'; + $functioncode = ''; + } +} + +if (!$functioncode) { + // Combo list of AI features + $out .= ''; + $out .= ajax_combobox("functioncode"); + + $out .= ''; +} +print $out; + +print '
'; + llxFooter(); $db->close(); diff --git a/htdocs/ai/lib/ai.lib.php b/htdocs/ai/lib/ai.lib.php index fe8c6232db0..25aa3482626 100644 --- a/htdocs/ai/lib/ai.lib.php +++ b/htdocs/ai/lib/ai.lib.php @@ -23,6 +23,30 @@ * \brief Library files with common functions for Ai */ + +/** + * Prepare admin pages header + * + * @return array>}> + */ +function getLitOfAIFeatures() +{ + global $langs; + + $arrayofaifeatures = array( + 'textgenerationemail' => array('label' => $langs->trans('TextGeneration').' ('.$langs->trans("EmailContent").')', 'picto'=>'', 'status'=>'dolibarr'), + 'textgenerationwebpage' => array('label' => $langs->trans('TextGeneration').' ('.$langs->trans("WebsitePage").')', 'picto'=>'', 'status'=>'dolibarr'), + 'textgeneration' => array('label' => $langs->trans('TextGeneration').' ('.$langs->trans("Other").')', 'picto'=>'', 'status'=>'notused'), + 'imagegeneration' => array('label' => 'ImageGeneration', 'picto'=>'', 'status'=>'notused'), + 'videogeneration' => array('label' => 'VideoGeneration', 'picto'=>'', 'status'=>'notused'), + 'audiogeneration' => array('label' => 'AudioGeneration', 'picto'=>'', 'status'=>'notused'), + 'transcription' => array('label' => 'Transcription', 'picto'=>'', 'status'=>'notused'), + 'translation' => array('label' => 'Translation', 'picto'=>'', 'status'=>'notused') + ); + + return $arrayofaifeatures; +} + /** * Prepare admin pages header * diff --git a/htdocs/core/tpl/formlayoutai.tpl.php b/htdocs/core/tpl/formlayoutai.tpl.php index 944f6d5722b..bff80825dc9 100644 --- a/htdocs/core/tpl/formlayoutai.tpl.php +++ b/htdocs/core/tpl/formlayoutai.tpl.php @@ -15,26 +15,22 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see . - * - * Need to have the following variables defined: - * $conf - * $formmail - * $formwebsite (optional) - * $showlinktolayout='emailing', 'email', 'websitepage', ... - * $showlinktolayoutlabel='...' - * $showlinktoai ('' or 'textgeneration', 'textgenerationemail', 'textgenerationwebpage', ...) - * $showlinktoailabel='...' - * $htmlname */ -/** + + /** * @var Conf $conf - * @var ?FormMail $formmail - * @var ?FormWebsite $formwebsite - * @var string $htmlname - * @var string $showlinktolayout - * @var string $showlinktolayoutlabel + * @var ?FormMail $formmail + * @var ?FormWebsite $formwebsite + * @var string $htmlname + * @var string $showlinktolayout 'emailing', 'email', 'websitepage', ... + * @var string $showlinktolayoutlabel '...' + * @var string $showlinktoai '' or 'textgeneration', 'textgenerationemail', 'textgenerationwebpage', ... + * @var string $showlinktoailabel '...' + * @var string $htmlname + * @var ?string $out */ -// Protection to avoid direct call of template + +//Protection to avoid direct call of template if (empty($conf) || !is_object($conf)) { print "Error, template page can't be called as URL"; exit(1); @@ -59,9 +55,10 @@ if (empty($htmlname)) { @phan-var-force ?string $out '; -if (!isset($out)) { +if (!isset($out)) { // Init to empty string if not defined $out = ''; } + // Add link to add layout if ($showlinktolayout) { $out .= '';