// Normal update process will automatically create new address with submitted values
// 1. loop through entire submitted address array
- $skipFields = ['is_primary', 'location_type_id', 'is_billing', 'master_id', 'update_current_employer'];
+ $skipFields = ['is_primary', 'location_type_id', 'is_billing', 'master_id', 'add_relationship'];
foreach ($address as & $values) {
// 2. check if "Use another contact's address" is checked, if not continue
// Additionally, if master_id is set (address was shared), set master_id to empty value.
continue;
}
- // Set update_current_employer checkbox value
- $values['update_current_employer'] = !empty($values['update_current_employer']);
+ // Set add_relationship checkbox value
+ $values['add_relationship'] = !empty($values['add_relationship']);
// 3. get the address details for master_id
$masterAddress = new CRM_Core_BAO_Address();
$form->addEntityRef("address[$blockId][master_contact_id]", ts('Share With'), ['create' => $profileLinks, 'api' => ['extra' => ['contact_type']]]);
// do we want to update employer for shared address
- $form->addElement('checkbox', "address[$blockId][update_current_employer]", NULL, ts('Set this organization as current employer'));
+ $form->addElement('checkbox', "address[$blockId][add_relationship]", NULL, ts('Create a relationship with this contact'));
}
}
$query = 'SELECT id, contact_id FROM civicrm_address WHERE master_id = %1';
$dao = CRM_Core_DAO::executeQuery($query, [1 => [$addressId, 'Integer']]);
+ // legacy - for api backward compatibility
+ if (!isset($params['add_relationship'] && isset($params['update_current_employer']))) {
+ // warning
+ CRM_Core_Error::deprecatedFunctionWarning('update_current_employer is deprecated, use add_relationship instead');
+ $params['add_relationship'] = $params['update_current_employer'];
+ }
+
// Default to TRUE if not set to maintain api backward compatibility.
- $createRelationship = isset($params['update_current_employer']) ? $params['update_current_employer'] : TRUE;
+ $createRelationship = isset($params['add_relationship']) ? $params['add_relationship'] : TRUE;
// unset contact id
$skipFields = ['is_primary', 'location_type_id', 'is_billing', 'contact_id'];
<div id="shared-address-{$blockId}" class="form-layout-compressed">
{$form.address.$blockId.master_contact_id.label}
{$form.address.$blockId.master_contact_id.html}
- <div class="shared-address-update-employer" style="display: none;">
- {$form.address.$blockId.update_current_employer.html}
- {$form.address.$blockId.update_current_employer.label}
- {help id="id-sharedAddress-updateRelationships" file="CRM/Contact/Form/Contact"}
+ <div class="shared-address-create-relationship" style="display: none;">
+ {$form.address.$blockId.add_relationship.html}
+ {$form.address.$blockId.add_relationship.label}
+ <div class="employer">{help id="id-sharedAddress-updateRelationships" file="CRM/Contact/Form/Contact"}</div>
</div>
<div class="shared-address-list">
{if !empty($sharedAddresses.$blockId.shared_address_display)}
CRM.$(function($) {
var blockNo = {/literal}{$blockId}{literal},
contactType = {/literal}{$contactType|@json_encode}{literal},
- $employerSection = $('#shared-address-' + blockNo + ' .shared-address-update-employer'),
+ $addRelationshipSection = $('#shared-address-' + blockNo + ' .shared-address-add-relationship'),
+ $employerSection = $('#shared-address-' + blockNo + ' .shared-address-add-relationship .employer'),
$contentArea = $('#shared-address-' + blockNo + ' .shared-address-list'),
$masterElement = $('input[name="address[' + blockNo + '][master_id]"]');
if (!sharedContactId || isNaN(sharedContactId)) {
$employerSection.hide();
+ $addRelationshipSection.hide();
return;
}
var otherContactType = $el.select2('data').extra.contact_type;
+ $addRelationshipSection.toggle(contactType === 'Individual' && (otherContactType === 'Organization' || otherContactType === 'Household'));
$employerSection.toggle(contactType === 'Individual' && otherContactType === 'Organization');
$.post(CRM.url('civicrm/ajax/inline'), {
$individualParams = [
'contact_id' => $individualID,
'master_id' => $address['id'],
- 'update_current_employer' => 0,
+ 'add_relationship' => 0,
];
$this->callAPISuccess('address', 'create', array_merge($this->_params, $individualParams));
$this->callAPISuccess('relationship', 'getcount', [