Add special handling of sorting by EndTime because it can be NULL. Fixes #3298

This commit is contained in:
Isaac Connor 2021-06-15 10:33:42 -04:00
parent f6c29b51ef
commit 0ca10fe7cd
1 changed files with 11 additions and 3 deletions

View File

@ -38,10 +38,20 @@ $search = isset($_REQUEST['search']) ? $_REQUEST['search'] : '';
// Bootstrap table sends json_ecoded array, which we must decode
$advsearch = isset($_REQUEST['advsearch']) ? json_decode($_REQUEST['advsearch'], JSON_OBJECT_AS_ARRAY) : array();
// Order specifies the sort direction, either asc or desc
$order = (isset($_REQUEST['order']) and (strtolower($_REQUEST['order']) == 'asc')) ? 'ASC' : 'DESC';
// Sort specifies the name of the column to sort on
$sort = 'StartDateTime';
if ( isset($_REQUEST['sort']) ) {
if (isset($_REQUEST['sort'])) {
$sort = $_REQUEST['sort'];
if ($sort == 'EndDateTime') {
if ($order == 'ASC') {
$sort = 'EndDateTime IS NULL, EndDateTime';
} else {
$sort = 'EndDateTime IS NOT NULL, EndDateTime';
}
}
}
// Offset specifies the starting row to return, used for pagination
@ -54,8 +64,6 @@ if ( isset($_REQUEST['offset']) ) {
}
}
// Order specifies the sort direction, either asc or desc
$order = (isset($_REQUEST['order']) and (strtolower($_REQUEST['order']) == 'asc')) ? 'ASC' : 'DESC';
// Limit specifies the number of rows to return
// Set the default to 0 for events view, to prevent an issue with ALL pagination