FIX substitution in ODT of thirdparties documents
This commit is contained in:
parent
f7556e7ad2
commit
cad44ee68a
@ -150,7 +150,7 @@ class doc_generic_odt extends ModeleThirdPartyDoc
|
||||
}
|
||||
$texte.='<div id="div_'.get_class($this).'">';
|
||||
}
|
||||
|
||||
|
||||
$texte.= '</td>';
|
||||
|
||||
$texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">';
|
||||
@ -272,53 +272,6 @@ class doc_generic_odt extends ModeleThirdPartyDoc
|
||||
}
|
||||
//print $odfHandler->__toString()."\n";
|
||||
|
||||
// Make substitutions into odt of user info
|
||||
$tmparray=$this->get_substitutionarray_user($user,$outputlangs);
|
||||
//var_dump($tmparray); exit;
|
||||
foreach($tmparray as $key=>$value)
|
||||
{
|
||||
try {
|
||||
if (preg_match('/logo$/',$key)) // Image
|
||||
{
|
||||
//var_dump($value);exit;
|
||||
if (file_exists($value)) $odfHandler->setImage($key, $value);
|
||||
else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
|
||||
}
|
||||
else // Text
|
||||
{
|
||||
//print $key.' '.$value;exit;
|
||||
$odfHandler->setVars($key, $value, true, 'UTF-8');
|
||||
}
|
||||
}
|
||||
catch(OdfException $e)
|
||||
{
|
||||
// setVars failed, probably because key not found
|
||||
}
|
||||
}
|
||||
// Make substitutions into odt of mysoc info
|
||||
$tmparray=$this->get_substitutionarray_mysoc($mysoc,$outputlangs);
|
||||
//var_dump($tmparray); exit;
|
||||
foreach($tmparray as $key=>$value)
|
||||
{
|
||||
try {
|
||||
if (preg_match('/logo$/',$key)) // Image
|
||||
{
|
||||
//var_dump($value);exit;
|
||||
if (file_exists($value)) $odfHandler->setImage($key, $value);
|
||||
else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
|
||||
}
|
||||
else // Text
|
||||
{
|
||||
$odfHandler->setVars($key, $value, true, 'UTF-8');
|
||||
}
|
||||
}
|
||||
catch(OdfException $e)
|
||||
{
|
||||
// setVars failed, probably because key not found
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Replace tags of lines for contacts
|
||||
$contact_arrray=array();
|
||||
|
||||
@ -333,7 +286,7 @@ class doc_generic_odt extends ModeleThirdPartyDoc
|
||||
if ($num)
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
|
||||
|
||||
|
||||
$i=0;
|
||||
$contactstatic = new Contact($this->db);
|
||||
|
||||
@ -380,13 +333,18 @@ class doc_generic_odt extends ModeleThirdPartyDoc
|
||||
}
|
||||
}
|
||||
|
||||
// Make substitutions into odt of thirdparty + external modules
|
||||
$tmparray=$this->get_substitutionarray_thirdparty($object,$outputlangs);
|
||||
// Make substitutions into odt
|
||||
$array_user=$this->get_substitutionarray_user($user,$outputlangs);
|
||||
$array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs);
|
||||
$array_thirdparty=$this->get_substitutionarray_thirdparty($object,$outputlangs);
|
||||
$array_other=$this->get_substitutionarray_other($outputlangs);
|
||||
|
||||
$tmparray = array_merge($array_user,$array_soc,$array_thirdparty,$array_other);
|
||||
complete_substitutions_array($tmparray, $outputlangs, $object);
|
||||
|
||||
// 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
|
||||
$reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
|
||||
|
||||
// Replace variables into document
|
||||
foreach($tmparray as $key=>$value)
|
||||
@ -438,13 +396,13 @@ class doc_generic_odt extends ModeleThirdPartyDoc
|
||||
$odfHandler->creator = $user->getFullName($outputlangs);
|
||||
$odfHandler->title = $object->builddoc_filename;
|
||||
$odfHandler->subject = $object->builddoc_filename;
|
||||
|
||||
|
||||
if (! empty($conf->global->ODT_ADD_DOLIBARR_ID))
|
||||
{
|
||||
$odfHandler->userdefined['dol_id'] = $object->id;
|
||||
$odfHandler->userdefined['dol_element'] = $object->element;
|
||||
}
|
||||
|
||||
|
||||
$odfHandler->saveToDisk($file);
|
||||
}catch (Exception $e){
|
||||
$this->error=$e->getMessage();
|
||||
@ -453,7 +411,7 @@ class doc_generic_odt extends ModeleThirdPartyDoc
|
||||
}
|
||||
$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
|
||||
|
||||
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($file, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user