diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 28b1dc9d4c1..1b0a9df9a92 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -590,10 +590,15 @@ abstract class CommonDocGenerator $resarray = $this->fill_substitutionarray_with_extrafields($line, $resarray, $extrafields, $array_key, $outputlangs); // Add the product supplier extrafields to the substitutions - $resql = $this->db->query("SELECT * FROM " . MAIN_DB_PREFIX . "product_fournisseur_price_extrafields AS ex INNER JOIN " . MAIN_DB_PREFIX . "product_fournisseur_price AS f ON ex.fk_object = f.rowid WHERE f.ref_fourn = " . $line->ref_fourn); + $extralabels=$extrafields->fetch_name_optionals_label("product_fournisseur_price"); + $columns = ""; + foreach ($extralabels as $key => $value) { + $columns .= "$key, "; + } + substr($columns, 0, strlen($columns) - 2); + $resql = $this->db->query("SELECT $columns FROM " . MAIN_DB_PREFIX . "product_fournisseur_price_extrafields AS ex INNER JOIN " . MAIN_DB_PREFIX . "product_fournisseur_price AS f ON ex.fk_object = f.rowid WHERE f.ref_fourn = " . $line->ref_fourn); if ($this->db->num_rows($resql) > 0) { $resql = $this->db->fetch_object($resql); - $extralabels=$extrafields->fetch_name_optionals_label("product_fournisseur_price"); foreach ($extralabels as $key => $value) { $resarray['line_product_supplier_'.$key] = $resql->{$key}; }