Switch search address location to select2 widget
authorColeman Watts <coleman@civicrm.org>
Fri, 22 Aug 2014 12:43:39 +0000 (13:43 +0100)
committerColeman Watts <coleman@civicrm.org>
Fri, 22 Aug 2014 12:43:39 +0000 (13:43 +0100)
CRM/Contact/BAO/Query.php
CRM/Contact/Form/Search/Criteria.php
templates/CRM/Contact/Form/Search/Criteria/Location.hlp [new file with mode: 0644]
templates/CRM/Contact/Form/Search/Criteria/Location.tpl

index 0781e4d1e2eaf0bced01ed88eb9f3e9c78c5ee3e..5dd767f493501086597be0be44a22cfa789b5bab 100644 (file)
@@ -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];
       }
 
index d550a53311d6a8c203083f39413a6f9d09700fe7..20e8ca637e101e0007fbf9f47dbe9d1a7cdc444e 100644 (file)
@@ -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'), '&nbsp;');
+    $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 (file)
index 0000000..23b700e
--- /dev/null
@@ -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"}
+  <p>{ts}Location search uses the PRIMARY location for each contact by default.{/ts}</p>
+  <p>{ts}To search by specific location types (e.g. Home, Work...), select one or more options.{/ts}</p>
+{/htxt}
index d0409198b8770abf07d8cb0d27c96f1fa84ec770..9db8068a253a348277f5055cd525502a323bce24 100644 (file)
   <table class="form-layout">
     <tr>
       <td>
-        {$form.location_type.label}<br />
+        <div>{$form.location_type.label} {help id="location_type" title=$form.location_type.label}</div>
         {$form.location_type.html}
-        <div class="description" >
-          {ts}Location search uses the PRIMARY location for each contact by default.{/ts}<br />
-          {ts}To search by specific location types (e.g. Home, Work...), check one or more boxes above.{/ts}
-        </div>
       </td>
       <td colspan="2">
         <div id="streetAddress">