dolibarr 25.0.0-alpha
doc_generic_proposal_odt.modules.php
Go to the documentation of this file.
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-2025 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/propale/modules_propale.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';
35require_once DOL_DOCUMENT_ROOT.'/core/lib/signature.lib.php';
36
37
42{
47 public $emetteur;
48
53 public $phpmin = array(7, 0);
54
58 public $version = 'dolibarr';
59
60
66 public function __construct($db)
67 {
68 global $langs, $mysoc;
69
70 // Load translation files required by the page
71 $langs->loadLangs(array("main", "companies"));
72
73 $this->db = $db;
74 $this->name = "ODT templates";
75 $this->description = $langs->trans("DocumentModelOdt");
76 $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template
77 $this->scandir = 'PROPALE_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan
78
79 // Page size for A4 format
80 $this->type = 'odt';
81 $this->page_largeur = 0;
82 $this->page_hauteur = 0;
83 $this->format = array($this->page_largeur, $this->page_hauteur);
84 $this->marge_gauche = 0;
85 $this->marge_droite = 0;
86 $this->marge_haute = 0;
87 $this->marge_basse = 0;
88
89 $this->option_logo = 1; // Display logo
90 $this->option_tva = 0; // Manage the vat option PROPALE_TVAOPTION
91 $this->option_modereg = 0; // Display payment mode
92 $this->option_condreg = 0; // Display payment terms
93 $this->option_multilang = 1; // Available in several languages
94 $this->option_escompte = 0; // Displays if there has been a discount
95 $this->option_credit_note = 0; // Support credit notes
96 $this->option_freetext = 1; // Support add of a personalised text
97 $this->option_draft_watermark = 0; // Support add of a watermark on drafts
98
99 if ($mysoc === null) {
100 dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'. getCallerInfoString(), LOG_ERR);
101 return;
102 }
103
104 // Get source company
105 $this->emetteur = $mysoc;
106 if (!$this->emetteur->country_code) {
107 $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined
108 }
109 }
110
111
118 public function info($langs)
119 {
120 global $langs;
121
122 // Load translation files required by the page
123 $langs->loadLangs(array("errors", "companies"));
124
125 $form = new Form($this->db);
126
127 $odtChosen = getDolGlobalInt('MAIN_PROPAL_CHOOSE_ODT_DOCUMENT') > 0;
128 $odtPath = trim(getDolGlobalString('PROPALE_ADDON_PDF_ODT_PATH'));
129
130 $texte = $this->description.".<br>\n";
131 $texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST" enctype="multipart/form-data">';
132 $texte .= '<input type="hidden" name="token" value="'.newToken().'">';
133 $texte .= '<input type="hidden" name="page_y" value="">';
134 $texte .= '<input type="hidden" name="action" value="setModuleOptions">';
135 $texte .= '<input type="hidden" name="param1" value="PROPALE_ADDON_PDF_ODT_PATH">';
136 if ($odtChosen) {
137 $texte .= '<input type="hidden" name="param2" value="PROPALE_ADDON_PDF_ODT_DEFAULT">';
138 $texte .= '<input type="hidden" name="param3" value="PROPALE_ADDON_PDF_ODT_TOBILL">';
139 $texte .= '<input type="hidden" name="param4" value="PROPALE_ADDON_PDF_ODT_CLOSED">';
140 }
141 $texte .= '<table class="nobordernopadding centpercent">';
142
143 // List of directories area
144 $texte .= '<tr><td>';
145 $texttitle = $langs->trans("ListOfDirectories");
146 $listofdir = explode(',', preg_replace('/[\r\n]+/', ',', $odtPath));
147 $listoffiles = array();
148 foreach ($listofdir as $key => $tmpdir) {
149 $tmpdir = trim($tmpdir);
150 $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir);
151 if (!$tmpdir) {
152 unset($listofdir[$key]);
153 continue;
154 }
155 if (!is_dir($tmpdir)) {
156 $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), '');
157 } else {
158 $tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)');
159 if (count($tmpfiles)) {
160 $listoffiles = array_merge($listoffiles, $tmpfiles);
161 }
162 }
163 }
164 $texthelp = $langs->trans("ListOfDirectoriesForModelGenODT");
165 $texthelp .= '<br><br><span class="opacitymedium">'.$langs->trans("ExampleOfDirectoriesForModelGen").'</span>';
166 // Add list of substitution keys
167 $texthelp .= '<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
168 $texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it
169
170 // Scan directories
171 $nbofiles = count($listoffiles);
172 if (!empty($odtPath)) {
173 $texte .= '<span class="opacitylow">'.$langs->trans("NumberOfModelFilesFound").': <b>';
174 //$texte.=$nbofiles?'<a id="a_'.get_class($this).'" href="#">':'';
175 $texte .= count($listoffiles);
176 //$texte.=$nbofiles?'</a>':'';
177 $texte .= '</b></span><br>';
178 }
179
180 if ($nbofiles) {
181 $texte .= '<div id="div_'.get_class($this).'" class="hiddenx opacitylow">';
182 // Show list of found files
183 foreach ($listoffiles as $file) {
184 $texte .= '- '.$file['name'];
185 $texte .= ' <a href="'.DOL_URL_ROOT.'/document.php?modulepart=doctemplates&file=proposals/'.urlencode(basename($file['name'])).'">'.img_picto('', 'listlight').'</a>';
186 $texte .= ' &nbsp; <a class="reposition" href="'.$_SERVER["PHP_SELF"].'?modulepart=doctemplates&keyforuploaddir=PROPALE_ADDON_PDF_ODT_PATH&action=deletefile&token='.newToken().'&file='.urlencode(basename($file['name'])).'">'.img_picto('', 'delete').'</a>';
187 $texte .= '<br>';
188 }
189 $texte .= '</div>';
190
191 // Set default template for different status of proposal
192 if ($odtChosen) {
193 // Model for creation
194 $list = ModelePDFPropales::liste_modeles($this->db);
195 $texte .= '<table width="50%">';
196 $texte .= '<tr>';
197 $texte .= '<td width="60%">'.$langs->trans("DefaultModelPropalCreate").'</td>';
198 $texte .= '<td colspan="">';
199 $texte .= $form->selectarray('value2', $list, getDolGlobalString('PROPALE_ADDON_PDF_ODT_DEFAULT'));
200 $texte .= "</td></tr>";
201
202 $texte .= '<tr>';
203 $texte .= '<td width="60%">'.$langs->trans("DefaultModelPropalToBill").'</td>';
204 $texte .= '<td colspan="">';
205 $texte .= $form->selectarray('value3', $list, getDolGlobalString('PROPALE_ADDON_PDF_ODT_TOBILL'));
206 $texte .= "</td></tr>";
207 $texte .= '<tr>';
208
209 $texte .= '<td width="60%">'.$langs->trans("DefaultModelPropalClosed").'</td>';
210 $texte .= '<td colspan="">';
211 $texte .= $form->selectarray('value4', $list, getDolGlobalString('PROPALE_ADDON_PDF_ODT_CLOSED'));
212 $texte .= "</td></tr>";
213 $texte .= '</table>';
214 }
215 }
216
217 $texte .= '<br>';
218 // Link to show/hide the area to manage directories of ODT models and template files
219 $texte .= '<span class="classlink cursorpointer" onclick="javascript: jQuery(\'.div_odtmodelsof'.get_class($this).'\').toggle();">'.img_picto('', 'add').' '.$langs->trans("UploadNewTemplate").'...</span>';
220 $texte .= '<div class="div_odtmodelsof'.get_class($this).'" style="display: none; margin-top: 6px;">';
221 $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1, 3, $this->name);
222 $texte .= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
223 $texte .= '<textarea class="flat textareafordir" spellcheck="false" cols="60" name="value1">';
224 $texte .= $odtPath;
225 $texte .= '</textarea>';
226 $texte .= '</div><div style="display: inline-block; vertical-align: middle;">';
227 $texte .= '<input type="submit" class="button button-edit reposition smallpaddingimp" name="modify" value="'.dolPrintHTMLForAttribute($langs->trans("Modify")).'">';
228 $texte .= '<br></div></div>';
229
230 // Add input to upload a new template file.
231 $texte .= '<div>';
232 $maxfilesizearray = getMaxFileSizeArray();
233 $maxmin = $maxfilesizearray['maxmin'];
234 if ($maxmin > 0) {
235 $texte .= '<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).'">'; // MAX_FILE_SIZE must precede the field type=file
236 }
237 $texte .= ' <input type="file" name="uploadfile">';
238 $texte .= '<input type="hidden" value="PROPALE_ADDON_PDF_ODT_PATH" name="keyforuploaddir">';
239 $texte .= '<input type="submit" class="button smallpaddingimp reposition" value="'.dol_escape_htmltag($langs->trans("Upload")).'" name="upload">';
240 $texte .= '</div>';
241 $texte .= '</div>';
242 $texte .= '</td>';
243
244 $texte .= '</tr>';
245
246 $texte .= '</table>';
247 $texte .= '</form>';
248
249 return $texte;
250 }
251
252 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
264 public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
265 {
266 // phpcs:enable
267 global $user, $langs, $conf, $mysoc, $hookmanager;
268
269 if (empty($srctemplatepath)) {
270 dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING);
271 return -1;
272 }
273
274 // Add odtgeneration hook
275 if (!is_object($hookmanager)) {
276 include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
277 $hookmanager = new HookManager($this->db);
278 }
279 $hookmanager->initHooks(array('odtgeneration'));
280 global $action;
281
282 if (!is_object($outputlangs)) {
283 $outputlangs = $langs;
284 }
285 $sav_charset_output = $outputlangs->charset_output;
286 $outputlangs->charset_output = 'UTF-8';
287
288 // Load translation files required by the page
289 $outputlangs->loadLangs(array("main", "dict", "companies", "bills"));
290
291 if ($conf->propal->multidir_output[$conf->entity]) {
292 // If $object is id instead of object
293 if (!is_object($object)) {
294 $id = $object;
295 $object = new Propal($this->db);
296 $result = $object->fetch($id);
297 if ($result < 0) {
298 dol_print_error($this->db, $object->error);
299 return -1;
300 }
301 }
302
303 $object->fetch_thirdparty();
304
305 $dir = $conf->propal->multidir_output[$object->entity ?? $conf->entity];
306 $objectref = dol_sanitizeFileName($object->ref);
307 if (!preg_match('/specimen/i', $objectref)) {
308 $dir .= "/".$objectref;
309 }
310 $file = $dir."/".$objectref.".odt";
311
312 if (!file_exists($dir)) {
313 if (dol_mkdir($dir) < 0) {
314 $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
315 return -1;
316 }
317 }
318
319 if (file_exists($dir)) {
320 //print "srctemplatepath=".$srctemplatepath; // Src filename
321 $newfile = basename($srctemplatepath);
322 $newfiletmp = preg_replace('/\.od[ts]/i', '', $newfile);
323 $newfiletmp = preg_replace('/template_/i', '', $newfiletmp);
324 $newfiletmp = preg_replace('/modele_/i', '', $newfiletmp);
325
326 $newfiletmp = $objectref . '_' . $newfiletmp;
327
328 // Get extension (ods or odt)
329 $newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
330 if (getDolGlobalString('MAIN_DOC_USE_TIMING')) {
331 $format = getDolGlobalString('MAIN_DOC_USE_TIMING');
332 if ($format == '1') {
333 $format = '%Y%m%d%H%M%S';
334 }
335 $filename = $newfiletmp . '-' . dol_print_date(dol_now(), $format) . '.' . $newfileformat;
336 } else {
337 $filename = $newfiletmp . '.' . $newfileformat;
338 }
339 $file = $dir . '/' . $filename;
340 //print "newdir=".$dir;
341 //print "newfile=".$newfile;
342 //print "file=".$file;
343 //print "conf->propal->dir_temp=".$conf->propal->dir_temp;
344
345 dol_mkdir($conf->propal->multidir_temp[$object->entity]);
346 if (!is_writable($conf->propal->dir_temp)) {
347 $this->error = $langs->transnoentities("ErrorFailedToWriteInTempDirectory", $conf->propal->dir_temp);
348 dol_syslog('Error in write_file: ' . $this->error, LOG_ERR);
349 return -1;
350 }
351
352 // If CUSTOMER contact defined on proposal, we use it
353 $usecontact = false;
354 $arrayidcontact = $object->getIdContact('external', 'CUSTOMER');
355 if (count($arrayidcontact) > 0) {
356 $usecontact = true;
357 $result = $object->fetch_contact($arrayidcontact[0]);
358 }
359
360 // Recipient name
361 $contactobject = null;
362 if (!empty($usecontact)) {
363 // We can use the company of contact instead of thirdparty company
364 if ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || getDolGlobalString('MAIN_USE_COMPANY_NAME_OF_CONTACT'))) {
365 $object->contact->fetch_thirdparty();
366 $socobject = $object->contact->thirdparty;
367 $contactobject = $object->contact;
368 } else {
369 $socobject = $object->thirdparty;
370 // if we have a CUSTOMER contact and we don't use it as thirdparty recipient we store the contact object for later use
371 $contactobject = $object->contact;
372 }
373 } else {
374 $socobject = $object->thirdparty;
375 }
376 // Make substitution
377 $substitutionarray = array(
378 '__FROM_NAME__' => $this->emetteur->name,
379 '__FROM_EMAIL__' => $this->emetteur->email,
380 '__TOTAL_TTC__' => $object->total_ttc,
381 '__TOTAL_HT__' => $object->total_ht,
382 '__TOTAL_VAT__' => $object->total_tva
383 );
384 complete_substitutions_array($substitutionarray, $langs, $object);
385 // Call the ODTSubstitution hook
386 $parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$substitutionarray);
387 $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
388
389 // Line of free text
390 $newfreetext = '';
391 $paramfreetext = 'PROPOSAL_FREE_TEXT';
392 if (getDolGlobalString($paramfreetext)) {
393 $newfreetext = make_substitutions(getDolGlobalString($paramfreetext), $substitutionarray);
394 }
395
396 // Open and load template
397 require_once ODTPHP_PATH.'odf.php';
398 try {
399 $odfHandler = new Odf(
400 $srctemplatepath,
401 array(
402 'PATH_TO_TMP' => $conf->propal->multidir_temp[$object->entity],
403 'ZIP_PROXY' => getDolGlobalString('MAIN_ODF_ZIP_PROXY', 'PclZipProxy'), // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
404 'DELIMITER_LEFT' => '{',
405 'DELIMITER_RIGHT' => '}'
406 )
407 );
408 } catch (Exception $e) {
409 $this->error = $e->getMessage();
410 dol_syslog($e->getMessage(), LOG_INFO);
411 return -1;
412 }
413 // After construction $odfHandler->contentXml contains content and
414 // [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by
415 // [!-- BEGIN lines --]*[!-- END lines --]
416 //print html_entity_decode($odfHandler->__toString());
417 //print exit;
418
419 $object->fetch_optionals();
420
421 // Make substitutions into odt of freetext
422 try {
423 $odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8');
424 } catch (OdfException $e) {
425 dol_syslog($e->getMessage(), LOG_INFO);
426 }
427
428 // Define substitution array
429 $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
430 $array_object_from_properties = $this->get_substitutionarray_each_var_object($object, $outputlangs);
431 $array_objet = $this->get_substitutionarray_object($object, $outputlangs);
432 $array_user = $this->get_substitutionarray_user($user, $outputlangs);
433 $array_soc = $this->get_substitutionarray_mysoc($mysoc, $outputlangs);
434 $array_thirdparty = $this->get_substitutionarray_thirdparty($socobject, $outputlangs);
435 $array_other = $this->get_substitutionarray_other($outputlangs);
436
437 include_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php';
438 $companybankaccount = new CompanyBankAccount($this->db);
439 // @phan-suppress-next-line PhanPluginSuspiciousParamPosition
440 $companybankaccount->fetch(0, '', $object->thirdparty->id);
441 $array_objet['company_default_bank_iban'] = $companybankaccount->iban;
442 $array_objet['company_default_bank_bic'] = $companybankaccount->bic;
443
444 // retrieve contact information for use in object as contact_xxx tags
445 $array_thirdparty_contact = array();
446 if ($usecontact && is_object($contactobject)) {
447 $array_thirdparty_contact = $this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact');
448 }
449
450 $tmparray = array_merge($substitutionarray, $array_object_from_properties, $array_user, $array_soc, $array_thirdparty, $array_objet, $array_other, $array_thirdparty_contact);
451 complete_substitutions_array($tmparray, $outputlangs, $object);
452
453 // Call the ODTSubstitution hook
454 $parameters = array('odfHandler' => &$odfHandler, 'file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$tmparray);
455 $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
456
457 // retrieve the constant to apply a ratio for image size or set the ratio to 1
458 if (getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')) {
459 $ratio = (float) getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO');
460 } else {
461 $ratio = 1;
462 }
463
464 foreach ($tmparray as $key => $value) {
465 try {
466 if (preg_match('/logo$/', $key)) {
467 // Image
468 if (file_exists($value)) {
469 $odfHandler->setImage($key, $value, $ratio);
470 } else {
471 $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
472 }
473 } else {
474 // Text
475 $odfHandler->setVars($key, $value, true, 'UTF-8');
476 }
477 } catch (OdfException $e) {
478 dol_syslog($e->getMessage(), LOG_INFO);
479 }
480 }
481 // Replace tags of lines
482 $foundtagforlines = 1;
483 try {
484 $listlines = $odfHandler->setSegment('lines');
485 } catch (OdfExceptionSegmentNotFound $e) {
486 // We may arrive here if tags for lines not present into template
487 $foundtagforlines = 0;
488 dol_syslog($e->getMessage(), LOG_INFO);
489 }
490 if ($foundtagforlines) {
491 $linenumber = 0;
492 foreach ($object->lines as $line) {
494 $linenumber++;
495 $tmparray = $this->get_substitutionarray_lines($line, $outputlangs, $linenumber);
496 complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines");
497 // Call the ODTSubstitutionLine hook
498 $parameters = array('odfHandler' => &$odfHandler, 'file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$tmparray, 'line' => $line);
499 $reshook = $hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
500 foreach ($tmparray as $key => $val) {
501 try {
502 $listlines->setVars($key, $val, true, 'UTF-8');
503 } catch (SegmentException $e) {
504 dol_syslog($e->getMessage(), LOG_INFO);
505 }
506 }
507 $listlines->merge();
508 }
509 try {
510 $odfHandler->mergeSegment($listlines);
511 } catch (OdfException $e) {
512 $this->error = $e->getMessage();
513 dol_syslog($this->error, LOG_WARNING);
514 return -1;
515 }
516 }
517
518 // Replace labels translated
519 $tmparray = $outputlangs->get_translations_for_substitutions();
520 foreach ($tmparray as $key => $value) {
521 try {
522 $odfHandler->setVars($key, $value, true, 'UTF-8');
523 } catch (OdfException $e) {
524 dol_syslog($e->getMessage(), LOG_INFO);
525 }
526 }
527
528 // Call the beforeODTSave hook
529 $parameters = array('odfHandler' => &$odfHandler, 'file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$tmparray);
530 $reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
531
532 // Write new file
533 if (getDolGlobalString('MAIN_ODT_AS_PDF')) {
534 try {
535 $odfHandler->exportAsAttachedPDF($file);
536 } catch (Exception $e) {
537 $this->error = $e->getMessage();
538 dol_syslog($e->getMessage(), LOG_INFO);
539 return -1;
540 }
541 } else {
542 try {
543 $odfHandler->saveToDisk($file);
544 } catch (Exception $e) {
545 $this->error = $e->getMessage();
546 dol_syslog($e->getMessage(), LOG_INFO);
547 return -1;
548 }
549 }
550 $parameters = array('odfHandler' => &$odfHandler, 'file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$tmparray);
551 $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
552
553 dolChmod($file);
554
555 $odfHandler = null; // Destroy object
556
557 $this->result = array('fullpath' => $file);
558
559 return 1; // Success
560 } else {
561 $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
562 return -1;
563 }
564 }
565
566 return -1;
567 }
568}
$propal type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
Definition propal.php:281
Class to manage generation of HTML components Only common components must be here.
Class mere des modeles de propale.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
write_file($object, $outputlangs, $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0)
Function to build a document on disk using the generic odt module.
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.
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:66
getCallerInfoString()
Get caller info as a string that can be appended to a log message.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
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.
conf($dolibarr_main_document_root, $realpathconf=null)
Load conf file (file must exists)
Definition inc.php:431
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:165
multi select button
0 = Do not include form tag and submit button -1 = Do not include form tag but include submit button