fix: List of travel entries in travel reimbursement PDF is not sorted on date.
This commit is contained in:
@@ -751,12 +751,38 @@ class API
|
||||
$values[] = $from;
|
||||
$values[] = $to;
|
||||
}
|
||||
|
||||
// ORDER BY
|
||||
if (isset($builder['orderBy']) && is_array($builder['orderBy'])) {
|
||||
|
||||
if (count($builder['orderBy']) !== 2) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$column = $builder['orderBy'][0];
|
||||
$direction = strtoupper($builder['orderBy'][1]);
|
||||
|
||||
if (!in_array($column, $this->allowedGetColumns, true)) {
|
||||
$this->apiOutput(400, ['error' => "The column $column is not allowed."]);
|
||||
}
|
||||
|
||||
if (!in_array($direction, ['ASC', 'DESC'], true)) {
|
||||
$this->apiOutput(400, ['error' => "Invalid order direction."]);
|
||||
}
|
||||
|
||||
$orderByClauses[] = "$column $direction";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!empty($whereClauses)) {
|
||||
$this->baseQuery .= " WHERE " . implode(" AND ", $whereClauses);
|
||||
}
|
||||
|
||||
if (!empty($orderByClauses)) {
|
||||
$this->baseQuery .= " ORDER BY " . implode(", ", $orderByClauses);
|
||||
}
|
||||
|
||||
return [$this->baseQuery, $types, $values];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user