$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)) {
}
}
}
+ if (!empty($DTparams)) {
+ return array($result, $sortedResult);
+ }
return $result;
}
$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']);
$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