Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 33
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
OlzTerminLocationsListParams
n/a
0 / 0
n/a
0 / 0
0
n/a
0 / 0
OlzTerminLocationsList
0.00% covered (danger)
0.00%
0 / 33
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 1
 getHtml
0.00% covered (danger)
0.00%
0 / 33
0.00% covered (danger)
0.00%
0 / 1
6
1<?php
2
3namespace Olz\Termine\Components\OlzTerminLocationsList;
4
5use Olz\Components\Common\OlzComponent;
6use Olz\Components\Page\OlzFooter\OlzFooter;
7use Olz\Components\Page\OlzHeader\OlzHeader;
8use Olz\Entity\Termine\TerminLocation;
9use Olz\Utils\HttpParams;
10
11/** @extends HttpParams<array{}> */
12class OlzTerminLocationsListParams extends HttpParams {
13}
14
15/** @extends OlzComponent<array<string, mixed>> */
16class OlzTerminLocationsList extends OlzComponent {
17    public function getHtml(mixed $args): string {
18        $this->httpUtils()->validateGetParams(OlzTerminLocationsListParams::class);
19        $code_href = $this->envUtils()->getCodeHref();
20
21        $out = OlzHeader::render([
22            'back_link' => "{$code_href}termine",
23            'title' => 'Termin-Orte',
24            'description' => "Orte, an denen Anlässe der OL Zimmerberg stattfinden.",
25            'norobots' => true,
26        ]);
27
28        // Creation Tools
29        $has_termine_permissions = $this->authUtils()->hasPermission('termine');
30        $creation_tools = '';
31        if ($has_termine_permissions) {
32            $creation_tools .= <<<ZZZZZZZZZZ
33                <div class='create-termin-location-container'>
34                    <button
35                        id='create-termin-location-button'
36                        class='btn btn-secondary'
37                        onclick='return olz.initOlzEditTerminLocationModal()'
38                    >
39                        <img src='{$code_href}assets/icns/new_white_16.svg' class='noborder' />
40                        Neuen Ort hinzufügen
41                    </button>
42                </div>
43                ZZZZZZZZZZ;
44        }
45
46        $termin_location_repo = $this->entityManager()->getRepository(TerminLocation::class);
47        $termin_locations = $termin_location_repo->findAll();
48        $locations_data = array_map(function (TerminLocation $termin_location) use ($code_href) {
49            return [
50                'url' => "{$code_href}termine/orte/{$termin_location->getId()}",
51                'name' => $termin_location->getName(),
52                'lat' => $termin_location->getLatitude(),
53                'lng' => $termin_location->getLongitude(),
54            ];
55        }, $termin_locations);
56        $locations_json = json_encode($locations_data);
57
58        $out .= <<<ZZZZZZZZZZ
59            <div class='content-full'>
60                {$creation_tools}
61                <h1>Termin-Orte</h1>
62                <div id='olz-termin-locations-map' class='test-flaky'></div>
63                <script>olz.olzTerminLocationsMapRender({$locations_json});</script>
64            </div>
65            ZZZZZZZZZZ;
66
67        $out .= OlzFooter::render();
68
69        return $out;
70    }
71}