diff --git a/CRM/Contact/Form/Search/Criteria.php b/CRM/Contact/Form/Search/Criteria.php index 3c1b3e7ea9fc..52d7a100168d 100644 --- a/CRM/Contact/Form/Search/Criteria.php +++ b/CRM/Contact/Form/Search/Criteria.php @@ -35,6 +35,7 @@ class CRM_Contact_Form_Search_Criteria { * @param CRM_Core_Form $form */ public static function basic(&$form) { + self::setBasicSearchFields($form); $form->addElement('hidden', 'hidden_basic', 1); if ($form->_searchOptions['contactType']) { @@ -69,7 +70,7 @@ public static function basic(&$form) { $contactTags = CRM_Core_BAO_Tag::getTags(); if ($contactTags) { - $form->add('select', 'contact_tags', ts('Tags'), $contactTags, FALSE, + $form->add('select', 'contact_tags', ts('Select Tag(s)'), $contactTags, FALSE, array('id' => 'contact_tags', 'multiple' => 'multiple', 'class' => 'crm-select2', 'style' => 'width: 100%;') ); } @@ -99,10 +100,10 @@ public static function basic(&$form) { } // add text box for last name, first name, street name, city - $form->addElement('text', 'sort_name', ts('Find...'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name')); + $form->addElement('text', 'sort_name', ts('Complete OR Partial Name'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name')); // add text box for last name, first name, street name, city - $form->add('text', 'email', ts('Contact Email'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name')); + $form->add('text', 'email', ts('Complete OR Partial Email'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name')); //added contact source $form->add('text', 'contact_source', ts('Contact Source'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'contact_source')); @@ -248,6 +249,74 @@ public static function basic(&$form) { $form->add('select', 'phone_phone_type_id', ts('Phone Type'), array('' => ts('- any -')) + $phoneType, FALSE, array('class' => 'crm-select2')); } + /** + * Defines the fields that can be displayed for the basic search section. + * + * @param CRM_Core_Form $form + */ + protected static function setBasicSearchFields($form) { + $userFramework = CRM_Core_Config::singleton()->userFramework; + + $form->assign('basicSearchFields', [ + 'sort_name' => ['name' => 'sort_name'], + 'email' => ['name' => 'email'], + 'contact_type' => ['name' => 'contact_type'], + 'group' => [ + 'name' => 'group', + 'template' => 'CRM/Contact/Form/Search/Criteria/Fields/group.tpl', + ], + 'contact_tags' => ['name' => 'contact_tags'], + 'tag_types_text' => ['name' => 'tag_types_text'], + 'tag_search' => [ + 'name' => 'tag_search', + 'help' => ['id' => 'id-all-tags'], + ], + 'tag_set' => [ + 'name' => 'tag_set', + 'is_custom' => TRUE, + 'template' => 'CRM/Contact/Form/Search/Criteria/Fields/tag_set.tpl', + ], + 'all_tag_types' => [ + 'name' => 'all_tag_types', + 'class' => 'search-field__span-3 search-field__checkbox', + 'help' => ['id' => 'id-all-tag-types'] + ], + 'phone_numeric' => [ + 'name' => 'phone_numeric', + 'description' => ts('Punctuation and spaces are ignored.'), + ], + 'phone_location_type_id' => ['name' => 'phone_location_type_id'], + 'phone_phone_type_id' => ['name' => 'phone_phone_type_id'], + 'privacy_toggle' => [ + 'name' => 'privacy_toggle', + 'class' => 'search-field__span-2', + 'template' => 'CRM/Contact/Form/Search/Criteria/Fields/privacy_toggle.tpl', + ], + 'preferred_communication_method' => [ + 'name' => 'preferred_communication_method', + 'template' => 'CRM/Contact/Form/Search/Criteria/Fields/preferred_communication_method.tpl', + ], + 'contact_source' => [ + 'name' => 'contact_source', + 'help' => ['id' => 'id-source', 'file' => 'CRM/Contact/Form/Contact'], + ], + 'job_title' => ['name' => 'job_title'], + 'preferred_language' => ['name' => 'preferred_language'], + 'contact_id' => [ + 'name' => 'contact_id', + 'help' => ['id' => 'id-contact-id', 'file' => 'CRM/Contact/Form/Contact'], + ], + 'external_identifier' => [ + 'name' => 'external_identifier', + 'help' => ['id' => 'id-external-id', 'file' => 'CRM/Contact/Form/Contact'], + ], + 'uf_user' => [ + 'name' => 'uf_user', + 'description' => ts('Does the contact have a %1 Account?', [$userFramework]), + ], + ]); + } + /** * @param CRM_Core_Form $form diff --git a/css/searchForm.css b/css/searchForm.css index bbafc5d745af..a0f57b283a8c 100644 --- a/css/searchForm.css +++ b/css/searchForm.css @@ -62,3 +62,32 @@ color: #41477E; font-weight: bold; } + +.advanced-search-fields { + display: grid; + grid-template-columns: [col] repeat(3, calc(100% / 3 - 10px)); + width: 100%; +} + +.advanced-search-fields .search-field { + padding: 5px; +} + +.advanced-search-fields .search-field__span-2 { + grid-column: col / span 2; +} +.advanced-search-fields .search-field__span-3 { + grid-column: col / span 3; +} + +.advanced-search-fields .search-field__checkbox { + display: flex; +} + +.advanced-search-fields .search-field__checkbox input[type="checkbox"] { + order: -1; +} + +.advanced-search-fields .search-field__checkbox label { + padding-right: 5px; +} diff --git a/templates/CRM/Contact/Form/Search/Criteria/Basic.tpl b/templates/CRM/Contact/Form/Search/Criteria/Basic.tpl index ba59ec4468c9..52f34e135da8 100644 --- a/templates/CRM/Contact/Form/Search/Criteria/Basic.tpl +++ b/templates/CRM/Contact/Form/Search/Criteria/Basic.tpl @@ -23,170 +23,31 @@ | see the CiviCRM license FAQ at http://civicrm.org/licensing | +--------------------------------------------------------------------+ *} - - - - - {if $form.contact_type} - - {else} - - {/if} - - - {if $form.group} - - {else} - - {/if} - {if $form.contact_tags} - - {else} - - {/if} - {if $isTagset} - - {/if} - - {if ! $isTagset} - - {/if} - - - {if $form.all_tag_types} - - - - {/if} - - - - - - - - - - - - - - - - - - - -

- {$form.sort_name.html} -
-
- {$form.email.html} -

- {$form.contact_type.html} -
 
-
-
- {$form.group.html} -
-
- -
- {$form.group_type.html} - {literal} - - {/literal} -
-
  - {$form.contact_tags.html} -  {include file="CRM/common/Tagset.tpl"}{$form.tag_search.label} {help id="id-all-tags"}
{$form.tag_search.html}
  
- {$form.all_tag_types.html} {$form.all_tag_types.label} {help id="id-all-tag-types"} -
-
- {$form.phone_numeric.label}
{$form.phone_numeric.html} -
-
- {ts}Punctuation and spaces are ignored.{/ts} +
+ {foreach from=$basicSearchFields item=fieldSpec} + {assign var=field value=$form[$fieldSpec.name]} + {if $field} +
+ {if $fieldSpec.template} + {include file=$fieldSpec.template} + {else} + {$field.label} + {if $fieldSpec.help} + {assign var=help value=$fieldSpec.help} + {capture assign=helpFile}{if $fieldSpec.help}{$fieldSpec.help}{else}''{/if}{/capture} + {help id=$help.id file=$help.file} + {/if} +
+ {$field.html} + {if $fieldSpec.description} +
+ {$fieldSpec.description} +
+ {/if} + {/if}
-
{$form.phone_location_type_id.label}
{$form.phone_location_type_id.html}
{$form.phone_phone_type_id.label}
{$form.phone_phone_type_id.html}
- - - - - - - - -
- {$form.privacy_toggle.html} {help id="id-privacy"} -
- {$form.privacy_options.html} - -
{$form.privacy_operator.html} {help id="privacy-operator"}
-
- {literal} - - {/literal} -
- {$form.preferred_communication_method.label}
- {$form.preferred_communication_method.html}
-
- {$form.email_on_hold.html} {$form.email_on_hold.label} -
- {$form.contact_source.label} {help id="id-source" file="CRM/Contact/Form/Contact"}
- {$form.contact_source.html} -
- {$form.job_title.label}
- {$form.job_title.html} -
- {$form.preferred_language.label}
- {$form.preferred_language.html} -
- {$form.contact_id.label} {help id="id-internal-id" file="CRM/Contact/Form/Contact"}
- {$form.contact_id.html} -
- {$form.external_identifier.label} {help id="id-external-id" file="CRM/Contact/Form/Contact"}
- {$form.external_identifier.html} -
- {if $form.uf_user} - {$form.uf_user.label} {$form.uf_user.html} -
- {ts 1=$config->userFramework}Does the contact have a %1 Account?{/ts} -
- {else} -   - {/if} -
+ {elseif $fieldSpec.is_custom} + {include file=$fieldSpec.template} + {/if} + {/foreach} + diff --git a/templates/CRM/Contact/Form/Search/Criteria/Fields/group.tpl b/templates/CRM/Contact/Form/Search/Criteria/Fields/group.tpl new file mode 100644 index 000000000000..bcc83d76f622 --- /dev/null +++ b/templates/CRM/Contact/Form/Search/Criteria/Fields/group.tpl @@ -0,0 +1,49 @@ +
+ +
+ {$form.group.html} +
+
+ +
+ {$form.group_type.html} + {literal} + + {/literal} +
diff --git a/templates/CRM/Contact/Form/Search/Criteria/Fields/preferred_communication_method.tpl b/templates/CRM/Contact/Form/Search/Criteria/Fields/preferred_communication_method.tpl new file mode 100644 index 000000000000..3e94b37b2d42 --- /dev/null +++ b/templates/CRM/Contact/Form/Search/Criteria/Fields/preferred_communication_method.tpl @@ -0,0 +1,10 @@ +{$form.preferred_communication_method.label} +
+{$form.preferred_communication_method.html} +
+ +{if $form.email_on_hold} +
+ {$form.email_on_hold.html} + {$form.email_on_hold.label} +{/if} diff --git a/templates/CRM/Contact/Form/Search/Criteria/Fields/privacy_toggle.tpl b/templates/CRM/Contact/Form/Search/Criteria/Fields/privacy_toggle.tpl new file mode 100644 index 000000000000..71e3c7642bf9 --- /dev/null +++ b/templates/CRM/Contact/Form/Search/Criteria/Fields/privacy_toggle.tpl @@ -0,0 +1,28 @@ + + + + + + + + +
+ {$form.privacy_toggle.html} {help id="id-privacy"} +
+ {$form.privacy_options.html} + +
+ {$form.privacy_operator.html} {help id="privacy-operator"} +
+
+{literal} + +{/literal} diff --git a/templates/CRM/Contact/Form/Search/Criteria/Fields/tag_set.tpl b/templates/CRM/Contact/Form/Search/Criteria/Fields/tag_set.tpl new file mode 100644 index 000000000000..48d97d5abddc --- /dev/null +++ b/templates/CRM/Contact/Form/Search/Criteria/Fields/tag_set.tpl @@ -0,0 +1,5 @@ +{if $isTagset} +
+ {include file="CRM/common/Tagset.tpl"} +
+{/if}