diff --git a/CRM/Contact/BAO/Query.php b/CRM/Contact/BAO/Query.php index 9d5e64a38a51..dc1fbd7dabf6 100644 --- a/CRM/Contact/BAO/Query.php +++ b/CRM/Contact/BAO/Query.php @@ -2032,6 +2032,7 @@ public function whereClauseSingle(&$values, $isForcePrimaryOnly = FALSE) { case 'relation_active_period_date_low': case 'relation_target_name': case 'relation_status': + case 'relation_description': case 'relation_date_low': case 'relation_date_high': $this->relationship($values); @@ -4160,6 +4161,7 @@ public function relationship(&$values) { // also get values array for relation_target_name // for relationship search we always do wildcard $relationType = $this->getWhereValues('relation_type_id', $grouping); + $description = $this->getWhereValues('relation_description', $grouping); $targetName = $this->getWhereValues('relation_target_name', $grouping); $relStatus = $this->getWhereValues('relation_status', $grouping); $targetGroup = $this->getWhereValues('relation_target_group', $grouping); @@ -4276,6 +4278,13 @@ public function relationship(&$values) { } } + // Description + if (!empty($description[2]) && trim($description[2])) { + $this->_qill[$grouping][] = ts('Relationship description - ' . $description[2]); + $description = CRM_Core_DAO::escapeString(trim($description[2])); + $where[$grouping][] = "civicrm_relationship.description LIKE '%{$description}%'"; + } + // Note we do not currently set mySql to handle timezones, so doing this the old-fashioned way $today = date('Ymd'); //check for active, inactive and all relation status diff --git a/CRM/Contact/Form/Search/Criteria.php b/CRM/Contact/Form/Search/Criteria.php index 2d5695b78d03..d6f731b0a844 100644 --- a/CRM/Contact/Form/Search/Criteria.php +++ b/CRM/Contact/Form/Search/Criteria.php @@ -487,12 +487,12 @@ public static function task(&$form) { } /** - * @param $form + * @param CRM_Core_Form_Search $form */ public static function relationship(&$form) { $form->add('hidden', 'hidden_relationship', 1); - $allRelationshipType = []; + $form->add('text', 'relation_description', ts('Description'), ['class' => 'twenty']); $allRelationshipType = CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, NULL, NULL, NULL, TRUE); $form->add('select', 'relation_type_id', ts('Relationship Type'), ['' => ts('- select -')] + $allRelationshipType, FALSE, ['multiple' => TRUE, 'class' => 'crm-select2']); $form->addElement('text', 'relation_target_name', ts('Target Contact'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name')); diff --git a/templates/CRM/Contact/Form/Search/Criteria/Relationship.tpl b/templates/CRM/Contact/Form/Search/Criteria/Relationship.tpl index 34fcb615d5bb..14619c0b5813 100644 --- a/templates/CRM/Contact/Form/Search/Criteria/Relationship.tpl +++ b/templates/CRM/Contact/Form/Search/Criteria/Relationship.tpl @@ -53,6 +53,12 @@ {$form.relation_target_group.html|crmAddClass:huge} +