dolibarr 24.0.0-beta
doc_generic_usergroup_odt.modules.php
1<?php
2/* Copyright (C) 2010-2012 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
4 * Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
5 * Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
6*
7* This program is free software; you can redistribute it and/or modify
8* it under the terms of the GNU General Public License as published by
9* the Free Software Foundation; either version 3 of the License, or
10* (at your option) any later version.
11*
12* This program is distributed in the hope that it will be useful,
13* but WITHOUT ANY WARRANTY; without even the implied warranty of
14* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15* GNU General Public License for more details.
16*
17* You should have received a copy of the GNU General Public License
18* along with this program. If not, see <https://www.gnu.org/licenses/>.
19* or see https://www.gnu.org/
20*/
21
28require_once DOL_DOCUMENT_ROOT.'/core/modules/usergroup/modules_usergroup.class.php';
29require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
30require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php';
31require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
32require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
33require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
34require_once DOL_DOCUMENT_ROOT.'/core/lib/doc.lib.php';
35
36
41{
46 public $version = 'dolibarr';
47
48
54 public function __construct($db)
55 {
56 global $langs, $mysoc;
57
58 // Load translation files required by the page
59 $langs->loadLangs(array("main", "companies"));
60
61 $this->db = $db;
62 $this->name = "ODT templates";
63 $this->description = $langs->trans("DocumentModelOdt");
64 $this->scandir = 'USERGROUP_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan
65
66 // Page size for A4 format
67 $this->type = 'odt';
68 $this->page_largeur = 0;
69 $this->page_hauteur = 0;
70 $this->format = array($this->page_largeur, $this->page_hauteur);
71 $this->marge_gauche = 0;
72 $this->marge_droite = 0;
73 $this->marge_haute = 0;
74 $this->marge_basse = 0;
75
76 $this->option_logo = 1; // Display logo
77 $this->option_tva = 0; // Manage the vat option USERGROUP_TVAOPTION
78 $this->option_modereg = 0; // Display payment mode
79 $this->option_condreg = 0; // Display payment terms
80 $this->option_multilang = 1; // Available in several languages
81 $this->option_escompte = 0; // Displays if there has been a discount
82 $this->option_credit_note = 0; // Support credit notes
83 $this->option_freetext = 1; // Support add of a personalised text
84 $this->option_draft_watermark = 0; // Support add of a watermark on drafts
85
86 if ($mysoc === null) {
87 dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'. getCallerInfoString(), LOG_ERR);
88 return;
89 }
90
91 // Get source company
92 $this->emetteur = $mysoc;
93 if (!$this->emetteur->country_code) {
94 $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined
95 }
96 }
97
98
105 public function info($langs)
106 {
107 global $conf, $langs;
108
109 // Load translation files required by the page
110 $langs->loadLangs(array("errors", "companies"));
111
112 $form = new Form($this->db);
113
114 $odtChosen = getDolGlobalInt('MAIN_PROPAL_CHOOSE_ODT_DOCUMENT') > 0;
115 $odtPath = trim(getDolGlobalString('USERGROUP_ADDON_PDF_ODT_PATH'));
116
117 $texte = $this->description.".<br>\n";
118 $texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST" enctype="multipart/form-data">';
119 $texte .= '<input type="hidden" name="token" value="'.newToken().'">';
120 $texte .= '<input type="hidden" name="page_y" value="">';
121 $texte .= '<input type="hidden" name="action" value="setModuleOptions">';
122 $texte .= '<input type="hidden" name="param1" value="USERGROUP_ADDON_PDF_ODT_PATH">';
123 if ($odtChosen) {
124 $texte .= '<input type="hidden" name="param2" value="USERGROUP_ADDON_PDF_ODT_DEFAULT">';
125 $texte .= '<input type="hidden" name="param3" value="USERGROUP_ADDON_PDF_ODT_TOBILL">';
126 $texte .= '<input type="hidden" name="param4" value="USERGROUP_ADDON_PDF_ODT_CLOSED">';
127 }
128 $texte .= '<table class="nobordernopadding" width="100%">';
129
130 // List of directories area
131 $texte .= '<tr><td>';
132 $texttitle = $langs->trans("ListOfDirectories");
133 $listofdir = explode(',', preg_replace('/[\r\n]+/', ',', $odtPath));
134 $listoffiles = array();
135 foreach ($listofdir as $key => $tmpdir) {
136 $tmpdir = trim($tmpdir);
137 $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir);
138 if (!$tmpdir) {
139 unset($listofdir[$key]);
140 continue;
141 }
142 if (!is_dir($tmpdir)) {
143 $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), '');
144 } else {
145 $tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)');
146 if (count($tmpfiles)) {
147 $listoffiles = array_merge($listoffiles, $tmpfiles);
148 }
149 }
150 }
151 $texthelp = $langs->trans("ListOfDirectoriesForModelGenODT");
152 $texthelp .= '<br><br><span class="opacitymedium">'.$langs->trans("ExampleOfDirectoriesForModelGen").'</span>';
153 // Add list of substitution keys
154 $texthelp .= '<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
155 $texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it
156
157 // Scan directories
158 if (count($listofdir)) {
159 $texte .= $langs->trans("NumberOfModelFilesFound").': <b>'.count($listoffiles).'</b>';
160
161 if ($odtChosen) {
162 // Model for creation
163 $list = ModelePDFUserGroup::liste_modeles($this->db);
164 $texte .= '<table width="50%;">';
165 $texte .= '<tr>';
166 $texte .= '<td width="60%;">'.$langs->trans("DefaultModelPropalCreate").'</td>';
167 $texte .= '<td colspan="">';
168 $texte .= $form->selectarray('value2', $list, getDolGlobalString('USERGROUP_ADDON_PDF_ODT_DEFAULT'));
169 $texte .= "</td></tr>";
170
171 $texte .= '<tr>';
172 $texte .= '<td width="60%;">'.$langs->trans("DefaultModelPropalToBill").'</td>';
173 $texte .= '<td colspan="">';
174 $texte .= $form->selectarray('value3', $list, getDolGlobalString('USERGROUP_ADDON_PDF_ODT_TOBILL'));
175 $texte .= "</td></tr>";
176 $texte .= '<tr>';
177
178 $texte .= '<td width="60%;">'.$langs->trans("DefaultModelPropalClosed").'</td>';
179 $texte .= '<td colspan="">';
180 $texte .= $form->selectarray('value4', $list, getDolGlobalString('USERGROUP_ADDON_PDF_ODT_CLOSED'));
181 $texte .= "</td></tr>";
182 $texte .= '</table>';
183 }
184 $texte .= '<div id="div_'.get_class($this).'" class="hiddenx">';
185 // Show list of found files
186 foreach ($listoffiles as $file) {
187 $texte .= '- '.$file['name'].' <a href="'.DOL_URL_ROOT.'/document.php?modulepart=doctemplates&file=usergroups/'.urlencode(basename($file['name'])).'">'.img_picto('', 'listlight').'</a>';
188 $texte .= ' &nbsp; <a class="reposition" href="'.$_SERVER["PHP_SELF"].'?modulepart=doctemplates&keyforuploaddir=USERGROUP_ADDON_PDF_ODT_PATH&action=deletefile&token='.newToken().'&file='.urlencode(basename($file['name'])).'">'.img_picto('', 'delete').'</a>';
189 $texte .= '<br>';
190 }
191 $texte .= '</div>';
192 }
193
194 $texte .= '<br>';
195 $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1, 3, $this->name);
196 $texte .= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
197 $texte .= '<textarea class="flat textareafordir" spellcheck="false" cols="60" name="value1">';
198 $texte .= $odtPath;
199 $texte .= '</textarea>';
200 $texte .= '</div><div style="display: inline-block; vertical-align: middle;">';
201 $texte .= '<input type="submit" class="button button-edit reposition smallpaddingimp" name="modify" value="'.dol_escape_htmltag($langs->trans("Modify")).'">';
202 $texte .= '<br></div></div>';
203
204 // Add input to upload a new template file.
205 $texte .= '<div>'.$langs->trans("UploadNewTemplate");
206 $maxfilesizearray = getMaxFileSizeArray();
207 $maxmin = $maxfilesizearray['maxmin'];
208 if ($maxmin > 0) {
209 $texte .= '<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).'">'; // MAX_FILE_SIZE must precede the field type=file
210 }
211 $texte .= ' <input type="file" name="uploadfile">';
212 $texte .= '<input type="hidden" value="USERGROUP_ADDON_PDF_ODT_PATH" name="keyforuploaddir">';
213 $texte .= '<input type="submit" class="button smallpaddingimp reposition" value="'.dol_escape_htmltag($langs->trans("Upload")).'" name="upload">';
214 $texte .= '</div>';
215
216 $texte .= '</td>';
217
218 $texte .= '</tr>';
219
220 $texte .= '</table>';
221 $texte .= '</form>';
222
223 return $texte;
224 }
225
226 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
238 public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
239 {
240 // phpcs:enable
241 global $user, $langs, $conf, $mysoc, $hookmanager;
242
243 if (empty($srctemplatepath)) {
244 dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING);
245 return -1;
246 }
247
248 // Add odtgeneration hook
249 if (!is_object($hookmanager)) {
250 include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
251 $hookmanager = new HookManager($this->db);
252 }
253 $hookmanager->initHooks(array('odtgeneration'));
254 global $action;
255
256 if (!is_object($outputlangs)) {
257 $outputlangs = $langs;
258 }
259 $sav_charset_output = $outputlangs->charset_output;
260 $outputlangs->charset_output = 'UTF-8';
261
262 // Load translation files required by the page
263 $outputlangs->loadLangs(array("main", "companies", "bills", "dict"));
264
265 if ($conf->user->dir_output) {
266 // If $object is id instead of object
267 if (!is_object($object)) {
268 $id = $object;
269 $object = new UserGroup($this->db);
270 $result = $object->fetch($id);
271 if ($result < 0) {
272 dol_print_error($this->db, $object->error);
273 return -1;
274 }
275 }
276
277 $dir = $conf->user->dir_output.'/usergroups';
278 $objectref = dol_sanitizeFileName($object->ref);
279 if (!preg_match('/specimen/i', $objectref)) {
280 $dir .= "/".$objectref;
281 }
282 $file = $dir."/".$objectref.".odt";
283
284 if (!file_exists($dir)) {
285 if (dol_mkdir($dir) < 0) {
286 $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
287 return -1;
288 }
289 }
290
291 if (file_exists($dir)) {
292 //print "srctemplatepath=".$srctemplatepath; // Src filename
293 $newfile = basename($srctemplatepath);
294 $newfiletmp = preg_replace('/\.od[ts]/i', '', $newfile);
295 $newfiletmp = preg_replace('/template_/i', '', $newfiletmp);
296 $newfiletmp = preg_replace('/modele_/i', '', $newfiletmp);
297
298 $newfiletmp = $objectref . '_' . $newfiletmp;
299
300 // Get extension (ods or odt)
301 $newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
302 if (getDolGlobalString('MAIN_DOC_USE_TIMING')) {
303 $format = getDolGlobalString('MAIN_DOC_USE_TIMING');
304 if ($format == '1') {
305 $format = '%Y%m%d%H%M%S';
306 }
307 $filename = $newfiletmp . '-' . dol_print_date(dol_now(), $format) . '.' . $newfileformat;
308 } else {
309 $filename = $newfiletmp . '.' . $newfileformat;
310 }
311 $file = $dir . '/' . $filename;
312 //print "newdir=".$dir;
313 //print "newfile=".$newfile;
314 //print "file=".$file;
315 //print "conf->user->dir_temp=".$conf->user->dir_temp;
316
317 dol_mkdir($conf->user->dir_temp);
318 if (!is_writable($conf->user->dir_temp)) {
319 $this->error = $langs->transnoentities("ErrorFailedToWriteInTempDirectory", $conf->user->dir_temp);
320 dol_syslog('Error in write_file: ' . $this->error, LOG_ERR);
321 return -1;
322 }
323
324 // If CUSTOMER contact defined on user, we use it
325 $usecontact = false;
326 $arrayidcontact = $object->getIdContact('external', 'CUSTOMER');
327 if (count($arrayidcontact) > 0) {
328 $usecontact = true;
329 $result = $object->fetch_contact($arrayidcontact[0]);
330 }
331
332 $contactobject = null;
333 // Recipient name
334 if (!empty($usecontact)) {
335 // We can use the company of contact instead of thirdparty company
336 if ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || getDolGlobalString('MAIN_USE_COMPANY_NAME_OF_CONTACT'))) {
337 $object->contact->fetch_thirdparty();
338 $socobject = $object->contact->thirdparty;
339 $contactobject = $object->contact;
340 } else {
341 $socobject = $object->thirdparty;
342 // if we have a CUSTOMER contact and we don't use it as thirdparty recipient we store the contact object for later use
343 $contactobject = $object->contact;
344 }
345 } else {
346 $socobject = $object->thirdparty;
347 }
348 // Make substitution
349 $substitutionarray = array(
350 '__FROM_NAME__' => $this->emetteur->name,
351 '__FROM_EMAIL__' => $this->emetteur->email,
352 '__TOTAL_TTC__' => $object->total_ttc,
353 '__TOTAL_HT__' => $object->total_ht,
354 '__TOTAL_VAT__' => $object->total_tva
355 );
356 complete_substitutions_array($substitutionarray, $langs, $object);
357 // Call the ODTSubstitution hook
358 $parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$substitutionarray);
359 $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
360
361 // Line of free text
362 $newfreetext = '';
363 $paramfreetext = 'user_FREE_TEXT';
364 if (getDolGlobalString($paramfreetext)) {
365 $newfreetext = make_substitutions(getDolGlobalString($paramfreetext), $substitutionarray);
366 }
367
368 // Open and load template
369 require_once ODTPHP_PATH.'odf.php';
370 try {
371 $odfHandler = new Odf(
372 $srctemplatepath,
373 array(
374 'PATH_TO_TMP' => $conf->user->dir_temp,
375 'ZIP_PROXY' => getDolGlobalString('MAIN_ODF_ZIP_PROXY', 'PclZipProxy'), // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
376 'DELIMITER_LEFT' => '{',
377 'DELIMITER_RIGHT' => '}'
378 )
379 );
380 } catch (Exception $e) {
381 $this->error = $e->getMessage();
382 dol_syslog($e->getMessage(), LOG_WARNING);
383 return -1;
384 }
385 // After construction $odfHandler->contentXml contains content and
386 // [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by
387 // [!-- BEGIN lines --]*[!-- END lines --]
388 //print html_entity_decode($odfHandler->__toString());
389 //print exit;
390
391
392 // Make substitutions into odt of freetext
393 try {
394 $odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8');
395 } catch (OdfException $e) {
396 dol_syslog($e->getMessage(), LOG_WARNING);
397 }
398
399 // Make substitutions into odt
400 $array_user = $this->get_substitutionarray_user($user, $outputlangs);
401 $array_global = $this->get_substitutionarray_each_var_object($object, $outputlangs);
402 $array_soc = $this->get_substitutionarray_mysoc($mysoc, $outputlangs);
403 $array_thirdparty = $this->get_substitutionarray_thirdparty($socobject, $outputlangs);
404 $array_objet = $this->get_substitutionarray_each_var_object($object, $outputlangs);
405 $array_other = $this->get_substitutionarray_other($outputlangs);
406 // retrieve contact information for use in object as contact_xxx tags
407 $array_thirdparty_contact = array();
408 if ($usecontact && is_object($contactobject)) {
409 $array_thirdparty_contact = $this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact');
410 }
411
412 $tmparray = array_merge($array_global, $array_user, $array_soc, $array_thirdparty, $array_objet, $array_other, $array_thirdparty_contact);
413 complete_substitutions_array($tmparray, $outputlangs, $object);
414 $object->fetch_optionals();
415 // Call the ODTSubstitution hook
416 $parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$tmparray);
417 $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
418
419 // retrieve the constant to apply a ratio for image size or set the ratio to 1
420 if (getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')) {
421 $ratio = (float) getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO');
422 } else {
423 $ratio = 1;
424 }
425
426 foreach ($tmparray as $key => $value) {
427 try {
428 if (preg_match('/logo$/', $key)) { // Image
429 if (file_exists($value)) {
430 $odfHandler->setImage($key, $value, $ratio);
431 } else {
432 $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
433 }
434 } else { // Text
435 $odfHandler->setVars($key, $value, true, 'UTF-8');
436 }
437 } catch (OdfException $e) {
438 dol_syslog($e->getMessage(), LOG_WARNING);
439 }
440 }
441 // Replace tags of lines
442 $foundtagforlines = 1;
443 try {
444 $listlines = $odfHandler->setSegment('lines');
445 } catch (OdfExceptionSegmentNotFound $e) {
446 // We may arrive here if tags for lines not present into template
447 $foundtagforlines = 0;
448 dol_syslog($e->getMessage(), LOG_INFO);
449 }
450 if ($foundtagforlines) {
451 foreach ($object->members as $u) {
452 $tmparray = $this->get_substitutionarray_each_var_object($u, $outputlangs);
453 unset($tmparray['object_pass']);
454 unset($tmparray['object_pass_indatabase']);
455 complete_substitutions_array($tmparray, $outputlangs, $object, $user, "completesubstitutionarray_users");
456 // Call the ODTSubstitutionLine hook
457 $parameters = array('odfHandler' => &$odfHandler, 'file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$tmparray, 'line' => $u);
458 $reshook = $hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
459 foreach ($tmparray as $key => $val) {
460 try {
461 if (!is_array($val)) { // @phpstan-ignore-line
462 $listlines->setVars($key, $val, true, 'UTF-8');
463 }
464 } catch (SegmentException $e) {
465 dol_syslog($e->getMessage(), LOG_WARNING);
466 }
467 }
468 $listlines->merge();
469 }
470 try {
471 $odfHandler->mergeSegment($listlines);
472 } catch (OdfException $e) {
473 $this->error = $e->getMessage();
474 dol_syslog($this->error, LOG_WARNING);
475 return -1;
476 }
477 }
478
479 // Replace labels translated
480 $tmparray = $outputlangs->get_translations_for_substitutions();
481 foreach ($tmparray as $key => $value) {
482 try {
483 $odfHandler->setVars($key, $value, true, 'UTF-8');
484 } catch (OdfException $e) {
485 dol_syslog($e->getMessage(), LOG_WARNING);
486 }
487 }
488
489 // Call the beforeODTSave hook
490 $parameters = array('odfHandler' => &$odfHandler, 'file' => $file, 'object' => $object, 'outputlangs' => $outputlangs);
491 $reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
492
493 // Write new file
494 if (getDolGlobalString('MAIN_ODT_AS_PDF')) {
495 try {
496 $odfHandler->exportAsAttachedPDF($file);
497 } catch (Exception $e) {
498 $this->error = $e->getMessage();
499 dol_syslog($e->getMessage(), LOG_WARNING);
500 return -1;
501 }
502 } else {
503 try {
504 $odfHandler->saveToDisk($file);
505 } catch (Exception $e) {
506 $this->error = $e->getMessage();
507 dol_syslog($e->getMessage(), LOG_WARNING);
508 return -1;
509 }
510 }
511
512 $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
513
514 dolChmod($file);
515
516 $odfHandler = null; // Destroy object
517
518 $this->result = array('fullpath' => $file);
519
520 return 1; // Success
521 } else {
522 $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
523 return -1;
524 }
525 }
526
527 return -1;
528 }
529}
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
get_substitutionarray_each_var_object(&$object, $outputlangs, $recursive=1)
Define array with couple substitution key => substitution value @phpstan-template T.
get_substitutionarray_mysoc($mysoc, $outputlangs)
Define array with couple substitution key => substitution value.
get_substitutionarray_contact($object, $outputlangs, $array_key='object')
Define array with couple substitution key => substitution value.
get_substitutionarray_other($outputlangs)
Define array with couple substitution key => substitution value.
get_substitutionarray_thirdparty($object, $outputlangs, $array_key='company')
Define array with couple substitution key => substitution value For example {company_name}...
get_substitutionarray_user($user, $outputlangs)
Define array with couple substitution key => substitution value.
Class to manage generation of HTML components Only common components must be here.
Class to manage hooks.
Parent class to manage intervention document templates.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
Class to manage user groups.
Class to build documents using ODF templates generator.
write_file($object, $outputlangs, $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0)
Function to build a document on disk using the generic odt module.
info($langs)
Return description of a module.
global $mysoc
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
dol_dir_list($utf8_path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
Definition files.lib.php:64
dol_now($mode='gmt')
Return date for now.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
getCallerInfoString()
Get caller info as a string that can be appended to a log message.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
dolChmod($filepath, $newmask='')
Change mod of a file.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
complete_substitutions_array(&$substitutionarray, $outputlangs, $object=null, $parameters=null, $callfunc="completesubstitutionarray")
Complete the $substitutionarray with more entries coming from external module that had set the "subst...
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
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).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
if(preg_match('/(crypted|dolcrypt):/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
Definition repair.php:130
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:133
getMaxFileSizeArray()
Return the max allowed for file upload.