From ec1edc63dfaaf9f100d9b894384894bd96cc4128 Mon Sep 17 00:00:00 2001 From: Rohan Katkar Date: Thu, 25 Sep 2014 19:55:14 +0530 Subject: [PATCH] CRM-15120 --- CRM/Contact/Form/Task/LabelCommon.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/CRM/Contact/Form/Task/LabelCommon.php b/CRM/Contact/Form/Task/LabelCommon.php index 5e72b24188..60b8ca94b4 100644 --- a/CRM/Contact/Form/Task/LabelCommon.php +++ b/CRM/Contact/Form/Task/LabelCommon.php @@ -106,7 +106,7 @@ class CRM_Contact_Form_Task_LabelCommon { $addressReturnProperties = CRM_Contact_Form_Task_LabelCommon::getAddressReturnProperties(); //build the returnproperties - $returnProperties = array('display_name' => 1, 'contact_type' => 1); + $returnProperties = array('display_name' => 1, 'contact_type' => 1, 'prefix_id' => 1); $mailingFormat = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'mailing_format' ); @@ -353,16 +353,26 @@ class CRM_Contact_Form_Task_LabelCommon { else { $name = $rows[$rowID]['display_name']; } + $formatted = array( + 'first_name' => $rows[$rowID]['first_name'], + 'individual_prefix' => $rows[$rowID]['individual_prefix'] + ); + $format = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'display_name_format'); + $firstNameWithPrefix = CRM_Utils_Address::format($formatted, $format, FALSE, FALSE, TRUE); + $firstNameWithPrefix = trim($firstNameWithPrefix); + // fill uniqueAddress array with last/first name tree if (isset($uniqueAddress[$address])) { - $uniqueAddress[$address]['names'][$name][] = $rows[$rowID]['first_name']; + $uniqueAddress[$address]['names'][$name][$firstNameWithPrefix] = $rows[$rowID]['first_name']; + $uniqueAddress[$address]['names'][$name][$firstNameWithPrefix] = $rows[$rowID]['addressee_display']; // drop unnecessary rows unset($rows[$rowID]); // this is the first listing at this address } else { $uniqueAddress[$address]['ID'] = $rowID; - $uniqueAddress[$address]['names'][$name][] = $rows[$rowID]['first_name']; + $uniqueAddress[$address]['names'][$name][$firstNameWithPrefix] = $rows[$rowID]['first_name']; + $uniqueAddress[$address]['names'][$name][$firstNameWithPrefix] = $rows[$rowID]['addressee_display']; } } foreach ($uniqueAddress as $address => $data) { -- 2.25.1