Merged in develop (pull request #5799)

Update branch

Approved-by: Paula Quispe <paula.quispe@processmaker.com>
This commit is contained in:
Paula Quispe
2017-07-18 13:07:46 +00:00
7 changed files with 158 additions and 59 deletions

View File

@@ -3329,4 +3329,42 @@ class Cases
);
}
}
/**
* This function get the table.column by order by the result
* We can include the additional table related to the custom cases list
*
* @param string $listPeer, name of the list class
* @param string $field, name of the fieldName
* @param string $sort, name of column by sort
* @param string $defaultSort, name of column by sort default
* @param string $additionalClassName, name of the className of pmTable
* @param array $additionalColumns, columns related to the custom cases list with the format TABLE_NAME.COLUMN_NAME
* @return string $tableName
*/
public function getSortColumn($listPeer, $field, $sort, $defaultSort, $additionalClassName = '', $additionalColumns = array())
{
$columnSort = $defaultSort;
$tableName = '';
//We will check if the column by sort is a LIST table
$columnsList = $listPeer::getFieldNames($field);
if (in_array($sort, $columnsList)) {
$columnSort = $listPeer::TABLE_NAME . '.' . $sort;
} else {
//We will sort by CUSTOM CASE LIST table
if (count($additionalColumns) > 0) {
require_once(PATH_DATA_SITE . 'classes' . PATH_SEP . $additionalClassName . '.php');
$aTable = explode('.', current($additionalColumns));
if (count($aTable) > 0) {
$tableName = $aTable[0];
}
}
if (in_array($tableName . '.' . $sort, $additionalColumns)) {
$columnSort = $tableName . '.' . $sort;
}
}
return $columnSort;
}
}