From 137fdd28ac1a6cdabb60acdfea97a4b05acdd413 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Nov 2024 03:59:30 +0100 Subject: [PATCH] Prepare code for a cleaner implementation of #24943 --- htdocs/core/tpl/extrafields_add.tpl.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/htdocs/core/tpl/extrafields_add.tpl.php b/htdocs/core/tpl/extrafields_add.tpl.php index e25ff129d0e..f6eeb4ad5e9 100644 --- a/htdocs/core/tpl/extrafields_add.tpl.php +++ b/htdocs/core/tpl/extrafields_add.tpl.php @@ -35,6 +35,7 @@ if (empty($conf) || !is_object($conf)) { @phan-var-force Conf $conf @phan-var-force Translate $langs @phan-var-force array $parameters +@phan-var-force Societe $thirdpartytopropagateextrafieldsfrom '; ?> @@ -59,6 +60,17 @@ if (empty($reshook)) { $params['tpl_context'] = $parameters['tpl_context']; } + // By default $thirdpartytopropagateextrafieldsfrom is not set. + // We can have it set to a thirdparty object to propagate also the extrafields from thirdparty to object. + if (!empty($thirdpartytopropagateextrafieldsfrom) && $thirdpartytopropagateextrafieldsfrom instanceof Societe && !empty($thirdpartytopropagateextrafieldsfrom->id)) { + // copy from thirdparty + $tpExtrafields = new Extrafields($db); + $tpExtrafieldLabels = $tpExtrafields->fetch_name_optionals_label($thirdpartytopropagateextrafieldsfrom->table_element); + if ($thirdpartytopropagateextrafieldsfrom->fetch_optionals() > 0) { + $object->array_options = array_merge($object->array_options, $thirdpartytopropagateextrafieldsfrom->array_options); + } + } + print $object->showOptionals($extrafields, 'create', $params); }