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