WowPress-Tailwind/theme/pages/single_raid.php

153 lines
7.4 KiB
PHP
Raw Normal View History

2024-04-23 22:43:54 +02:00
<?php
2024-04-16 15:25:22 +02:00
2024-04-23 22:43:54 +02:00
use WoWPress\Frontend\Icon;
use WoWPress\Frontend\ToggleButton;
use WoWPress\Models\Character;
use WoWPress\Models\Raid;
2024-04-16 15:25:22 +02:00
2024-04-23 22:43:54 +02:00
$raid = $GLOBALS['wowpress']['raid'];
set_sidebar_status('top', false);
set_sidebar_status('left', false);
set_sidebar_status('right', false);
2024-04-16 15:25:22 +02:00
2024-04-23 22:43:54 +02:00
global $user;
2024-04-17 22:10:17 +02:00
2024-04-23 22:43:54 +02:00
if ($raid->id_wowaudit) {
2024-08-05 20:19:44 +02:00
if ($raid->sync(true)) {
2024-06-19 21:10:42 +02:00
$raid->save();
2024-08-05 20:19:44 +02:00
} else {
2024-06-19 21:10:42 +02:00
$raid->status = "Cancelled";
$raid->save();
}
2024-04-23 22:43:54 +02:00
}
2024-04-23 00:44:42 +02:00
2024-04-17 22:10:17 +02:00
2024-04-23 22:43:54 +02:00
$unknowns = [];
get_header();
?>
2024-09-05 21:48:11 +02:00
<div class="top-title flex flex-row justify-between flex-wrap gap-auto mx-1" style="margin-top:calc(-1 * var(--wowp-gap))">
2024-04-23 22:43:54 +02:00
<?php if ($raid->previous) : ?>
2024-09-05 21:48:11 +02:00
<a href="<?= $raid->previous->link ?>" class="btn btn-outline lg:flex flex-wrap order-2 lg:order-1">Vorheriger</a>
2024-04-23 22:43:54 +02:00
<?php endif; ?>
2024-09-05 21:48:11 +02:00
<div class="text-3xl font-bold bg-glass shadow p-3 text-center flex-grow w-auto order-1 lg:order-2">
2024-08-05 20:19:44 +02:00
<?php if (current_user_can('wowpress_edit_raids')) : ?>
<form action="/request" method="POST">
<?php wp_nonce_field('updateRaidTitle', 'updateRaidTitle_nonce'); ?>
<input type="hidden" name="action" value="updateRaidTitle">
<input type="hidden" name="raid_id" value="<?= $raid->ID ?>">
<div class="flex flex-row gap-1 justify-center">
<input type="text" name="name" class="bg-white bg-opacity-0 border-alliance" value="<?= $raid->title ?>">
<button class="btn btn-green">Titel ändern</button>
</div>
</form>
<?php else : ?>
<?= $raid->title ?>
<?php endif; ?>
2024-04-22 15:38:22 +02:00
</div>
2024-04-23 22:43:54 +02:00
<?php if ($raid->next) : ?>
2024-09-05 21:48:11 +02:00
<a href="<?= $raid->next->link ?>" class="btn btn-outline lg:flex order-3">Nächster</a>
2024-04-23 22:43:54 +02:00
<?php endif; ?>
</div>
<section id="primary">
2024-08-05 20:19:44 +02:00
<?php if ($raid->status == "Cancelled") : ?>
<main id="main">
<div class="flex flex-col lg:flex-row gap-auto">
<div class="bg-glass shadow p-auto w-full text-center">
<h1 class="text-3xl font-bold text-red">Raid abgesagt!</h1>
2024-04-17 22:10:17 +02:00
</div>
2024-04-23 22:43:54 +02:00
</div>
2024-08-05 20:19:44 +02:00
</main>
<?php else : ?>
<main id="main">
<div class="flex flex-col lg:flex-row gap-auto" x-data="{encounter:<?= $raid->encounters[0]['id'] ?>}">
<div class="bg-glass shadow p-auto w-full lg:w-1/5 order-2 lg:order-1">
<h3 class="text-xl font-bold text-center">Bosse</h3>
<div class="grid gap-auto">
2024-04-23 22:43:54 +02:00
<?php foreach ($raid->encounters as $encounter) : ?>
2024-08-05 20:19:44 +02:00
<button <?= $encounter['enabled'] ? "" : "disabled" ?> x-on:click="encounter=<?= $encounter['id'] ?>" class="btn btn-outline <?= $encounter['enabled'] ? "btn-green" : "btn-slate" ?>" :class="{'current-menu-item' : encounter==<?= $encounter['id'] ?> }"><?= $encounter['name'] ?></button>
2024-04-23 22:43:54 +02:00
<?php endforeach; ?>
2024-04-22 15:38:22 +02:00
</div>
2024-04-23 22:43:54 +02:00
</div>
2024-08-05 20:19:44 +02:00
<div class="w-full flex flex-col gap-auto order-3 lg:order-2">
<div class="flex flex-col lg:flex-row gap-auto">
<div class="bg-glass shadow p-auto w-full lg:w-1/5">
<div class="grid text-center gap-1">
<div class="bg-<?= $raid->color ?> text-black text-2xl "><?= format_date($raid->start, "EEEE") ?></div>
<div class="border border-<?= $raid->color ?>">
<div class="text-3xl p-auto "><?= format_date($raid->start, "dd. MMMM") ?></div>
</div>
<div class="border border-<?= $raid->color ?> p-2">Start: <?= format_date($raid->start, "HH:mm") ?></div>
<div class="border border-<?= $raid->color ?> p-2">Ende: <?= format_date($raid->end, "HH:mm") ?></div>
<?php if ($raid->difficulty) : ?>
<div class="border border-<?= $raid->color ?> p-2"><?= $raid->difficulty ?></div>
<?php endif; ?>
</div>
</div>
<div class="bg-glass shadow p-auto w-full">
<?php foreach ($raid->encounters as $encounter) : ?>
<div x-cloak x-show="encounter==<?= $encounter['id'] ?>">
<h3 class="text-xl font-bold">Informationen für : <?= $encounter['name'] ?></h3>
<div>
<?= $encounter['notes'] ?>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
2024-04-17 22:10:17 +02:00
2024-04-16 15:25:22 +02:00
2024-08-05 20:19:44 +02:00
<div class="flex flex-col lg:flex-row gap-auto">
<?php foreach ($raid->encounters as $encounter) : ?>
<div x-cloak x-show="encounter==<?= $encounter['id'] ?>" class="w-full">
2024-04-22 15:38:22 +02:00
2024-08-05 20:19:44 +02:00
<div class="w-full grid grid-cols-1 lg:grid-cols-4 gap-auto">
<?php
foreach ($encounter['selections']->groupBy('role') as $role => $signups) :
if ($role != "Unknown") :
?>
<div class="bg-glass shadow p-auto flex flex-col gap-auto">
<h3 class="text-xl font-bold text-center"><?= $role ?></h3>
<?php foreach ($signups as $signup) : ?>
<?= $signup->showForm(false, true, false, $encounter['id'] == 0, true) ?>
<?php endforeach; ?>
</div>
<?php
else : if ($encounter['id'] == 0) : $unknowns = $signups;
endif;
2024-04-22 15:38:22 +02:00
endif;
2024-08-05 20:19:44 +02:00
endforeach;
?>
</div>
2024-04-16 15:25:22 +02:00
2024-08-05 20:19:44 +02:00
</div>
<?php endforeach; ?>
2024-04-23 22:43:54 +02:00
2024-08-05 20:19:44 +02:00
</div>
2024-04-16 15:25:22 +02:00
</div>
2024-08-05 20:19:44 +02:00
<div class="flex flex-col gap-auto w-full lg:w-1/5 order-1 lg:order-3">
<div class="bg-glass shadow p-auto">
<div class="flex flex-col gap-auto">
<h3 class="text-xl font-bold text-center">Status</h3>
<?= $raid->showSignup($user->characters->first(), true, true, true) ?>
</div>
2024-04-23 22:43:54 +02:00
</div>
2024-04-22 15:38:22 +02:00
</div>
2024-04-16 15:25:22 +02:00
</div>
2024-08-05 20:19:44 +02:00
<div class="w-full order-4 bg-glass shadow p-auto flex flex-col gap-auto">
<h3 class="text-xl font-bold text-center">Keine Rückmeldung</h3>
<div class="grid grid-cols-1 lg:grid-cols-5 flex-wrap gap-auto">
<?php foreach ($unknowns as $signup) : ?>
<?= $signup->showForm() ?>
<?php endforeach; ?>
</div>
2024-04-23 22:43:54 +02:00
</div>
2024-06-19 21:10:42 +02:00
<?php endif; ?>
2024-08-05 20:19:44 +02:00
</main>
2024-04-23 22:43:54 +02:00
</section>
<?php
get_footer();