2
0
forked from Wavyzz/dolibarr

FIX Can use odx templates that does not include lines tags

This commit is contained in:
Laurent Destailleur
2018-02-24 12:32:48 +01:00
parent e68612fa09
commit cbfe241c1b
7 changed files with 287 additions and 198 deletions

View File

@@ -389,7 +389,7 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup
$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
try
{
if (preg_match('/logo$/',$key)) // Image
{
@@ -408,34 +408,46 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup
// Replace tags of lines
try
{
$listlines = $odfHandler->setSegment('lines');
foreach ($object->members as $u)
$foundtagforlines = 1;
try {
$listlines = $odfHandler->setSegment('lines');
}
catch(OdfException $e)
{
$tmparray=$this->get_substitutionarray_each_var_object($u,$outputlangs);
unset($tmparray['object_pass']);
unset($tmparray['object_pass_indatabase']);
complete_substitutions_array($tmparray, $outputlangs, $object, $user, "completesubstitutionarray_users");
// Call the ODTSubstitutionLine hook
$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$u);
$reshook=$hookmanager->executeHooks('ODTSubstitutionLine',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
foreach($tmparray as $key => $val)
// We may arrive here if tags for lines not present into template
$foundtagforlines = 0;
dol_syslog($e->getMessage(), LOG_INFO);
}
if ($foundtagforlines)
{
foreach ($object->members as $u)
{
try
$tmparray=$this->get_substitutionarray_each_var_object($u,$outputlangs);
unset($tmparray['object_pass']);
unset($tmparray['object_pass_indatabase']);
complete_substitutions_array($tmparray, $outputlangs, $object, $user, "completesubstitutionarray_users");
// Call the ODTSubstitutionLine hook
$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$u);
$reshook=$hookmanager->executeHooks('ODTSubstitutionLine',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
foreach($tmparray as $key => $val)
{
if(!is_array($val)) {
$listlines->setVars($key, $val, true, 'UTF-8');
try
{
if(!is_array($val)) {
$listlines->setVars($key, $val, true, 'UTF-8');
}
}
catch(OdfException $e)
{
}
catch(SegmentException $e)
{
}
}
catch(OdfException $e)
{
}
catch(SegmentException $e)
{
}
$listlines->merge();
}
$listlines->merge();
$odfHandler->mergeSegment($listlines);
}
$odfHandler->mergeSegment($listlines);
}
catch(OdfException $e)
{
@@ -443,7 +455,7 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup
dol_syslog($this->error, LOG_WARNING);
return -1;
}
// Replace labels translated
$tmparray=$outputlangs->get_translations_for_substitutions();
foreach($tmparray as $key=>$value)
@@ -486,7 +498,7 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup
$odfHandler=null; // Destroy object
$this->result = array('fullpath'=>$file);
return 1; // Success
}
else