From 0573fd28c8beb9c5137b72e3179f5df2c81b4bc6 Mon Sep 17 00:00:00 2001 From: eileen Date: Thu, 4 Jan 2018 10:01:46 +1300 Subject: [PATCH] CRM-21634 Stdise search fields as they relate to contacts --- CRM/Contribute/Form/Search.php | 50 ++++++++++++------- CRM/Core/Form/Search.php | 35 +++++++++++++ CRM/Event/Form/Search.php | 38 +++++++++++--- CRM/Member/Form/Search.php | 32 +++++++++++- CRM/Pledge/Form/Search.php | 32 +++++++++++- .../Form/Search/ContactSearchFields.tpl | 31 ++++++++++++ templates/CRM/Contribute/Form/Search.tpl | 24 +-------- templates/CRM/Event/Form/Search.tpl | 13 +---- templates/CRM/Member/Form/Search.tpl | 7 +-- templates/CRM/Pledge/Form/Search.tpl | 6 +-- 10 files changed, 195 insertions(+), 73 deletions(-) create mode 100644 templates/CRM/Contact/Form/Search/ContactSearchFields.tpl diff --git a/CRM/Contribute/Form/Search.php b/CRM/Contribute/Form/Search.php index b0174523f6..3eecbe8f5b 100644 --- a/CRM/Contribute/Form/Search.php +++ b/CRM/Contribute/Form/Search.php @@ -166,25 +166,7 @@ class CRM_Contribute_Form_Search extends CRM_Core_Form_Search { */ public function buildQuickForm() { parent::buildQuickForm(); - $this->addSortNameField(); - - $this->_group = CRM_Core_PseudoConstant::nestedGroup(); - - // multiselect for groups - if ($this->_group) { - $this->add('select', 'group', ts('Groups'), $this->_group, FALSE, - array('id' => 'group', 'multiple' => 'multiple', 'class' => 'crm-select2') - ); - } - - // multiselect for tags - $contactTags = CRM_Core_BAO_Tag::getTags(); - - if ($contactTags) { - $this->add('select', 'contact_tags', ts('Tags'), $contactTags, FALSE, - array('id' => 'contact_tags', 'multiple' => 'multiple', 'class' => 'crm-select2') - ); - } + $this->addContactSearchFields(); CRM_Contribute_BAO_Query::buildSearchForm($this); @@ -229,6 +211,36 @@ class CRM_Contribute_Form_Search extends CRM_Core_Form_Search { return ts('Contributor Name'); } + /** + * Get the label for the tag field. + * + * We do this in a function so the 'ts' wraps the whole string to allow + * better translation. + * + * @return string + */ + protected function getTagLabel() { + return ts('Contributor Tag(s)'); + } + + /** + * Get the label for the group field. + * + * @return string + */ + protected function getGroupLabel() { + return ts('Contributor Group(s)'); + } + + /** + * Get the label for the group field. + * + * @return string + */ + protected function getContactTypeLabel() { + return ts('Contributor Contact Type'); + } + /** * The post processing of the form gets done here. * diff --git a/CRM/Core/Form/Search.php b/CRM/Core/Form/Search.php index ec2ef4844c..dabab8620f 100644 --- a/CRM/Core/Form/Search.php +++ b/CRM/Core/Form/Search.php @@ -199,4 +199,39 @@ class CRM_Core_Form_Search extends CRM_Core_Form { return 'search'; } + /** + * Add generic fields that specify the contact. + */ + protected function addContactSearchFields() { + $this->addSortNameField(); + + $this->_group = CRM_Core_PseudoConstant::nestedGroup(); + if ($this->_group) { + $this->add('select', 'group', $this->getGroupLabel(), $this->_group, FALSE, + array( + 'id' => 'group', + 'multiple' => 'multiple', + 'class' => 'crm-select2', + ) + ); + } + + $contactTags = CRM_Core_BAO_Tag::getTags(); + if ($contactTags) { + $this->add('select', 'contact_tags', $this->getTagLabel(), $contactTags, FALSE, + array( + 'id' => 'contact_tags', + 'multiple' => 'multiple', + 'class' => 'crm-select2', + ) + ); + } + $this->addField('contact_type', array('entity' => 'Contact')); + + if (CRM_Core_Permission::check('access deleted contacts') && Civi::settings()->get('contact_undelete')) { + $this->addElement('checkbox', 'deleted_contacts', ts('Search in Trash') . '
' . ts('(deleted contacts)')); + } + + } + } diff --git a/CRM/Event/Form/Search.php b/CRM/Event/Form/Search.php index 4552103135..5f5783d575 100644 --- a/CRM/Event/Form/Search.php +++ b/CRM/Event/Form/Search.php @@ -29,8 +29,6 @@ * * @package CRM * @copyright CiviCRM LLC (c) 2004-2017 - * $Id$ - * */ /** @@ -168,11 +166,7 @@ class CRM_Event_Form_Search extends CRM_Core_Form_Search { */ public function buildQuickForm() { parent::buildQuickForm(); - $this->addSortNameField(); - - if (CRM_Core_Permission::check('access deleted contacts') and Civi::settings()->get('contact_undelete')) { - $this->addElement('checkbox', 'deleted_contacts', ts('Search in Trash') . '
' . ts('(deleted contacts)')); - } + $this->addContactSearchFields(); CRM_Event_BAO_Query::buildSearchForm($this); @@ -272,6 +266,36 @@ class CRM_Event_Form_Search extends CRM_Core_Form_Search { return ts('Participant Name'); } + /** + * Get the label for the tag field. + * + * We do this in a function so the 'ts' wraps the whole string to allow + * better translation. + * + * @return string + */ + protected function getTagLabel() { + return ts('Participant Tag(s)'); + } + + /** + * Get the label for the group field. + * + * @return string + */ + protected function getGroupLabel() { + return ts('Participant Group(s)'); + } + + /** + * Get the label for the group field. + * + * @return string + */ + protected function getContactTypeLabel() { + return ts('Participant Contact Type'); + } + /** * The post processing of the form gets done here. * diff --git a/CRM/Member/Form/Search.php b/CRM/Member/Form/Search.php index e21293931a..0890a4bcce 100644 --- a/CRM/Member/Form/Search.php +++ b/CRM/Member/Form/Search.php @@ -153,7 +153,7 @@ class CRM_Member_Form_Search extends CRM_Core_Form_Search { */ public function buildQuickForm() { parent::buildQuickForm(); - $this->addSortNameField(); + $this->addContactSearchFields(); CRM_Member_BAO_Query::buildSearchForm($this); @@ -192,6 +192,36 @@ class CRM_Member_Form_Search extends CRM_Core_Form_Search { return ts('Member Name'); } + /** + * Get the label for the tag field. + * + * We do this in a function so the 'ts' wraps the whole string to allow + * better translation. + * + * @return string + */ + protected function getTagLabel() { + return ts('Member Tag(s)'); + } + + /** + * Get the label for the group field. + * + * @return string + */ + protected function getGroupLabel() { + return ts('Member Group(s)'); + } + + /** + * Get the label for the group field. + * + * @return string + */ + protected function getContactTypeLabel() { + return ts('Member Contact Type'); + } + /** * The post processing of the form gets done here. * diff --git a/CRM/Pledge/Form/Search.php b/CRM/Pledge/Form/Search.php index e0e23cfa06..6859f79545 100644 --- a/CRM/Pledge/Form/Search.php +++ b/CRM/Pledge/Form/Search.php @@ -145,7 +145,7 @@ class CRM_Pledge_Form_Search extends CRM_Core_Form_Search { */ public function buildQuickForm() { parent::buildQuickForm(); - $this->addSortNameField(); + $this->addContactSearchFields(); CRM_Pledge_BAO_Query::buildSearchForm($this); @@ -184,6 +184,36 @@ class CRM_Pledge_Form_Search extends CRM_Core_Form_Search { return ts('Pledger Name'); } + /** + * Get the label for the tag field. + * + * We do this in a function so the 'ts' wraps the whole string to allow + * better translation. + * + * @return string + */ + protected function getTagLabel() { + return ts('Pledger Tag(s)'); + } + + /** + * Get the label for the group field. + * + * @return string + */ + protected function getGroupLabel() { + return ts('Pledger Group(s)'); + } + + /** + * Get the label for the group field. + * + * @return string + */ + protected function getContactTypeLabel() { + return ts('Pledger Contact Type'); + } + /** * The post processing of the form gets done here. * diff --git a/templates/CRM/Contact/Form/Search/ContactSearchFields.tpl b/templates/CRM/Contact/Form/Search/ContactSearchFields.tpl new file mode 100644 index 0000000000..53aef6858c --- /dev/null +++ b/templates/CRM/Contact/Form/Search/ContactSearchFields.tpl @@ -0,0 +1,31 @@ + + + {$form.sort_name.label}  {$form.sort_name.html|crmAddClass:'twenty'} + + {$form.buttons.html} + + + {if $form.contact_tags} + + {$form.contact_tags.html} + + {else} +   + {/if} + + {if $form.group} + + {$form.group.html} + + {else} +   + {/if} + + + {$form.contact_type.label}  {$form.contact_type.html}
+ + {if $form.deleted_contacts} + {$form.deleted_contacts.html}  {$form.deleted_contacts.label} + {/if} + + diff --git a/templates/CRM/Contribute/Form/Search.tpl b/templates/CRM/Contribute/Form/Search.tpl index bf8c8e88c3..aa54b7f8a0 100644 --- a/templates/CRM/Contribute/Form/Search.tpl +++ b/templates/CRM/Contribute/Form/Search.tpl @@ -34,28 +34,8 @@
{strip} - - - - - {if $form.contact_tags} - - {else} - - {/if} - - {if $form.group} - - {else} - - {/if} - -{include file="CRM/Contribute/Form/Search/Common.tpl"} + {include file="CRM/Contact/Form/Search/ContactSearchFields.tpl"} + {include file="CRM/Contribute/Form/Search/Common.tpl"} diff --git a/templates/CRM/Event/Form/Search.tpl b/templates/CRM/Event/Form/Search.tpl index 5921830790..624702e39d 100644 --- a/templates/CRM/Event/Form/Search.tpl +++ b/templates/CRM/Event/Form/Search.tpl @@ -35,18 +35,7 @@
{strip}
{$form.sort_name.label}  {$form.sort_name.html|crmAddClass:'twenty'}   {$form.buttons.html} -
- {$form.contact_tags.html} -   - {$form.group.html} -  
{$form.buttons.html}
- - - - {if $form.deleted_contacts} - - - - {/if} + {include file="CRM/Contact/Form/Search/ContactSearchFields.tpl"} {include file="CRM/Event/Form/Search/Common.tpl"} diff --git a/templates/CRM/Member/Form/Search.tpl b/templates/CRM/Member/Form/Search.tpl index 64e805639a..705df016aa 100644 --- a/templates/CRM/Member/Form/Search.tpl +++ b/templates/CRM/Member/Form/Search.tpl @@ -31,12 +31,7 @@
{strip}
- {$form.sort_name.label}  {$form.sort_name.html|crmAddClass:'twenty'}   {$form.buttons.html} -
- {$form.deleted_contacts.html}  {$form.deleted_contacts.label} -
- - - - + {include file="CRM/Contact/Form/Search/ContactSearchFields.tpl"} {include file="CRM/Member/Form/Search/Common.tpl"} diff --git a/templates/CRM/Pledge/Form/Search.tpl b/templates/CRM/Pledge/Form/Search.tpl index dfe749e502..d5f205f1ce 100644 --- a/templates/CRM/Pledge/Form/Search.tpl +++ b/templates/CRM/Pledge/Form/Search.tpl @@ -34,11 +34,7 @@
{strip}
- {$form.sort_name.label}  {$form.sort_name.html|crmAddClass:'twenty'}   {$form.buttons.html} -
- - - + {include file="CRM/Contact/Form/Search/ContactSearchFields.tpl"} {include file="CRM/Pledge/Form/Search/Common.tpl"} -- 2.25.1
- {$form.sort_name.label}  {$form.sort_name.html|crmAddClass:'twenty'}   {$form.buttons.html} -