Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 64 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
OlzPanini2024AllParams | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | n/a |
0 / 0 |
|||
OlzPanini2024All | |
0.00% |
0 / 64 |
|
0.00% |
0 / 3 |
156 | |
0.00% |
0 / 1 |
getSearchTitle | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getSearchResults | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getHtml | |
0.00% |
0 / 62 |
|
0.00% |
0 / 1 |
110 |
1 | <?php |
2 | |
3 | namespace Olz\Apps\Panini2024\Components\OlzPanini2024All; |
4 | |
5 | use Olz\Apps\Panini2024\Metadata; |
6 | use Olz\Apps\Panini2024\Utils\Panini2024Utils; |
7 | use Olz\Components\Apps\OlzNoAppAccess\OlzNoAppAccess; |
8 | use Olz\Components\Common\OlzRootComponent; |
9 | use Olz\Components\Page\OlzFooter\OlzFooter; |
10 | use Olz\Components\Page\OlzHeader\OlzHeader; |
11 | use Olz\Entity\Panini2024\Panini2024Picture; |
12 | use Olz\Users\Components\OlzUserInfoModal\OlzUserInfoModal; |
13 | use Olz\Utils\HttpParams; |
14 | |
15 | /** @extends HttpParams<array{}> */ |
16 | class OlzPanini2024AllParams extends HttpParams { |
17 | } |
18 | |
19 | /** @extends OlzRootComponent<array<string, mixed>> */ |
20 | class OlzPanini2024All extends OlzRootComponent { |
21 | public function getSearchTitle(): string { |
22 | return 'TODO'; |
23 | } |
24 | |
25 | public function getSearchResults(array $terms): array { |
26 | return []; |
27 | } |
28 | |
29 | public function getHtml(mixed $args): string { |
30 | $this->httpUtils()->validateGetParams(OlzPanini2024AllParams::class); |
31 | $code_href = $this->envUtils()->getCodeHref(); |
32 | $entity_manager = $this->dbUtils()->getEntityManager(); |
33 | $metadata = new Metadata(); |
34 | |
35 | $out = OlzHeader::render([ |
36 | 'back_link' => "{$code_href}service/", |
37 | 'title' => "Panini '24 All", |
38 | 'norobots' => true, |
39 | ]); |
40 | |
41 | $out .= "<div class='content-full'>"; |
42 | $out .= "<div class='olz-panini-2024-all'>"; |
43 | |
44 | if ($this->authUtils()->hasPermission('panini2024')) { |
45 | $panini_repo = $entity_manager->getRepository(Panini2024Picture::class); |
46 | $pictures = $panini_repo->findAll(); |
47 | $out .= "<table>"; |
48 | $ids = json_encode(array_map(function ($picture) { |
49 | return $picture->getId(); |
50 | }, $pictures)); |
51 | $out .= <<<ZZZZZZZZZZ |
52 | <tr> |
53 | <th class='column id'>ID</th> |
54 | <th class='column name'>Name</th> |
55 | <th class='column account'>OLZ-Konto</th> |
56 | <th class='column association'>Wappen</th> |
57 | <th class='column infos'>Infos</th> |
58 | <th class='column active'>Aktiv</th> |
59 | <th class='column picture'> |
60 | Bild |
61 | <button onclick='olzPanini2024.showPaniniPictures({$ids})'> |
62 | alle anzeigen |
63 | </button> |
64 | </th> |
65 | </tr> |
66 | ZZZZZZZZZZ; |
67 | foreach ($pictures as $picture) { |
68 | $id = $picture->getId(); |
69 | $line1 = $picture->getLine1(); |
70 | $line2 = $picture->getLine2(); |
71 | $owner_user = $picture->getOwnerUser(); |
72 | $user_html = $owner_user ? OlzUserInfoModal::render([ |
73 | 'user' => $owner_user, |
74 | 'mode' => 'name', |
75 | ]) : '-'; |
76 | $association = $picture->getAssociation(); |
77 | $association_emoji = (Panini2024Utils::ASSOCIATION_MAP[$association] ?? 0) ? '✅' : '❌'; |
78 | $infos = $picture->getInfos(); |
79 | $infos_emojis = ''; |
80 | for ($i = 0; $i < 5; $i++) { |
81 | if ($i !== 0) { |
82 | $infos_emojis .= ' '; |
83 | } |
84 | $is_valid = ($infos[$i] ?? false) && strlen($infos[$i]) > 0; |
85 | $infos_emojis .= $is_valid ? '✅' : '❌'; |
86 | } |
87 | $on_off = $picture->getOnOff(); |
88 | $on_off_emoji = $on_off ? '✅' : '❌'; |
89 | $out .= <<<ZZZZZZZZZZ |
90 | <tr> |
91 | <td class='column id'>{$id}</td> |
92 | <td class='column name'>{$line1}<br/>{$line2}</td> |
93 | <td class='column account'>{$user_html}</td> |
94 | <td class='column association'>{$association_emoji} {$association}</td> |
95 | <td class='column infos'>{$infos_emojis}</td> |
96 | <td class='column active'>{$on_off_emoji}</td> |
97 | <td class='column picture' id='panini-picture-{$id}'> |
98 | <button onclick='olzPanini2024.showPaniniPicture("{$id}")'> |
99 | anzeigen |
100 | </button> |
101 | </td> |
102 | </tr> |
103 | ZZZZZZZZZZ; |
104 | } |
105 | $out .= "</table>"; |
106 | } else { |
107 | $out .= OlzNoAppAccess::render([ |
108 | 'app' => $metadata, |
109 | ]); |
110 | } |
111 | |
112 | $out .= "</div>"; |
113 | $out .= "</div>"; |
114 | |
115 | $out .= $metadata->getJsCssImports(); |
116 | $out .= OlzFooter::render(); |
117 | |
118 | return $out; |
119 | } |
120 | } |