Details
-
Type: New Feature
-
Status: Done/Fixed
-
Priority: Major
-
Resolution: Fixed/Completed
-
Affects Version/s: 1.8
-
Fix Version/s: 1.8
-
Component/s: Core CiviCRM
-
Labels:None
Description
========
Rationale
========
Organizations need to manage postal mailings such that household addresses are stored in a single consistent place for individuals who share an address (members of a household). These changes are designed to make it easier to input Individual PLUS Household information, display shared address information for household members, and target mailings at households OR individuals.
========
Summary
========
Modify the "New Individual" screen to allow users to specify that a Household Address is to be used for this contact - and to select or create the associated Household.
Modify the "Edit Individual" screen to replace Address block fields with read-only display of the linked Household Address when "Use Household Address" is specified for a contact location.
Modify logic which retrieves Address objects to "Use Household Address" when specified for an Individual contact. This should be effective for Contact Summary screen, Export (csv), Mailing Labels, Search Result selectors.
============
Implementation
============
Data Model
*************
The civicrm_individual table currently includes a mail_to_household_id column which was intended to service this type of functionality. We'll use this to store the contact.id of the associated househould. This data model carries the following assumptions:
- We are overriding the address record associated with the Individual contact's PRIMARY location with the address associated with the PRIMARY location of the household.
- No other location entities are affected (e.g. Phone(s), Email(s), IM(s)).
New Individual
****************
New checkbox is rendered at the top of Address Fieldset for the Primary location block.
[ _ ] Use Household Address
Default = false
If checked, we "show" a nested fieldset (hidden by default) with the following elements:
Radio Button -
[ o ] Create new household [ _ ] Select existing household
If "Create new household" checked, show field below
Household Name [ __________________ ]
If "Select existing household" checked, show dojo autocomplete field
Find Household [ ___________________________^ ]
This field works like existing quick search widget with following modifications:
- only Household records are queried
- option label strings are composed of $sort_name . substr($street_address,0,25) . $city
When "Select existing household" is checked, we also hide the "Address" fieldset for the Primary location block. If "Create new household" case - keep the Address fieldset visible, but replace the fieldset legend with "Household Address".
Edit Individual
***************
For the Edit case, we check in preProcess to see if the contact is a "Member of Household" (i.e. query for relatiionship records with relationship_type = 7 where this contact is contact_a).
If contact is NOT a household member, screen UI is same as "New Contact" above.
If contact IS a member of one or more households, we can either replace the dojo autocomplete with a simple <select> whose options are the Households they belong to. Or, keep the dojo select and have the (or the first) Household contact show up as a default select option.
If "Use Household Address" is checked (true) when the form is loaded - the address fieldset for the Primary location is a replaced by a read-only display of the associated household's primary address. I think we can retain the block in the tpl and use setDefaults plus the QF freeze functionality to accomplish this.
Additional Post Process Steps for New/Edit Individual
**********************************************************
If "Use Household Address" is true, validate that we have either a Household ID in the <select> Household field OR a "create household" Household Name.
If "create household:
- insert household record
- insert primary location for household
- insert address for household primary location- use address fields from Individual's primary location block to populate the household address (copy location_type from individual's primary location block - hopefully this is "Home")
- set individual.mail_to_household_id (can either do this as an update or insert household first ??)
- insert relationship record type 7 (Household Member...)
If "select existing household":
- check for "household member" relationship - insert if it doesn't exist
- set individual.mail_to_household_id
Retrieve Primary Address
****************************
For Contact Summary, Export, Mailing Labels, Search selectors...
If individual. mail_to_household_id is populated, use the referenced contact's primary location address as the primary address for output.
Attachments
Issue Links
- is blocked by
-
CRM-2047 Wrong behaviour after "Use household address" is unchecked
- Done/Fixed