diff --git a/modules/shared/auth/ui/home.php b/modules/shared/auth/ui/home.php index 3d7a4d9..72ca095 100644 --- a/modules/shared/auth/ui/home.php +++ b/modules/shared/auth/ui/home.php @@ -160,6 +160,39 @@ function auth_render_markets_content(array $marketTable): string . ''; } +function auth_render_market_definitions_content(array $marketTable): string +{ + $rows = $marketTable['rows'] ?? $marketTable; + $html = []; + $html[] = '
'; + $html[] = '
'; + $html[] = '
'; + $html[] = '
Märkte
'; + $html[] = '
'; + foreach (['Markt', 'Kategorie', 'Website', 'Durchführungen', 'Status'] as $label) { + $html[] = '
' . auth_escape_html($label) . '
'; + } + $html[] = '
'; + foreach ($rows as $index => $row) { + $rowClass = 'sg-card-segment sg-card-segment--body sg-card-segment--white sg-large-table__row'; + if ($index % 2 === 1) { + $rowClass .= ' sg-large-table__row--striped-light'; + } + $website = (string) ($row['website_url'] ?? ''); + $websiteValue = $website === '' ? 'Nicht hinterlegt' : $website; + $status = ($row['archived_at'] ?? null) === null ? 'Aktiv' : 'Archiviert'; + $html[] = '
'; + $html[] = '
' . auth_escape_html((string) ($row['name'] ?? '')) . '
'; + $html[] = '
' . auth_escape_html((string) ($row['category_name'] ?? $row['category_code'] ?? '')) . '
'; + $html[] = '
' . auth_escape_html($websiteValue) . '
'; + $html[] = '
' . auth_escape_html((string) ($row['occurrence_count'] ?? 0)) . '
'; + $html[] = '
' . auth_escape_html($status) . '
'; + $html[] = '
'; + } + $html[] = '
'; + return implode('', $html); +} + function auth_render_bestellungen_large_table(array $bestellungenTable): string { $rows = $bestellungenTable['rows'] ?? []; @@ -597,7 +630,7 @@ function auth_render_lager_content(array $lagerProducts, array $lagerArtikel, ar . ''; } -function render_auth_home_page(array $user, array $otcProducts = [], array $otcMarketOptions = [], array $bestellungenTable = [], array $marketOccurrencesTable = [], array $lagerProducts = [], array $lagerArtikel = [], array $lagerManufacturers = []): void +function render_auth_home_page(array $user, array $otcProducts = [], array $otcMarketOptions = [], array $bestellungenTable = [], array $marketOccurrencesTable = [], array $lagerProducts = [], array $lagerArtikel = [], array $lagerManufacturers = [], array $marketDefinitionsTable = []): void { $otcProductRows = ''; foreach ($otcProducts as $product) { @@ -653,11 +686,13 @@ function render_auth_home_page(array $user, array $otcProducts = [], array $otcM ); $bestellungenContent = auth_render_bestellungen_content($bestellungenTable); $marketsContent = auth_render_markets_content($marketOccurrencesTable); + $marketDefinitionsContent = auth_render_market_definitions_content($marketDefinitionsTable); $lagerContent = auth_render_lager_content($lagerProducts, $lagerArtikel, $lagerManufacturers, auth_csrf_token()); $moduleContentCards = json_encode( [ 'Bestellungen' => $bestellungenContent, 'Markttage' => $marketsContent, + 'Märkte' => $marketDefinitionsContent, 'Lager' => $lagerContent, 'Artikel' => auth_render_lager_content([], $lagerArtikel, $lagerManufacturers, auth_csrf_token(), 'Artikel'), ], diff --git a/public/index.php b/public/index.php index c013dc0..51df629 100644 --- a/public/index.php +++ b/public/index.php @@ -79,6 +79,15 @@ if ($currentUser !== null) { 'page_size' => 20, ]; $marketOccurrencesTable['has_more'] = count($marketOccurrencesTable['rows']) >= $marketLimit; + $marketDefinitionsTable = [ + 'rows' => market_management_search_markets($pdo, [ + 'include_archived' => true, + 'sort' => 'name', + 'sort_direction' => 'ASC', + 'limit' => 100, + 'offset' => 0, + ]), + ]; if ((string) ($_GET['bestellungen_fragment'] ?? '') === '1') { echo auth_render_bestellungen_content($bestellungenTable); exit; @@ -87,7 +96,7 @@ if ($currentUser !== null) { echo auth_render_markets_content($marketOccurrencesTable); exit; } - render_auth_home_page($currentUser, $otcProducts, $otcMarketOptions, $bestellungenTable, $marketOccurrencesTable, $lagerProducts, $lagerArtikel, $lagerManufacturers); + render_auth_home_page($currentUser, $otcProducts, $otcMarketOptions, $bestellungenTable, $marketOccurrencesTable, $lagerProducts, $lagerArtikel, $lagerManufacturers, $marketDefinitionsTable); exit; }