From: atif-shaikh Date: Thu, 16 Oct 2014 14:05:35 +0000 (+0530) Subject: CRM-15301 - Sorted order is not respected in 'Export Contacts' csv X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=33a5a53deec0337010b627851944b5f5f57e18ef;p=civicrm-core.git CRM-15301 - Sorted order is not respected in 'Export Contacts' csv https://issues.civicrm.org/jira/browse/CRM-15301 --- diff --git a/CRM/Activity/Selector/Search.php b/CRM/Activity/Selector/Search.php index 0bd140e84d..7b69027c09 100644 --- a/CRM/Activity/Selector/Search.php +++ b/CRM/Activity/Selector/Search.php @@ -396,7 +396,7 @@ class CRM_Activity_Selector_Search extends CRM_Core_Selector_Base implements CRM ), array( 'name' => ts('Status'), - 'sort' => 'status_id', + 'sort' => 'activity_status', 'direction' => CRM_Utils_Sort::DONTCARE, ), array( diff --git a/CRM/Case/Selector/Search.php b/CRM/Case/Selector/Search.php index 72b8c74453..cc97a36e66 100644 --- a/CRM/Case/Selector/Search.php +++ b/CRM/Case/Selector/Search.php @@ -449,7 +449,7 @@ class CRM_Case_Selector_Search extends CRM_Core_Selector_Base { ), array( 'name' => ts('Case Type'), - 'sort' => 'case_type_id', + 'sort' => 'case_type', 'direction' => CRM_Utils_Sort::DONTCARE, ), array( diff --git a/CRM/Contact/Form/Search.php b/CRM/Contact/Form/Search.php index 2f422efb05..f9d1d17178 100644 --- a/CRM/Contact/Form/Search.php +++ b/CRM/Contact/Form/Search.php @@ -461,7 +461,7 @@ class CRM_Contact_Form_Search extends CRM_Core_Form_Search { $selectedContactIds = array(); $qfKeyParam = CRM_Utils_Array::value('qfKey', $this->_formValues); // We use ajax to handle selections only if the search results component_mode is set to "contacts" - if ($qfKeyParam && $this->get('component_mode') <= 1) { + if ($qfKeyParam && ($this->get('component_mode') <= 1 || $this->get('component_mode') == 7)) { $this->addClass('crm-ajax-selection-form'); $qfKeyParam = "civicrm search {$qfKeyParam}"; $selectedContactIdsArr = CRM_Core_BAO_PrevNextCache::getSelection($qfKeyParam); diff --git a/CRM/Contribute/Selector/Search.php b/CRM/Contribute/Selector/Search.php index 7166d025e4..6c96eba78e 100644 --- a/CRM/Contribute/Selector/Search.php +++ b/CRM/Contribute/Selector/Search.php @@ -477,7 +477,7 @@ class CRM_Contribute_Selector_Search extends CRM_Core_Selector_Base implements C array( array( 'name' => ts('Type'), - 'sort' => 'financial_type_id', + 'sort' => 'financial_type', 'direction' => CRM_Utils_Sort::DONTCARE, ), array( @@ -497,7 +497,7 @@ class CRM_Contribute_Selector_Search extends CRM_Core_Selector_Base implements C ), array( 'name' => ts('Status'), - 'sort' => 'contribution_status_id', + 'sort' => 'contribution_status', 'direction' => CRM_Utils_Sort::DONTCARE, ), array( diff --git a/CRM/Event/Selector/Search.php b/CRM/Event/Selector/Search.php index c81664a558..c3709486e7 100644 --- a/CRM/Event/Selector/Search.php +++ b/CRM/Event/Selector/Search.php @@ -464,12 +464,12 @@ class CRM_Event_Selector_Search extends CRM_Core_Selector_Base implements CRM_Co ), array( 'name' => ts('Fee Level'), - 'sort' => 'fee_level', + 'sort' => 'participant_fee_level', 'direction' => CRM_Utils_Sort::DONTCARE, ), array( 'name' => ts('Amount'), - 'sort' => 'fee_amount', + 'sort' => 'participant_fee_amount', 'direction' => CRM_Utils_Sort::DONTCARE, ), array( diff --git a/CRM/Export/BAO/Export.php b/CRM/Export/BAO/Export.php index 0ceeb076a6..1da2248ba1 100644 --- a/CRM/Export/BAO/Export.php +++ b/CRM/Export/BAO/Export.php @@ -400,6 +400,9 @@ INSERT INTO {$componentTable} SELECT distinct gc.contact_id FROM civicrm_group_c FALSE, TRUE, TRUE, NULL, $queryOperator ); + //sort by state + //CRM-15301 + $query->_sort = $order; list($select, $from, $where, $having) = $query->query(); if ($mergeSameHousehold == 1) { @@ -590,11 +593,20 @@ INSERT INTO {$componentTable} SELECT distinct gc.contact_id FROM civicrm_group_c $groupBy = " GROUP BY civicrm_activity.id "; } $queryString .= $groupBy; + + // always add contact_a.id to the ORDER clause + // so the order is deterministic + //CRM-15301 + if (strpos('contact_a.id', $order) === FALSE) { + $order .= ", contact_a.id"; + } + if ($order) { list($field, $dir) = explode(' ', $order, 2); $field = trim($field); if (!empty($returnProperties[$field])) { - // $queryString .= " ORDER BY $order"; + //CRM-15301 + $queryString .= " ORDER BY $order"; } } diff --git a/CRM/Member/Selector/Search.php b/CRM/Member/Selector/Search.php index 813a6fe5e0..9e21b4cb4d 100644 --- a/CRM/Member/Selector/Search.php +++ b/CRM/Member/Selector/Search.php @@ -477,7 +477,7 @@ class CRM_Member_Selector_Search extends CRM_Core_Selector_Base implements CRM_C self::$_columnHeaders = array( array( 'name' => ts('Type'), - 'sort' => 'membership_type_id', + 'sort' => 'membership_type', 'direction' => CRM_Utils_Sort::DONTCARE, ), array('name' => ts('Member Since'), @@ -501,7 +501,7 @@ class CRM_Member_Selector_Search extends CRM_Core_Selector_Base implements CRM_C ), array( 'name' => ts('Status'), - 'sort' => 'status_id', + 'sort' => 'membership_status', 'direction' => CRM_Utils_Sort::DONTCARE, ), array(