Added ability to sort alert schedules by status (#9257)

Signed-off-by: Rémy Jacquin <[email protected]>
This commit is contained in:
Rémy Jacquin
2018-11-05 08:10:27 +00:00
committed by Neil Lathwood
parent 38e3250528
commit 4e8acdd894
2 changed files with 20 additions and 2 deletions
+19 -1
View File
@@ -31,7 +31,13 @@ if (empty($total)) {
$total = 0;
}
if (!isset($sort) || empty($sort)) {
if (isset($sort) && !empty($sort)) {
list($sort_column, $sort_order) = explode(' ', trim($sort));
if ($sort_column == 'status') {
$sort_by_status = true;
$sort = "`S`.`start` $sort_order";
}
} else {
$sort = '`S`.`start` DESC ';
}
@@ -108,6 +114,18 @@ foreach (dbFetchRows($sql, $param) as $schedule) {
);
}
if (isset($sort_by_status) && $sort_by_status) {
if ($sort_order == 'asc') {
usort($response, function ($a, $b) {
return $a['status'] - $b['status'];
});
} else {
usort($response, function ($a, $b) {
return $b['status'] - $a['status'];
});
}
}
$output = array(
'current' => $current,
'rowCount' => $rowCount,
+1 -1
View File
@@ -43,7 +43,7 @@ if (LegacyAuth::user()->hasGlobalAdmin()) {
<th data-column-id="end_recurring_hr">End recurring hr</th>
<th data-column-id="recurring_day" data-sortable="false" data-searchable="false">Recurring on days</th>
<th data-column-id="actions" data-sortable="false" data-searchable="false" data-formatter="commands">Actions</th>
<th data-column-id="status" data-sortable="false" data-searchable="false" data-formatter="schedstatus">Status</th>
<th data-column-id="status" data-searchable="false" data-formatter="schedstatus">Status</th>
</tr>
</thead>
</table>