30require
'../../main.inc.php';
38require_once DOL_DOCUMENT_ROOT.
"/core/lib/admin.lib.php";
39require_once DOL_DOCUMENT_ROOT.
"/core/lib/files.lib.php";
40require_once DOL_DOCUMENT_ROOT.
"/ai/lib/ai.lib.php";
41require_once DOL_DOCUMENT_ROOT.
"/ai/class/ai.class.php";
42require_once DOL_DOCUMENT_ROOT.
"/core/class/html.formai.class.php";
44$langs->loadLangs(array(
"admin",
"website",
"other"));
50$action =
GETPOST(
'action',
'aZ09');
51$backtopage =
GETPOST(
'backtopage',
'alpha');
52$cancel =
GETPOST(
'cancel',
'alpha');
53$modulepart =
GETPOST(
'modulepart',
'aZ09');
55$functioncode =
GETPOST(
'functioncode',
'alpha');
56$pre_prompt =
GETPOST(
'prePrompt');
57$post_prompt =
GETPOST(
'postPrompt');
58$blacklists =
GETPOST(
'blacklists');
60$key = (string)
GETPOST(
'key',
'alpha');
80if (!class_exists(
'FormSetup')) {
81 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formsetup.class.php';
90$ocrmodelfieldname =
'AI_API_'.strtoupper($aiservice).
'_MODEL_DOCPARSING';
91$ocrmodeldefault = (!empty($arrayofai[$aiservice][
'docparsing'][
'default']) && $arrayofai[$aiservice][
'docparsing'][
'default'] !=
'na') ? $arrayofai[$aiservice][
'docparsing'][
'default'] :
'';
95$formSetup->formHiddenInputs[
'action'] =
"updatefeaturemodel";
96foreach ($arrayofaifeatures as $featurekey => $feature) {
97 $newfeaturekey = $featurekey;
98 if (preg_match(
'/^text/', $featurekey)) {
99 $newfeaturekey =
'textgeneration';
101 $item = $formSetup->newItem(
'AI_API_'.strtoupper($aiservice).
'_MODEL_'.$feature[
"function"]);
103 if ($aiservice ==
'custom') {
104 $item->nameText = $langs->trans(
"AI_API_MODEL_".$feature[
"function"]);
105 } elseif (!empty($arrayofai[$aiservice][$newfeaturekey][
'default']) && $arrayofai[$aiservice][$newfeaturekey][
'default'] !=
'na') {
106 $item->nameText =
'<span class="valignmiddle">'.$langs->trans(
"AI_API_MODEL_".$feature[
"function"]).
' </span><span class="opacitymedium valignmiddle">('.$langs->trans(
"Default").
' = '.$arrayofai[$aiservice][$newfeaturekey][
'default'].
')</span>';
107 if (!empty($arrayofai[$aiservice][$newfeaturekey][
'examples'])) {
108 $htmltooltip = $langs->trans(
"Example").
': '.$arrayofai[$aiservice][$newfeaturekey][
'examples'];
109 $item->nameText .= $form->textwithpicto(
'', $htmltooltip);
112 $item->nameText = $langs->trans(
"AI_API_MODEL_".$feature[
"function"]).
' <span class="opacitymedium">('.$langs->trans(
"None").
')</span>';
115 if ($feature[
"function"] ==
'DOCPARSING' &&
getDolGlobalString(
'AI_USED_FOR_FILE_TO_TEXT_CONVERTION')) {
116 $item->nameText .=
' '.$form->textwithpicto(
'', $langs->trans(
"AIUsedForFileToTextConvertionModelHelp"), 1,
'info');
118 $item->cssClass =
'minwidth500 input';
121$setupnotempty += count($formSetup->items);
123$dirmodels = array_merge(array(
'/'), (array)
$conf->modules_parts[
'models']);
133$currentConfigurations = json_decode($currentConfigurationsJson,
true);
135if ($action ==
'updatefeaturemodel' && !empty($user->admin)) {
136 $formSetup->saveConfFromPost();
140if ($action ==
'update' && $cancel) {
144if ($action ==
'update' && !$cancel && !$test) {
146 if (empty($functioncode)) {
148 setEventMessages($langs->trans(
'ErrorInputRequired'),
null,
'errors');
150 if (!is_array($currentConfigurations)) {
151 $currentConfigurations = [];
154 $blacklistArray = array_filter(array_map(
'trim', explode(
',', $blacklists)));
156 if (empty($functioncode) || (empty($pre_prompt) && empty($post_prompt) && empty($blacklists))) {
157 if (isset($currentConfigurations[$functioncode])) {
158 unset($currentConfigurations[$functioncode]);
161 $currentConfigurations[$functioncode] = [
162 'prePrompt' => $pre_prompt,
163 'postPrompt' => $post_prompt,
164 'blacklists' => $blacklistArray,
168 $newConfigurationsJson = json_encode($currentConfigurations, JSON_UNESCAPED_UNICODE);
169 $result =
dolibarr_set_const($db,
'AI_CONFIGURATIONS_PROMPT', $newConfigurationsJson,
'chaine', 0,
'',
$conf->entity);
172 header(
"Location: ".$_SERVER[
'PHP_SELF']);
173 setEventMessages($langs->trans(
"SetupSaved"),
null,
'mesgs');
176 setEventMessages($langs->trans(
"ErrorUpdating"),
null,
'errors');
184if ($action ==
'updatePrompts' && !$test) {
185 $blacklistArray = array_filter(array_map(
'trim', explode(
',', $blacklists)));
187 $currentConfigurations[$key] = [
188 'prePrompt' => $pre_prompt,
189 'postPrompt' => $post_prompt,
190 'blacklists' => $blacklistArray,
193 $newConfigurationsJson = json_encode($currentConfigurations, JSON_UNESCAPED_UNICODE);
194 $result =
dolibarr_set_const($db,
'AI_CONFIGURATIONS_PROMPT', $newConfigurationsJson,
'chaine', 0,
'',
$conf->entity);
198 setEventMessages($langs->trans(
"SetupSaved"),
null,
'mesgs');
200 setEventMessages($langs->trans(
"ErrorUpdating"),
null,
'errors');
206if ($action ==
'updatePrompts' && $test) {
211if ($action ==
'confirm_deleteproperty' &&
GETPOST(
'confirm') ==
'yes') {
212 if (isset($currentConfigurations[$key])) {
213 unset($currentConfigurations[$key]);
215 $newConfigurationsJson = json_encode($currentConfigurations, JSON_UNESCAPED_UNICODE);
216 $res =
dolibarr_set_const($db,
'AI_CONFIGURATIONS_PROMPT', $newConfigurationsJson,
'chaine', 0,
'',
$conf->entity);
218 header(
"Location: ".$_SERVER[
'PHP_SELF']);
219 setEventMessages($langs->trans(
"RecordDeleted"),
null,
'mesgs');
222 setEventMessages($langs->trans(
"NoRecordDeleted"),
null,
'errors');
231$ocrtestfilename =
'';
235$ocrtstformvisible = 0;
236if ($action ==
'testocr') {
238 $ocrtstformvisible = 1;
239 $upload_dir =
$conf->ai->dir_temp;
242 if (empty($_FILES[
'ocrtstfile'][
'name']) || !empty($_FILES[
'ocrtstfile'][
'error'])) {
243 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"File")),
null,
'errors');
245 $ocrtestfilename = (string) $_FILES[
'ocrtstfile'][
'name'];
247 $resupload =
dol_move_uploaded_file($_FILES[
'ocrtstfile'][
'tmp_name'], $filetotest, 1, 0, (
int) $_FILES[
'ocrtstfile'][
'error'], 0,
'ocrtstfile', $upload_dir);
248 if ($resupload > 0) {
250 $ocrtestservice = $ai->getApiService();
251 $rawfile = $ai->getPayloadToConvertRawFileIntoText($filetotest);
252 if (!empty($rawfile[
'error'])) {
253 setEventMessages($rawfile[
'message'],
null,
'errors');
256 $ocrtestmodel = (isset($rawfile[
'payload'][
'model']) && is_scalar($rawfile[
'payload'][
'model'])) ? (
string) $rawfile[
'payload'][
'model'] :
'';
257 $microtimestart = microtime(
true);
258 $result = $ai->generateContent($rawfile[
'payload'],
'auto', $rawfile[
'function'],
'');
259 $ocrtestduration = microtime(
true) - $microtimestart;
260 if (is_array($result)) {
263 $ocrtestresult = (string) $result;
268 setEventMessages($langs->trans(
"ErrorFailedToSaveFile"),
null,
'errors');
284llxHeader(
'', $langs->trans($title), $help_url,
'', 0, 0,
'',
'',
'',
'mod-ai page-admin_custom_prompt');
286$linkback =
'<a href="'.($backtopage ? $backtopage : DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1').
'">'.img_picto($langs->trans(
"BackToModuleList"),
'back',
'class="pictofixedwidth"').
'<span class="hideonsmartphone">'.$langs->trans(
"BackToModuleList").
'</span></a>';
294$newcardbutton =
dolGetButtonTitle($langs->trans(
'NewCustomPrompt'),
'',
'fa fa-plus-circle', $_SERVER[
"PHP_SELF"].
'?action=create',
'', 1);
303print
load_fiche_titre($langs->trans(
"AIPromptForFeatures", $arrayofai[$aiservice][
'label']), $newcardbutton,
'');
305if ($action ==
'deleteproperty') {
306 $formconfirm = $form->formconfirm(
307 $_SERVER[
"PHP_SELF"].
'?key='.urlencode(
GETPOST(
'key',
'alpha')),
308 $langs->trans(
'Delete'),
309 $langs->trans(
'ConfirmDeleteSetup',
GETPOST(
'key',
'alpha')),
310 'confirm_deleteproperty',
318if ($action ==
'create') {
319 $out =
'<div class="addcustomprompt">';
321 $out .=
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
322 $out .=
'<input type="hidden" name="token" value="'.newToken().
'">';
323 $out .=
'<input type="hidden" name="action" value="update">';
326 $out .=
'<table class="noborder centpercent">';
328 $out .=
'<tr class="liste_titre">';
329 $out .=
'<td>'.$langs->trans(
'NewCustomPrompt').
'</td>';
335 $out .=
'<tr class="oddeven">';
336 $out .=
'<td class="col-setup-title titlefield">';
337 $out .=
'<span id="module" class="spanforparamtooltip">'.$langs->trans(
"Feature").
'</span>';
341 $out .=
'<select name="functioncode" id="functioncode" class="flat minwidth500">';
342 $out .=
'<option> </option>';
343 foreach ($arrayofaifeatures as $featurekey => $feature) {
344 $labelhtml = $langs->trans($arrayofaifeatures[$featurekey][
'label']).($arrayofaifeatures[$featurekey][
'status'] ==
'notused' ?
' <span class="opacitymedium">('.$langs->trans(
"NotYetAvailable").
')</span>' :
"");
345 $labeltext = $langs->trans($arrayofaifeatures[$featurekey][
'label']);
346 $out .=
'<option value="'.dolPrintHTMLForAttribute($featurekey).
'" data-html="'.dolPrintHTMLForAttribute($labelhtml).
'">'.dolPrintHTML($labeltext).
'</option>';
350 $out .=
'<script type="text/javascript">
351 jQuery(document).ready(function() {
352 jQuery("#functioncode").on("change", function() {
353 console.log("We change value of ai function");
354 var changedValue = $(this).val();
355 console.log(changedValue);
356 var arrayplaceholder = {';
357 foreach ($arrayofaifeatures as $featurekey => $feature) {
361 jQuery("#prePromptInput'.dol_sanitizeKeyCode($key).
'").val(arrayplaceholder[changedValue]);
370 $out .=
'<tr class="oddeven">';
371 $out .=
'<td class="col-setup-title">';
372 $out .=
'<span id="prePrompt" class="spanforparamtooltip">';
373 $out .= $form->textwithpicto($langs->trans(
"Pre-Prompt"), $langs->trans(
"Pre-PromptHelp"));
377 $out .=
'<textarea class="flat minwidth500 quatrevingtpercent" id="prePromptInput'.$key.
'" name="prePrompt" rows="2"></textarea>';
380 $out .=
'<tr class="oddeven">';
381 $out .=
'<td class="col-setup-title">';
382 $out .=
'<span id="postPrompt" class="spanforparamtooltip">';
383 $out .= $form->textwithpicto($langs->trans(
"Post-Prompt"), $langs->trans(
"Post-PromptHelp"));
387 $out .=
'<textarea class="flat minwidth500 quatrevingtpercent" id="postPromptInput" name="postPrompt" rows="2"></textarea>';
390 $out .=
'<tr class="oddeven">';
391 $out .=
'<td class="col-setup-title">';
392 $out .=
'<span id="blacklists" class="spanforparamtooltip">';
393 $out .= $form->textwithpicto($langs->trans(
"BlackListWords"), $langs->trans(
"BlackListWordsAIHelp").
'.<br>'.$langs->trans(
"BlackListWordsHelp"));
397 $out .=
'<input type="text" class="flat minwidth500 quatrevingtpercent" id="blacklistsInput" name="blacklists">';
403 $out .= $form->buttonsSaveCancel(
"Add",
"");
414if ($action ==
'edit' || $action ==
'create' || $action ==
'deleteproperty') {
417 if (empty($currentConfigurations)) {
418 if ($action !=
'create') {
419 print
'<!-- no custom prompt-->'.
"\n";
420 print
'<span class="opacitymedium">'.$langs->trans(
"None").
'</span>';
428 foreach ($currentConfigurations as $confkey => $config) {
429 if (!empty($confkey) && !preg_match(
'/^[a-z]+$/i', $confkey)) {
433 $out .=
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
434 $out .=
'<input type="hidden" name="token" value="'.newToken().
'">';
435 $out .=
'<input type="hidden" name="key" value="'.$confkey.
'" />';
436 $out .=
'<input type="hidden" name="action" value="updatePrompts">';
437 $out .=
'<input type="hidden" name="page_y" value="">';
439 $out .=
'<table class="noborder centpercent">';
441 $out .=
'<tr class="liste_titre">';
442 $out .=
'<td class="titlefield">'.$arrayofaifeatures[$confkey][
'picto'].
' '.$langs->trans($arrayofaifeatures[$confkey][
'label']);
443 $out .=
'<a class="deletefielda reposition marginleftonly right" href="'.$_SERVER[
"PHP_SELF"].
'?action=deleteproperty&token='.
newToken().
'&key='.urlencode($confkey).
'">'.img_delete().
'</a>';
450 $out .=
'<tr class="oddeven">';
451 $out .=
'<td class="col-setup-title">';
452 $out .=
'<span id="prePrompt" class="spanforparamtooltip">'.$langs->trans(
"Pre-Prompt").
'</span>';
455 $out .=
'<textarea class="flat minwidth500 quatrevingtpercent" id="prePromptInput_'.$confkey.
'" name="prePrompt" rows="2">'.$config[
'prePrompt'].
'</textarea>';
459 $out .=
'<tr class="oddeven">';
460 $out .=
'<td class="col-setup-title">';
461 $out .=
'<span id="postPrompt" class="spanforparamtooltip">'.$langs->trans(
"Post-Prompt").
'</span>';
464 $out .=
'<textarea class="flat minwidth500 quatrevingtpercent" id="postPromptInput_'.$confkey.
'" name="postPrompt" rows="2">'.$config[
'postPrompt'].
'</textarea>';
468 $out .=
'<tr id="fichetwothirdright-'.$confkey.
'" class="oddeven">';
469 $out .=
'<td>'.$form->textwithpicto($langs->trans(
"BlackListWords"), $langs->trans(
"BlackListWordsHelp")).
'</td>';
471 $out .=
'<input type="text" class="flat minwidth500 quatrevingtpercent" id="blacklist_'.$confkey.
'" name="blacklists" value="'.(isset($config[
'blacklists']) ? implode(
', ', (array) $config[
'blacklists']) :
'').
'">';
476 $out .=
'<td>'.$langs->trans(
"Test").
'</td>';
479 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
481 $formmail->withaiprompt =
'html';
483 $showlinktoai = $confkey;
484 $showlinktoailabel = $langs->trans(
"ToTest");
485 $htmlname = $confkey;
486 $onlyenhancements = $confkey;
487 $showlinktolayout = 0;
490 include DOL_DOCUMENT_ROOT.
'/core/tpl/formlayoutai.tpl.php';
492 $out .=
'<div id="'.$htmlname.
'"></div>';
500 $out .=
'<center><input type="submit" class="button small submitBtn reposition" name="modify" data-index="'.$confkey.
'" value="'.
dol_escape_htmltag($langs->trans(
"Save")).
'"/></center>';
520$runfailservice = is_array($runfail) ? (string) ($runfail[
'service'] ??
'') :
'';
521if ($runfailservice !==
'' && $runfailservice !==
getDolGlobalString(
'AI_API_SERVICE')) {
524if (is_array($runfail) && !empty($runfail[
'model'])) {
525 $msg = $langs->trans(
526 "AIModelRuntimeFailureBanner",
532 if (!empty($modellist[
'models'])) {
534 if ($suggest !==
'') {
535 $msg .=
' '.dol_escape_htmltag($langs->trans(
"AIModelClosestAvailable", $suggest));
542if ($action ==
'edit' || $action ==
'create' || $action ==
'deleteproperty') {
543 print
load_fiche_titre($langs->trans(
"AIModelForFeature", $arrayofai[$aiservice][
'label']),
'',
'');
545 print $formSetup->generateOutput(
true);
551if ($action ==
'edit' || $action ==
'create' || $action ==
'deleteproperty') {
552 print
'<div id="ocrtstformdiv"'.(empty($ocrtstformvisible) ?
' style="display: none"' :
'').
'>';
556 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" enctype="multipart/form-data">';
557 print
'<input type="hidden" name="token" value="'.newToken().
'">';
558 print
'<input type="hidden" name="action" value="testocr">';
559 print
'<input type="hidden" name="page_y" value="">';
560 print
'<table class="noborder centpercent">';
562 print
'<tr class="liste_titre">';
563 print
'<td class="titlefield" colspan="2">'.$langs->trans(
"AI_API_MODEL_DOCPARSING").
' : '.dolPrintLabel($modelforocr !==
'' ? $modelforocr : $langs->trans(
"None")).
'</td>';
567 print
'<tr class="oddeven">';
568 print
'<td class="col-setup-title">'.$langs->trans(
"File").
'</td>';
569 print
'<td><input type="file" class="flat minwidth500" name="ocrtstfile" accept="application/pdf,image/png,image/jpeg,image/gif,image/bmp,image/tiff,image/webp"></td>';
573 print
'<center><input type="submit" class="button small reposition" name="testocr" value="'.dol_escape_htmltag($langs->trans(
"Test")).
'"></center>';
576 if ($ocrtestresult !==
'') {
579 $ocrtestservicelabel = (isset($arrayofai[$ocrtestservice][
'label']) && is_string($arrayofai[$ocrtestservice][
'label'])) ? $arrayofai[$ocrtestservice][
'label'] : $ocrtestservice;
580 print
'<div class="opacitymedium">';
581 print $langs->trans(
"File").
' : '.dolPrintLabel($ocrtestfilename).
' - '.dolPrintLabel($ocrtestservicelabel);
582 print
' - '.$langs->trans(
"AI_API_MODEL_DOCPARSING").
' : '.dolPrintLabel($ocrtestmodel);
583 print
' - '.$langs->trans(
"Duration").
' : '.sprintf(
'%.1f', $ocrtestduration).
' s';
585 print
'<div class="ocrtstresult"><div style="white-space: pre-wrap; line-height: 1em;" class="neutral">'.dolPrintText($ocrtestresult).
'</div></div>';
591 print
'<script nonce="'.getNonce().
'">
592var ocrmodeldefaultisset = '.($ocrmodeldefault !==
'' ?
'true' :
'false').
';
593document.querySelectorAll("input[name=\''.
dol_escape_js($ocrmodelfieldname).
'\']
").forEach(function (i) {
594 var b = document.createElement("a
");
596 b.textContent = \''.dol_escape_js($langs->trans("TestOCR
")).'\';
597 var refreshbuttonstate = function () {
598 b.disabled = (!i.value && !ocrmodeldefaultisset);
599 b.className = "button smallpaddingimp
".concat(b.disabled ? " disabled" : "");
601 b.onclick = function () {
602 if (b.disabled) { return false; }
603 var d = document.getElementById("ocrtstformdiv
");
604 if (d) { d.style.display = (d.style.display === "none
" ? "" : "none
"); }
607 i.insertAdjacentElement("afterend
", b);
608 i.addEventListener("input
", refreshbuttonstate);
609 refreshbuttonstate();
615if (empty($setupnotempty)) {
616 print '<br>'.$langs->trans("NothingToSetup
");
620// Datalist of the provider's available model ids (fed by ajax/list_models.php,
621// cached 1h server-side): every *_MODEL_* text input gets autocompletion, which
622// avoids typos in the seven free-text model fields. The fields stay plain free
623// text (a datalist only suggests, never constrains — required for local AI
624// providers with no model-listing API, where this whole block is a no-op).
625// Active check: a saved model absent from the provider's current list gets a
626// warning picto — warn only, never block, since a listing can be incomplete
627// (aliases, fine-tunes) while the value still works.
628print '<datalist id="ai-model-ids
"></datalist>'."\n
";
629print '<script nonce="'.getNonce().'">
630fetch("'.dol_buildpath('/ai/ajax/list_models.php
', 1).'").then(function (r) { return r.json(); }).then(function (j) {
631 if (!j || !j.models || !j.models.length) return;
632 var dl = document.getElementById("ai-model-ids
");
633 j.models.forEach(function (id) { var o = document.createElement("option
"); o.value = id; dl.appendChild(o); });
634 document.querySelectorAll("input[
name*=\
'_MODEL_\']").forEach(function (i) {
635 i.setAttribute("list", "ai-model-ids");
636 if (i.value && j.models.indexOf(i.value) < 0) {
637 // Closest-match suggestion: longest shared prefix with an offered id
638 var v = i.value.toLowerCase(), best = "", bestlen = 0;
639 j.models.forEach(function (m) {
640 var b = m.toLowerCase(), n = 0;
641 while (n < v.length && n < b.length && v.charAt(n) === b.charAt(n)) n++;
642 if (n > bestlen) { bestlen = n; best = m; }
644 var w = document.createElement("span");
645 w.className = "fas fa-exclamation-triangle pictowarning paddingleft";
646 w.title = \''.dol_escape_js($langs->trans(
"AIModelNotInProviderList")).
'\';
647 if (best && bestlen >= 4) {
648 w.title += \
' \' + \''.dol_escape_js($langs->trans(
"AIModelClosestAvailable",
'{m}')).
'\'.replace(
"{m}", best);
650 i.insertAdjacentElement(
"afterend", w);
653}).
catch(
function () {});
657print dol_get_fiche_end();
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
getListOfAIFeatures()
Prepare admin pages header.
aiAdminPrepareHead()
Prepare admin pages header.
getAiProviderModelList($db, $forcerefresh=false)
Return the list of model ids offered by the configured AI provider, with a 1-hour cache in the consta...
getListOfAIServices()
Get list of available ai services.
getAIErrorMessage($result)
Return a user-friendly error message from the error array returned by Ai\generateContent()
aiSuggestClosestModel($missing, array $models)
Suggest the closest available model id for a model that disappeared from the provider's list: same fa...
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1', $morecss='', $placeholder='')
Convert a html select field into an ajax combobox.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1, $nolog=0)
Remove a file or several files with a mask.
dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disablevirusscan=0, $uploaderrorcode=0, $nohook=0, $keyforsourcefile='addedfile', $upload_dir='', $mode=0)
Check validity of a file upload from an GUI page, and move it to its final destination.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into JavaScript code.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_sanitizeKeyCode($str)
Clean a string to use it as a key or code.
isModEnabled($module)
Is Dolibarr module enabled.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='', $textonpictotooltip='', $cssfordropdown='info_admin')
Show information in HTML for admin users or standard users.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
$conf db name
Only used if Module[ID]Name translation string is not found.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
multi select button
0 = Do not include form tag and submit button -1 = Do not include form tag but include submit button