From 3c5031f79dc884e95fa7e53c676069139f3c6806 Mon Sep 17 00:00:00 2001 From: Nishant Date: Fri, 20 Dec 2019 18:36:25 +0530 Subject: [PATCH 1/2] Autofill related contacts for all contacts on webform when configured --- includes/wf_crm_webform_ajax.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/wf_crm_webform_ajax.inc b/includes/wf_crm_webform_ajax.inc index 397203e3d..0e4612eae 100644 --- a/includes/wf_crm_webform_ajax.inc +++ b/includes/wf_crm_webform_ajax.inc @@ -134,7 +134,7 @@ class wf_crm_webform_ajax extends wf_crm_webform_base { } } // Populate related contacts - elseif ($c == 1 && $i > $c && $field == 'existing') { + elseif ($i > $c && $field == 'existing') { $related_component = $this->getComponent($fid); if (wf_crm_aval($related_component['extra'], 'default') == 'relationship') { $old_related_cid = wf_crm_aval($this->ent, "contact:$i:id"); From a63d3c7c08cc5aa2a4de8240c55da616ad95028e Mon Sep 17 00:00:00 2001 From: Nishant Date: Fri, 20 Dec 2019 18:39:50 +0530 Subject: [PATCH 2/2] Fetch active relationships for given contact id --- includes/contact_component.inc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/includes/contact_component.inc b/includes/contact_component.inc index 64682aa6f..55a42a69a 100644 --- a/includes/contact_component.inc +++ b/includes/contact_component.inc @@ -253,7 +253,7 @@ function _webform_edit_civicrm_contact($component) { '#parents' => array('extra', 'default_custom_ref'), ); } - + $case_count = isset($data['case']['number_of_case']) ? $data['case']['number_of_case'] : 0; if ($case_count > 0) { $form['defaults']['default']['#options']['case_roles'] = t('Case roles'); @@ -918,8 +918,8 @@ function wf_crm_find_relations($cid, $types = array(), $current = TRUE) { } $params = [ 'return' => ['contact_id_a', 'contact_id_b', 'relationship_type_id', 'end_date'], - 'contact_id_a' => 'user_contact_id', - 'contact_id_b' => 'user_contact_id', + 'contact_id_a' => $cid, + 'contact_id_b' => $cid, 'options' => ['or' => [['contact_id_a', 'contact_id_b']]], ]; if ($type_ids) {