WowPress-Tailwind/theme/pages/sks.php

186 lines
8.7 KiB
PHP
Raw Normal View History

2024-04-22 15:38:22 +02:00
<?php
use Wenprise\Eloquent\Database;
use Wenprise\Eloquent\Facades\DB;
2024-04-23 00:44:42 +02:00
use WoWPress\Frontend\Icon;
2024-05-02 23:31:44 +02:00
use WoWPress\Models\Log;
2024-04-22 15:38:22 +02:00
use WoWPress\Models\SKS;
2024-05-02 23:31:44 +02:00
2024-04-22 15:38:22 +02:00
set_sidebar_status('top', false);
$liste = $GLOBALS['wowpress']['liste'];
2024-05-02 21:29:31 +02:00
if (!empty($liste)) {
$liste = SKS::where('list_name', $liste)->first();
if (empty($liste->list_name)) {
2024-04-23 22:43:54 +02:00
$liste = SKS::first();
}
}
2024-04-22 15:38:22 +02:00
2024-04-23 22:43:54 +02:00
if (empty($liste->list_name)) {
2024-04-22 15:38:22 +02:00
$listen = SKS::getLists();
get_header();
?>
2024-04-23 00:44:42 +02:00
<div class="top-title flex flex-row gap-2" style="margin-top:calc(-1 * var(--wowp-gap))">
<div class="text-3xl font-bold bg-glass shadow p-3 text-center w-full">
<?= $GLOBALS['wowpress']['page_title'] ?>n
2024-04-22 15:38:22 +02:00
</div>
2024-04-23 00:44:42 +02:00
</div>
<section id="primary">
<main id="main">
<div class="bg-glass shadow p-auto">
<?php foreach ($listen as $list) : ?>
2024-04-23 22:43:54 +02:00
<a class="btn btn-outline" href="/sks/<?= $list->list_name ?>"><?= $list->list_name ?></a>
2024-04-23 00:44:42 +02:00
<?php endforeach; ?>
</div>
</main>
</section>
2024-04-22 15:38:22 +02:00
<?php
2024-04-23 00:44:42 +02:00
} else {
get_header();
2024-04-22 15:38:22 +02:00
?>
2024-04-23 00:44:42 +02:00
<div class="top-title flex flex-row gap-2" style="margin-top:calc(-1 * var(--wowp-gap))">
<div class="text-3xl font-bold bg-glass shadow p-3 text-center w-full">
<?= $GLOBALS['wowpress']['page_title'] ?> "<?= $liste->list_name ?>"
</div>
</div>
<section id="primary">
<main id="main">
<div class="bg-glass shadow p-auto">
<table class="table-auto w-full">
<thead>
<tr class="bg-glass">
<th class="p-auto w-40">Rang</th>
<th class="p-auto">Charakter</th>
<th class="p-auto hidden lg:table-cell">Server</th>
<?php if (current_user_can('wowpress_edit_raids')) : ?>
2024-04-23 22:43:54 +02:00
<th class="p-auto hidden lg:table-cell">Status</th>
2024-04-23 00:44:42 +02:00
<th class="p-auto w-0">Aktion</th>
<?php endif; ?>
</tr>
</thead>
2024-09-20 09:43:17 +02:00
<tbody class="bg-black">
2024-04-23 00:44:42 +02:00
<?php
foreach (SKS::getList($liste->list_name) as $sk) :
?>
<tr class="text-<?= $sk->active ? $sk->character->color : "slate-500" ?> odd:bg-slate-900">
<?php if (current_user_can('wowpress_edit_raids')) : ?>
<td class="p-auto text-center">
2024-04-23 22:43:54 +02:00
<form action="/request" method="POST">
<div class="flex flex-row">
<input type="text" class="bg-glass w-full text-center border-0 border-b border-<?= $sk->character->color ?>" name="rank" value="<?= $sk->rank ?>">
<button class="btn btn-outline btn-alliance" title="Manueller Eingriff">
<?= Icon::get('o-wrench') ?>
</button>
<?php wp_nonce_field('fixSKS', 'fixSKS_nonce'); ?>
<input type="hidden" name="action" value="fixSKS">
<input type="hidden" name="sks_id" value="<?= $sk->ID ?>">
2024-05-02 21:29:31 +02:00
2024-04-23 22:43:54 +02:00
</div>
</form>
2024-04-23 00:44:42 +02:00
</td>
<?php else : ?>
<td class="p-auto text-center"><?= $sk->rank ?></td>
<?php endif; ?>
2024-09-20 09:43:17 +02:00
<td class="p-auto text-center" style="font-size:1.3em"><?= $sk->character->name ?></td>
<td class="p-auto text-center hidden lg:table-cell" style="font-size:1.3em"><?= $sk->character->realm ?></td>
2024-04-23 22:43:54 +02:00
2024-04-23 00:44:42 +02:00
<?php if (current_user_can('wowpress_edit_raids')) : ?>
2024-04-23 22:43:54 +02:00
<td class="p-auto text-center hidden lg:table-cell">
<form action="/request" method="POST">
<?php wp_nonce_field('toggleSKS', 'toggleSKS_nonce'); ?>
<input type="hidden" name="action" value="toggleSKS">
<input type="hidden" name="sks_id" value="<?= $sk->ID ?>">
<button type="submit" class="btn w-full btn-outline btn-<?= $sk->active ? $sk->character->color : "slate" ?>"><?= $sk->active ? "Aktiv" : "Inaktiv" ?></button>
</form>
</td>
2024-04-23 00:44:42 +02:00
<td class="p-auto">
<div class="flex gap-2 flex-col lg:flex-row justify-end">
<?php if ($sk->active) : ?>
<form action="/request" method="POST">
2024-04-23 22:43:54 +02:00
<?php wp_nonce_field('lootSKS', 'lootSKS_nonce'); ?>
2024-04-23 00:44:42 +02:00
<input type="hidden" name="action" value="lootSKS">
2024-04-23 22:43:54 +02:00
<input type="hidden" name="sks_id" value="<?= $sk->ID ?>">
<button type="submit" title="Looten" class="btn btn-outline btn-<?= $sk->character->color ?>"><?= Icon::get('o-sparkles') ?></button>
2024-04-23 00:44:42 +02:00
</form>
<?php else : ?>
<form action="/request" method="POST">
<?php wp_nonce_field('deleteSKS', 'deleteSKS_nonce'); ?>
<input type="hidden" name="action" value="deleteSKS">
2024-04-23 22:43:54 +02:00
<input type="hidden" name="sks_id" value="<?= $sk->ID ?>">
<button type="submit" title="Löschen" class="btn btn-outline btn-red"><?= Icon::get('o-trash') ?></button>
2024-04-23 00:44:42 +02:00
</form>
<? endif; ?>
</div>
</td>
<?php endif; ?>
</tr>
</div>
<?php
endforeach;
?>
</tbody>
</table>
</div>
</main>
</section>
2024-04-23 22:43:54 +02:00
<?php
}
2024-05-02 21:29:31 +02:00
if (current_user_can('wowpress_edit_raids')) : ?>
2024-04-23 22:43:54 +02:00
<div x-data>
<template x-teleport="#sidebar_right">
<div class="bg-glass shadow p-auto order-1">
<h4 class="text-xl font-bold text-center mb-2">Charakter Hinzufügen</h4>
<form action="/request" method="POST">
<div class="flex flex-col gap-2">
<?php wp_nonce_field('addSKS', 'addSKS_nonce'); ?>
<input type="hidden" name="action" value="addSKS">
<input type="text" name="name" placeholder="Name" class="text-black">
<input type="text" name="realm" placeholder="Server" class="text-black">
<input type="text" name="list_name" placeholder="Listenname" value="<?= !empty($liste->list_name) ? $liste->list_name : "" ?>" class="text-black">
<button type="submit" class="btn btn-outline btn-hunter">Hinzufügen</a>
</div>
</form>
</div>
</template>
2024-05-02 21:29:31 +02:00
<?php if (!empty($liste->list_name)) : ?>
<template x-teleport="#sidebar_right">
2024-09-20 09:43:17 +02:00
<!--div class="bg-glass shadow p-auto order-1">
2024-05-02 21:29:31 +02:00
<h4 class="text-xl font-bold text-center mb-2">Liste neu Würfeln</h4>
<form action="/request" method="POST">
<div class="flex flex-col gap-2">
<?php wp_nonce_field('rollSKS', 'rollSKS_nonce'); ?>
<input type="hidden" name="action" value="rollSKS">
<input type="hidden" name="list_name" value="<?= $liste->list_name ?>">
<button type="submit" class="btn btn-outline btn-orange"><?= Icon::get('o-arrow-path') ?> Würfeln</a>
</div>
</form>
2024-09-20 09:43:17 +02:00
</div-->
2024-05-02 21:29:31 +02:00
</template>
<?php endif; ?>
2024-04-23 22:43:54 +02:00
</div>
2024-04-23 00:44:42 +02:00
2024-04-22 15:38:22 +02:00
<?php
2024-04-23 22:43:54 +02:00
endif;
get_footer();
2024-04-23 00:44:42 +02:00
2024-04-22 15:38:22 +02:00
?>