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