From: Coleman Watts Date: Fri, 22 Aug 2014 12:43:39 +0000 (+0100) Subject: Switch search address location to select2 widget X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=d8a8bb0b826fce67ce623f85cd5fc447f6be1a51;p=civicrm-core.git Switch search address location to select2 widget --- diff --git a/CRM/Contact/BAO/Query.php b/CRM/Contact/BAO/Query.php index 0781e4d1e2..5dd767f493 100644 --- a/CRM/Contact/BAO/Query.php +++ b/CRM/Contact/BAO/Query.php @@ -3562,13 +3562,13 @@ WHERE id IN ( $groupIDs ) list($name, $op, $value, $grouping, $wildcard) = $values; if (is_array($value)) { - $this->_where[$grouping][] = 'civicrm_address.location_type_id IN (' . implode(',', array_keys($value)) . ')'; + $this->_where[$grouping][] = 'civicrm_address.location_type_id IN (' . implode(',', $value) . ')'; $this->_tables['civicrm_address'] = 1; $this->_whereTables['civicrm_address'] = 1; $locationType = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id'); $names = array(); - foreach (array_keys($value) as $id) { + foreach ($value as $id) { $names[] = $locationType[$id]; } diff --git a/CRM/Contact/Form/Search/Criteria.php b/CRM/Contact/Form/Search/Criteria.php index d550a53311..20e8ca637e 100644 --- a/CRM/Contact/Form/Search/Criteria.php +++ b/CRM/Contact/Form/Search/Criteria.php @@ -387,13 +387,13 @@ class CRM_Contact_Form_Search_Criteria { $worldRegions = array('' => '') + CRM_Core_PseudoConstant::worldRegion(); $form->addSelect('world_region', array('entity' => 'address', 'placeholder' => ts('- any -'), 'option_url' => NULL)); - // checkboxes for location type - $location_type = array(); + // select for location type $locationType = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id'); - foreach ($locationType as $locationTypeID => $locationTypeName) { - $location_type[] = $form->createElement('checkbox', $locationTypeID, NULL, $locationTypeName); - } - $form->addGroup($location_type, 'location_type', ts('Location Types'), ' '); + $form->add('select', 'location_type', ts('Address Location'), $locationType, FALSE, array( + 'multiple' => TRUE, + 'class' => 'crm-select2', + 'placeholder' => ts('Primary'), + )); // custom data extending addresses - $extends = array('Address'); diff --git a/templates/CRM/Contact/Form/Search/Criteria/Location.hlp b/templates/CRM/Contact/Form/Search/Criteria/Location.hlp new file mode 100644 index 0000000000..23b700ef48 --- /dev/null +++ b/templates/CRM/Contact/Form/Search/Criteria/Location.hlp @@ -0,0 +1,30 @@ +{* + +--------------------------------------------------------------------+ + | CiviCRM version 4.5 | + +--------------------------------------------------------------------+ + | Copyright CiviCRM LLC (c) 2004-2014 | + +--------------------------------------------------------------------+ + | This file is a part of CiviCRM. | + | | + | CiviCRM is free software; you can copy, modify, and distribute it | + | under the terms of the GNU Affero General Public License | + | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | + | | + | CiviCRM is distributed in the hope that it will be useful, but | + | WITHOUT ANY WARRANTY; without even the implied warranty of | + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | + | See the GNU Affero General Public License for more details. | + | | + | You should have received a copy of the GNU Affero General Public | + | License and the CiviCRM Licensing Exception along | + | with this program; if not, contact CiviCRM LLC | + | at info[AT]civicrm[DOT]org. If you have questions about the | + | GNU Affero General Public License or the licensing of CiviCRM, | + | see the CiviCRM license FAQ at http://civicrm.org/licensing | + +--------------------------------------------------------------------+ +*} + +{htxt id="location_type"} +

{ts}Location search uses the PRIMARY location for each contact by default.{/ts}

+

{ts}To search by specific location types (e.g. Home, Work...), select one or more options.{/ts}

+{/htxt} diff --git a/templates/CRM/Contact/Form/Search/Criteria/Location.tpl b/templates/CRM/Contact/Form/Search/Criteria/Location.tpl index d0409198b8..9db8068a25 100644 --- a/templates/CRM/Contact/Form/Search/Criteria/Location.tpl +++ b/templates/CRM/Contact/Form/Search/Criteria/Location.tpl @@ -27,12 +27,8 @@
- {$form.location_type.label}
+
{$form.location_type.label} {help id="location_type" title=$form.location_type.label}
{$form.location_type.html} -
- {ts}Location search uses the PRIMARY location for each contact by default.{/ts}
- {ts}To search by specific location types (e.g. Home, Work...), check one or more boxes above.{/ts} -