From 88820b18ae2b8011b2635021b95d01ea3c5da708 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Fri, 12 Sep 2014 20:19:11 -0400 Subject: [PATCH] CRM-15287 - More consistent behavior when editing/adding shared address --- CRM/Contact/BAO/Contact/Utils.php | 1 + CRM/Contact/Form/Edit/Address.php | 4 ++ CRM/Core/BAO/Address.php | 2 +- templates/CRM/Contact/Form/ShareAddress.tpl | 53 +++++++++++---------- 4 files changed, 33 insertions(+), 27 deletions(-) diff --git a/CRM/Contact/BAO/Contact/Utils.php b/CRM/Contact/BAO/Contact/Utils.php index 5da54baa54..94b2dc79df 100644 --- a/CRM/Contact/BAO/Contact/Utils.php +++ b/CRM/Contact/BAO/Contact/Utils.php @@ -850,6 +850,7 @@ Group By componentId"; $contactNames[$dao->id] = array( 'name' => "{$dao->display_name}", 'is_deleted' => $dao->is_deleted, + 'contact_id' => $dao->cid, ); } } diff --git a/CRM/Contact/Form/Edit/Address.php b/CRM/Contact/Form/Edit/Address.php index 936869c1c9..676c4282e5 100644 --- a/CRM/Contact/Form/Edit/Address.php +++ b/CRM/Contact/Form/Edit/Address.php @@ -339,10 +339,14 @@ class CRM_Contact_Form_Edit_Address { foreach ($defaults['address'] as $key => $addressValue) { if (!empty($addressValue['master_id']) && !$shareAddressContactNames[$addressValue['master_id']]['is_deleted']) { + $master_cid = $shareAddressContactNames[$addressValue['master_id']]['contact_id']; $sharedAddresses[$key]['shared_address_display'] = array( 'address' => $addressValue['display'], 'name' => $shareAddressContactNames[$addressValue['master_id']]['name'], + 'options' => CRM_Core_BAO_Address::getValues(array('entity_id' => $master_cid, 'contact_id' => $master_cid)), + 'master_id' => $addressValue['master_id'], ); + $defaults['address'][$key]['master_contact_id'] = $master_cid; } else { $defaults['address'][$key]['use_shared_address'] = 0; diff --git a/CRM/Core/BAO/Address.php b/CRM/Core/BAO/Address.php index 5903c00ef5..1c1ebf7604 100644 --- a/CRM/Core/BAO/Address.php +++ b/CRM/Core/BAO/Address.php @@ -463,7 +463,7 @@ class CRM_Core_BAO_Address extends CRM_Core_DAO_Address { * @access public * @static */ - static function &getValues(&$entityBlock, $microformat = FALSE, $fieldName = 'contact_id') { + static function &getValues($entityBlock, $microformat = FALSE, $fieldName = 'contact_id') { if (empty($entityBlock)) { return NULL; } diff --git a/templates/CRM/Contact/Form/ShareAddress.tpl b/templates/CRM/Contact/Form/ShareAddress.tpl index 95a301b249..3e39050c4c 100644 --- a/templates/CRM/Contact/Form/ShareAddress.tpl +++ b/templates/CRM/Contact/Form/ShareAddress.tpl @@ -26,25 +26,20 @@ {* template for handling share address functionality*} - {$form.address.$blockId.use_shared_address.html}{$form.address.$blockId.use_shared_address.label} {help id="id-sharedAddress" file="CRM/Contact/Form/Contact.hlp"}
- {if !empty($sharedAddresses.$blockId.shared_address_display)} - - {$sharedAddresses.$blockId.shared_address_display.name} - - - - {$sharedAddresses.$blockId.shared_address_display.address} ( {ts}Change current shared address{/ts} ) - - - - ( {ts}Cancel{/ts} ) - - {/if} - -
+ {$form.address.$blockId.use_shared_address.html}{$form.address.$blockId.use_shared_address.label} {help id="id-sharedAddress" file="CRM/Contact/Form/Contact.hlp"} +
{$form.address.$blockId.master_contact_id.label} {$form.address.$blockId.master_contact_id.html} -
+
+ {if !empty($sharedAddresses.$blockId.shared_address_display)} + {foreach item='sa' from=$sharedAddresses.$blockId.shared_address_display.options} + {assign var="sa_name" value="selected_shared_address-`$blockId`"} + {assign var="sa_id" value="`$sa_name`-`$sa.id`"} + +
+ {/foreach} + {/if} +
@@ -53,24 +48,32 @@ {literal}