2024-04-15 16:00:49 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
use WoWPress\Api\BattleNet;
|
|
|
|
use WoWPress\Database\Cache;
|
2024-04-15 23:07:29 +02:00
|
|
|
use WoWPress\Frontend\Icon;
|
2024-04-15 16:00:49 +02:00
|
|
|
use WoWPress\Models\Character;
|
2024-04-22 15:38:22 +02:00
|
|
|
use WoWPress\Models\User;
|
2024-04-15 16:00:49 +02:00
|
|
|
|
|
|
|
global $widget_area;
|
2024-04-16 15:25:22 +02:00
|
|
|
set_sidebar_status('top', false);
|
2024-04-15 16:00:49 +02:00
|
|
|
|
|
|
|
$characters = Character::orderBy('rank')->get();
|
|
|
|
get_header();
|
|
|
|
|
|
|
|
?>
|
2024-04-16 15:25:22 +02:00
|
|
|
<div class="top-title flex flex-row gap-2" style="margin-top:calc(-1 * var(--wowp-gap))">
|
2024-04-22 15:38:22 +02:00
|
|
|
<div class="text-3xl font-bold bg-glass shadow p-3 text-center w-full">
|
|
|
|
<?= $GLOBALS['wowpress']['page_title'] ?>
|
|
|
|
</div>
|
2024-04-16 15:25:22 +02:00
|
|
|
</div>
|
|
|
|
|
2024-04-15 23:07:29 +02:00
|
|
|
<section id="primary">
|
|
|
|
<main id="main">
|
|
|
|
<div class="bg-glass shadow p-auto">
|
|
|
|
<table class="table-auto w-full">
|
|
|
|
<thead class="bg-glass">
|
|
|
|
<tr>
|
|
|
|
<td class="p-auto">Name</td>
|
2024-04-16 15:25:22 +02:00
|
|
|
<td class="p-auto hidden lg:table-cell">Klasse</td>
|
|
|
|
<td class="p-auto hidden lg:table-cell">Rang</td>
|
|
|
|
<td class="p-auto hidden lg:table-cell">Server</td>
|
|
|
|
<td class="p-auto hidden lg:table-cell">Gilde</td>
|
2024-04-22 15:46:40 +02:00
|
|
|
<td class="p-auto hidden lg:table-cell">Raider</td>
|
|
|
|
|
2024-04-22 15:38:22 +02:00
|
|
|
<?php if (current_user_can('wowpress_edit_characters')) : ?>
|
|
|
|
<td class="p-auto hidden lg:table-cell">
|
|
|
|
User
|
|
|
|
</td>
|
|
|
|
<td class="p-auto">Aktionen</td>
|
|
|
|
<?php endif; ?>
|
2024-04-15 23:07:29 +02:00
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody class="bg-slate-900">
|
|
|
|
<?php foreach ($characters as $char) : ?>
|
2024-04-16 15:25:22 +02:00
|
|
|
<tr class="text-<?= $char->color ?> even:bg-slate-800">
|
2024-04-15 16:00:49 +02:00
|
|
|
<td class="p-auto">
|
2024-04-15 23:07:29 +02:00
|
|
|
<div class="flex flex-row gap-2 items-center">
|
|
|
|
<img class="w-[42px] aspect-1 rounded-full" src="<?= $char->avatar ?>" alt="">
|
|
|
|
<span><?= $char->name ?></span>
|
|
|
|
</div>
|
2024-04-15 16:00:49 +02:00
|
|
|
</td>
|
2024-04-16 15:25:22 +02:00
|
|
|
<td class="p-auto hidden lg:table-cell">
|
2024-04-15 23:07:29 +02:00
|
|
|
<div class="flex flex-row gap-2 items-center">
|
|
|
|
<img class="w-[30px] aspect-1 rounded-full" src="<?= $char->class_icon ?>" alt="">
|
|
|
|
<img class="w-[30px] aspect-1 rounded-full" src="<?= $char->spec_icon ?>" alt="">
|
|
|
|
<span><?= translate_string($char->class) ?> -
|
|
|
|
<?= translate_string($char->spec) ?></span>
|
|
|
|
</div>
|
|
|
|
</td>
|
2024-04-16 15:25:22 +02:00
|
|
|
<td class="p-auto hidden lg:table-cell"><?= $char->rank ?></td>
|
|
|
|
<td class="p-auto hidden lg:table-cell"><?= $char->realm ?></td>
|
|
|
|
<td class="p-auto hidden lg:table-cell"><?= $char->guild ?></td>
|
2024-04-22 15:46:40 +02:00
|
|
|
<td class="p-auto hidden lg:table-cell"><?= $char->raidchar?"Ja":"Nein" ?></td>
|
|
|
|
|
2024-04-22 15:38:22 +02:00
|
|
|
<?php if (current_user_can('wowpress_edit_characters')) : ?>
|
|
|
|
<td class="p-auto hidden lg:table-cell">
|
2024-04-15 23:07:29 +02:00
|
|
|
<form action="/request" method="POST">
|
2024-04-22 15:38:22 +02:00
|
|
|
<input type="hidden" name="char_id" value="<?= $char->ID ?>">
|
|
|
|
<?php wp_nonce_field('changeUser', 'changeUser_nonce'); ?>
|
|
|
|
<input type="hidden" name="action" value="changeUser">
|
|
|
|
<div class="flex flex-row">
|
|
|
|
<div x-data="{ open: false, uid: '<?= $char->user ? $char->user->ID : "0" ?>' , selected: '<?= $char->user ? $char->user->login : "" ?>' }" @click.away="open = false" class="relative">
|
|
|
|
|
|
|
|
<input type="hidden" name="uid" x-model="uid">
|
|
|
|
|
|
|
|
<!-- Button -->
|
|
|
|
<button type="button" @click="open = !open" class="min-w-[180px] max-w-[180px] h-full px-4 py-2 border-e-0 border border-<?= $char->color ?> flex items-center justify-between" :class="{'text-<?= $char->color ?>': selected !== '', 'text-gray-500': selected === ''}">
|
|
|
|
<span class="max-w-[120px] overflow-hidden" x-text="selected === '' ? 'Kein User' : selected"></span>
|
|
|
|
<svg class="ml-2 w-4 h-4" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" />
|
|
|
|
</svg>
|
|
|
|
</button>
|
|
|
|
|
|
|
|
<!-- Dropdown Menu -->
|
|
|
|
<div x-show="open" class="absolute mt-2 bg-glass border border-<?= $char->color ?> w-full z-10" x-cloak>
|
|
|
|
<ul class="max-h-[240px] overflow-auto [&>li]:text-slate-200 [&>li]:px-4 [&>li]:py-2 hover:[&>li]:bg-slate-600 [&>li]:cursor-pointer">
|
|
|
|
<li @click="selected = ''; uid='0'; open = false;" value="0">Kein User</li>
|
|
|
|
<?php foreach (User::all() as $user) : ?>
|
|
|
|
<li @click="selected = '<?= $user->login ?>'; uid = '<?= $user->ID ?>'; open = false;" value="<?= $user->ID ?>"><?= $user->login ?></li>
|
|
|
|
<?php endforeach; ?>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<button type="submit" class="btn btn-<?= $char->color ?>"><?= Icon::get('o-user-plus') ?></button>
|
|
|
|
</div>
|
2024-04-15 23:07:29 +02:00
|
|
|
</form>
|
2024-04-22 15:38:22 +02:00
|
|
|
</td>
|
|
|
|
<td class="p-auto">
|
|
|
|
<div class="flex flex-row justify-end gap-2">
|
|
|
|
<form action="/request" method="POST">
|
|
|
|
<?php wp_nonce_field('updateCharacter', 'updateCharacter_nonce'); ?>
|
|
|
|
<input type="hidden" name="action" value="updateCharacter">
|
|
|
|
<input type="hidden" name="id" value="<?= $char->ID ?>">
|
|
|
|
<button type="submit" class="btn btn-outline button-green"><?= Icon::get('o-arrow-path') ?></button>
|
|
|
|
</form>
|
|
|
|
<form action="/request" method="POST">
|
|
|
|
<?php wp_nonce_field('deleteCharacter', 'deleteCharacter_nonce'); ?>
|
|
|
|
<input type="hidden" name="action" value="deleteCharacter">
|
|
|
|
<input type="hidden" name="id" value="<?= $char->ID ?>">
|
|
|
|
<button type="submit" class="btn btn-outline button-red"><?= Icon::get('o-trash') ?></button>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
</td>
|
|
|
|
<?php endif; ?>
|
2024-04-15 16:00:49 +02:00
|
|
|
</tr>
|
2024-04-15 23:07:29 +02:00
|
|
|
<?php endforeach; ?>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
</main><!-- #main -->
|
|
|
|
</section><!-- #primary -->
|
2024-04-22 15:38:22 +02:00
|
|
|
<?php if (current_user_can('wowpress_edit_characters')) : ?>
|
|
|
|
<div x-data="{addChar:true}">
|
|
|
|
<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('addCharacter', 'addCharacter_nonce'); ?>
|
|
|
|
<input type="hidden" name="action" value="addCharacter">
|
|
|
|
<input type="text" name="name" placeholder="Name" class="text-black">
|
|
|
|
<input type="text" name="realm" placeholder="Server" class="text-black">
|
|
|
|
<button type="submit" class="btn btn-outline btn-hunter">Hinzufügen</a>
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</div>
|
2024-04-15 16:00:49 +02:00
|
|
|
|
|
|
|
<?php
|
2024-04-22 15:38:22 +02:00
|
|
|
endif;
|
2024-04-15 16:00:49 +02:00
|
|
|
get_footer();
|