diff --git a/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php b/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php index c840f8e02c1..c5b938fe8f1 100644 --- a/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php +++ b/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php @@ -229,7 +229,7 @@ class doc_generic_contract_odt extends ModelePDFContract // Load translation files required by page $outputlangs->loadLangs(array("main", "dict", "companies", "bills")); - if ($conf->contrat->multidir_output[$object->entity]) { + if ($conf->contract->multidir_output[$object->entity]) { // If $object is id instead of object if (!is_object($object)) { $id = $object; @@ -243,7 +243,7 @@ class doc_generic_contract_odt extends ModelePDFContract $object->fetch_thirdparty(); - $dir = $conf->contrat->multidir_output[$object->entity]; + $dir = $conf->contract->multidir_output[$object->entity]; $objectref = dol_sanitizeFileName($object->ref); if (!preg_match('/specimen/i', $objectref)) { $dir .= "/".$objectref; @@ -283,8 +283,8 @@ class doc_generic_contract_odt extends ModelePDFContract //print "file=".$file; //print "conf->contrat->dir_temp=".$conf->contrat->dir_temp; - dol_mkdir($conf->contrat->dir_temp); - if (!is_writable($conf->contrat->dir_temp)) { + dol_mkdir($conf->contract->dir_temp); + if (!is_writable($conf->contract->dir_temp)) { $this->error = $langs->transnoentities("ErrorFailedToWriteInTempDirectory", $conf->contrat->dir_temp); dol_syslog('Error in write_file: ' . $this->error, LOG_ERR); return -1; @@ -483,7 +483,6 @@ class doc_generic_contract_odt extends ModelePDFContract return 1; // Success } else { $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); - return -1; } } diff --git a/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php b/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php index 78666dd5e9f..c8781cdd2cc 100644 --- a/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php +++ b/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php @@ -84,7 +84,7 @@ class doc_generic_shipment_odt extends ModelePdfExpedition $this->option_freetext = 1; // Support add of a personalised text $this->option_draft_watermark = 0; // Support add of a watermark on drafts - // Recupere emetteur + // Get source company $this->emetteur = $mysoc; if (!$this->emetteur->country_code) { $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined @@ -227,10 +227,10 @@ class doc_generic_shipment_odt extends ModelePdfExpedition $sav_charset_output = $outputlangs->charset_output; $outputlangs->charset_output = 'UTF-8'; - // Load traductions files required by page + // Load translation files required by page $outputlangs->loadLangs(array("main", "dict", "companies", "bills")); - if ($conf->expedition->dir_output."/sending") { + if ($conf->expedition->multidir_output[$object->entity]."/sending") { // If $object is id instead of object if (!is_object($object)) { $id = $object; @@ -244,7 +244,7 @@ class doc_generic_shipment_odt extends ModelePdfExpedition $object->fetch_thirdparty(); - $dir = $conf->expedition->dir_output."/sending"; + $dir = $conf->expedition->multidir_output[$object->entity]."/sending"; $objectref = dol_sanitizeFileName($object->ref); if (!preg_match('/specimen/i', $objectref)) { $dir .= "/".$objectref; @@ -451,21 +451,25 @@ class doc_generic_shipment_odt extends ModelePdfExpedition // Call the ODTSubstitution hook $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + foreach ($tmparray as $key => $value) { try { - if (preg_match('/logo$/', $key)) { // Image + if (preg_match('/logo$/', $key)) { + // Image if (file_exists($value)) { $odfHandler->setImage($key, $value); } else { $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); } - } else { // Text + } else { + // Text $odfHandler->setVars($key, $value, true, 'UTF-8'); } } catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } } + // Replace tags of lines $foundtagforlines = 1; try { @@ -476,8 +480,10 @@ class doc_generic_shipment_odt extends ModelePdfExpedition dol_syslog($e->getMessage(), LOG_INFO); } if ($foundtagforlines) { + $linenumber = 0; foreach ($object->lines as $line) { - $tmparray = $this->get_substitutionarray_lines($line, $outputlangs); + $linenumber++; + $tmparray = $this->get_substitutionarray_lines($line, $outputlangs, $linenumber); complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines"); // Call the ODTSubstitutionLine hook $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray, 'line'=>$line); @@ -532,6 +538,7 @@ class doc_generic_shipment_odt extends ModelePdfExpedition return -1; } } + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks @@ -544,7 +551,6 @@ class doc_generic_shipment_odt extends ModelePdfExpedition return 1; // Success } else { $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); - return -1; } }