diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 822fcdcd44b..e6637c59549 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1253,7 +1253,9 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, // If we want another language, and if label is same than default language (we did force it to a specific value), we can use translation. //var_dump($outputlangs->defaultlang.' - '.$langs->defaultlang.' - '.$label.' - '.$prodser->label);exit; $textwasmodified = ($label == $prodser->label); - if (!empty($prodser->multilangs[$outputlangs->defaultlang]["label"]) && ($textwasmodified || $translatealsoifmodified)) $label = $prodser->multilangs[$outputlangs->defaultlang]["label"]; + if (!empty($prodser->multilangs[$outputlangs->defaultlang]["label"]) && ($textwasmodified || $translatealsoifmodified)) { + $label = $prodser->multilangs[$outputlangs->defaultlang]["label"]; + } // Set desc // Manage HTML entities description test because $prodser->description is store with htmlentities but $desc no @@ -1281,6 +1283,17 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, $libelleproduitservice = ''.$libelleproduitservice.''; } + // Add ref of subproducts + if (!empty($conf->global->SHOW_SUBPRODUCT_REF_IN_PDF)) { + $prodser->get_sousproduits_arbo(); + if (!empty($prodser->sousprods) && is_array($prodser->sousprods) && count($prodser->sousprods)) { + $tmparrayofsubproducts = reset($prodser->sousprods); + foreach($tmparrayofsubproducts as $subprodval) { + $libelleproduitservice .= "\n * ".$subprodval[5].(($subprodval[5] && $subprodval[3]) ? ' - ' : '').$subprodval[3].' ('.$subprodval[1].')'; + } + } + } + // Description long of product line if (!empty($desc) && ($desc != $label)) { @@ -1314,12 +1327,16 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, $discount->fetch($object->lines[$i]->fk_remise_except); $libelleproduitservice = $outputlangs->transnoentitiesnoconv("DiscountFromExcessPaid", $discount->ref_invoice_supplier_source); } else { - if ($idprod) - { - if (empty($hidedesc)) - { - if (!empty($conf->global->MAIN_DOCUMENTS_DESCRIPTION_FIRST)) - { + if ($idprod) { + // Check if description must be output + if (!empty($object->element)) { + $tmpkey = 'MAIN_DOCUMENTS_HIDE_DESCRIPTION_FOR_'.strtoupper($object->element); + if (!empty($conf->global->$tmpkey)) { + $hidedesc = 1; + } + } + if (empty($hidedesc)) { + if (!empty($conf->global->MAIN_DOCUMENTS_DESCRIPTION_FIRST)) { $libelleproduitservice = $desc."\n".$libelleproduitservice; } else { if (!empty($conf->global->HIDE_LABEL_VARIANT_PDF) && $prodser->isVariant()) { diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index e17e8bbea7b..6505741d5a2 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -4358,18 +4358,19 @@ class Product extends CommonObject /** * Return childs of product $id * - * @param int $id Id of product to search childs of - * @param int $firstlevelonly Return only direct child - * @param int $level Level of recursing call (start to 1) - * @return array Return array(prodid=>array(0=prodid, 1=>qty, 2=> ...) + * @param int $id Id of product to search childs of + * @param int $firstlevelonly Return only direct child + * @param int $level Level of recursing call (start to 1) + * @return array Return array(prodid=>array(0=prodid, 1=>qty, 2=>product type, 3=>label, 4=>incdec, 5=>product ref) */ public function getChildsArbo($id, $firstlevelonly = 0, $level = 1) { global $alreadyfound; - $sql = "SELECT p.rowid, p.label as label, pa.qty as qty, pa.fk_product_fils as id, p.fk_product_type, pa.incdec"; - $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; - $sql .= ", ".MAIN_DB_PREFIX."product_association as pa"; + $sql = "SELECT p.rowid, p.ref, p.label as label, p.fk_product_type,"; + $sql .= " pa.qty as qty, pa.fk_product_fils as id, pa.incdec"; + $sql .= " FROM ".MAIN_DB_PREFIX."product as p,"; + $sql .= " ".MAIN_DB_PREFIX."product_association as pa"; $sql .= " WHERE p.rowid = pa.fk_product_fils"; $sql .= " AND pa.fk_product_pere = ".$id; $sql .= " AND pa.fk_product_fils != ".$id; // This should not happens, it is to avoid infinite loop if it happens @@ -4397,7 +4398,8 @@ class Product extends CommonObject 1=>$rec['qty'], 2=>$rec['fk_product_type'], 3=>$this->db->escape($rec['label']), - 4=>$rec['incdec'] + 4=>$rec['incdec'], + 5=>$rec['ref'] ); //$prods[$this->db->escape($rec['label'])]= array(0=>$rec['id'],1=>$rec['qty'],2=>$rec['fk_product_type']); //$prods[$this->db->escape($rec['label'])]= array(0=>$rec['id'],1=>$rec['qty']); @@ -4419,7 +4421,7 @@ class Product extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Return tree of all subproducts for product. Tree contains id, name and quantity. + * Return tree of all subproducts for product. Tree contains array of array(0=prodid, 1=>qty, 2=>product type, 3=>label, 4=>incdec, 5=>product ref) * Set this->sousprods * * @return void