dolibarr 25.0.0-alpha
doc_generic_myobject_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) 2014 Marcos García <marcosgdf@gmail.com>
5 * Copyright (C) 2016 Charlie Benke <charlie@patas-monkey.com>
6 * Copyright (C) 2018-2021 Philippe Grand <philippe.grand@atoo-net.com>
7 * Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
8 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
9 * Copyright (C) ---Replace with your own copyright and developer email---
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <https://www.gnu.org/licenses/>.
23 * or see https://www.gnu.org/
24 */
25
32dol_include_once('/mymodule/core/modules/mymodule/modules_myobject.php');
33require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
34require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
35require_once DOL_DOCUMENT_ROOT . '/core/lib/functions.lib.php';
36require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
37require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
38require_once DOL_DOCUMENT_ROOT.'/core/lib/doc.lib.php';
39
40
45{
50 public $emetteur;
51
56 public $phpmin = array(7, 0);
57
61 public $version = 'dolibarr';
62
63
69 public function __construct($db)
70 {
71 global $langs, $mysoc;
72
73 // Load translation files required by the page
74 $langs->loadLangs(array("main", "companies"));
75
76 $this->db = $db;
77 $this->name = "ODT templates";
78 $this->description = $langs->trans("DocumentModelOdt");
79 $this->scandir = 'MYMODULE_MYOBJECT_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan
80
81 // Page size for A4 format
82 $this->type = 'odt';
83 $this->page_largeur = 0;
84 $this->page_hauteur = 0;
85 $this->format = array($this->page_largeur, $this->page_hauteur);
86 $this->marge_gauche = 0;
87 $this->marge_droite = 0;
88 $this->marge_haute = 0;
89 $this->marge_basse = 0;
90
91 $this->option_logo = 1; // Display logo
92 $this->option_tva = 0; // Manage the vat option FACTURE_TVAOPTION
93 $this->option_modereg = 0; // Display payment mode
94 $this->option_condreg = 0; // Display payment terms
95 $this->option_multilang = 1; // Available in several languages
96 $this->option_escompte = 0; // Displays if there has been a discount
97 $this->option_credit_note = 0; // Support credit notes
98 $this->option_freetext = 1; // Support add of a personalised text
99 $this->option_draft_watermark = 0; // Support add of a watermark on drafts
100
101 if ($mysoc === null) {
102 dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'. getCallerInfoString(), LOG_ERR);
103 return;
104 }
105
106 // Get source company
107 $this->emetteur = $mysoc;
108 if (!$this->emetteur->country_code) {
109 $this->emetteur->country_code = dol_substr($langs->defaultlang, -2); // By default if not defined
110 }
111 }
112
113
120 public function info($langs)
121 {
122 global $langs;
123
124 // Load translation files required by the page
125 $langs->loadLangs(array("errors", "companies"));
126
127 $form = new Form($this->db);
128
129 $odtPath = trim(getDolGlobalString('MYMODULE_MYOBJECT_ADDON_PDF_ODT_PATH'));
130
131 $texte = $this->description.".<br>\n";
132 $texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST" enctype="multipart/form-data">';
133 $texte .= '<input type="hidden" name="token" value="'.newToken().'">';
134 $texte .= '<input type="hidden" name="page_y" value="">';
135 $texte .= '<input type="hidden" name="action" value="setModuleOptions">';
136 $texte .= '<input type="hidden" name="param1" value="MYMODULE_MYOBJECT_ADDON_PDF_ODT_PATH">';
137
138 $texte .= '<table class="nobordernopadding centpercent">';
139
140 // List of directories area
141 $texte .= '<tr><td>';
142 $texttitle = $langs->trans("ListOfDirectories");
143 $listofdir = explode(',', preg_replace('/[\r\n]+/', ',', $odtPath));
144 $listoffiles = array();
145 foreach ($listofdir as $key => $tmpdir) {
146 $tmpdir = trim($tmpdir);
147 $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir);
148 if (!$tmpdir) {
149 unset($listofdir[$key]);
150 continue;
151 }
152 if (!dol_is_dir($tmpdir)) {
153 $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), '');
154 } else {
155 $tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)');
156 if (count($tmpfiles)) {
157 $listoffiles = array_merge($listoffiles, $tmpfiles);
158 }
159 }
160 }
161 $texthelp = $langs->trans("ListOfDirectoriesForModelGenODT");
162 $texthelp .= '<br><br><span class="opacitymedium">'.$langs->trans("ExampleOfDirectoriesForModelGen").'</span>';
163 // Add list of substitution keys
164 $texthelp .= '<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
165 $texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it
166
167 // Scan directories
168 $nbofiles = count($listoffiles);
169 if ($odtPath) {
170 $texte .= $langs->trans("NumberOfModelFilesFound").': <b>';
171 //$texte.=$nbofiles?'<a id="a_'.get_class($this).'" href="#">':'';
172 $texte .= count($listoffiles);
173 //$texte.=$nbofiles?'</a>':'';
174 $texte .= '</b>';
175 }
176
177 if ($nbofiles) {
178 $texte .= '<div id="div_'.get_class($this).'" class="hiddenx">';
179 // Show list of found files
180 foreach ($listoffiles as $file) {
181 $texte .= '- '.$file['name'].' <a href="'.DOL_URL_ROOT.'/document.php?modulepart=doctemplates&file=mymodule_myobject/'.urlencode(basename($file['name'])).'">'.img_picto('', 'listlight').'</a>';
182 $texte .= ' &nbsp; <a class="reposition" href="'.$_SERVER["PHP_SELF"].'?modulepart=doctemplates&keyforuploaddir=MYMODULE_MYOBJECT_ADDON_PDF_ODT_PATH&action=deletefile&token='.newToken().'&file='.urlencode(basename($file['name'])).'">'.img_picto('', 'delete').'</a>';
183 $texte .= '<br>';
184 }
185 $texte .= '</div>';
186 }
187
188 if (!getDolGlobalString('MAIN_NO_MULTIDIR_FOR_ODT')) {
189 $texte .= '<br>';
190 $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1, 3, $this->name);
191 $texte .= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
192 $texte .= '<textarea class="flat textareafordir" spellcheck="false" cols="60" name="value1">';
193 $texte .= $odtPath;
194 $texte .= '</textarea>';
195 $texte .= '</div><div style="display: inline-block; vertical-align: middle;">';
196 $texte .= '<input type="submit" class="button button-edit smallpaddingimp reposition" name="modify" value="'.dolPrintHTMLForAttribute($langs->trans("Modify")).'">';
197 $texte .= '<br></div></div>';
198 } else {
199 $texte .= '<br>';
200 $texte .= '<input type="hidden" name="value1" value="MYMODULE_MYOBJECT_ADDON_PDF_ODT_PATH">';
201 }
202
203 // Add input to upload a new template file.
204 $texte .= '<div>'.$langs->trans("UploadNewTemplate");
205 $maxfilesizearray = getMaxFileSizeArray();
206 $maxmin = $maxfilesizearray['maxmin'];
207 if ($maxmin > 0) {
208 $texte .= '<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).'">'; // MAX_FILE_SIZE must precede the field type=file
209 }
210 $texte .= ' <input type="file" name="uploadfile">';
211 $texte .= '<input type="hidden" value="MYMODULE_MYOBJECT_ADDON_PDF_ODT_PATH" name="keyforuploaddir">';
212 $texte .= '<input type="submit" class="button smallpaddingimp reposition" value="'.dol_escape_htmltag($langs->trans("Upload")).'" name="upload">';
213 $texte .= '</div>';
214
215 $texte .= '</td>';
216
217 $texte .= '</tr>';
218
219 $texte .= '</table>';
220 $texte .= '</form>';
221
222 return $texte;
223 }
224
225 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
237 public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
238 {
239 // phpcs:enable
240 global $user, $langs, $conf, $mysoc, $hookmanager;
241 global $action;
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 $outputlangs->loadLangs(array("main", "dict", "companies", "bills"));
263
264 if ($conf->mymodule->dir_output) {
265 // If $object is id instead of object
266 if (!is_object($object)) {
267 $id = $object;
268 $object = new MyObject($this->db);
269 $result = $object->fetch($id);
270 if ($result < 0) {
271 dol_print_error($this->db, $object->error);
272 return -1;
273 }
274 }
275
276 $object->fetch_thirdparty();
277
278 $dir = $conf->mymodule->multidir_output[isset($object->entity) ? $object->entity : 1];
279 $objectref = dol_sanitizeFileName($object->ref);
280 if (!preg_match('/specimen/i', $objectref)) {
281 $dir .= "/".$objectref;
282 }
283 $file = $dir."/".$objectref.".odt";
284
285 if (!file_exists($dir)) {
286 if (dol_mkdir($dir) < 0) {
287 $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
288 return -1;
289 }
290 }
291
292 if (file_exists($dir)) {
293 //print "srctemplatepath=".$srctemplatepath; // Src filename
294 $newfile = basename($srctemplatepath);
295 $newfiletmp = preg_replace('/\.od[ts]/i', '', $newfile);
296 $newfiletmp = preg_replace('/template_/i', '', $newfiletmp);
297 $newfiletmp = preg_replace('/modele_/i', '', $newfiletmp);
298
299 $newfiletmp = $objectref . '_' . $newfiletmp;
300 //$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt';
301
302 // Get extension (ods or odt)
303 $newfileformat = dol_substr($newfile, strrpos($newfile, '.') + 1);
304 if (getDolGlobalString('MAIN_DOC_USE_TIMING')) {
305 $format = getDolGlobalString('MAIN_DOC_USE_TIMING');
306 if ($format == '1') {
307 $format = '%Y%m%d%H%M%S';
308 }
309 $filename = $newfiletmp . '-' . dol_print_date(dol_now(), $format) . '.' . $newfileformat;
310 } else {
311 $filename = $newfiletmp . '.' . $newfileformat;
312 }
313 $file = $dir . '/' . $filename;
314 //print "newdir=".$dir;
315 //print "newfile=".$newfile;
316 //print "file=".$file;
317 //print "conf->societe->dir_temp=".$conf->societe->dir_temp;
318
319 dol_mkdir($conf->mymodule->dir_temp);
320 if (!dol_is_writable($conf->mymodule->dir_temp)) {
321 $this->error = $langs->transnoentities("ErrorFailedToWriteInTempDirectory", $conf->mymodule->dir_temp);
322 dol_syslog('Error in write_file: ' . $this->error, LOG_ERR);
323 return -1;
324 }
325
326 // If CUSTOMER contact defined on object, we use it
327 $usecontact = false;
328 $arrayidcontact = $object->getIdContact('external', 'CUSTOMER');
329 if (count($arrayidcontact) > 0) {
330 $usecontact = true;
331 $result = $object->fetch_contact($arrayidcontact[0]);
332 }
333
334 // Recipient name
335 $contactobject = null;
336 if (!empty($usecontact)) {
337 // We can use the company of contact instead of thirdparty company
338 if ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || getDolGlobalInt('MAIN_USE_COMPANY_NAME_OF_CONTACT'))) {
339 $object->contact->fetch_thirdparty();
340 $socobject = $object->contact->thirdparty;
341 $contactobject = $object->contact;
342 } else {
343 $socobject = $object->thirdparty;
344 // if we have a CUSTOMER contact and we don't use it as thirdparty recipient we store the contact object for later use
345 $contactobject = $object->contact;
346 }
347 } else {
348 $socobject = $object->thirdparty;
349 }
350
351 // Make substitution
352 $substitutionarray = array(
353 '__FROM_NAME__' => $this->emetteur->name,
354 '__FROM_EMAIL__' => $this->emetteur->email,
355 '__TOTAL_TTC__' => $object->total_ttc,
356 '__TOTAL_HT__' => $object->total_ht,
357 '__TOTAL_VAT__' => $object->total_tva
358 );
359 complete_substitutions_array($substitutionarray, $langs, $object);
360 // Call the ODTSubstitution hook
361 $parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$substitutionarray);
362 $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
363
364 // Line of free text
365 $newfreetext = '';
366 $paramfreetext = 'MYMODULE_MYOBJECT_FREE_TEXT';
367 if (getDolGlobalString($paramfreetext)) {
368 $newfreetext = make_substitutions(getDolGlobalString($paramfreetext), $substitutionarray);
369 }
370
371 // Open and load template
372 require_once ODTPHP_PATH.'odf.php';
373 try {
374 $odfHandler = new Odf(
375 $srctemplatepath,
376 array(
377 'PATH_TO_TMP' => $conf->mymodule->dir_temp,
378 'ZIP_PROXY' => getDolGlobalString('MAIN_ODF_ZIP_PROXY', 'PclZipProxy'), // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
379 'DELIMITER_LEFT' => '{',
380 'DELIMITER_RIGHT' => '}'
381 )
382 );
383 } catch (Exception $e) {
384 $this->error = $e->getMessage();
385 dol_syslog($e->getMessage(), LOG_INFO);
386 return -1;
387 }
388 // After construction $odfHandler->contentXml contains content and
389 // [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by
390 // [!-- BEGIN lines --]*[!-- END lines --]
391 //print html_entity_decode($odfHandler->__toString());
392 //print exit;
393
394 $object->fetch_optionals();
395
396 // Make substitutions into odt of freetext
397 try {
398 $odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8');
399 } catch (OdfException $e) {
400 dol_syslog($e->getMessage(), LOG_INFO);
401 }
402
403 // Define substitution array
404 $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
405 $array_object_from_properties = $this->get_substitutionarray_each_var_object($object, $outputlangs);
406 $array_objet = $this->get_substitutionarray_object($object, $outputlangs);
407 $array_user = $this->get_substitutionarray_user($user, $outputlangs);
408 $array_soc = $this->get_substitutionarray_mysoc($mysoc, $outputlangs);
409 $array_thirdparty = $this->get_substitutionarray_thirdparty($socobject, $outputlangs);
410 $array_other = $this->get_substitutionarray_other($outputlangs);
411 // retrieve contact information for use in object as contact_xxx tags
412 $array_thirdparty_contact = array();
413 if ($usecontact && is_object($contactobject)) {
414 $array_thirdparty_contact = $this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact');
415 }
416
417 $tmparray = array_merge($substitutionarray, $array_object_from_properties, $array_user, $array_soc, $array_thirdparty, $array_objet, $array_other, $array_thirdparty_contact);
418 complete_substitutions_array($tmparray, $outputlangs, $object);
419
420 // Call the ODTSubstitution hook
421 $parameters = array('odfHandler' => &$odfHandler, 'file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$tmparray);
422 $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
423
424 // retrieve the constant to apply a ratio for image size or set the ratio to 1
425 if (getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')) {
426 $ratio = (float) getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO');
427 } else {
428 $ratio = 1;
429 }
430
431 foreach ($tmparray as $key => $value) {
432 try {
433 if (preg_match('/logo$/', $key)) {
434 // Image
435 if (file_exists($value)) {
436 $odfHandler->setImage($key, $value, $ratio);
437 } else {
438 $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
439 }
440 } else {
441 // Text
442 $odfHandler->setVars($key, $value, true, 'UTF-8');
443 }
444 } catch (OdfException $e) {
445 dol_syslog($e->getMessage(), LOG_INFO);
446 }
447 }
448 // Replace tags of lines
449 $foundtagforlines = 1;
450 try {
451 $listlines = $odfHandler->setSegment('lines');
452 } catch (OdfExceptionSegmentNotFound $e) {
453 // We may arrive here if tags for lines not present into template
454 $foundtagforlines = 0;
455 dol_syslog($e->getMessage(), LOG_INFO);
456 }
457
458 if ($foundtagforlines) {
459 $linenumber = 0;
460 foreach ($object->lines as $line) {
462 $linenumber++;
463
464 $tmparray = $this->get_substitutionarray_lines($line, $outputlangs, $linenumber);
465 complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines");
466 // Call the ODTSubstitutionLine hook
467 $parameters = array('odfHandler' => &$odfHandler, 'file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$tmparray, 'line' => $line);
468 $reshook = $hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
469 foreach ($tmparray as $key => $val) {
470 try {
471 $listlines->setVars($key, $val, true, 'UTF-8');
472 } catch (SegmentException $e) {
473 dol_syslog($e->getMessage(), LOG_INFO);
474 }
475 }
476 $listlines->merge();
477 }
478 try {
479 $odfHandler->mergeSegment($listlines);
480 } catch (OdfException $e) {
481 $this->error = $e->getMessage();
482 dol_syslog($this->error, LOG_WARNING);
483 return -1;
484 }
485 }
486
487 // Replace labels translated
488 $tmparray = $outputlangs->get_translations_for_substitutions();
489 foreach ($tmparray as $key => $value) {
490 try {
491 $odfHandler->setVars($key, $value, true, 'UTF-8');
492 } catch (OdfException $e) {
493 dol_syslog($e->getMessage(), LOG_INFO);
494 }
495 }
496
497 // Call the beforeODTSave hook
498
499 $parameters = array('odfHandler' => &$odfHandler, 'file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$tmparray);
500 $reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
501
502 // Write new file
503 if (getDolGlobalString('MAIN_ODT_AS_PDF')) {
504 try {
505 $odfHandler->exportAsAttachedPDF($file);
506 } catch (Exception $e) {
507 $this->error = $e->getMessage();
508 dol_syslog($e->getMessage(), LOG_INFO);
509 return -1;
510 }
511 } else {
512 try {
513 $odfHandler->saveToDisk($file);
514 } catch (Exception $e) {
515 $this->error = $e->getMessage();
516 dol_syslog($e->getMessage(), LOG_INFO);
517 return -1;
518 }
519 }
520
521 $parameters = array('odfHandler' => &$odfHandler, 'file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$tmparray);
522 $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
523
524 dolChmod($file);
525
526 $odfHandler = null; // Destroy object
527
528 $this->result = array('fullpath' => $file);
529
530 return 1; // Success
531 } else {
532 $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
533 return -1;
534 }
535 }
536
537 return -1;
538 }
539}
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
$propal type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
Definition propal.php:280
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_lines($line, $outputlangs, $linenumber=0)
Define array with couple substitution key => substitution value Note that vars into substitutions arr...
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 for document models.
write_file($object, $outputlangs, $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0)
Function to build a document on disk.
Class for MyObject.
Class to build documents using ODF templates generator.
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_is_writable($folderorfile)
Test if directory or filename is writable.
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:65
dol_is_dir($folder)
Test if filename is a directory.
dol_now($mode='gmt')
Return date for now.
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.
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
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...
dol_substr($string, $start, $length=null, $stringencoding='', $trunconbytes=0)
Make a substring.
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).
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)
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:140
getMaxFileSizeArray()
Return the max allowed for file upload.