Add more search options
authoreileen <emcnaughton@wikimedia.org>
Thu, 21 May 2020 03:38:34 +0000 (15:38 +1200)
committereileen <emcnaughton@wikimedia.org>
Tue, 2 Jun 2020 05:57:07 +0000 (17:57 +1200)
This adds more fields to the filters on search for individual
- organization_name (Employer Name)
- first_name
- nick_name
- last_name

Note
1) organization_name is populated for individuals with employers - it's handy to be able
to filter by as a quick way to narrow down. I wasn't too worried about declaring it only
for individuals as sort_name covers this for organizations
2) Last name these feels a bit unnecessary as it co-incides with sort_name
but it also feels odd not to add it
3) Ideally for these text fields they would be always or optionally 'like' searches
(respecting the site +wildcard setting). I took a a quick look but decided to leave it
out of scope at this stage.
4) I thought 'email' might have been useful too but given 3 & the fact that the main use I saw
was as a proxy for 1 (employer) and that email is the preferred search for email anyway (
which was the entity I was working on) I excluded it too in the end.

The use case for this is narrowing down in a large database. Take finding Johnathan Smith.
Being able to add 'Johnathan' as a filter helps get past all the Johns quicker.

Lastly - I have a sneaky feeling that users in our org will abuse the nick name filter heavily &
add nicknames to all contacts they frequently email....

CRM/Contact/BAO/Contact.php

index e27e551f52978f4292cffc9a79519c5cefbcc334..304a554e3b19b43ad30b6a667645513c368e8584 100644 (file)
@@ -3718,8 +3718,15 @@ LEFT JOIN civicrm_address ON ( civicrm_address.contact_id = civicrm_contact.id )
       ['key' => 'contact_type', 'value' => ts('Contact Type')],
       ['key' => 'group', 'value' => ts('Group'), 'entity' => 'GroupContact'],
       ['key' => 'tag', 'value' => ts('Tag'), 'entity' => 'EntityTag'],
+      ['key' => 'city', 'value' => ts('City'), 'entity' => 'Address'],
+      ['key' => 'street_address', 'value' => ts('Street Address'), 'entity' => 'Address'],
+      ['key' => 'postal_code', 'value' => ts('Postal Code'), 'entity' => 'Address'],
       ['key' => 'state_province', 'value' => ts('State/Province'), 'entity' => 'Address'],
       ['key' => 'country', 'value' => ts('Country'), 'entity' => 'Address'],
+      ['key' => 'first_name', 'value' => ts('First Name'), 'type' => 'text', 'condition' => ['contact_type' => 'Individual']],
+      ['key' => 'last_name', 'value' => ts('Last Name'), 'type' => 'text', 'condition' => ['contact_type' => 'Individual']],
+      ['key' => 'nick_name', 'value' => ts('Nick Name'), 'type' => 'text', 'condition' => ['contact_type' => 'Individual']],
+      ['key' => 'organization_name', 'value' => ts('Employer name'), 'type' => 'text', 'condition' => ['contact_type' => 'Individual']],
       ['key' => 'gender_id', 'value' => ts('Gender'), 'condition' => ['contact_type' => 'Individual']],
       ['key' => 'is_deceased', 'value' => ts('Deceased'), 'condition' => ['contact_type' => 'Individual']],
       ['key' => 'contact_id', 'value' => ts('Contact ID'), 'type' => 'text'],