diff --git a/header.php b/header.php index 0096fe6..26ee6dd 100644 --- a/header.php +++ b/header.php @@ -179,8 +179,22 @@ } $order_by_column = ($sort_column === 'timeframes') ? 'last_updated' : $sort_column; + $direction = ($sort_order === 'asc' ? 'ASC' : 'DESC'); - $order_clause = "ORDER BY " . $order_by_column . " " . ($sort_order === 'asc' ? 'ASC' : 'DESC'); + if ($order_by_column === 'status') { + $order_clause = "ORDER BY CASE status + WHEN 'Pending Submission' THEN 1 + WHEN '1st Step' THEN 2 + WHEN '1st Step Pending' THEN 3 + WHEN '2nd Step' THEN 4 + WHEN '2nd Step Pending' THEN 5 + WHEN 'Settled' THEN 6 + WHEN 'Withdrawn' THEN 7 + ELSE 8 + END " . $direction; + } else { + $order_clause = "ORDER BY " . $order_by_column . " " . $direction; + } try { $stmt = $pdo->prepare("SELECT * FROM grievances WHERE category = ? $order_clause");