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.='<div id="div_'.get_class($this).'">';
|
||||||
}
|
}
|
||||||
|
|
||||||
$texte.= '</td>';
|
$texte.= '</td>';
|
||||||
|
|
||||||
$texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">';
|
$texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">';
|
||||||
@ -272,53 +272,6 @@ class doc_generic_odt extends ModeleThirdPartyDoc
|
|||||||
}
|
}
|
||||||
//print $odfHandler->__toString()."\n";
|
//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
|
// Replace tags of lines for contacts
|
||||||
$contact_arrray=array();
|
$contact_arrray=array();
|
||||||
|
|
||||||
@ -333,7 +286,7 @@ class doc_generic_odt extends ModeleThirdPartyDoc
|
|||||||
if ($num)
|
if ($num)
|
||||||
{
|
{
|
||||||
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
|
||||||
|
|
||||||
$i=0;
|
$i=0;
|
||||||
$contactstatic = new Contact($this->db);
|
$contactstatic = new Contact($this->db);
|
||||||
|
|
||||||
@ -380,13 +333,18 @@ class doc_generic_odt extends ModeleThirdPartyDoc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make substitutions into odt of thirdparty + external modules
|
// Make substitutions into odt
|
||||||
$tmparray=$this->get_substitutionarray_thirdparty($object,$outputlangs);
|
$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);
|
complete_substitutions_array($tmparray, $outputlangs, $object);
|
||||||
|
|
||||||
// Call the ODTSubstitution hook
|
// Call the ODTSubstitution hook
|
||||||
$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
|
$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
|
// Replace variables into document
|
||||||
foreach($tmparray as $key=>$value)
|
foreach($tmparray as $key=>$value)
|
||||||
@ -438,13 +396,13 @@ class doc_generic_odt extends ModeleThirdPartyDoc
|
|||||||
$odfHandler->creator = $user->getFullName($outputlangs);
|
$odfHandler->creator = $user->getFullName($outputlangs);
|
||||||
$odfHandler->title = $object->builddoc_filename;
|
$odfHandler->title = $object->builddoc_filename;
|
||||||
$odfHandler->subject = $object->builddoc_filename;
|
$odfHandler->subject = $object->builddoc_filename;
|
||||||
|
|
||||||
if (! empty($conf->global->ODT_ADD_DOLIBARR_ID))
|
if (! empty($conf->global->ODT_ADD_DOLIBARR_ID))
|
||||||
{
|
{
|
||||||
$odfHandler->userdefined['dol_id'] = $object->id;
|
$odfHandler->userdefined['dol_id'] = $object->id;
|
||||||
$odfHandler->userdefined['dol_element'] = $object->element;
|
$odfHandler->userdefined['dol_element'] = $object->element;
|
||||||
}
|
}
|
||||||
|
|
||||||
$odfHandler->saveToDisk($file);
|
$odfHandler->saveToDisk($file);
|
||||||
}catch (Exception $e){
|
}catch (Exception $e){
|
||||||
$this->error=$e->getMessage();
|
$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);
|
$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
|
$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))
|
if (! empty($conf->global->MAIN_UMASK))
|
||||||
@chmod($file, octdec($conf->global->MAIN_UMASK));
|
@chmod($file, octdec($conf->global->MAIN_UMASK));
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user