Skip to content

Commit

Permalink
Merge pull request #15123 from mattwire/fixhardcodedheadofhouseholdre…
Browse files Browse the repository at this point in the history
…lationship

Fix hardcoded ID for Head of Household relationship
  • Loading branch information
eileenmcnaughton authored Aug 24, 2019
2 parents 80b3a61 + eabf1c2 commit f5c715a
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions CRM/Contact/BAO/Relationship.php
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,17 @@ public static function add($params, $ids = [], $contactId = NULL) {

// check if the relationship type is Head of Household then update the
// household's primary contact with this contact.
if ($relationshipTypeID == 6) {
CRM_Contact_BAO_Household::updatePrimaryContact($relationship->contact_id_b, $relationship->contact_id_a);
try {
$headOfHouseHoldID = civicrm_api3('RelationshipType', 'getvalue', [
'return' => "id",
'name_a_b' => "Head of Household for",
]);
if ($relationshipTypeID == $headOfHouseHoldID) {
CRM_Contact_BAO_Household::updatePrimaryContact($relationship->contact_id_b, $relationship->contact_id_a);
}
}
catch (Exception $e) {
// No "Head of Household" relationship found so we skip specific processing
}

if (!empty($params['id']) && self::isCurrentEmployerNeedingToBeCleared($relationship->toArray(), $params['id'], $relationshipTypeID)) {
Expand Down

0 comments on commit f5c715a

Please sign in to comment.