From 8cb877c118b52a49ffb68a52468608fba255e2b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 26 Apr 2023 08:43:11 +0200 Subject: [PATCH 1/4] can setup max extrafields to show in tooltip --- htdocs/core/class/commonobject.class.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 32802660e73..39a24f830b2 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -731,13 +731,14 @@ abstract class CommonObject { global $action, $extrafields, $langs, $hookmanager; - $MAX_EXTRAFIELDS_TO_SHOW_IN_TOOLTIP = 5; // If there is too much extrafields, we do not include them into tooltip + // If there is too much extrafields, we do not include them into tooltip + $MAX_EXTRAFIELDS_TO_SHOW_IN_TOOLTIP = getDolGlobalInt('MAX_EXTRAFIELDS_TO_SHOW_IN_TOOLTIP', 5); $datas = $this->getTooltipContentArray($params); // Add extrafields if (!empty($extrafields->attributes[$this->table_element]['label'])) { - if (count($extrafields->attributes[$this->table_element]['label']) < $MAX_EXTRAFIELDS_TO_SHOW_IN_TOOLTIP) { + if ($extrafields->attributes[$this->table_element]['count'] < $MAX_EXTRAFIELDS_TO_SHOW_IN_TOOLTIP) { foreach ($extrafields->attributes[$this->table_element]['label'] as $key => $val) { if (!empty($extrafields->attributes[$this->table_element]['langfile'][$key])) { $langs->load($extrafields->attributes[$this->table_element]['langfile'][$key]); From a93cb8b5727d1f211e37b02643d2762d2011818d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 26 Apr 2023 10:56:52 +0200 Subject: [PATCH 2/4] Update commonobject.class.php --- htdocs/core/class/commonobject.class.php | 29 +++++++++++++----------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 39a24f830b2..a101181d7cb 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -735,21 +735,24 @@ abstract class CommonObject $MAX_EXTRAFIELDS_TO_SHOW_IN_TOOLTIP = getDolGlobalInt('MAX_EXTRAFIELDS_TO_SHOW_IN_TOOLTIP', 5); $datas = $this->getTooltipContentArray($params); - + $count = 0; // Add extrafields if (!empty($extrafields->attributes[$this->table_element]['label'])) { - if ($extrafields->attributes[$this->table_element]['count'] < $MAX_EXTRAFIELDS_TO_SHOW_IN_TOOLTIP) { - foreach ($extrafields->attributes[$this->table_element]['label'] as $key => $val) { - if (!empty($extrafields->attributes[$this->table_element]['langfile'][$key])) { - $langs->load($extrafields->attributes[$this->table_element]['langfile'][$key]); - } - $labelextra = $langs->trans((string) $extrafields->attributes[$this->table_element]['label'][$key]); - if ($extrafields->attributes[$this->table_element]['type'][$key] == 'separate') { - $datas[$key]= '
'. $labelextra . ''; - } else { - $value = (empty($this->array_options['options_' . $key]) ? '' : $this->array_options['options_' . $key]); - $datas[$key]= '
'. $labelextra . ': ' . $extrafields->showOutputField($key, $value, '', $this->table_element); - } + foreach ($extrafields->attributes[$this->table_element]['label'] as $key => $val) { + if ($count >= $MAX_EXTRAFIELDS_TO_SHOW_IN_TOOLTIP) { + $datas['more_extrafields'] = '
.../...'; + break; + } + if (!empty($extrafields->attributes[$this->table_element]['langfile'][$key])) { + $langs->load($extrafields->attributes[$this->table_element]['langfile'][$key]); + } + $labelextra = $langs->trans((string) $extrafields->attributes[$this->table_element]['label'][$key]); + if ($extrafields->attributes[$this->table_element]['type'][$key] == 'separate') { + $datas[$key]= '
'. $labelextra . ''; + } else { + $value = (empty($this->array_options['options_' . $key]) ? '' : $this->array_options['options_' . $key]); + $datas[$key]= '
'. $labelextra . ': ' . $extrafields->showOutputField($key, $value, '', $this->table_element); + $count++; } } } From cf9ce353c36b271aa5cb68ce0adb66e77ba942da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 26 Apr 2023 10:58:19 +0200 Subject: [PATCH 3/4] Update ajaxtooltip.php --- htdocs/core/ajax/ajaxtooltip.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/ajax/ajaxtooltip.php b/htdocs/core/ajax/ajaxtooltip.php index 33cdfb4831f..06bd008cd5b 100644 --- a/htdocs/core/ajax/ajaxtooltip.php +++ b/htdocs/core/ajax/ajaxtooltip.php @@ -80,6 +80,7 @@ $html = ''; if (is_object($object)) { if ($object->id > 0 || !empty($object->ref)) { + /** @var CommonObject $object */ $html = $object->getTooltipContent($params); } elseif ($res == 0) { $html = $langs->trans('Deleted'); From d7c654665f415dc8f0444ecc454cd49c8d23f258 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 26 Apr 2023 20:56:11 +0200 Subject: [PATCH 4/4] fix display extrafields in tooltip --- htdocs/core/class/commonobject.class.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index a101181d7cb..c276f4febc3 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -743,6 +743,26 @@ abstract class CommonObject $datas['more_extrafields'] = '
.../...'; break; } + $enabled = 1; + if ($enabled && isset($extrafields->attributes[$this->table_element]['enabled'][$key])) { + $enabled = dol_eval($extrafields->attributes[$this->table_element]['enabled'][$key], 1, 1, '2'); + } + if ($enabled && isset($extrafields->attributes[$this->table_element]['list'][$key])) { + $enabled = dol_eval($extrafields->attributes[$this->table_element]['list'][$key], 1, 1, '2'); + } + $perms = 1; + if ($perms && isset($extrafields->attributes[$this->table_element]['perms'][$key])) { + $perms = dol_eval($extrafields->attributes[$this->table_element]['perms'][$key], 1, 1, '2'); + } + if (empty($enabled)) { + continue; // 0 = Never visible field + } + if (abs($enabled) != 1 && abs($enabled) != 3 && abs($enabled) != 5 && abs($enabled) != 4) { + continue; // <> -1 and <> 1 and <> 3 = not visible on forms, only on list <> 4 = not visible at the creation + } + if (empty($perms)) { + continue; // 0 = Not visible + } if (!empty($extrafields->attributes[$this->table_element]['langfile'][$key])) { $langs->load($extrafields->attributes[$this->table_element]['langfile'][$key]); }