fix dead catch in odt stock (#30059)
This commit is contained in:
parent
6348ce6e91
commit
77986d3d10
1 changed files with 33 additions and 34 deletions
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/* Copyright (C) 2010-2012 Laurent Destailleur <eldy@stocks.sourceforge.net>
|
||||
* Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
|
||||
* Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -279,10 +279,6 @@ class doc_generic_stock_odt extends ModelePDFStock
|
|||
$filename = $newfiletmp . '.' . $newfileformat;
|
||||
}
|
||||
$file = $dir . '/' . $filename;
|
||||
//print "newdir=".$dir;
|
||||
//print "newfile=".$newfile;
|
||||
//print "file=".$file;
|
||||
//print "conf->product->dir_temp=".$conf->product->dir_temp;
|
||||
|
||||
dol_mkdir($conf->product->dir_temp);
|
||||
if (!is_writable($conf->product->dir_temp)) {
|
||||
|
|
@ -317,11 +313,11 @@ class doc_generic_stock_odt extends ModelePDFStock
|
|||
}
|
||||
// Make substitution
|
||||
$substitutionarray = array(
|
||||
'__FROM_NAME__' => $this->emetteur->name,
|
||||
'__FROM_EMAIL__' => $this->emetteur->email,
|
||||
'__TOTAL_TTC__' => $object->total_ttc,
|
||||
'__TOTAL_HT__' => $object->total_ht,
|
||||
'__TOTAL_VAT__' => $object->total_tva
|
||||
'__FROM_NAME__' => $this->emetteur->name,
|
||||
'__FROM_EMAIL__' => $this->emetteur->email,
|
||||
'__TOTAL_TTC__' => $object->total_ttc,
|
||||
'__TOTAL_HT__' => $object->total_ht,
|
||||
'__TOTAL_VAT__' => $object->total_tva
|
||||
);
|
||||
complete_substitutions_array($substitutionarray, $langs, $object);
|
||||
// Call the ODTSubstitution hook
|
||||
|
|
@ -355,8 +351,6 @@ class doc_generic_stock_odt extends ModelePDFStock
|
|||
// After construction $odfHandler->contentXml contains content and
|
||||
// [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by
|
||||
// [!-- BEGIN lines --]*[!-- END lines --]
|
||||
//print html_entity_decode($odfHandler->__toString());
|
||||
//print exit;
|
||||
|
||||
$object->fetch_optionals();
|
||||
|
||||
|
|
@ -370,7 +364,7 @@ class doc_generic_stock_odt extends ModelePDFStock
|
|||
// Define substitution array
|
||||
$substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
|
||||
$array_object_from_properties = $this->get_substitutionarray_each_var_object($object, $outputlangs);
|
||||
//$array_objet=$this->get_substitutionarray_object($object,$outputlangs);
|
||||
//$array_objet = $this->get_substitutionarray_object($object,$outputlangs);
|
||||
$array_user = $this->get_substitutionarray_user($user, $outputlangs);
|
||||
$array_soc = $this->get_substitutionarray_mysoc($mysoc, $outputlangs);
|
||||
$array_thirdparty = $this->get_substitutionarray_thirdparty($socobject, $outputlangs);
|
||||
|
|
@ -404,32 +398,37 @@ class doc_generic_stock_odt extends ModelePDFStock
|
|||
}
|
||||
}
|
||||
// Replace tags of lines
|
||||
$foundtagforlines = 1;
|
||||
try {
|
||||
$listlines = $odfHandler->setSegment('supplierprices');
|
||||
if (!empty($object->supplierprices)) {
|
||||
foreach ($object->supplierprices as $supplierprice) {
|
||||
$array_lines = $this->get_substitutionarray_each_var_object($supplierprice, $outputlangs);
|
||||
complete_substitutions_array($array_lines, $outputlangs, $object, $supplierprice, "completesubstitutionarray_lines");
|
||||
// Call the ODTSubstitutionLine hook
|
||||
$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$array_lines, 'line'=>$supplierprice);
|
||||
$reshook = $hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
|
||||
foreach ($array_lines as $key => $val) {
|
||||
try {
|
||||
$listlines->setVars($key, $val, true, 'UTF-8');
|
||||
} catch (OdfException $e) {
|
||||
dol_syslog($e->getMessage(), LOG_INFO);
|
||||
} catch (SegmentException $e) {
|
||||
dol_syslog($e->getMessage(), LOG_INFO);
|
||||
}
|
||||
} catch (OdfExceptionSegmentNotFound $e) {
|
||||
// We may arrive here if tags for lines not present into template
|
||||
$foundtagforlines = 0;
|
||||
dol_syslog($e->getMessage(), LOG_INFO);
|
||||
}
|
||||
if ($foundtagforlines && !empty($object->supplierprices)) {
|
||||
foreach ($object->supplierprices as $supplierprice) {
|
||||
$array_lines = $this->get_substitutionarray_each_var_object($supplierprice, $outputlangs);
|
||||
complete_substitutions_array($array_lines, $outputlangs, $object, $supplierprice, "completesubstitutionarray_lines");
|
||||
// Call the ODTSubstitutionLine hook
|
||||
$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$array_lines, 'line'=>$supplierprice);
|
||||
$reshook = $hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
|
||||
foreach ($array_lines as $key => $val) {
|
||||
try {
|
||||
$listlines->setVars($key, $val, true, 'UTF-8');
|
||||
} catch (SegmentException $e) {
|
||||
dol_syslog($e->getMessage(), LOG_INFO);
|
||||
}
|
||||
$listlines->merge();
|
||||
}
|
||||
$listlines->merge();
|
||||
}
|
||||
try {
|
||||
$odfHandler->mergeSegment($listlines);
|
||||
} catch (OdfException $e) {
|
||||
$this->error = $e->getMessage();
|
||||
dol_syslog($this->error, LOG_WARNING);
|
||||
return -1;
|
||||
}
|
||||
$odfHandler->mergeSegment($listlines);
|
||||
} catch (OdfException $e) {
|
||||
$this->error = $e->getMessage();
|
||||
dol_syslog($this->error, LOG_WARNING);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Replace labels translated
|
||||
|
|
|
|||
Loading…
Reference in a new issue