diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php
index 1e640f7afbe..a5c8a11ade0 100644
--- a/htdocs/comm/action/class/actioncomm.class.php
+++ b/htdocs/comm/action/class/actioncomm.class.php
@@ -1127,8 +1127,16 @@ 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;
+ if (empty($this->type_code)) {
+ $cactioncomm = new CActionComm($this->db);
+ $result = $cactioncomm->fetch($this->type_id);
+ if ($result >= 0 && !empty($cactioncomm->code)) {
+ $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');
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
diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php
index 3d94469759b..21c1cce4cfd 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,
@@ -808,25 +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;
- }
- if (is_array($value) && $recursive) {
- $array_other['object_'.$key] = $this->get_substitutionarray_each_var_object($value, $outputlangs, false);
+ } elseif (is_array($value) && $recursive) {
+ $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) {
+ $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);