forked from Wavyzz/dolibarr
FIX Can use odx templates that does not include lines tags
This commit is contained in:
@@ -163,7 +163,7 @@ class doc_generic_order_odt extends ModelePDFCommandes
|
||||
}
|
||||
$texte.='<div id="div_'.get_class($this).'">';
|
||||
}
|
||||
|
||||
|
||||
$texte.= '</td>';
|
||||
|
||||
$texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">';
|
||||
@@ -368,7 +368,7 @@ class doc_generic_order_odt extends ModelePDFCommandes
|
||||
$tmparray = array_merge($array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_thirdparty_contact);
|
||||
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
|
||||
|
||||
@@ -392,30 +392,42 @@ class doc_generic_order_odt extends ModelePDFCommandes
|
||||
// Replace tags of lines
|
||||
try
|
||||
{
|
||||
$listlines = $odfHandler->setSegment('lines');
|
||||
foreach ($object->lines as $line)
|
||||
{
|
||||
$tmparray=$this->get_substitutionarray_lines($line,$outputlangs);
|
||||
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);
|
||||
$reshook=$hookmanager->executeHooks('ODTSubstitutionLine',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
|
||||
foreach($tmparray as $key => $val)
|
||||
{
|
||||
try
|
||||
{
|
||||
$listlines->setVars($key, $val, true, 'UTF-8');
|
||||
}
|
||||
catch(OdfException $e)
|
||||
{
|
||||
}
|
||||
catch(SegmentException $e)
|
||||
{
|
||||
}
|
||||
}
|
||||
$listlines->merge();
|
||||
$foundtagforlines = 1;
|
||||
try {
|
||||
$listlines = $odfHandler->setSegment('lines');
|
||||
}
|
||||
catch(OdfException $e)
|
||||
{
|
||||
// We may arrive here if tags for lines not present into template
|
||||
$foundtagforlines = 0;
|
||||
dol_syslog($e->getMessage(), LOG_INFO);
|
||||
}
|
||||
if ($foundtagforlines)
|
||||
{
|
||||
foreach ($object->lines as $line)
|
||||
{
|
||||
$tmparray=$this->get_substitutionarray_lines($line,$outputlangs);
|
||||
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);
|
||||
$reshook=$hookmanager->executeHooks('ODTSubstitutionLine',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
|
||||
foreach($tmparray as $key => $val)
|
||||
{
|
||||
try
|
||||
{
|
||||
$listlines->setVars($key, $val, true, 'UTF-8');
|
||||
}
|
||||
catch(OdfException $e)
|
||||
{
|
||||
}
|
||||
catch(SegmentException $e)
|
||||
{
|
||||
}
|
||||
}
|
||||
$listlines->merge();
|
||||
}
|
||||
$odfHandler->mergeSegment($listlines);
|
||||
}
|
||||
$odfHandler->mergeSegment($listlines);
|
||||
}
|
||||
catch(OdfException $e)
|
||||
{
|
||||
@@ -468,7 +480,7 @@ class doc_generic_order_odt extends ModelePDFCommandes
|
||||
$odfHandler=null; // Destroy object
|
||||
|
||||
$this->result = array('fullpath'=>$file);
|
||||
|
||||
|
||||
return 1; // Success
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user