CRM-14961 Fix
authorjitendrapurohit <jituraj7760@gmail.com>
Tue, 15 Jul 2014 14:44:12 +0000 (20:14 +0530)
committerCiviCRM <info@civicrm.org>
Thu, 17 Jul 2014 14:49:18 +0000 (20:19 +0530)
CRM/Contact/Form/Merge.php
CRM/Dedupe/Merger.php

index 75ae4ef10a8076f96d298a6925eca2a8f5aa0eab..c0aa640e38caf1a08ae2c4d46ee9bec203ed5279 100644 (file)
@@ -194,18 +194,12 @@ class CRM_Contact_Form_Merge extends CRM_Core_Form {
       CRM_Core_Error::fatal(ts('The other contact record does not exist'));
     }
 
-    $subtypes = CRM_Contact_BAO_ContactType::subTypePairs(NULL, TRUE, '');
-
     $this->assign('contact_type', $main['contact_type']);
     if (!empty($main['contact_sub_type'])) {
-      $this->assign('main_contact_subtype',
-        CRM_Utils_Array::value($main['contact_sub_type'][0], $subtypes)
-      );
+      $this->assign('main_contact_subtype', $main['contact_sub_type_display']);
     }
     if (!empty($other['contact_sub_type'])) {
-      $this->assign('other_contact_subtype',
-        CRM_Utils_Array::value($other['contact_sub_type'][0], $subtypes)
-      );
+      $this->assign('other_contact_subtype', $other['contact_sub_type_display']);
     }
     $this->assign('main_name', $main['display_name']);
     $this->assign('other_name', $other['display_name']);
index 688cc8885b6a1f1caf5a73403f327727465587cb..2e975a321784213e41f5309509d44cb438ea60c5 100644 (file)
@@ -816,6 +816,9 @@ INNER JOIN  civicrm_membership membership2 ON membership1.membership_type_id = m
       CRM_Core_DAO::freeResult();
     }
 
+    // get all contact subtypes
+    $contactSubTypes = CRM_Contact_BAO_ContactType::subTypePairs(NULL, TRUE, '');
+
     // FIXME: there must be a better way
     foreach (array('main', 'other') as $moniker) {
       $contact = &$$moniker;
@@ -823,6 +826,7 @@ INNER JOIN  civicrm_membership membership2 ON membership1.membership_type_id = m
       $value = empty($preferred_communication_method) ? array() : $preferred_communication_method;
       $specialValues[$moniker] = array(
         'preferred_communication_method' => $value,
+        'contact_sub_type' => $value,
       );
 
       if (!empty($contact['preferred_communication_method'])){
@@ -840,6 +844,17 @@ INNER JOIN  civicrm_membership membership2 ON membership1.membership_type_id = m
         ),
       );
       CRM_Core_OptionGroup::lookupValues($specialValues[$moniker], $names);
+
+      if (!empty($contact['contact_sub_type'])) {
+        $specialValues[$moniker]['contact_sub_type'] = implode(CRM_Core_DAO::VALUE_SEPARATOR, $contact['contact_sub_type']);
+
+        // fix contact sub type label for contact with sub type
+        $subtypes = array();
+        foreach ($contact['contact_sub_type'] as $key => $value) {
+          $subtypes[] = CRM_Utils_Array::retrieveValueRecursive($contactSubTypes, $value);
+        }
+        $contact['contact_sub_type_display'] = $specialValues[$moniker]['contact_sub_type_display'] = implode(', ', $subtypes);
+      }
     }
 
     static $optionValueFields = array();