From: jitendrapurohit Date: Thu, 23 Jun 2016 13:23:23 +0000 (+0530) Subject: CRM-18988 - multi custom data: after sorting, unable to edit X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=1c66bdc705b496d80c8294fcfcb21d13f182cc5e;p=civicrm-core.git CRM-18988 - multi custom data: after sorting, unable to edit --- diff --git a/CRM/Core/BAO/CustomValueTable.php b/CRM/Core/BAO/CustomValueTable.php index e71e106fff..4c4c4a0363 100644 --- a/CRM/Core/BAO/CustomValueTable.php +++ b/CRM/Core/BAO/CustomValueTable.php @@ -468,8 +468,17 @@ AND $cond $file[$dao->table_name][$dao->fieldID] = $dao->fieldDataType; } - $result = array(); + $result = $sortedResult = array(); foreach ($select as $tableName => $clauses) { + if (!empty($DTparams['sort'])) { + $query = CRM_Core_DAO::executeQuery("SELECT id FROM {$tableName} WHERE entity_id = {$entityID}"); + $count = 1; + while ($query->fetch()) { + $sortedResult["{$query->id}"] = $count; + $count++; + } + } + $query = "SELECT SQL_CALC_FOUND_ROWS id, " . implode(', ', $clauses) . " FROM $tableName WHERE entity_id = $entityID {$orderBy} {$limit}"; $dao = CRM_Core_DAO::executeQuery($query); if (!empty($DTparams)) { @@ -492,6 +501,9 @@ AND $cond } } } + if (!empty($DTparams)) { + return array($result, $sortedResult); + } return $result; } diff --git a/CRM/Profile/Page/MultipleRecordFieldsListing.php b/CRM/Profile/Page/MultipleRecordFieldsListing.php index 88410a1d2f..f2db4ba0eb 100644 --- a/CRM/Profile/Page/MultipleRecordFieldsListing.php +++ b/CRM/Profile/Page/MultipleRecordFieldsListing.php @@ -262,7 +262,7 @@ class CRM_Profile_Page_MultipleRecordFieldsListing extends CRM_Core_Page_Basic { $DTparams = !empty($this->_DTparams) ? $this->_DTparams : NULL; // commonly used for both views i.e profile listing view (profileDataView) and custom data listing view (customDataView) - $result = CRM_Core_BAO_CustomValueTable::getEntityValues($this->_contactId, NULL, $fieldIDs, TRUE, $DTparams); + list($result, $sortedResult) = CRM_Core_BAO_CustomValueTable::getEntityValues($this->_contactId, NULL, $fieldIDs, TRUE, $DTparams); $resultCount = !empty($result['count']) ? $result['count'] : count($result); unset($result['count']); @@ -389,7 +389,7 @@ class CRM_Profile_Page_MultipleRecordFieldsListing extends CRM_Core_Page_Basic { $actionParams['cid'] = $actionParams['entityID'] = $this->_contactId; $actionParams['recId'] = $recId; $actionParams['type'] = $this->_contactType; - $actionParams['cgcount'] = empty($DTparams['sort']) ? $cgcount : $recId; + $actionParams['cgcount'] = empty($DTparams['sort']) ? $cgcount : $sortedResult[$recId]; $actionParams['newCgCount'] = $newCgCount; // DELETE action links