diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php
index d7982a44069..2bbd1759453 100644
--- a/htdocs/bom/class/bom.class.php
+++ b/htdocs/bom/class/bom.class.php
@@ -16,7 +16,7 @@
*/
/**
- * \file bom/class/bom.class.php
+ * \file htdocs/bom/class/bom.class.php
* \ingroup bom
* \brief This file is a CRUD class file for BOM (Create/Read/Update/Delete)
*/
@@ -1064,6 +1064,43 @@ class BOM extends CommonObject
return $this->setStatusCommon($user, self::STATUS_VALIDATED, $notrigger, 'BOM_REOPEN');
}
+ /**
+ * getTooltipContentArray
+ * @param array $params params to construct tooltip data
+ * @since v18
+ * @return array
+ */
+ public function getTooltipContentArray($params)
+ {
+ global $conf, $langs, $user;
+
+ $langs->load('mrp');
+
+ $datas = [];
+
+ if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
+ return ['optimize' => $langs->trans("ShowBillOfMaterials")];
+ }
+ $picto = img_picto('', $this->picto).' '.$langs->trans("BillOfMaterials").'';
+ if (isset($this->status)) {
+ $picto .= ' '.$this->getLibStatut(5);
+ }
+ $datas['picto'] = $picto;
+ $datas['ref'] = '
'.$langs->trans('Ref').': '.$this->ref;
+ if (isset($this->label)) {
+ $datas['label'] = '
'.$langs->trans('Label').': '.$this->label;
+ }
+ if (!empty($this->fk_product) && $this->fk_product > 0) {
+ include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
+ $product = new Product($this->db);
+ $resultFetch = $product->fetch($this->fk_product);
+ if ($resultFetch > 0) {
+ $datas['product'] = "
".$langs->trans("Product").': '.$product->ref.' - '.$product->label;
+ }
+ }
+
+ return $datas;
+ }
/**
* Return a link to the object card (with optionaly the picto)
@@ -1123,8 +1160,18 @@ class BOM extends CommonObject
$label = $langs->trans("ShowBillOfMaterials");
$linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
}
- $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
- $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
+ if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) {
+ $params = [
+ 'id' => $this->id,
+ 'objecttype' => $this->element,
+ 'option' => $option,
+ ];
+ $linkclose .= ' data-params='.json_encode($params).' id="' . uniqid('bom') . '" title="' . $langs->trans('Loading') . '"';
+ $linkclose .= ' class="classforajaxtooltip'.($morecss ? ' '.$morecss : '').'"';
+ } else {
+ $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
+ $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
+ }
} else {
$linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
}