Merge pull request #3813 from NileemaJadhav/CRM-master
[civicrm-core.git] / CRM / Contact / Form / Search / Custom / Group.php
index f4f4aed558e32ead6deda58c46e2b7d3e0ef97b2..ae65bd301530d7c28a9f118354a63fab85d4942a 100644 (file)
@@ -51,7 +51,7 @@ class CRM_Contact_Form_Search_Custom_Group
   function __construct(&$formValues) {
     $this->_formValues = $formValues;
     $this->_columns = array(
-      ts('Contact Id') => 'contact_id',
+      ts('Contact ID') => 'contact_id',
       ts('Contact Type') => 'contact_type',
       ts('Name') => 'sort_name',
       ts('Group Name') => 'gname',
@@ -91,13 +91,13 @@ class CRM_Contact_Form_Search_Custom_Group
   }
 
   /**
-   * @param $form
+   * @param CRM_Core_Form $form
    */
   function buildForm(&$form) {
 
     $this->setTitle(ts('Include / Exclude Search'));
 
-    $groups = CRM_Core_PseudoConstant::group();
+    $groups = CRM_Core_PseudoConstant::nestedGroup();
 
     $tags = CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE));
     if (count($groups) == 0 || count($tags) == 0) {
@@ -106,22 +106,25 @@ class CRM_Contact_Form_Search_Custom_Group
       CRM_Utils_System::redirect($url);
     }
 
-    $inG = &$form->addElement('advmultiselect', 'includeGroups',
-      ts('Include Group(s)') . ' ', $groups,
-      array(
-        'size' => 5,
-        'style' => 'width:240px',
-        'class' => 'advmultiselect',
-      )
+    $select2style = array(
+      'multiple' => TRUE,
+      'style' => 'width: 100%; max-width: 60em;',
+      'class' => 'crm-select2',
+      'placeholder' => ts('- select -'),
     );
 
-    $outG = &$form->addElement('advmultiselect', 'excludeGroups',
-      ts('Exclude Group(s)') . ' ', $groups,
-      array(
-        'size' => 5,
-        'style' => 'width:240px',
-        'class' => 'advmultiselect',
-      )
+    $form->add('select', 'includeGroups',
+      ts('Include Group(s)'),
+      $groups,
+      FALSE,
+      $select2style
+    );
+
+    $form->add('select', 'excludeGroups',
+      ts('Exclude Group(s)'),
+      $groups,
+      FALSE,
+      $select2style
     );
 
     $andOr = array(
@@ -130,36 +133,20 @@ class CRM_Contact_Form_Search_Custom_Group
     );
     $form->addRadio('andOr', ts('AND/OR'), $andOr, NULL, '<br />', TRUE);
 
-    $int = &$form->addElement('advmultiselect', 'includeTags',
-      ts('Include Tag(s)') . ' ', $tags,
-      array(
-        'size' => 5,
-        'style' => 'width:240px',
-        'class' => 'advmultiselect',
-      )
+    $form->add('select', 'includeTags',
+      ts('Include Tag(s)'),
+      $tags,
+      FALSE,
+      $select2style
     );
 
-    $outt = &$form->addElement('advmultiselect', 'excludeTags',
-      ts('Exclude Tag(s)') . ' ', $tags,
-      array(
-        'size' => 5,
-        'style' => 'width:240px',
-        'class' => 'advmultiselect',
-      )
+    $form->add('select', 'excludeTags',
+      ts('Exclude Tag(s)'),
+      $tags,
+      FALSE,
+      $select2style
     );
 
-    //add/remove buttons for groups
-    $inG->setButtonAttributes('add', array('value' => ts('Add >>')));;
-    $outG->setButtonAttributes('add', array('value' => ts('Add >>')));;
-    $inG->setButtonAttributes('remove', array('value' => ts('<< Remove')));;
-    $outG->setButtonAttributes('remove', array('value' => ts('<< Remove')));;
-
-    //add/remove buttons for tags
-    $int->setButtonAttributes('add', array('value' => ts('Add >>')));;
-    $outt->setButtonAttributes('add', array('value' => ts('Add >>')));;
-    $int->setButtonAttributes('remove', array('value' => ts('<< Remove')));;
-    $outt->setButtonAttributes('remove', array('value' => ts('<< Remove')));;
-
     /**
      * if you are using the standard template, this array tells the template what elements
      * are part of the search criteria
@@ -181,6 +168,9 @@ class CRM_Contact_Form_Search_Custom_Group
 
       $defaults['includeGroups'] = CRM_Utils_Array::value('includeGroups', $this->_formValues);
       $defaults['excludeGroups'] = CRM_Utils_Array::value('excludeGroups', $this->_formValues);
+
+      $defaults['includeTags'] = CRM_Utils_Array::value('includeTags', $this->_formValues);
+      $defaults['excludeTags'] = CRM_Utils_Array::value('excludeTags', $this->_formValues);
     }
 
     return $defaults;