From 6a632cc73c92ace1d43d35f1378bd2b3208be9ee Mon Sep 17 00:00:00 2001 From: Nicolas Date: Fri, 10 Sep 2021 17:11:12 +0200 Subject: [PATCH] [PreventionPlanList] fix: all data for custom fields --- preventionplan_list.php | 42 +++++++++++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/preventionplan_list.php b/preventionplan_list.php index 69ac495fd..dd3330f80 100644 --- a/preventionplan_list.php +++ b/preventionplan_list.php @@ -65,6 +65,7 @@ $title = $langs->trans("PreventionPlan"); $preventionplan = new PreventionPlan($db); +$signatory = new PreventionPlanSignature($db); $digiriskresources = new DigiriskResources($db); $societe = new Societe($db); $contact = new Contact($db); @@ -473,18 +474,39 @@ foreach ($val as $name => $resource) { if ($resource['checked']) { - $resourceLinked = $digiriskresources->fetchResourcesFromObject($name, $preventionplan); - print ''; - if (!empty($resourceLinked) && $resourceLinked > 0) { - if ($resource == 'ExtSocietyIntervenants') { - $resourcesLinked = array_shift($resourceLinked); - foreach ($resourcesLinked as $resourceLinkedSingle) { - print $resourceLinkedSingle->getNomUrl(1); - print '
'; + if ($resource['label'] == 'MaitreOeuvre') { + $element = $signatory->fetchSignatory('PP_MAITRE_OEUVRE', $preventionplan->id); + if ($element > 0) { + $element = array_shift($element); + $usertmp->fetch($element->element_id); + print $usertmp->getNomUrl(1); + } + } + elseif ($resource['label'] == 'ExtSociety') { + $ext_society = $digiriskresources->fetchResourcesFromObject('PP_EXT_SOCIETY', $preventionplan); + if ($ext_society > 0) { + print $ext_society->getNomUrl(1); + } + } + if ($resource['label'] == 'ExtSocietyResponsible') { + $element = $signatory->fetchSignatory('PP_EXT_SOCIETY_RESPONSIBLE', $preventionplan->id); + if ($element > 0) { + $element = array_shift($element); + $contact->fetch($element->element_id); + print $contact->getNomUrl(1); + } + } + if ($resource['label'] == 'ExtSocietyIntervenants') { + $ext_society_intervenants = $signatory->fetchSignatory('PP_EXT_SOCIETY_INTERVENANTS', $preventionplan->id); + if (is_array($ext_society_intervenants) && !empty ($ext_society_intervenants) && $ext_society_intervenants > 0) { + foreach ($ext_society_intervenants as $element) { + if ($element > 0) { + $contact->fetch($element->element_id); + print $contact->getNomUrl(1); + print '
'; + } } - } else { - print $resourceLinked->getNomUrl(1); } } print '';