dolibarr 19.0.4
doc_generic_invoice_odt.modules.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2010-2012 Laurent Destailleur <ely@users.sourceforge.net>
3 * Copyright (C) 2012 Regis Houssin <regis.houssin@inodbox.com>
4 * Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
5 * Copyright (C) 2016 Charlie Benke <charlie@patas-monkey.com>
6 * Copyright (C) 2018-2019 Frédéric France <frederic.france@netlogic.fr>
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/facture/modules_facture.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 $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/ODS templates";
63 $this->description = $langs->trans("DocumentModelOdt");
64 $this->scandir = 'FACTURE_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 FACTURE_TVAOPTION
78 $this->option_modereg = 1; // Display payment mode
79 $this->option_condreg = 1; // 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); // Par defaut, si n'etait pas defini
90 }
91 }
92
93
100 public function info($langs)
101 {
102 global $conf, $langs;
103
104 // Load translation files required by the page
105 $langs->loadLangs(array("errors", "companies"));
106
107 $form = new Form($this->db);
108
109 $texte = $this->description.".<br>\n";
110 $texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST" enctype="multipart/form-data">';
111 $texte .= '<input type="hidden" name="token" value="'.newToken().'">';
112 $texte .= '<input type="hidden" name="page_y" value="">';
113 $texte .= '<input type="hidden" name="action" value="setModuleOptions">';
114 $texte .= '<input type="hidden" name="param1" value="FACTURE_ADDON_PDF_ODT_PATH">';
115 $texte .= '<table class="nobordernopadding" width="100%">';
116
117 // List of directories area
118 $texte .= '<tr><td valign="middle">';
119 $texttitle = $langs->trans("ListOfDirectories");
120 $listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->FACTURE_ADDON_PDF_ODT_PATH)));
121 $listoffiles = array();
122 foreach ($listofdir as $key => $tmpdir) {
123 $tmpdir = trim($tmpdir);
124 $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir);
125 if (!$tmpdir) {
126 unset($listofdir[$key]);
127 continue;
128 }
129 if (!is_dir($tmpdir)) {
130 $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0);
131 } else {
132 $tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)');
133 if (count($tmpfiles)) {
134 $listoffiles = array_merge($listoffiles, $tmpfiles);
135 }
136 }
137 }
138 $texthelp = $langs->trans("ListOfDirectoriesForModelGenODT");
139 $texthelp .= '<br><br><span class="opacitymedium">'.$langs->trans("ExampleOfDirectoriesForModelGen").'</span>';
140 // Add list of substitution keys
141 $texthelp .= '<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
142 $texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it
143
144 $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1, 3, $this->name);
145 $texte .= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
146 $texte .= '<textarea class="flat" cols="60" name="value1">';
147 $texte .= getDolGlobalString('FACTURE_ADDON_PDF_ODT_PATH');
148 $texte .= '</textarea>';
149 $texte .= '</div><div style="display: inline-block; vertical-align: middle;">';
150 $texte .= '<input type="submit" class="button button-edit reposition smallpaddingimp" name="modify" value="'.dol_escape_htmltag($langs->trans("Modify")).'">';
151 $texte .= '<br></div></div>';
152
153 // Scan directories
154 $nbofiles = count($listoffiles);
155 if (getDolGlobalString('FACTURE_ADDON_PDF_ODT_PATH')) {
156 $texte .= $langs->trans("NumberOfModelFilesFound").': <b>';
157 //$texte.=$nbofiles?'<a id="a_'.get_class($this).'" href="#">':'';
158 $texte .= count($listoffiles);
159 //$texte.=$nbofiles?'</a>':'';
160 $texte .= '</b>';
161 }
162 if ($nbofiles) {
163 $texte .= '<div id="div_'.get_class($this).'" class="hiddenx">';
164 // Show list of found files
165 foreach ($listoffiles as $file) {
166 $texte .= '- '.$file['name'].' <a href="'.DOL_URL_ROOT.'/document.php?modulepart=doctemplates&file=invoices/'.urlencode(basename($file['name'])).'">'.img_picto('', 'listlight').'</a>';
167 $texte .= ' &nbsp; <a class="reposition" href="'.$_SERVER["PHP_SELF"].'?modulepart=doctemplates&keyforuploaddir=FACTURE_ADDON_PDF_ODT_PATH&action=deletefile&token='.newToken().'&file='.urlencode(basename($file['name'])).'">'.img_picto('', 'delete').'</a>';
168 $texte .= '<br>';
169 }
170 $texte .= '</div>';
171 }
172 // Add input to upload a new template file.
173 $texte .= '<div>'.$langs->trans("UploadNewTemplate");
174 $maxfilesizearray = getMaxFileSizeArray();
175 $maxmin = $maxfilesizearray['maxmin'];
176 if ($maxmin > 0) {
177 $texte .= '<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).'">'; // MAX_FILE_SIZE must precede the field type=file
178 }
179 $texte .= ' <input type="file" name="uploadfile">';
180 $texte .= '<input type="hidden" value="FACTURE_ADDON_PDF_ODT_PATH" name="keyforuploaddir">';
181 $texte .= '<input type="submit" class="button smallpaddingimp reposition" value="'.dol_escape_htmltag($langs->trans("Upload")).'" name="upload">';
182 $texte .= '</div>';
183 $texte .= '</td>';
184
185 $texte .= '</tr>';
186
187 $texte .= '</table>';
188 $texte .= '</form>';
189
190 return $texte;
191 }
192
193 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
205 public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
206 {
207 // phpcs:enable
208 global $user, $langs, $conf, $mysoc, $hookmanager;
209
210 if (empty($srctemplatepath)) {
211 dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING);
212 return -1;
213 }
214
215 // Add odtgeneration hook
216 if (!is_object($hookmanager)) {
217 include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
218 $hookmanager = new HookManager($this->db);
219 }
220 $hookmanager->initHooks(array('odtgeneration'));
221 global $action;
222
223 if (!is_object($outputlangs)) {
224 $outputlangs = $langs;
225 }
226 $sav_charset_output = $outputlangs->charset_output;
227 $outputlangs->charset_output = 'UTF-8';
228
229 // Load translation files required by the page
230 $outputlangs->loadLangs(array("main", "dict", "companies", "bills"));
231
232 if ($conf->facture->dir_output) {
233 // If $object is id instead of object
234 if (!is_object($object)) {
235 $id = $object;
236 $object = new Facture($this->db);
237 $result = $object->fetch($id);
238 if ($result < 0) {
239 dol_print_error($this->db, $object->error);
240 return -1;
241 }
242 }
243
244 $object->fetch_thirdparty();
245
246 $dir = empty($conf->facture->multidir_output[$object->entity]) ? $conf->facture->dir_output : $conf->facture->multidir_output[$object->entity];
247 $objectref = dol_sanitizeFileName($object->ref);
248 if (!preg_match('/specimen/i', $objectref)) {
249 $dir .= "/".$objectref;
250 }
251 $file = $dir."/".$objectref.".odt";
252
253 if (!file_exists($dir)) {
254 if (dol_mkdir($dir) < 0) {
255 $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
256 return -1;
257 }
258 }
259
260 if (file_exists($dir)) {
261 //print "srctemplatepath=".$srctemplatepath; // Src filename
262 $newfile = basename($srctemplatepath);
263 $newfiletmp = preg_replace('/\.od[ts]/i', '', $newfile);
264 $newfiletmp = preg_replace('/template_/i', '', $newfiletmp);
265 $newfiletmp = preg_replace('/modele_/i', '', $newfiletmp);
266
267 $newfiletmp = $objectref . '_' . $newfiletmp;
268
269 // Get extension (ods or odt)
270 $newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
271 if (getDolGlobalString('MAIN_DOC_USE_TIMING')) {
272 $format = getDolGlobalString('MAIN_DOC_USE_TIMING');
273 if ($format == '1') {
274 $format = '%Y%m%d%H%M%S';
275 }
276 $filename = $newfiletmp . '-' . dol_print_date(dol_now(), $format) . '.' . $newfileformat;
277 } else {
278 $filename = $newfiletmp . '.' . $newfileformat;
279 }
280 $file = $dir . '/' . $filename;
281 //$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt';
282 //print "newdir=".$dir;
283 //print "newfile=".$newfile;
284 //print "file=".$file;
285 //print "conf->societe->dir_temp=".$conf->societe->dir_temp;
286
287 dol_mkdir($conf->facture->dir_temp);
288 if (!is_writable($conf->facture->dir_temp)) {
289 $this->error = $langs->transnoentities("ErrorFailedToWriteInTempDirectory", $conf->facture->dir_temp);
290 dol_syslog('Error in write_file: ' . $this->error, LOG_ERR);
291 return -1;
292 }
293
294 // If BILLING contact defined on invoice, we use it
295 $usecontact = false;
296 $arrayidcontact = $object->getIdContact('external', 'BILLING');
297 if (count($arrayidcontact) > 0) {
298 $usecontact = true;
299 $result = $object->fetch_contact($arrayidcontact[0]);
300 }
301
302 // Recipient name
303 $contactobject = null;
304 if (!empty($usecontact)) {
305 // We can use the company of contact instead of thirdparty company
306 if ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || getDolGlobalString('MAIN_USE_COMPANY_NAME_OF_CONTACT'))) {
307 $object->contact->fetch_thirdparty();
308 $socobject = $object->contact->thirdparty;
309 $contactobject = $object->contact;
310 } else {
311 $socobject = $object->thirdparty;
312 // if we have a BILLING contact and we dont use it as thirdparty recipient we store the contact object for later use
313 $contactobject = $object->contact;
314 }
315 } else {
316 $socobject = $object->thirdparty;
317 }
318
319 // Fetch info for linked propal
320 $object->fetchObjectLinked('', '', '', '');
321 //print_r($object->linkedObjects['propal']); exit;
322
323 $propal_object = null;
324 if (!empty($object->linkedObjects['propal'])) {
325 $array_propal_object = $object->linkedObjects['propal'];
326 if (isset($array_propal_object) && is_array($array_propal_object) && count($array_propal_object) > 0) {
327 $tmparrayofvalue = array_values($array_propal_object);
328 $propal_object = $tmparrayofvalue[0];
329 }
330 }
331
332 // and determine category of operation
333 $categoryOfOperation = 0;
334 $nbProduct = 0;
335 $nbService = 0;
336 foreach ($object->lines as $line) {
337 // determine category of operation
338 if ($categoryOfOperation < 2) {
339 $lineProductType = $line->product_type;
340 if ($lineProductType == Product::TYPE_PRODUCT) {
341 $nbProduct++;
342 } elseif ($lineProductType == Product::TYPE_SERVICE) {
343 $nbService++;
344 }
345 if ($nbProduct > 0 && $nbService > 0) {
346 // mixed products and services
347 $categoryOfOperation = 2;
348 }
349 }
350 }
351
352 // determine category of operation
353 if ($categoryOfOperation <= 0) {
354 // only services
355 if ($nbProduct == 0 && $nbService > 0) {
356 $categoryOfOperation = 1;
357 }
358 }
359
360 // Make substitution
361 $substitutionarray = array(
362 '__FROM_NAME__' => $this->emetteur->name,
363 '__FROM_EMAIL__' => $this->emetteur->email,
364 '__TOTAL_TTC__' => $object->total_ttc,
365 '__TOTAL_HT__' => $object->total_ht,
366 '__TOTAL_VAT__' => $object->total_tva
367 );
368 complete_substitutions_array($substitutionarray, $langs, $object);
369 // Call the ODTSubstitution hook
370 $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$substitutionarray);
371 $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
372
373 // Line of free text
374 $newfreetext = '';
375 $paramfreetext = 'INVOICE_FREE_TEXT';
376 if (!empty($conf->global->$paramfreetext)) {
377 $newfreetext = make_substitutions(getDolGlobalString($paramfreetext), $substitutionarray);
378 }
379
380 // Open and load template
381 require_once ODTPHP_PATH.'odf.php';
382 try {
383 $odfHandler = new Odf(
384 $srctemplatepath,
385 array(
386 'PATH_TO_TMP' => $conf->facture->dir_temp,
387 'ZIP_PROXY' => getDolGlobalString('MAIN_ODF_ZIP_PROXY', 'PclZipProxy'), // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
388 'DELIMITER_LEFT' => '{',
389 'DELIMITER_RIGHT' => '}'
390 )
391 );
392 } catch (Exception $e) {
393 $this->error = $e->getMessage();
394 dol_syslog($e->getMessage(), LOG_INFO);
395 return -1;
396 }
397 // After construction $odfHandler->contentXml contains content and
398 // [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by
399 // [!-- BEGIN lines --]*[!-- END lines --]
400 //print html_entity_decode($odfHandler->__toString());
401 //print exit;
402
403
404 // Make substitutions into odt of freetext
405 try {
406 $odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8');
407 } catch (OdfException $e) {
408 dol_syslog($e->getMessage(), LOG_INFO);
409 }
410
411 // Define substitution array
412 $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); // Set tags __...__
413 $array_object_from_properties = $this->get_substitutionarray_each_var_object($object, $outputlangs);
414 $array_objet = $this->get_substitutionarray_object($object, $outputlangs); // Set tags object_...
415 $array_user = $this->get_substitutionarray_user($user, $outputlangs); // Set tags myuser_...
416 $array_soc = $this->get_substitutionarray_mysoc($mysoc, $outputlangs);
417 $array_thirdparty = $this->get_substitutionarray_thirdparty($socobject, $outputlangs);
418 $array_propal = is_object($propal_object) ? $this->get_substitutionarray_object($propal_object, $outputlangs, 'propal') : array();
419 $array_other = $this->get_substitutionarray_other($outputlangs);
420 // retrieve contact information for use in object as contact_xxx tags
421 $array_thirdparty_contact = array();
422 if ($usecontact && is_object($contactobject)) {
423 $array_thirdparty_contact = $this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact');
424 }
425
426 $tmparray = array_merge($substitutionarray, $array_object_from_properties, $array_user, $array_soc, $array_thirdparty, $array_objet, $array_propal, $array_other, $array_thirdparty_contact);
427 complete_substitutions_array($tmparray, $outputlangs, $object);
428
429 // Complete also with substitution from keys directly found into template
430 // TODO Search all tags {object_...:xxxx} into template then loop on this found tags to analyze them and the the corresponding
431 // property of object and use the xxxx to know how to format it.
432 // Before that, we hard code this substitution as if we have found them into the template.
433
434 $tmparray['object_PREVIOUS_MONTH'] = dol_print_date(dol_time_plus_duree($object->date, -1, 'm'), '%m');
435 $tmparray['object_MONTH'] = dol_print_date($object->date, '%m');
436 $tmparray['object_NEXT_MONTH'] = dol_print_date(dol_time_plus_duree($object->date, 1, 'm'), '%m');
437 $tmparray['object_PREVIOUS_MONTH_TEXT'] = dol_print_date(dol_time_plus_duree($object->date, -1, 'm'), '%B');
438 $tmparray['object_MONTH_TEXT'] = dol_print_date($object->date, '%B');
439 $tmparray['object_NEXT_MONTH_TEXT'] = dol_print_date(dol_time_plus_duree($object->date, 1, 'm'), '%B');
440 $tmparray['object_PREVIOUS_YEAR'] = dol_print_date(dol_time_plus_duree($object->date, -1, 'y'), '%Y');
441 $tmparray['object_YEAR'] = dol_print_date($object->date, '%Y');
442 $tmparray['object_NEXT_YEAR'] = dol_print_date(dol_time_plus_duree($object->date, 1, 'y'), '%Y');
443 $tmparray['object_productorservice_operation'] = $outputlangs->transnoentities("MentionCategoryOfOperations" . $categoryOfOperation);
444
445
446 // Call the ODTSubstitution hook
447 $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
448 $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
449
450 //var_dump($tmparray); exit;
451 foreach ($tmparray as $key => $value) {
452 try {
453 if (preg_match('/logo$/', $key)) { // Image
454 //var_dump($value);exit;
455 if (file_exists($value)) {
456 $odfHandler->setImage($key, $value);
457 } else {
458 $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
459 }
460 } else {
461 // Text
462 $odfHandler->setVars($key, $value, true, 'UTF-8');
463 }
464 } catch (OdfException $e) {
465 dol_syslog($e->getMessage(), LOG_INFO);
466 }
467 }
468 // Replace tags of lines
469 try {
470 $foundtagforlines = 1;
471 try {
472 $listlines = $odfHandler->setSegment('lines');
473 } catch (OdfExceptionSegmentNotFound $e) {
474 // We may arrive here if tags for lines not present into template
475 $foundtagforlines = 0;
476 dol_syslog($e->getMessage(), LOG_INFO);
477 } catch (OdfException $e) {
478 $foundtagforlines = 0;
479 dol_syslog($e->getMessage(), LOG_INFO);
480 }
481 if ($foundtagforlines) {
482 $linenumber = 0;
483 foreach ($object->lines as $line) {
484 $linenumber++;
485 $tmparray = $this->get_substitutionarray_lines($line, $outputlangs, $linenumber);
486 complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines");
487 // Call the ODTSubstitutionLine hook
488 $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray, 'line'=>$line);
489 $reshook = $hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
490 foreach ($tmparray as $key => $val) {
491 try {
492 $listlines->setVars($key, $val, true, 'UTF-8');
493 } catch (OdfException $e) {
494 dol_syslog($e->getMessage(), LOG_INFO);
495 } catch (SegmentException $e) {
496 dol_syslog($e->getMessage(), LOG_INFO);
497 }
498 }
499 $listlines->merge();
500 }
501 $odfHandler->mergeSegment($listlines);
502 }
503 } catch (OdfException $e) {
504 $this->error = $e->getMessage();
505 dol_syslog($this->error, LOG_WARNING);
506 return -1;
507 }
508
509 // Replace labels translated
510 $tmparray = $outputlangs->get_translations_for_substitutions();
511 foreach ($tmparray as $key => $value) {
512 try {
513 $odfHandler->setVars($key, $value, true, 'UTF-8');
514 } catch (OdfException $e) {
515 dol_syslog($e->getMessage(), LOG_INFO);
516 }
517 }
518
519 // Call the beforeODTSave hook
520 $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
521 $reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
522
523 // Write new file
524 if (getDolGlobalString('MAIN_ODT_AS_PDF')) {
525 try {
526 $odfHandler->exportAsAttachedPDF($file);
527 } catch (Exception $e) {
528 $this->error = $e->getMessage();
529 dol_syslog($e->getMessage(), LOG_INFO);
530 return -1;
531 }
532 } else {
533 try {
534 $odfHandler->saveToDisk($file);
535 } catch (Exception $e) {
536 $this->error = $e->getMessage();
537 dol_syslog($e->getMessage(), LOG_INFO);
538 return -1;
539 }
540 }
541 $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
542 $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
543
544 dolChmod($file);
545
546 $odfHandler = null; // Destroy object
547
548 $this->result = array('fullpath'=>$file);
549
550 return 1; // Success
551 } else {
552 $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
553 return -1;
554 }
555 }
556
557 return -1;
558 }
559}
get_substitutionarray_each_var_object(&$object, $outputlangs, $recursive=1)
Define array with couple substitution key => substitution value.
get_substitutionarray_object($object, $outputlangs, $array_key='object')
Define array with couple substitution key => substitution value Note that vars into substitutions arr...
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 invoices.
Class to manage generation of HTML components Only common components must be here.
Class to manage hooks.
Parent class of invoice document generators.
const TYPE_PRODUCT
Regular product.
const TYPE_SERVICE
Service.
Class to build documents using ODF templates generator.
write_file($object, $outputlangs, $srctemplatepath, $hidedetails=0, $hidedesc=0, $hideref=0)
Function to build a document on disk using the generic odt module.
info($langs)
Return description of a module.
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0)
Add a delay to a date.
Definition date.lib.php:125
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($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:62
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dolChmod($filepath, $newmask='')
Change mod of a file.
dol_now($mode='auto')
Return date for now.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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.
getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $object=null, $include=null)
Return array of possible common substitutions.
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:121
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:124
getMaxFileSizeArray()
Return the max allowed for file upload.