From b1e21ed5fc302ebef8fe6b63dc336074ec997233 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 11 Jul 2019 22:18:44 +0200 Subject: [PATCH] FIX Computed field were not calculated into lists. --- htdocs/core/class/extrafields.class.php | 2 ++ .../core/tpl/extrafields_list_print_fields.tpl.php | 12 +++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index eeb653aec8a..9e83a1d836b 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1627,6 +1627,8 @@ class ExtraFields if ($hidden) return ''; // This is a protection. If field is hidden, we should just not call this method. + //if ($computed) $value = // $value is already calculated into $value before calling this method + $showsize=0; if ($type == 'date') { diff --git a/htdocs/core/tpl/extrafields_list_print_fields.tpl.php b/htdocs/core/tpl/extrafields_list_print_fields.tpl.php index 1dad8a6739d..35aefb9f719 100644 --- a/htdocs/core/tpl/extrafields_list_print_fields.tpl.php +++ b/htdocs/core/tpl/extrafields_list_print_fields.tpl.php @@ -40,7 +40,17 @@ if (! empty($extrafieldsobjectkey)) // $extrafieldsobject is the $object->table_ { $value = $obj->$tmpkey; } - + // If field is a computed field, we make computation to get value + if ($extrafields->attributes[$extrafieldsobjectkey]['computed'][$key]) + { + //global $obj, $object; + //var_dump($extrafields->attributes[$extrafieldsobjectkey]['computed'][$key]); + //var_dump($obj); + //var_dump($extrafields->attributes[$extrafieldsobjectkey]['computed'][$key]); + $value = dol_eval($extrafields->attributes[$extrafieldsobjectkey]['computed'][$key], 1); + //var_dump($value); + } + print $extrafields->showOutputField($key, $value, '', $extrafieldsobjectkey); print ''; if (! $i) $totalarray['nbfield']++;