Merge pull request #3912 from eileenmcnaughton/CRM-15168
[civicrm-core.git] / CRM / Report / Form.php
index 2dbc1bd4b74019ae5dc0c35508cd1cb78c920235..00e2a540247541491056cea63459e1433f03d77f 100644 (file)
@@ -921,13 +921,12 @@ class CRM_Report_Form extends CRM_Core_Form {
               if (count($operations) <= 1) {
                 $element->freeze();
               }
-              $select = $this->addElement('select', "{$fieldName}_value", NULL,
-                        $field['options'], array(
-                          'size' => 4,
-                          'style' => 'min-width:250px',
-                        )
-              );
-              $select->setMultiple(TRUE);
+              $this->addElement('select', "{$fieldName}_value", NULL, $field['options'], array(
+                'style' => 'min-width:250px',
+                'class' => 'crm-select2',
+                'multiple' => TRUE,
+                'placeholder' => ts('- select -'),
+              ));
             }
             break;
 
@@ -967,6 +966,14 @@ class CRM_Report_Form extends CRM_Core_Form {
         }
       }
     }
+
+    $stateCountryMap[] = array(
+      'country' => 'country_id_value',
+      'state_province' => 'state_province_id_value',
+      'county' => 'county_id_value'
+    );
+    CRM_Core_BAO_Address::addStateCountryMap($stateCountryMap);
+
     $this->assign('filters', $filters);
   }
 
@@ -1100,13 +1107,13 @@ class CRM_Report_Form extends CRM_Core_Form {
 
     if (CRM_Core_Permission::check('administer Reports') && $this->_add2groupSupported) {
       $this->addElement('select', 'groups', ts('Group'),
-        array('' => ts('- select group -')) + CRM_Core_PseudoConstant::staticGroup()
+        array('' => ts('Add Contacts to Group')) + CRM_Core_PseudoConstant::nestedGroup(),
+        array('class' => 'crm-select2 crm-action-menu action-icon-plus huge')
       );
       $this->assign('group', TRUE);
     }
 
-    $label = ts('Add These Contacts to Group');
-    $this->addElement('submit', $this->_groupButtonName, $label, array('onclick' => 'return checkGroup();'));
+    $this->addElement('submit', $this->_groupButtonName, '', array('style' => 'display: none;'));
 
     $this->addChartOptions();
     $this->addButtons(array(
@@ -1275,7 +1282,7 @@ class CRM_Report_Form extends CRM_Core_Form {
         'title' => ts('Group'),
         'operatorType' => CRM_Report_Form::OP_MULTISELECT,
         'group' => TRUE,
-        'options' => CRM_Core_PseudoConstant::group(),
+        'options' => CRM_Core_PseudoConstant::nestedGroup(),
       ),
     );
     if (empty($this->_columns['civicrm_group']['dao'])) {
@@ -2992,37 +2999,37 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND
     if (!is_array($value)) {
       $value = array($value);
     }
-    
+
     $tmp_membership_org_sql_list = implode(', ', $value);
     return " {$this->_aliases['civicrm_contact']}.id {$sqlOp} (
                           SELECT DISTINCT mem.contact_id
-                          FROM civicrm_membership mem 
+                          FROM civicrm_membership mem
                           LEFT JOIN civicrm_membership_status mem_status ON mem.status_id = mem_status.id
-                          LEFT JOIN civicrm_membership_type mt ON mem.membership_type_id = mt.id 
+                          LEFT JOIN civicrm_membership_type mt ON mem.membership_type_id = mt.id
                           WHERE mt.member_of_contact_id IN (".$tmp_membership_org_sql_list.")
                           AND mt.is_active = '1'
                           AND mem_status.is_current_member = '1'
                           AND mem_status.is_active = '1' )  ";
-    }    
+    }
 
   function whereMembershipTypeClause($field, $value, $op) {
     $sqlOp = $this->getSQLOperator($op);
     if (!is_array($value)) {
       $value = array($value);
     }
-      
+
     $tmp_membership_sql_list  = implode(', ', $value);
     return " {$this->_aliases['civicrm_contact']}.id {$sqlOp} (
                           SELECT DISTINCT mem.contact_id
-                          FROM civicrm_membership mem 
-                          LEFT JOIN civicrm_membership_status mem_status ON mem.status_id = mem_status.id 
-                          LEFT JOIN civicrm_membership_type mt ON mem.membership_type_id = mt.id 
+                          FROM civicrm_membership mem
+                          LEFT JOIN civicrm_membership_status mem_status ON mem.status_id = mem_status.id
+                          LEFT JOIN civicrm_membership_type mt ON mem.membership_type_id = mt.id
                           WHERE mem.membership_type_id IN (".$tmp_membership_sql_list.")
                           AND mt.is_active = '1'
                           AND mem_status.is_current_member = '1'
                           AND mem_status.is_active = '1' ) ";
   }
-    
+
   /**
    * @param string $tableAlias
    */
@@ -3476,18 +3483,18 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a
           array('title' => ts('Postal Code Suffix'),
             'default' => CRM_Utils_Array::value('postal_code_suffix', $defaults, FALSE),
           ),
-          'county_id' =>
-          array('title' => ts('County'),
-            'default' => CRM_Utils_Array::value('county_id', $defaults, FALSE),
-          ),
+          'country_id' =>
+            array('title' => ts('Country'),
+              'default' => CRM_Utils_Array::value('country_id', $defaults, FALSE),
+            ),
           'state_province_id' =>
           array('title' => ts('State/Province'),
             'default' => CRM_Utils_Array::value('state_province_id', $defaults, FALSE),
           ),
-          'country_id' =>
-          array('title' => ts('Country'),
-            'default' => CRM_Utils_Array::value('country_id', $defaults, FALSE),
-          ),
+          'county_id' =>
+            array('title' => ts('County'),
+              'default' => CRM_Utils_Array::value('county_id', $defaults, FALSE),
+            ),
         ),
         'grouping' => 'location-fields',
       ),
@@ -3511,32 +3518,32 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a
                 'operator' => 'like',
                 'name' => 'city',
         ),
-        'county_id' => array(
-          'name' => 'county_id',
-          'title' => ts('County'),
+        'country_id' => array(
+          'name' => 'country_id',
+          'title' => ts('Country'),
           'type' => CRM_Utils_Type::T_INT,
           'operatorType' =>
-          CRM_Report_Form::OP_MULTISELECT,
+            CRM_Report_Form::OP_MULTISELECT,
           'options' =>
-          CRM_Core_PseudoConstant::county(),
+            CRM_Core_PseudoConstant::country(),
         ),
         'state_province_id' => array(
           'name' => 'state_province_id',
           'title' => ts('State/Province'),
           'type' => CRM_Utils_Type::T_INT,
           'operatorType' =>
-          CRM_Report_Form::OP_MULTISELECT,
+            CRM_Report_Form::OP_MULTISELECT,
           'options' =>
-          CRM_Core_PseudoConstant::stateProvince(),
+            CRM_Core_PseudoConstant::stateProvince(),
         ),
-        'country_id' => array(
-          'name' => 'country_id',
-          'title' => ts('Country'),
+        'county_id' => array(
+          'name' => 'county_id',
+          'title' => ts('County'),
           'type' => CRM_Utils_Type::T_INT,
           'operatorType' =>
           CRM_Report_Form::OP_MULTISELECT,
           'options' =>
-          CRM_Core_PseudoConstant::country(),
+          CRM_Core_PseudoConstant::county(),
         ),
       );
     }