From 7d84a47d009a5804a94c3cca6ab2ad84d206aff8 Mon Sep 17 00:00:00 2001 From: Jitendra Purohit Date: Wed, 13 Feb 2019 18:48:03 +0530 Subject: [PATCH] Enable 'add new' by default on merge screen --- CRM/Dedupe/Merger.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/CRM/Dedupe/Merger.php b/CRM/Dedupe/Merger.php index 8563d3603f..1c82527efb 100644 --- a/CRM/Dedupe/Merger.php +++ b/CRM/Dedupe/Merger.php @@ -1433,7 +1433,16 @@ INNER JOIN civicrm_membership membership2 ON membership1.membership_type_id = m } } if ($name == 'rel_table_memberships') { - $elements[] = array('checkbox', "operation[move_{$name}][add]", NULL, ts('add new')); + //Enable 'add new' checkbox if main contact does not contain any membership similar to duplicate contact. + $attributes = ['checked' => 'checked']; + $otherContactMemberships = CRM_Member_BAO_Membership::getAllContactMembership($otherId); + foreach ($otherContactMemberships as $membership) { + $mainMembership = CRM_Member_BAO_Membership::getContactMembership($mainId, $membership['membership_type_id'], FALSE); + if ($mainMembership) { + $attributes = []; + } + } + $elements[] = array('checkbox', "operation[move_{$name}][add]", NULL, ts('add new'), $attributes); $migrationInfo["operation"]["move_{$name}"]['add'] = 1; } } -- 2.25.1