From f6e53b40dac2138cb700ffa1279df640527d56e0 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Thu, 2 Jun 2022 15:20:00 +0200 Subject: [PATCH 1/9] fix: actioncomm.code have to be updated with correct c_actioncomm code (like in create) until we decide to remove this column --- htdocs/comm/action/class/actioncomm.class.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 1e640f7afbe..6369fe82cb7 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1128,6 +1128,12 @@ class ActionComm extends CommonObject $sql .= " SET percent = '".$this->db->escape($this->percentage)."'"; if ($this->type_id > 0) { $sql .= ", fk_action = '".$this->db->escape($this->type_id)."'"; + $cactioncomm = new CActionComm($this->db); + $result = $cactioncomm->fetch($this->type_id); + if ($result>=0) { + $sql .= ", code = '" . $this->db->escape($cactioncomm->code) . "'"; + } + } $sql .= ", label = ".($this->label ? "'".$this->db->escape($this->label)."'" : "null"); $sql .= ", datep = ".(strval($this->datep) != '' ? "'".$this->db->idate($this->datep)."'" : 'null'); From d73982d1eb6f551856f2a15b4be9629388b085bf Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 2 Jun 2022 13:26:06 +0000 Subject: [PATCH 2/9] Fixing style errors. --- htdocs/comm/action/class/actioncomm.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 6369fe82cb7..2c130117154 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1133,7 +1133,6 @@ class ActionComm extends CommonObject if ($result>=0) { $sql .= ", code = '" . $this->db->escape($cactioncomm->code) . "'"; } - } $sql .= ", label = ".($this->label ? "'".$this->db->escape($this->label)."'" : "null"); $sql .= ", datep = ".(strval($this->datep) != '' ? "'".$this->db->idate($this->datep)."'" : 'null'); From 43207429aefda6537385e2ff157cc17642ae945f Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Thu, 2 Jun 2022 15:32:16 +0200 Subject: [PATCH 3/9] fix: actioncomm.code have to be updated with correct c_actioncomm code (like in create) until we decide to remove this column --- htdocs/comm/action/class/actioncomm.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 6369fe82cb7..f21face045f 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1127,7 +1127,7 @@ class ActionComm extends CommonObject $sql = "UPDATE ".MAIN_DB_PREFIX."actioncomm "; $sql .= " SET percent = '".$this->db->escape($this->percentage)."'"; if ($this->type_id > 0) { - $sql .= ", fk_action = '".$this->db->escape($this->type_id)."'"; + $sql .= ", fk_action = ".(int)$this->type_id; $cactioncomm = new CActionComm($this->db); $result = $cactioncomm->fetch($this->type_id); if ($result>=0) { From 19dc0f124ce65b1c1f5a320b6471bccbec9b65e9 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 2 Jun 2022 13:37:55 +0000 Subject: [PATCH 4/9] Fixing style errors. --- htdocs/comm/action/class/actioncomm.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index c92adc0a413..efb6d618e6f 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1127,7 +1127,7 @@ class ActionComm extends CommonObject $sql = "UPDATE ".MAIN_DB_PREFIX."actioncomm "; $sql .= " SET percent = '".$this->db->escape($this->percentage)."'"; if ($this->type_id > 0) { - $sql .= ", fk_action = ".(int)$this->type_id; + $sql .= ", fk_action = ".(int) $this->type_id; $cactioncomm = new CActionComm($this->db); $result = $cactioncomm->fetch($this->type_id); if ($result>=0) { From 7f38d556485883f142f442292f1675b83b743531 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Thu, 2 Jun 2022 21:28:17 +0200 Subject: [PATCH 5/9] better fix --- htdocs/comm/action/class/actioncomm.class.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index c92adc0a413..b9cd825ad49 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1128,12 +1128,15 @@ class ActionComm extends CommonObject $sql .= " SET percent = '".$this->db->escape($this->percentage)."'"; if ($this->type_id > 0) { $sql .= ", fk_action = ".(int)$this->type_id; - $cactioncomm = new CActionComm($this->db); - $result = $cactioncomm->fetch($this->type_id); - if ($result>=0) { - $sql .= ", code = '" . $this->db->escape($cactioncomm->code) . "'"; + if (empty($this->type_code)) { + $cactioncomm = new CActionComm($this->db); + $result = $cactioncomm->fetch($this->type_id); + if ($result>=0) { + $this->type_code = $cactioncomm->code; + } } } + $sql .= ", code = " . (isset($this->type_code)? "'".$this->db->escape($this->type_code) . "'":"null"); $sql .= ", label = ".($this->label ? "'".$this->db->escape($this->label)."'" : "null"); $sql .= ", datep = ".(strval($this->datep) != '' ? "'".$this->db->idate($this->datep)."'" : 'null'); $sql .= ", datep2 = ".(strval($this->datef) != '' ? "'".$this->db->idate($this->datef)."'" : 'null'); From e48ce5b159c7d14dce501821de393505dee2ce41 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 2 Jun 2022 19:34:39 +0000 Subject: [PATCH 6/9] Fixing style errors. --- htdocs/comm/action/class/actioncomm.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index fe5769473c7..a5c8a11ade0 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1127,7 +1127,7 @@ class ActionComm extends CommonObject $sql = "UPDATE ".MAIN_DB_PREFIX."actioncomm "; $sql .= " SET percent = '".$this->db->escape($this->percentage)."'"; if ($this->type_id > 0) { - $sql .= ", fk_action = ".(int)$this->type_id; + $sql .= ", fk_action = ".(int) $this->type_id; if (empty($this->type_code)) { $cactioncomm = new CActionComm($this->db); $result = $cactioncomm->fetch($this->type_id); From 648a8f5c18f9cded56c362201ab6a03bdd676d8f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 7 Jun 2022 18:58:53 +0200 Subject: [PATCH 7/9] FIX xml file for company with special chars in name --- .../class/bonprelevement.class.php | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index afd6b5e075c..fcf13fe8c0e 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -1489,7 +1489,7 @@ class BonPrelevement extends CommonObject fputs($this->file, ' '.$i.''.$CrLf); fputs($this->file, ' '.$this->total.''.$CrLf); fputs($this->file, ' '.$CrLf); - fputs($this->file, ' '.dolEscapeXML(strtoupper(dol_string_unaccent($this->raison_sociale))).''.$CrLf); + fputs($this->file, ' '.dolEscapeXML(strtoupper(dol_string_nospecial(dol_string_unaccent($this->raison_sociale)))).''.$CrLf); fputs($this->file, ' '.$CrLf); fputs($this->file, ' '.$CrLf); fputs($this->file, ' '.$CrLf); @@ -1605,7 +1605,7 @@ class BonPrelevement extends CommonObject fputs($this->file, ' '.$i.''.$CrLf); fputs($this->file, ' '.$this->total.''.$CrLf); fputs($this->file, ' '.$CrLf); - fputs($this->file, ' '.dolEscapeXML(strtoupper(dol_string_unaccent($this->raison_sociale))).''.$CrLf); + fputs($this->file, ' '.dolEscapeXML(strtoupper(dol_string_nospecial(dol_string_unaccent($this->raison_sociale)))).''.$CrLf); fputs($this->file, ' '.$CrLf); fputs($this->file, ' '.$CrLf); fputs($this->file, ' '.$CrLf); @@ -1855,16 +1855,16 @@ class BonPrelevement extends CommonObject $XML_DEBITOR .= ' '.$CrLf; $XML_DEBITOR .= ' '.$CrLf; $XML_DEBITOR .= ' '.$CrLf; - $XML_DEBITOR .= ' '.dolEscapeXML(strtoupper(dol_string_unaccent($row_nom))).''.$CrLf; + $XML_DEBITOR .= ' '.dolEscapeXML(strtoupper(dol_string_nospecial(dol_string_unaccent($row_nom)))).''.$CrLf; $XML_DEBITOR .= ' '.$CrLf; $XML_DEBITOR .= ' '.$row_country_code.''.$CrLf; $addressline1 = strtr($row_address, array(CHR(13) => ", ", CHR(10) => "")); $addressline2 = strtr($row_zip.(($row_zip && $row_town) ? ' ' : ''.$row_town), array(CHR(13) => ", ", CHR(10) => "")); if (trim($addressline1)) { - $XML_DEBITOR .= ' '.dolEscapeXML(dol_trunc(dol_string_unaccent($addressline1), 70, 'right', 'UTF-8', 1)).''.$CrLf; + $XML_DEBITOR .= ' '.dolEscapeXML(dol_trunc(dol_string_nospecial(dol_string_unaccent($addressline1)), 70, 'right', 'UTF-8', 1)).''.$CrLf; } if (trim($addressline2)) { - $XML_DEBITOR .= ' '.dolEscapeXML(dol_trunc(dol_string_unaccent($addressline2), 70, 'right', 'UTF-8', 1)).''.$CrLf; + $XML_DEBITOR .= ' '.dolEscapeXML(dol_trunc(dol_string_nospecial(dol_string_unaccent($addressline2)), 70, 'right', 'UTF-8', 1)).''.$CrLf; } $XML_DEBITOR .= ' '.$CrLf; $XML_DEBITOR .= ' '.$CrLf; @@ -1906,16 +1906,16 @@ class BonPrelevement extends CommonObject $XML_CREDITOR .= ' '.$CrLf; $XML_CREDITOR .= ' '.$CrLf; $XML_CREDITOR .= ' '.$CrLf; - $XML_CREDITOR .= ' '.dolEscapeXML(strtoupper(dol_string_unaccent($row_nom))).''.$CrLf; + $XML_CREDITOR .= ' '.dolEscapeXML(strtoupper(dol_string_nospecial(dol_string_unaccent($row_nom)))).''.$CrLf; $XML_CREDITOR .= ' '.$CrLf; $XML_CREDITOR .= ' '.$row_country_code.''.$CrLf; $addressline1 = strtr($row_address, array(CHR(13) => ", ", CHR(10) => "")); $addressline2 = strtr($row_zip.(($row_zip && $row_town) ? ' ' : ''.$row_town), array(CHR(13) => ", ", CHR(10) => "")); if (trim($addressline1)) { - $XML_CREDITOR .= ' '.dolEscapeXML(dol_trunc(dol_string_unaccent($addressline1), 70, 'right', 'UTF-8', 1)).''.$CrLf; + $XML_CREDITOR .= ' '.dolEscapeXML(dol_trunc(dol_string_nospecial(dol_string_unaccent($addressline1)), 70, 'right', 'UTF-8', 1)).''.$CrLf; } if (trim($addressline2)) { - $XML_CREDITOR .= ' '.dolEscapeXML(dol_trunc(dol_string_unaccent($addressline2), 70, 'right', 'UTF-8', 1)).''.$CrLf; + $XML_CREDITOR .= ' '.dolEscapeXML(dol_trunc(dol_string_nospecial(dol_string_unaccent($addressline2)), 70, 'right', 'UTF-8', 1)).''.$CrLf; } $XML_CREDITOR .= ' '.$CrLf; $XML_CREDITOR .= ' '.$CrLf; @@ -2078,16 +2078,16 @@ class BonPrelevement extends CommonObject $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$dateTime_ETAD.''.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; - $XML_SEPA_INFO .= ' '.dolEscapeXML(strtoupper(dol_string_unaccent($this->raison_sociale))).''.$CrLf; + $XML_SEPA_INFO .= ' '.dolEscapeXML(strtoupper(dol_string_nospecial(dol_string_unaccent($this->raison_sociale)))).''.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$country[1].''.$CrLf; $addressline1 = strtr($configuration->global->MAIN_INFO_SOCIETE_ADDRESS, array(CHR(13) => ", ", CHR(10) => "")); $addressline2 = strtr($configuration->global->MAIN_INFO_SOCIETE_ZIP.(($configuration->global->MAIN_INFO_SOCIETE_ZIP || ' '.$configuration->global->MAIN_INFO_SOCIETE_TOWN) ? ' ' : '').$configuration->global->MAIN_INFO_SOCIETE_TOWN, array(CHR(13) => ", ", CHR(10) => "")); if ($addressline1) { - $XML_SEPA_INFO .= ' '.dolEscapeXML(dol_trunc(dol_string_unaccent($addressline1), 70, 'right', 'UTF-8', 1)).''.$CrLf; + $XML_SEPA_INFO .= ' '.dolEscapeXML(dol_trunc(dol_string_nospecial(dol_string_unaccent($addressline1)), 70, 'right', 'UTF-8', 1)).''.$CrLf; } if ($addressline2) { - $XML_SEPA_INFO .= ' '.dolEscapeXML(dol_trunc(dol_string_unaccent($addressline2), 70, 'right', 'UTF-8', 1)).''.$CrLf; + $XML_SEPA_INFO .= ' '.dolEscapeXML(dol_trunc(dol_string_nospecial(dol_string_unaccent($addressline2)), 70, 'right', 'UTF-8', 1)).''.$CrLf; } $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; @@ -2102,11 +2102,11 @@ class BonPrelevement extends CommonObject $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; /* $XML_SEPA_INFO .= ' '.$CrLf; - $XML_SEPA_INFO .= ' '.dolEscapeXML(strtoupper(dol_string_unaccent($this->raison_sociale))).''.$CrLf; + $XML_SEPA_INFO .= ' '.dolEscapeXML(strtoupper(dol_string_nospecial(dol_string_unaccent($this->raison_sociale)))).''.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$country[1].''.$CrLf; - $XML_SEPA_INFO .= ' '.dolEscapeXML(dol_string_unaccent($conf->global->MAIN_INFO_SOCIETE_ADDRESS.'').$CrLf; - $XML_SEPA_INFO .= ' '.dolEscapeXML(dol_string_unaccent($conf->global->MAIN_INFO_SOCIETE_ZIP.' '.$conf->global->MAIN_INFO_SOCIETE_TOWN).''.$CrLf; + $XML_SEPA_INFO .= ' '.dolEscapeXML(dol_string_nospecial(dol_string_unaccent($conf->global->MAIN_INFO_SOCIETE_ADDRESS))).''.$CrLf; + $XML_SEPA_INFO .= ' '.dolEscapeXML(dol_string_nospecial(dol_string_unaccent($conf->global->MAIN_INFO_SOCIETE_ZIP.' '.$conf->global->MAIN_INFO_SOCIETE_TOWN)).''.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf;*/ $XML_SEPA_INFO .= ' SLEV'.$CrLf; // Field "Responsible of fees". Must be SLEV @@ -2144,16 +2144,16 @@ class BonPrelevement extends CommonObject */ $XML_SEPA_INFO .= ' '.dol_print_date($dateTime_ETAD, 'dayrfc').''.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; - $XML_SEPA_INFO .= ' '.dolEscapeXML(strtoupper(dol_string_unaccent($this->raison_sociale))).''.$CrLf; + $XML_SEPA_INFO .= ' '.dolEscapeXML(strtoupper(dol_string_nospecial(dol_string_unaccent($this->raison_sociale)))).''.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$country[1].''.$CrLf; $addressline1 = strtr($configuration->global->MAIN_INFO_SOCIETE_ADDRESS, array(CHR(13) => ", ", CHR(10) => "")); $addressline2 = strtr($configuration->global->MAIN_INFO_SOCIETE_ZIP.(($configuration->global->MAIN_INFO_SOCIETE_ZIP || ' '.$configuration->global->MAIN_INFO_SOCIETE_TOWN) ? ' ' : '').$configuration->global->MAIN_INFO_SOCIETE_TOWN, array(CHR(13) => ", ", CHR(10) => "")); if ($addressline1) { - $XML_SEPA_INFO .= ' '.dolEscapeXML(dol_trunc(dol_string_unaccent($addressline1), 70, 'right', 'UTF-8', 1)).''.$CrLf; + $XML_SEPA_INFO .= ' '.dolEscapeXML(dol_trunc(dol_string_nospecial(dol_string_unaccent($addressline1)), 70, 'right', 'UTF-8', 1)).''.$CrLf; } if ($addressline2) { - $XML_SEPA_INFO .= ' '.dolEscapeXML(dol_trunc(dol_string_unaccent($addressline2), 70, 'right', 'UTF-8', 1)).''.$CrLf; + $XML_SEPA_INFO .= ' '.dolEscapeXML(dol_trunc(dol_string_nospecial(dol_string_unaccent($addressline2)), 70, 'right', 'UTF-8', 1)).''.$CrLf; } $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; @@ -2168,11 +2168,11 @@ class BonPrelevement extends CommonObject $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; /* $XML_SEPA_INFO .= ' '.$CrLf; - $XML_SEPA_INFO .= ' '.dolEscapeXML(strtoupper(dol_string_unaccent($this->raison_sociale))).''.$CrLf; + $XML_SEPA_INFO .= ' '.dolEscapeXML(strtoupper(dol_string_nospecial(dol_string_unaccent($this->raison_sociale)))).''.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$country[1].''.$CrLf; - $XML_SEPA_INFO .= ' '.dolEscapeXML(dol_string_unaccent($conf->global->MAIN_INFO_SOCIETE_ADDRESS).''.$CrLf; - $XML_SEPA_INFO .= ' '.dolEscapeXML(dol_string_unaccent($conf->global->MAIN_INFO_SOCIETE_ZIP.' '.$conf->global->MAIN_INFO_SOCIETE_TOWN).''.$CrLf; + $XML_SEPA_INFO .= ' '.dolEscapeXML(dol_string_nospecial(dol_string_unaccent($conf->global->MAIN_INFO_SOCIETE_ADDRESS))).''.$CrLf; + $XML_SEPA_INFO .= ' '.dolEscapeXML(dol_string_nospecial(dol_string_unaccent($conf->global->MAIN_INFO_SOCIETE_ZIP.' '.$conf->global->MAIN_INFO_SOCIETE_TOWN)).''.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf;*/ $XML_SEPA_INFO .= ' SLEV'.$CrLf; // Field "Responsible of fees". Must be SLEV From 8303347ab8c7136247221d9c170377d0027d14b1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 7 Jun 2022 19:27:43 +0200 Subject: [PATCH 8/9] FIX label and get_substitutionarray_each_var_object on ODT generation --- htdocs/core/class/commondocgenerator.class.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 3d94469759b..3167bd0c64c 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -421,8 +421,9 @@ abstract class CommonDocGenerator $resarray = array( $array_key.'_id'=>$object->id, - $array_key.'_ref'=>$object->ref, - $array_key.'_ref_ext'=>$object->ref_ext, + $array_key.'_ref' => (property_exists($object, 'ref') ? $object->ref : ''), + $array_key.'_label' => (property_exists($object, 'label') ? $object->label : ''), + $array_key.'_ref_ext' => (property_exists($object, 'ref_ext') ? $object->ref_ext : ''), $array_key.'_ref_customer'=>(!empty($object->ref_client) ? $object->ref_client : (empty($object->ref_customer) ? '' : $object->ref_customer)), $array_key.'_ref_supplier'=>(!empty($object->ref_fournisseur) ? $object->ref_fournisseur : (empty($object->ref_supplier) ? '' : $object->ref_supplier)), $array_key.'_source_invoice_ref'=>$invoice_source->ref, @@ -443,7 +444,7 @@ abstract class CommonDocGenerator $array_key.'_payment_term_code'=>$object->cond_reglement_code, $array_key.'_payment_term'=>($outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code) != 'PaymentCondition'.$object->cond_reglement_code ? $outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code) : ($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement)), - $array_key.'_incoterms'=>(method_exists($object, 'display_incoterms') ? $object->display_incoterms() : ''), + $array_key.'_incoterms' => (method_exists($object, 'display_incoterms') ? $object->display_incoterms() : ''), $array_key.'_bank_iban'=>$bank_account->iban, $array_key.'_bank_bic'=>$bank_account->bic, @@ -820,8 +821,9 @@ abstract class CommonDocGenerator if (!empty($value)) { if (!is_array($value) && !is_object($value)) { $array_other['object_'.$key] = $value; - } - if (is_array($value) && $recursive) { + } elseif (is_array($value) && $recursive) { + $array_other['object_'.$key] = $this->get_substitutionarray_each_var_object($value, $outputlangs, false); + } elseif (is_object($value) && $recursive) { $array_other['object_'.$key] = $this->get_substitutionarray_each_var_object($value, $outputlangs, false); } } From 7ee4cccc840e2faeb3ad23d8222891bb6feab5c2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 7 Jun 2022 19:59:33 +0200 Subject: [PATCH 9/9] FIX ODT tags for subobjects {object_subobject_yyy} was not working. --- .../core/class/commondocgenerator.class.php | 20 +++++++++++++++---- .../bom/doc/doc_generic_bom_odt.modules.php | 1 + 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 3167bd0c64c..21c1cce4cfd 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -809,26 +809,38 @@ abstract class CommonDocGenerator * * @param Object $object Dolibarr Object * @param Translate $outputlangs Language object for output - * @param boolean $recursive Want to fetch child array or child object + * @param boolean|int $recursive Want to fetch child array or child object. * @return array Array of substitution key->code */ - public function get_substitutionarray_each_var_object(&$object, $outputlangs, $recursive = true) + public function get_substitutionarray_each_var_object(&$object, $outputlangs, $recursive = 1) { // phpcs:enable $array_other = array(); if (!empty($object)) { foreach ($object as $key => $value) { + if (in_array($key, array('db', 'fields', 'lines', 'modelpdf', 'model_pdf'))) { // discard some properties + continue; + } if (!empty($value)) { if (!is_array($value) && !is_object($value)) { $array_other['object_'.$key] = $value; } elseif (is_array($value) && $recursive) { - $array_other['object_'.$key] = $this->get_substitutionarray_each_var_object($value, $outputlangs, false); + $tmparray = $this->get_substitutionarray_each_var_object($value, $outputlangs, 0); + foreach ($tmparray as $key2 => $value2) { + $array_other['object_'.$key.'_'.preg_replace('/^object_/', '', $key2)] = $value2; + } } elseif (is_object($value) && $recursive) { - $array_other['object_'.$key] = $this->get_substitutionarray_each_var_object($value, $outputlangs, false); + $tmparray = $this->get_substitutionarray_each_var_object($value, $outputlangs, 0); + foreach ($tmparray as $key2 => $value2) { + $array_other['object_'.$key.'_'.preg_replace('/^object_/', '', $key2)] = $value2; + } } } } } + + //var_dump($array_other); + return $array_other; } diff --git a/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php b/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php index 31c20cf1ecd..c070e3b1058 100644 --- a/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php +++ b/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php @@ -246,6 +246,7 @@ class doc_generic_bom_odt extends ModelePDFBom } $object->fetch_thirdparty(); + $object->fetch_product(); $dir = $conf->bom->multidir_output[isset($object->entity) ? $object->entity : 1]; $objectref = dol_sanitizeFileName($object->ref);