dolibarr 21.0.0-alpha
doc_generic_supplier_proposal_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) 2016 Charlie Benke <charlie@patas-monkey.com>
5 * Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
6 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
7*
8* This program is free software; you can redistribute it and/or modify
9* it under the terms of the GNU General Public License as published by
10* the Free Software Foundation; either version 3 of the License, or
11* (at your option) any later version.
12*
13* This program is distributed in the hope that it will be useful,
14* but WITHOUT ANY WARRANTY; without even the implied warranty of
15* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16* GNU General Public License for more details.
17*
18* You should have received a copy of the GNU General Public License
19* along with this program. If not, see <https://www.gnu.org/licenses/>.
20* or see https://www.gnu.org/
21*/
22
29require_once DOL_DOCUMENT_ROOT.'/core/modules/supplier_proposal/modules_supplier_proposal.php';
30require_once DOL_DOCUMENT_ROOT.'/product/class/product.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 $conf, $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 = 'SUPPLIER_PROPOSAL_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 PROPALE_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 // Recupere emetteur
87 $this->emetteur = $mysoc;
88 if (!$this->emetteur->country_code) {
89 $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined
90 }
91 }
92
93
100 public function info($langs)
101 {
102 global $langs;
103
104 // Load translation files required by the page
105 $langs->loadLangs(array('companies', 'errors'));
106
107 $form = new Form($this->db);
108
109 $odtChosen = getDolGlobalInt('MAIN_SUPPLIER_PROPOSAL_CHOOSE_ODT_DOCUMENT') > 0;
110 $odtPath = trim(getDolGlobalString('SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH'));
111
112 $texte = $this->description.".<br>\n";
113 $texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
114 $texte .= '<input type="hidden" name="token" value="'.newToken().'">';
115 $texte .= '<input type="hidden" name="page_y" value="">';
116 $texte .= '<input type="hidden" name="action" value="setModuleOptions">';
117 $texte .= '<input type="hidden" name="param1" value="SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH">';
118 if ($odtChosen) {
119 $texte .= '<input type="hidden" name="param2" value="SUPPLIER_PROPOSAL_ADDON_PDF_ODT_DEFAULT">';
120 $texte .= '<input type="hidden" name="param3" value="SUPPLIER_PROPOSAL_ADDON_PDF_ODT_TOBILL">';
121 $texte .= '<input type="hidden" name="param4" value="SUPPLIER_PROPOSAL_ADDON_PDF_ODT_CLOSED">';
122 }
123 $texte .= '<table class="nobordernopadding" width="100%">';
124
125 // List of directories area
126 $texte .= '<tr><td>';
127 $texttitle = $langs->trans("ListOfDirectories");
128 $listofdir = explode(',', preg_replace('/[\r\n]+/', ',', $odtPath));
129 $listoffiles = array();
130 foreach ($listofdir as $key => $tmpdir) {
131 $tmpdir = trim($tmpdir);
132 $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir);
133 if (!$tmpdir) {
134 unset($listofdir[$key]);
135 continue;
136 }
137 if (!is_dir($tmpdir)) {
138 $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), '');
139 } else {
140 $tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)');
141 if (count($tmpfiles)) {
142 $listoffiles = array_merge($listoffiles, $tmpfiles);
143 }
144 }
145 }
146 $texthelp = $langs->trans("ListOfDirectoriesForModelGenODT");
147 $texthelp .= '<br><br><span class="opacitymedium">'.$langs->trans("ExampleOfDirectoriesForModelGen").'</span>';
148 // Add list of substitution keys
149 $texthelp .= '<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
150 $texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it
151
152 $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1, 3, $this->name);
153 $texte .= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
154 $texte .= '<textarea class="flat" cols="60" name="value1">';
155 $texte .= $odtPath;
156 $texte .= '</textarea>';
157 $texte .= '</div><div style="display: inline-block; vertical-align: middle;">';
158 $texte .= '<input type="submit" class="button button-edit reposition smallpaddingimp" name="modify" value="'.dol_escape_htmltag($langs->trans("Modify")).'">';
159 $texte .= '<br></div></div>';
160
161 // Scan directories
162 $nbofiles = count($listoffiles);
163 if (!empty($odtPath)) {
164 $texte .= $langs->trans("NumberOfModelFilesFound").': <b>';
165 //$texte.=$nbofiles?'<a id="a_'.get_class($this).'" href="#">':'';
166 $texte .= count($listoffiles);
167 //$texte.=$nbofiles?'</a>':'';
168 $texte .= '</b>';
169 }
170
171 if ($nbofiles) {
172 $texte .= '<div id="div_'.get_class($this).'" class="hiddenx">';
173 // Show list of found files
174 foreach ($listoffiles as $file) {
175 $texte .= '- '.$file['name'].' <a href="'.DOL_URL_ROOT.'/document.php?modulepart=doctemplates&file=supplier_proposal/'.urlencode(basename($file['name'])).'">'.img_picto('', 'listlight').'</a>';
176 $texte .= ' &nbsp; <a class="reposition" href="'.$_SERVER["PHP_SELF"].'?modulepart=doctemplates&keyforuploaddir=SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH&action=deletefile&token='.newToken().'&file='.urlencode(basename($file['name'])).'">'.img_picto('', 'delete').'</a>';
177 $texte .= '<br>';
178 }
179 $texte .= '</div>';
180
181 if ($odtChosen) {
182 // Model for creation
184 $texte .= '<table width="50%;">';
185 $texte .= '<tr>';
186 $texte .= '<td width="60%;">'.$langs->trans("DefaultModelSupplierProposalCreate").'</td>';
187 $texte .= '<td colspan="">';
188 $texte .= $form->selectarray('value2', $list, getDolGlobalString('SUPPLIER_PROPOSAL_ADDON_PDF_ODT_DEFAULT'));
189 $texte .= "</td></tr>";
190
191 $texte .= '<tr>';
192 $texte .= '<td width="60%;">'.$langs->trans("DefaultModelSupplierProposalToBill").'</td>';
193 $texte .= '<td colspan="">';
194 $texte .= $form->selectarray('value3', $list, getDolGlobalString('SUPPLIER_PROPOSAL_ADDON_PDF_ODT_TOBILL'));
195 $texte .= "</td></tr>";
196 $texte .= '<tr>';
197
198 $texte .= '<td width="60%;">'.$langs->trans("DefaultModelSupplierProposalClosed").'</td>';
199 $texte .= '<td colspan="">';
200 $texte .= $form->selectarray('value4', $list, getDolGlobalString('SUPPLIER_PROPOSAL_ADDON_PDF_ODT_CLOSED'));
201 $texte .= "</td></tr>";
202 $texte .= '</table>';
203 }
204 }
205
206 $texte .= '</td>';
207
208 $texte .= '</tr>';
209
210 $texte .= '</table>';
211 $texte .= '</form>';
212
213 return $texte;
214 }
215
216 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
228 public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
229 {
230 // phpcs:enable
231 global $user, $langs, $conf, $mysoc, $hookmanager;
232
233 if (empty($srctemplatepath)) {
234 dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING);
235 return -1;
236 }
237
238 // Add odtgeneration hook
239 if (!is_object($hookmanager)) {
240 include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
241 $hookmanager = new HookManager($this->db);
242 }
243 $hookmanager->initHooks(array('odtgeneration'));
244 global $action;
245
246 if (!is_object($outputlangs)) {
247 $outputlangs = $langs;
248 }
249 $sav_charset_output = $outputlangs->charset_output;
250 $outputlangs->charset_output = 'UTF-8';
251
252 // Load translation files required by the page
253 $outputlangs->loadLangs(array("main", "companies", "bills", "dict"));
254
255 if ($conf->supplier_proposal->dir_output) {
256 // If $object is id instead of object
257 if (!is_object($object)) {
258 $id = $object;
259 $object = new SupplierProposal($this->db);
260 $result = $object->fetch($id);
261 if ($result < 0) {
262 dol_print_error($this->db, $object->error);
263 return -1;
264 }
265 }
266
267 $object->fetch_thirdparty();
268
269 $dir = $conf->supplier_proposal->dir_output;
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->propal->dir_temp=".$conf->propal->dir_temp;
308
309 dol_mkdir($conf->supplier_proposal->dir_temp);
310 if (!is_writable($conf->supplier_proposal->dir_temp)) {
311 $this->error = $langs->transnoentities("ErrorFailedToWriteInTempDirectory", $conf->supplier_proposal->dir_temp);
312 dol_syslog('Error in write_file: ' . $this->error, LOG_ERR);
313 return -1;
314 }
315
316 // If BILLING contact defined on invoice, we use it
317 $usecontact = false;
318 $arrayidcontact = $object->getIdContact('external', 'BILLING');
319 if (count($arrayidcontact) > 0) {
320 $usecontact = true;
321 $result = $object->fetch_contact($arrayidcontact[0]);
322 }
323
324 // Recipient name
325 $contactobject = null;
326 if (!empty($usecontact)) {
327 // We can use the company of contact instead of thirdparty company
328 if ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || getDolGlobalString('MAIN_USE_COMPANY_NAME_OF_CONTACT'))) {
329 $object->contact->fetch_thirdparty();
330 $socobject = $object->contact->thirdparty;
331 $contactobject = $object->contact;
332 } else {
333 $socobject = $object->thirdparty;
334 // if we have a CUSTOMER contact and we don't use it as thirdparty recipient we store the contact object for later use
335 $contactobject = $object->contact;
336 }
337 } else {
338 $socobject = $object->thirdparty;
339 }
340
341 // Make substitution
342 $substitutionarray = array(
343 '__FROM_NAME__' => $this->emetteur->name,
344 '__FROM_EMAIL__' => $this->emetteur->email,
345 '__TOTAL_TTC__' => $object->total_ttc,
346 '__TOTAL_HT__' => $object->total_ht,
347 '__TOTAL_VAT__' => $object->total_tva
348 );
349 complete_substitutions_array($substitutionarray, $langs, $object);
350 // Call the ODTSubstitution hook
351 $parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$substitutionarray);
352 $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
353
354 // Line of free text
355 $newfreetext = '';
356 $paramfreetext = 'SUPPLIER_PROPOSAL_FREE_TEXT';
357 if (getDolGlobalString($paramfreetext)) {
358 $newfreetext = make_substitutions(getDolGlobalString($paramfreetext), $substitutionarray);
359 }
360
361 // Open and load template
362 require_once ODTPHP_PATH.'odf.php';
363 try {
364 $odfHandler = new Odf(
365 $srctemplatepath,
366 array(
367 'PATH_TO_TMP' => $conf->supplier_proposal->dir_temp,
368 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
369 'DELIMITER_LEFT' => '{',
370 'DELIMITER_RIGHT' => '}'
371 )
372 );
373 } catch (Exception $e) {
374 $this->error = $e->getMessage();
375 dol_syslog($e->getMessage(), LOG_INFO);
376 return -1;
377 }
378 // After construction $odfHandler->contentXml contains content and
379 // [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by
380 // [!-- BEGIN lines --]*[!-- END lines --]
381 //print html_entity_decode($odfHandler->__toString());
382 //print exit;
383
384
385 // Make substitutions into odt of freetext
386 try {
387 $odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8');
388 } catch (OdfException $e) {
389 dol_syslog($e->getMessage(), LOG_INFO);
390 }
391
392 // Define substitution array
393 $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
394 $array_objet = $this->get_substitutionarray_object($object, $outputlangs);
395 $array_user = $this->get_substitutionarray_user($user, $outputlangs);
396 $array_soc = $this->get_substitutionarray_mysoc($mysoc, $outputlangs);
397 $array_thirdparty = $this->get_substitutionarray_thirdparty($socobject, $outputlangs);
398 $array_other = $this->get_substitutionarray_other($outputlangs);
399
400 $array_thirdparty_contact = array();
401 if ($usecontact && is_object($contactobject)) {
402 $array_thirdparty_contact = $this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact');
403 }
404
405 $tmparray = array_merge($substitutionarray, $array_user, $array_soc, $array_thirdparty, $array_objet, $array_other, $array_thirdparty_contact);
406 complete_substitutions_array($tmparray, $outputlangs, $object);
407
408 // Call the ODTSubstitution hook
409 $parameters = array('odfHandler' => &$odfHandler, 'file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$tmparray);
410 $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
411
412 foreach ($tmparray as $key => $value) {
413 try {
414 if (preg_match('/logo$/', $key)) { // Image
415 if (file_exists($value)) {
416 $odfHandler->setImage($key, $value);
417 } else {
418 $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
419 }
420 } else { // Text
421 $odfHandler->setVars($key, $value, true, 'UTF-8');
422 }
423 } catch (OdfException $e) {
424 dol_syslog($e->getMessage(), LOG_INFO);
425 }
426 }
427 // Replace tags of lines
428 $foundtagforlines = 1;
429 try {
430 $listlines = $odfHandler->setSegment('lines');
431 } catch (OdfExceptionSegmentNotFound $e) {
432 // We may arrive here if tags for lines not present into template
433 $foundtagforlines = 0;
434 dol_syslog($e->getMessage(), LOG_INFO);
435 }
436 if ($foundtagforlines) {
437 $linenumber = 0;
438 foreach ($object->lines as $line) {
439 $linenumber++;
440 $tmparray = $this->get_substitutionarray_lines($line, $outputlangs, $linenumber);
441 complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines");
442 // Call the ODTSubstitutionLine hook
443 $parameters = array('odfHandler' => &$odfHandler, 'file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$tmparray, 'line' => $line);
444 $reshook = $hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
445 foreach ($tmparray as $key => $val) {
446 try {
447 $listlines->setVars($key, $val, true, 'UTF-8');
448 } catch (SegmentException $e) {
449 dol_syslog($e->getMessage(), LOG_INFO);
450 }
451 }
452 $listlines->merge();
453 }
454 try {
455 $odfHandler->mergeSegment($listlines);
456 } catch (OdfException $e) {
457 $this->error = $e->getMessage();
458 dol_syslog($this->error, LOG_WARNING);
459 return -1;
460 }
461 }
462
463 // Replace labels translated
464 $tmparray = $outputlangs->get_translations_for_substitutions();
465 foreach ($tmparray as $key => $value) {
466 try {
467 $odfHandler->setVars($key, $value, true, 'UTF-8');
468 } catch (OdfException $e) {
469 dol_syslog($e->getMessage(), LOG_INFO);
470 }
471 }
472
473 // Call the beforeODTSave hook
474 $parameters = array('odfHandler' => &$odfHandler, 'file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$tmparray);
475 $reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
476
477 // Write new file
478 if (getDolGlobalString('MAIN_ODT_AS_PDF')) {
479 try {
480 $odfHandler->exportAsAttachedPDF($file);
481 } catch (Exception $e) {
482 $this->error = $e->getMessage();
483 dol_syslog($e->getMessage(), LOG_INFO);
484 return -1;
485 }
486 } else {
487 try {
488 $odfHandler->saveToDisk($file);
489 } catch (Exception $e) {
490 $this->error = $e->getMessage();
491 dol_syslog($e->getMessage(), LOG_INFO);
492 return -1;
493 }
494 }
495 $parameters = array('odfHandler' => &$odfHandler, 'file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$tmparray);
496 $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
497
498 dolChmod($file);
499
500 $odfHandler = null; // Destroy object
501
502 $this->result = array('fullpath' => $file);
503
504 return 1; // Success
505 } else {
506 $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
507 return -1;
508 }
509 }
510
511 return -1;
512 }
513}
$id
Definition account.php:39
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
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.
Perent class of the Proposal models.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
Class to manage price ask supplier.
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.
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...
getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $object=null, $include=null)
Return array of possible common substitutions.
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:/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