Ergaenze Markt-Durchfuehrungstabelle im Portal
This commit is contained in:
1 parent
c147624d71
commit
bbec87abfa
4 files changed
+164
-5
No files matched your search
@@ -260,9 +260,26 @@ function market_management_search_occurrences(PDO $pdo, array $input): array
|
||||
$where = [];
|
||||
$params = [':limit' => min(100, max(1, (int) ($input['limit'] ?? 50))), ':offset' => max(0, (int) ($input['offset'] ?? 0))];
|
||||
$includeArchived = (bool) ($input['include_archived'] ?? false);
|
||||
$search = market_management_optional_string($input, 'search');
|
||||
$sort = (string) ($input['sort'] ?? 'earliest_date');
|
||||
$sortDirection = strtolower((string) ($input['sort_direction'] ?? 'asc')) === 'desc' ? 'DESC' : 'ASC';
|
||||
$sortColumn = match ($sort) {
|
||||
'market_name' => 'm.name',
|
||||
'place' => 'o.place',
|
||||
'status' => 'o.status',
|
||||
default => 'MIN(d.date)',
|
||||
};
|
||||
if (!$includeArchived) {
|
||||
$where[] = 'o.archived_at IS NULL';
|
||||
}
|
||||
if ($search !== null) {
|
||||
$where[] = '(m.name ILIKE :search_name OR o.place ILIKE :search_place OR o.status ILIKE :search_status OR EXISTS (SELECT 1 FROM market_occurrence_day sd WHERE sd.occurrence_id = o.id AND TO_CHAR(sd.date, \'DD.MM.YYYY\') ILIKE :search_date))';
|
||||
$searchValue = '%' . $search . '%';
|
||||
$params[':search_name'] = $searchValue;
|
||||
$params[':search_place'] = $searchValue;
|
||||
$params[':search_status'] = $searchValue;
|
||||
$params[':search_date'] = $searchValue;
|
||||
}
|
||||
if (array_key_exists('market_definition_id', $input)) {
|
||||
$where[] = 'o.market_definition_id = :market_definition_id';
|
||||
$params[':market_definition_id'] = market_management_require_positive_id($input['market_definition_id'], 'market_definition_id');
|
||||
@@ -298,7 +315,7 @@ function market_management_search_occurrences(PDO $pdo, array $input): array
|
||||
LEFT JOIN market_occurrence_day d ON d.occurrence_id = o.id
|
||||
WHERE ' . ($where === [] ? 'TRUE' : implode(' AND ', $where)) . '
|
||||
GROUP BY o.id, m.name, m.category_id, c.code, c.name
|
||||
ORDER BY earliest_date NULLS LAST, o.id ASC
|
||||
ORDER BY ' . $sortColumn . ' ' . $sortDirection . ' NULLS LAST, o.id ASC
|
||||
LIMIT :limit OFFSET :offset'
|
||||
);
|
||||
foreach ($params as $key => $value) {
|
||||
|
||||
Reference in new issue
Block a user