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