mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-03-12 00:45:34 +00:00
add sorting by name,date for documents in search()
This commit is contained in:
parent
3e4d90fe91
commit
b8bc69bb11
|
@ -1307,6 +1307,7 @@ class SeedDMS_Core_DMS {
|
|||
* @return array|bool
|
||||
*/
|
||||
function search($query, $limit=0, $offset=0, $logicalmode='AND', $searchin=array(), $startFolder=null, $owner=null, $status = array(), $creationstartdate=array(), $creationenddate=array(), $modificationstartdate=array(), $modificationenddate=array(), $categories=array(), $attributes=array(), $mode=0x3, $expirationstartdate=array(), $expirationenddate=array()) { /* {{{ */
|
||||
$orderby = '';
|
||||
if(is_array($query)) {
|
||||
foreach(array('limit', 'offset', 'logicalmode', 'searchin', 'startFolder', 'owner', 'status', 'creationstartdate', 'creationenddate', 'modificationstartdate', 'modificationenddate', 'categories', 'attributes', 'mode', 'expirationstartdate', 'expirationenddate') as $paramname)
|
||||
${$paramname} = isset($query[$paramname]) ? $query[$paramname] : ${$paramname};
|
||||
|
@ -1686,6 +1687,23 @@ class SeedDMS_Core_DMS {
|
|||
"`tblDocumentContent`.`version`, ".
|
||||
"`tblDocumentStatusLog`.`status`, `tblDocumentLocks`.`userID` as `lockUser` ".$searchQuery;
|
||||
|
||||
switch($orderby) {
|
||||
case 'dd':
|
||||
$orderbyQuery = " ORDER BY `tblDocuments`.`date` DESC";
|
||||
break;
|
||||
case 'da':
|
||||
case 'd':
|
||||
$orderbyQuery = " ORDER BY `tblDocuments`.`date`";
|
||||
break;
|
||||
case 'nd':
|
||||
$orderbyQuery = " ORDER BY `tblDocuments`.`name` DESC";
|
||||
break;
|
||||
case 'na':
|
||||
default:
|
||||
$orderbyQuery = " ORDER BY `tblDocuments`.`name`";
|
||||
break;
|
||||
}
|
||||
|
||||
// calculate the remaining entrїes of the current page
|
||||
// If page is not full yet, get remaining entries
|
||||
if($limit) {
|
||||
|
@ -1698,7 +1716,7 @@ class SeedDMS_Core_DMS {
|
|||
if($limit)
|
||||
$searchQuery .= " LIMIT ".$limit." OFFSET ".$offset;
|
||||
|
||||
$searchQuery .= " ORDER BY `tblDocuments`.`name`";
|
||||
$searchQuery .= $orderbyQuery;
|
||||
|
||||
// Send the complete search query to the database.
|
||||
$resArr = $this->db->getResultArray($searchQuery);
|
||||
|
@ -1708,7 +1726,7 @@ class SeedDMS_Core_DMS {
|
|||
$resArr = array();
|
||||
}
|
||||
} else {
|
||||
$searchQuery .= " ORDER BY `tblDocuments`.`name`";
|
||||
$searchQuery .= $orderbyQuery;
|
||||
|
||||
// Send the complete search query to the database.
|
||||
$resArr = $this->db->getResultArray($searchQuery);
|
||||
|
|
Loading…
Reference in New Issue
Block a user