mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-18 07:21:30 +01:00
FIX Can use odx templates that does not include lines tags
This commit is contained in:
@@ -392,7 +392,18 @@ class doc_generic_order_odt extends ModelePDFCommandes
|
|||||||
// Replace tags of lines
|
// Replace tags of lines
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
$foundtagforlines = 1;
|
||||||
|
try {
|
||||||
$listlines = $odfHandler->setSegment('lines');
|
$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)
|
foreach ($object->lines as $line)
|
||||||
{
|
{
|
||||||
$tmparray=$this->get_substitutionarray_lines($line,$outputlangs);
|
$tmparray=$this->get_substitutionarray_lines($line,$outputlangs);
|
||||||
@@ -417,6 +428,7 @@ class doc_generic_order_odt extends ModelePDFCommandes
|
|||||||
}
|
}
|
||||||
$odfHandler->mergeSegment($listlines);
|
$odfHandler->mergeSegment($listlines);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch(OdfException $e)
|
catch(OdfException $e)
|
||||||
{
|
{
|
||||||
$this->error=$e->getMessage();
|
$this->error=$e->getMessage();
|
||||||
|
|||||||
@@ -290,17 +290,38 @@ class doc_generic_contract_odt extends ModelePDFContract
|
|||||||
{
|
{
|
||||||
$socobject=$object->thirdparty;
|
$socobject=$object->thirdparty;
|
||||||
}
|
}
|
||||||
// Make substitution
|
|
||||||
$substitutionarray=array(
|
$object->fetch_optionals();
|
||||||
'__FROM_NAME__' => $this->emetteur->name,
|
|
||||||
'__FROM_EMAIL__' => $this->emetteur->email,
|
|
||||||
'__TOTAL_TTC__' => $object->total_ttc,
|
// Define substitution array
|
||||||
'__TOTAL_HT__' => $object->total_ht,
|
$substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
|
||||||
'__TOTAL_VAT__' => $object->total_vat
|
/* deprecated
|
||||||
);
|
$substitutionarray['__FROM_NAME__'] = $this->emetteur->name;
|
||||||
complete_substitutions_array($substitutionarray, $langs, $object);
|
$substitutionarray['__FROM_EMAIL__'] = $this->emetteur->email;
|
||||||
|
$substitutionarray['__TOTAL_TTC__'] = $object->total_ttc;
|
||||||
|
$substitutionarray['__TOTAL_HT__'] = $object->total_ht;
|
||||||
|
$substitutionarray['__TOTAL_VAT__'] = $object->total_vat;
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Make substitutions into ODT
|
||||||
|
$array_contract=$this->get_substitutionarray_each_var_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);
|
||||||
|
$array_objet=$this->get_substitutionarray_object($object,$outputlangs);
|
||||||
|
$array_other=$this->get_substitutionarray_other($outputlangs);
|
||||||
|
// retrieve contact information for use in contract as contact_xxx tags
|
||||||
|
$array_thirdparty_contact = array();
|
||||||
|
if ($usecontact) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact');
|
||||||
|
|
||||||
|
$substitutionarray = array_merge($substitutionarray,$array_contract,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_thirdparty_contact);
|
||||||
|
complete_substitutions_array($substitutionarray, $outputlangs, $object);
|
||||||
|
|
||||||
|
$tmparray = $substitutionarray;
|
||||||
|
|
||||||
// Call the ODTSubstitution hook
|
// Call the ODTSubstitution hook
|
||||||
$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray);
|
$parameters=array('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
|
||||||
|
|
||||||
// Line of free text
|
// Line of free text
|
||||||
@@ -311,6 +332,7 @@ class doc_generic_contract_odt extends ModelePDFContract
|
|||||||
$newfreetext=make_substitutions($conf->global->$paramfreetext,$substitutionarray);
|
$newfreetext=make_substitutions($conf->global->$paramfreetext,$substitutionarray);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Open and load template
|
// Open and load template
|
||||||
require_once ODTPHP_PATH.'odf.php';
|
require_once ODTPHP_PATH.'odf.php';
|
||||||
try {
|
try {
|
||||||
@@ -344,24 +366,6 @@ class doc_generic_contract_odt extends ModelePDFContract
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make substitutions into odt
|
|
||||||
$array_contract=$this->get_substitutionarray_each_var_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);
|
|
||||||
$array_objet=$this->get_substitutionarray_object($object,$outputlangs);
|
|
||||||
$array_other=$this->get_substitutionarray_other($outputlangs);
|
|
||||||
// retrieve contact information for use in contract as contact_xxx tags
|
|
||||||
$array_thirdparty_contact = array();
|
|
||||||
if ($usecontact)
|
|
||||||
$array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact');
|
|
||||||
|
|
||||||
$tmparray = array_merge($array_contract,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_thirdparty_contact);
|
|
||||||
complete_substitutions_array($tmparray, $outputlangs, $object);
|
|
||||||
$object->fetch_optionals();
|
|
||||||
// Call the ODTSubstitution hook
|
|
||||||
$parameters=array('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
|
|
||||||
foreach($tmparray as $key=>$value)
|
foreach($tmparray as $key=>$value)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
@@ -379,10 +383,22 @@ class doc_generic_contract_odt extends ModelePDFContract
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Replace tags of lines
|
// Replace tags of lines
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
$foundtagforlines = 1;
|
||||||
|
try {
|
||||||
$listlines = $odfHandler->setSegment('lines');
|
$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)
|
foreach ($object->lines as $line)
|
||||||
{
|
{
|
||||||
$tmparray=$this->get_substitutionarray_lines($line,$outputlangs);
|
$tmparray=$this->get_substitutionarray_lines($line,$outputlangs);
|
||||||
@@ -407,6 +423,7 @@ class doc_generic_contract_odt extends ModelePDFContract
|
|||||||
}
|
}
|
||||||
$odfHandler->mergeSegment($listlines);
|
$odfHandler->mergeSegment($listlines);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch(OdfException $e)
|
catch(OdfException $e)
|
||||||
{
|
{
|
||||||
$this->error=$e->getMessage();
|
$this->error=$e->getMessage();
|
||||||
|
|||||||
@@ -437,7 +437,18 @@ class doc_generic_shipment_odt extends ModelePdfExpedition
|
|||||||
// Replace tags of lines
|
// Replace tags of lines
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
$foundtagforlines = 1;
|
||||||
|
try {
|
||||||
$listlines = $odfHandler->setSegment('lines');
|
$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)
|
foreach ($object->lines as $line)
|
||||||
{
|
{
|
||||||
$tmparray=$this->get_substitutionarray_shipment_lines($line,$outputlangs);
|
$tmparray=$this->get_substitutionarray_shipment_lines($line,$outputlangs);
|
||||||
@@ -462,6 +473,7 @@ class doc_generic_shipment_odt extends ModelePdfExpedition
|
|||||||
}
|
}
|
||||||
$odfHandler->mergeSegment($listlines);
|
$odfHandler->mergeSegment($listlines);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch(OdfException $e)
|
catch(OdfException $e)
|
||||||
{
|
{
|
||||||
$this->error=$e->getMessage();
|
$this->error=$e->getMessage();
|
||||||
|
|||||||
@@ -401,7 +401,18 @@ class doc_generic_invoice_odt extends ModelePDFFactures
|
|||||||
// Replace tags of lines
|
// Replace tags of lines
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
$foundtagforlines = 1;
|
||||||
|
try {
|
||||||
$listlines = $odfHandler->setSegment('lines');
|
$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)
|
foreach ($object->lines as $line)
|
||||||
{
|
{
|
||||||
$tmparray=$this->get_substitutionarray_lines($line,$outputlangs);
|
$tmparray=$this->get_substitutionarray_lines($line,$outputlangs);
|
||||||
@@ -426,6 +437,7 @@ class doc_generic_invoice_odt extends ModelePDFFactures
|
|||||||
}
|
}
|
||||||
$odfHandler->mergeSegment($listlines);
|
$odfHandler->mergeSegment($listlines);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch(OdfException $e)
|
catch(OdfException $e)
|
||||||
{
|
{
|
||||||
$this->error=$e->getMessage();
|
$this->error=$e->getMessage();
|
||||||
|
|||||||
@@ -421,7 +421,18 @@ class doc_generic_proposal_odt extends ModelePDFPropales
|
|||||||
// Replace tags of lines
|
// Replace tags of lines
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
$foundtagforlines = 1;
|
||||||
|
try {
|
||||||
$listlines = $odfHandler->setSegment('lines');
|
$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)
|
foreach ($object->lines as $line)
|
||||||
{
|
{
|
||||||
$tmparray=$this->get_substitutionarray_lines($line,$outputlangs);
|
$tmparray=$this->get_substitutionarray_lines($line,$outputlangs);
|
||||||
@@ -446,6 +457,7 @@ class doc_generic_proposal_odt extends ModelePDFPropales
|
|||||||
}
|
}
|
||||||
$odfHandler->mergeSegment($listlines);
|
$odfHandler->mergeSegment($listlines);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch(OdfException $e)
|
catch(OdfException $e)
|
||||||
{
|
{
|
||||||
$this->error=$e->getMessage();
|
$this->error=$e->getMessage();
|
||||||
|
|||||||
@@ -413,7 +413,18 @@ class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal
|
|||||||
// Replace tags of lines
|
// Replace tags of lines
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
$foundtagforlines = 1;
|
||||||
|
try {
|
||||||
$listlines = $odfHandler->setSegment('lines');
|
$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)
|
foreach ($object->lines as $line)
|
||||||
{
|
{
|
||||||
$tmparray=$this->get_substitutionarray_lines($line,$outputlangs);
|
$tmparray=$this->get_substitutionarray_lines($line,$outputlangs);
|
||||||
@@ -438,6 +449,7 @@ class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal
|
|||||||
}
|
}
|
||||||
$odfHandler->mergeSegment($listlines);
|
$odfHandler->mergeSegment($listlines);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch(OdfException $e)
|
catch(OdfException $e)
|
||||||
{
|
{
|
||||||
$this->error=$e->getMessage();
|
$this->error=$e->getMessage();
|
||||||
|
|||||||
@@ -408,7 +408,18 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup
|
|||||||
// Replace tags of lines
|
// Replace tags of lines
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
$foundtagforlines = 1;
|
||||||
|
try {
|
||||||
$listlines = $odfHandler->setSegment('lines');
|
$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->members as $u)
|
foreach ($object->members as $u)
|
||||||
{
|
{
|
||||||
$tmparray=$this->get_substitutionarray_each_var_object($u,$outputlangs);
|
$tmparray=$this->get_substitutionarray_each_var_object($u,$outputlangs);
|
||||||
@@ -437,6 +448,7 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup
|
|||||||
}
|
}
|
||||||
$odfHandler->mergeSegment($listlines);
|
$odfHandler->mergeSegment($listlines);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch(OdfException $e)
|
catch(OdfException $e)
|
||||||
{
|
{
|
||||||
$this->error=$e->getMessage();
|
$this->error=$e->getMessage();
|
||||||
|
|||||||
Reference in New Issue
Block a user