SKS und Widgets
parent
b116f4f090
commit
775966f0dd
|
@ -16,6 +16,7 @@ if (empty($chars) || empty($chars->first())) {
|
|||
$chars = [$this->character];
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
||||
<div class="flex <?= $vertical ? "flex-col" : "flex-row" ?> border border-<?= $this->character->color ?> shadow" x-data="{open : false}">
|
||||
|
@ -42,7 +43,7 @@ if (empty($chars) || empty($chars->first())) {
|
|||
<form id="<?= $id ?>" action="/request" method="POST">
|
||||
<?php wp_nonce_field('signupRaid', 'signupRaid_nonce'); ?>
|
||||
<input type="hidden" name="action" value="signupRaid">
|
||||
<input type="hidden" name="raid_id" value="<?= $this->raid_ID ?>">
|
||||
<input type="hidden" name="raid_id" value="<?= $this->raid->ID ?>">
|
||||
|
||||
<div class="grid p-auto gap-auto">
|
||||
|
||||
|
|
|
@ -5,6 +5,8 @@ use WoWPress\Database\CreateCharacterTable;
|
|||
use WoWPress\Database\CreateRaidTable;
|
||||
use WoWPress\Database\CreateSignupTable;
|
||||
use WoWPress\Database\CreateSKSTable;
|
||||
use WoWPress\Frontend\Widgets\BossKills;
|
||||
use WoWPress\Frontend\Widgets\CharacterSearch;
|
||||
use WoWPress\Frontend\Widgets\RaidSignup;
|
||||
use WoWPress\Models\Character;
|
||||
|
||||
|
@ -461,6 +463,8 @@ function wowpress_add_category_meta($taxonomy)
|
|||
|
||||
/** Widgets */
|
||||
$widget_raid_signup = new RaidSignup();
|
||||
$widget_boss_kills = new BossKills();
|
||||
$widget_char_search = new CharacterSearch();
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -35,9 +35,9 @@ global $user;
|
|||
<template x-data x-teleport="#sidebar_left">
|
||||
<div class="bg-glass shadow p-auto order-1">
|
||||
<div class="flex flex-row justify-between">
|
||||
<div>Hallo <?= $user->login ?></div>
|
||||
<div>Hallo <?= $user->username ?></div>
|
||||
<?php if (!$user->ID) : ?>
|
||||
<div>Bitte <a href="/wp-login.php" class="text-alliance underline">einloggen</a>:)</div>
|
||||
<div>Bitte <a href="/wp-login.php" class="text-alliance underline">einloggen</a> :)</div>
|
||||
<?php else : ?>
|
||||
<div><a href="/wp-login.php?action=logout" class="text-alliance underline"><?= Icon::get('o-power') ?></a></div>
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ add_filter('generate_rewrite_rules', function ($wp_rewrite) {
|
|||
['raid/(\d+)/?$' => 'index.php?wowpress_page=raid&raid_id=$matches[1]'],
|
||||
['request/?$' => 'index.php?wowpress_page=form_request'],
|
||||
['sks/?$' => 'index.php?wowpress_page=sks'],
|
||||
['sks/(\d+)?$' => 'index.php?wowpress_page=sks&list_name=$matches[1]'],
|
||||
['sks/([A-Za-z-]+)?$' => 'index.php?wowpress_page=sks&list_name=$matches[1]'],
|
||||
$wp_rewrite->rules
|
||||
);
|
||||
});
|
||||
|
|
|
@ -57,14 +57,13 @@ get_header();
|
|||
}
|
||||
}
|
||||
?>
|
||||
<div class="bg-glass p-auto text-center <?php if (count($has_raid) > 0) { ?> glow shadow-<?= $has_raid[0]->color ?> <?php } ?> grid grid-cols-2 grid-rows-2">
|
||||
<div class="bg-glass p-auto text-center aspect-[1/0.8] <?php if (count($has_raid) > 0) { ?> glow shadow-<?= $has_raid[0]->color ?> <?php } ?> grid grid-cols-2 grid-rows-2" <?php if (count($has_raid) > 0) { ?> style="background-position:center;background-size: cover;background-image:url('<?=$has_raid[0]->thumbnail?>')" <?php } ?>>
|
||||
<div class="text-left"><?= date('d', strtotime("$year-$month-$i")) ?></div>
|
||||
<div class="text-right"><?= format_date("$year-$month-$i", 'E') ?></div>
|
||||
|
||||
<?php
|
||||
foreach ($has_raid as $raid) {
|
||||
?>
|
||||
|
||||
<a href="<?= $raid->link ?>" class="group" style="grid-area: 2 / 1 / 3 / 3;">
|
||||
<div class="group-hover:text-<?= $raid->color ?> bg-<?= $raid->color ?>-200"><?= $raid->title ?></div>
|
||||
<?php if ($raid->difficulty) : ?><div class="text-sm text-slate-500">(<?= $raid->difficulty ?>)</div><?php endif; ?>
|
||||
|
@ -85,7 +84,7 @@ get_header();
|
|||
<?php foreach ($raids as $raid) : ?>
|
||||
<a href="<?= $raid->link ?>" class="group text-center p-2 border border-<?= $raid->color ?>">
|
||||
<div class="group-hover:text-<?= $raid->color ?> bg-<?= $raid->color ?>-200"><?= $raid->title ?></div>
|
||||
<div><?=format_date($raid->start,'dd.MM.yyyy HH:mm')?></div>
|
||||
<div><?= format_date($raid->start, 'dd.MM.yyyy HH:mm') ?></div>
|
||||
|
||||
<?php if ($raid->difficulty) : ?><div class="text-sm text-slate-500">(<?= $raid->difficulty ?>)</div><?php endif; ?>
|
||||
</a>
|
||||
|
@ -99,15 +98,16 @@ get_header();
|
|||
<template x-teleport="#sidebar_right">
|
||||
<div class="bg-glass shadow p-auto order-1 hidden lg:block">
|
||||
<div class="flex flex-col gap-2">
|
||||
<h4 class="text-xl font-bold text-center mb-2">Raid importieren</h4>
|
||||
<form action="/request" method="POST">
|
||||
<div class="flex flex-col gap-2">
|
||||
<?php wp_nonce_field('importRaid', 'importRaid_nonce'); ?>
|
||||
<input type="hidden" name="action" value="importRaid">
|
||||
<input type="text" name="id_wowaudit" placeholder="WoW-Audit ID" class="text-black">
|
||||
<button type="submit" class="btn btn-outline btn-hunter">Importieren</a>
|
||||
</div>
|
||||
</form>
|
||||
<h4 class="text-xl font-bold text-center mb-2">Raid importieren</h4>
|
||||
<form action="/request" method="POST">
|
||||
<div class="flex flex-col gap-2">
|
||||
<?php wp_nonce_field('importRaid', 'importRaid_nonce'); ?>
|
||||
<input type="hidden" name="action" value="importRaid">
|
||||
<input type="text" name="id_wowaudit" placeholder="WoW-Audit ID" class="text-black">
|
||||
<button type="submit" class="btn btn-outline btn-hunter">Importieren</a>
|
||||
</div>
|
||||
</form>
|
||||
<!--
|
||||
<div class="text-sm text-center">- oder -</div>
|
||||
<h4 class="text-xl font-bold text-center mb-2 mt-2">Termin erstellen</h4>
|
||||
<form action="/request" method="POST">
|
||||
|
@ -128,7 +128,8 @@ get_header();
|
|||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
-->
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -1,125 +1,125 @@
|
|||
<?php
|
||||
<?php
|
||||
|
||||
use WoWPress\Frontend\Icon;
|
||||
use WoWPress\Frontend\ToggleButton;
|
||||
use WoWPress\Models\Character;
|
||||
use WoWPress\Models\Raid;
|
||||
use WoWPress\Frontend\Icon;
|
||||
use WoWPress\Frontend\ToggleButton;
|
||||
use WoWPress\Models\Character;
|
||||
use WoWPress\Models\Raid;
|
||||
|
||||
|
||||
|
||||
$raid = $GLOBALS['wowpress']['raid'];
|
||||
set_sidebar_status('top', false);
|
||||
set_sidebar_status('left', false);
|
||||
set_sidebar_status('right', false);
|
||||
$raid = $GLOBALS['wowpress']['raid'];
|
||||
set_sidebar_status('top', false);
|
||||
set_sidebar_status('left', false);
|
||||
set_sidebar_status('right', false);
|
||||
|
||||
global $user;
|
||||
global $user;
|
||||
|
||||
if($raid->id_wowaudit){
|
||||
$raid->sync(true);
|
||||
$raid->save();
|
||||
}
|
||||
if ($raid->id_wowaudit) {
|
||||
$raid->sync(true);
|
||||
$raid->save();
|
||||
}
|
||||
|
||||
|
||||
$unknowns = [];
|
||||
|
||||
get_header();
|
||||
?>
|
||||
<div class="top-title flex flex-col lg:flex-row gap-auto" style="margin-top:calc(-1 * var(--wowp-gap))">
|
||||
<?php if ($raid->previous) : ?>
|
||||
<a href="<?= $raid->previous->link ?>" class="btn btn-outline hidden lg:flex">Vorheriger</a>
|
||||
<?php endif; ?>
|
||||
<div class="text-3xl font-bold bg-glass shadow p-3 text-center w-full">
|
||||
<?= $raid->title ?>
|
||||
</div>
|
||||
<?php if ($raid->next) : ?>
|
||||
<a href="<?= $raid->next->link ?>" class="btn btn-outline hidden lg:flex">Nächster</a>
|
||||
<?php endif; ?>
|
||||
$unknowns = [];
|
||||
|
||||
get_header();
|
||||
?>
|
||||
<div class="top-title flex flex-col lg:flex-row gap-auto" style="margin-top:calc(-1 * var(--wowp-gap))">
|
||||
<?php if ($raid->previous) : ?>
|
||||
<a href="<?= $raid->previous->link ?>" class="btn btn-outline hidden lg:flex">Vorheriger</a>
|
||||
<?php endif; ?>
|
||||
<div class="text-3xl font-bold bg-glass shadow p-3 text-center w-full">
|
||||
<?= $raid->title ?>
|
||||
</div>
|
||||
<section id="primary">
|
||||
<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">
|
||||
<?php foreach ($raid->encounters as $encounter) : ?>
|
||||
<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>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
<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>
|
||||
|
||||
|
||||
<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">
|
||||
|
||||
<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) ?>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php
|
||||
else : if ($encounter['id'] == 0) : $unknowns = $signups;
|
||||
endif;
|
||||
endif;
|
||||
endforeach;
|
||||
?>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<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 if ($raid->next) : ?>
|
||||
<a href="<?= $raid->next->link ?>" class="btn btn-outline hidden lg:flex">Nächster</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<section id="primary">
|
||||
<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">
|
||||
<?php foreach ($raid->encounters as $encounter) : ?>
|
||||
<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>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
</section>
|
||||
<?php
|
||||
get_footer();
|
||||
<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>
|
||||
|
||||
|
||||
<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">
|
||||
|
||||
<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) ?>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php
|
||||
else : if ($encounter['id'] == 0) : $unknowns = $signups;
|
||||
endif;
|
||||
endif;
|
||||
endforeach;
|
||||
?>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<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>
|
||||
</div>
|
||||
</main>
|
||||
</section>
|
||||
<?php
|
||||
get_footer();
|
||||
|
|
|
@ -9,17 +9,15 @@ use WoWPress\Models\SKS;
|
|||
set_sidebar_status('top', false);
|
||||
|
||||
$liste = $GLOBALS['wowpress']['liste'];
|
||||
|
||||
#$sks = new SKS();
|
||||
#$sks->list_name = "Normal";
|
||||
#$sks->char_name = "Gasti";
|
||||
#$sks->realm_name = "McGaston";
|
||||
#$sks->rank = 4;
|
||||
#$sks->active = true;
|
||||
#$sks->save();
|
||||
if(!empty($liste)){
|
||||
$liste = SKS::where('list_name',$liste)->first();
|
||||
if(empty($liste->list_name)){
|
||||
$liste = SKS::first();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!$liste) {
|
||||
if (empty($liste->list_name)) {
|
||||
|
||||
$listen = SKS::getLists();
|
||||
|
||||
|
@ -34,19 +32,13 @@ if (!$liste) {
|
|||
<main id="main">
|
||||
<div class="bg-glass shadow p-auto">
|
||||
<?php foreach ($listen as $list) : ?>
|
||||
<a class="btn btn-outline" href="/sks/<?= $list->ID ?>"><?= $list->list_name ?></a>
|
||||
<a class="btn btn-outline" href="/sks/<?= $list->list_name ?>"><?= $list->list_name ?></a>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</main>
|
||||
</section>
|
||||
<?php
|
||||
get_footer();
|
||||
exit;
|
||||
} else {
|
||||
$liste = SKS::find($liste);
|
||||
|
||||
|
||||
|
||||
get_header();
|
||||
?>
|
||||
<div class="top-title flex flex-row gap-2" style="margin-top:calc(-1 * var(--wowp-gap))">
|
||||
|
@ -63,8 +55,9 @@ if (!$liste) {
|
|||
<th class="p-auto w-40">Rang</th>
|
||||
<th class="p-auto">Charakter</th>
|
||||
<th class="p-auto hidden lg:table-cell">Server</th>
|
||||
<th class="p-auto hidden lg:table-cell">Status</th>
|
||||
<?php if (current_user_can('wowpress_edit_raids')) : ?>
|
||||
<th class="p-auto hidden lg:table-cell">Status</th>
|
||||
|
||||
<th class="p-auto w-0">Aktion</th>
|
||||
<?php endif; ?>
|
||||
</tr>
|
||||
|
@ -76,12 +69,22 @@ if (!$liste) {
|
|||
<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">
|
||||
<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>
|
||||
</div>
|
||||
<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 ?>">
|
||||
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
|
||||
</td>
|
||||
<?php else : ?>
|
||||
|
@ -89,25 +92,31 @@ if (!$liste) {
|
|||
<?php endif; ?>
|
||||
<td class="p-auto text-center"><?= $sk->character->name ?></td>
|
||||
<td class="p-auto text-center hidden lg:table-cell"><?= $sk->character->realm ?></td>
|
||||
<td class="p-auto text-center hidden lg:table-cell">
|
||||
<button class="btn w-full btn-outline btn-<?= $sk->active ? $sk->character->color : "slate" ?>"><?= $sk->active ? "Aktiv" : "Inaktiv" ?></button>
|
||||
</td>
|
||||
|
||||
<?php if (current_user_can('wowpress_edit_raids')) : ?>
|
||||
<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>
|
||||
<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">
|
||||
<?php wp_nonce_field('lootSKS', 'lootSKSnonce'); ?>
|
||||
<?php wp_nonce_field('lootSKS', 'lootSKS_nonce'); ?>
|
||||
<input type="hidden" name="action" value="lootSKS">
|
||||
<input type="hidden" name="id" value="<?= $sk->ID ?>">
|
||||
<button type="submit" class="btn btn-outline btn-<?=$sk->character->color?>"><?= Icon::get('o-sparkles') ?></button>
|
||||
<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>
|
||||
</form>
|
||||
<?php else : ?>
|
||||
<form action="/request" method="POST">
|
||||
<?php wp_nonce_field('deleteSKS', 'deleteSKS_nonce'); ?>
|
||||
<input type="hidden" name="action" value="deleteSKS">
|
||||
<input type="hidden" name="id" value="<?= $sk->ID ?>">
|
||||
<button type="submit" class="btn btn-outline btn-gray"><?= Icon::get('o-trash') ?></button>
|
||||
<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>
|
||||
</form>
|
||||
<? endif; ?>
|
||||
|
||||
|
@ -126,27 +135,34 @@ if (!$liste) {
|
|||
</div>
|
||||
</main>
|
||||
</section>
|
||||
<?php if (current_user_can('wowpress_edit_characters')) : ?>
|
||||
<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">
|
||||
<button type="submit" class="btn btn-outline btn-hunter">Hinzufügen</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
if (current_user_can('wowpress_edit_characters')) : ?>
|
||||
<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>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
endif;
|
||||
endif;
|
||||
|
||||
get_footer();
|
||||
|
||||
|
||||
|
||||
get_footer();
|
||||
}
|
||||
?>
|
|
@ -7,8 +7,8 @@ class WoWPressNavWalker extends \Walker_Nav_Menu
|
|||
|
||||
function start_lvl(&$output, $depth=0, $args=null) {
|
||||
$output .= '
|
||||
<div x-show="open" x-transition:enter="transition ease-out duration-100" x-transition:enter-start="transform opacity-0 scale-95" x-transition:enter-end="transform opacity-100 scale-100" x-transition:leave="transition ease-in duration-75" x-transition:leave-start="transform opacity-100 scale-100" x-transition:leave-end="transform opacity-0 scale-95" class="block xl:absolute right-0 w-full mt-2 origin-top-right rounded-md shadow-lg xl:w-48">
|
||||
<div class="px-2 py-2 bg-glass shadow dark-mode:bg-gray-800 w-full flex flex-col gap-2">
|
||||
<div x-cloak x-show="open" x-transition:enter="transition ease-out duration-100" x-transition:enter-start="transform opacity-0 scale-95" x-transition:enter-end="transform opacity-100 scale-100" x-transition:leave="transition ease-in duration-75" x-transition:leave-start="transform opacity-100 scale-100" x-transition:leave-end="transform opacity-0 scale-95" class="block xl:absolute right-0 w-full mt-2 origin-top-right rounded-md shadow-lg xl:w-48">
|
||||
<div x-cloak class="px-2 py-2 bg-glass shadow dark-mode:bg-gray-800 w-full flex flex-col gap-2">
|
||||
';
|
||||
}
|
||||
function end_lvl(&$output, $depth= 0, $args=null) {
|
||||
|
@ -30,7 +30,7 @@ class WoWPressNavWalker extends \Walker_Nav_Menu
|
|||
|
||||
|
||||
if($args->walker->has_children){
|
||||
$output .= '<div @click.away="open = false" class="relative" x-data="{ open: false }">';
|
||||
$output .= '<div x-cloak @click.away="open = false" class="relative" x-data="{ open: false }">';
|
||||
$output .= '<button @click="open = !open" class="w-full nav-btn ' . implode(" ", $item->classes) . '">';
|
||||
}
|
||||
elseif ($item->url && $item->url != '#') {
|
||||
|
|
|
@ -5,6 +5,7 @@ use Illuminate\Support\Facades\Redirect;
|
|||
use WoWPress\Models\Character;
|
||||
use WoWPress\Models\Raid;
|
||||
use WoWPress\Models\Signup;
|
||||
use WoWPress\Models\SKS;
|
||||
use WoWPress\Models\User;
|
||||
|
||||
if (empty($_POST['action'])) {
|
||||
|
@ -90,15 +91,15 @@ switch ($_POST['action']) {
|
|||
if (isset($_POST['importRaid_nonce']) && wp_verify_nonce($_POST['importRaid_nonce'], 'importRaid')) {
|
||||
if (isset($_POST['id_wowaudit'])) {
|
||||
|
||||
if(!empty(Raid::where('id_wowaudit',$_POST['id_wowaudit'])->first())){
|
||||
if (!empty(Raid::where('id_wowaudit', $_POST['id_wowaudit'])->first())) {
|
||||
break;
|
||||
}
|
||||
$raid = new Raid();
|
||||
$raid->id_wowaudit = $_POST['id_wowaudit'];
|
||||
|
||||
|
||||
$raid->sync();
|
||||
|
||||
if(!empty($raid->title)){
|
||||
|
||||
if (!empty($raid->title)) {
|
||||
$raid->save();
|
||||
}
|
||||
}
|
||||
|
@ -142,6 +143,86 @@ switch ($_POST['action']) {
|
|||
}
|
||||
}
|
||||
break;
|
||||
case 'addSKS':
|
||||
isAllowed('wowpress_edit_raids');
|
||||
if (isset($_POST['addSKS_nonce']) && wp_verify_nonce($_POST['addSKS_nonce'], 'addSKS')) {
|
||||
if (isset($_POST['name']) && isset($_POST['realm']) && isset($_POST['list_name'])) {
|
||||
$char = Character::whereName($_POST['name'])->whereRealm($_POST['realm'])->first();
|
||||
if (empty($char->ID)) {
|
||||
$char = new Character();
|
||||
$char->name = $_POST['name'];
|
||||
$char->realm = $_POST['realm'];
|
||||
}
|
||||
|
||||
|
||||
|
||||
$sks = new SKS();
|
||||
$sks->char_name = $char->name;
|
||||
$sks->realm_name = $char->realm;
|
||||
$sks->list_name = $_POST['list_name'];
|
||||
$sks->active = true;
|
||||
$sks_last = SKS::where('list_name', $sks->list_name)->orderBy('rank', 'desc')->first();
|
||||
|
||||
$sks->rank = !empty($sks_last->rank) ? $sks_last->rank + 1 : 1;
|
||||
|
||||
$sks->save();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'toggleSKS':
|
||||
isAllowed('wowpress_edit_raids');
|
||||
if (isset($_POST['toggleSKS_nonce']) && wp_verify_nonce($_POST['toggleSKS_nonce'], 'toggleSKS')) {
|
||||
if (isset($_POST['sks_id'])) {
|
||||
$sks = SKS::find($_POST['sks_id']);
|
||||
if ($sks->ID) {
|
||||
$sks->active = !$sks->active;
|
||||
$sks->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'deleteSKS':
|
||||
isAllowed('wowpress_edit_raids');
|
||||
if (isset($_POST['deleteSKS_nonce']) && wp_verify_nonce($_POST['deleteSKS_nonce'], 'deleteSKS')) {
|
||||
if (isset($_POST['sks_id'])) {
|
||||
$sks = SKS::find($_POST['sks_id']);
|
||||
if ($sks->ID) {
|
||||
$after = $sks->getAfter(false);
|
||||
foreach ($after as $sk) {
|
||||
$sk->rank = $sk->rank - 1;
|
||||
$sk->save();
|
||||
}
|
||||
|
||||
$sks->delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'lootSKS':
|
||||
isAllowed('wowpress_edit_raids');
|
||||
if (isset($_POST['lootSKS_nonce']) && wp_verify_nonce($_POST['lootSKS_nonce'], 'lootSKS')) {
|
||||
if (isset($_POST['sks_id'])) {
|
||||
$sks = SKS::find($_POST['sks_id']);
|
||||
if ($sks->ID) {
|
||||
|
||||
$sks->loot();
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'fixSKS':
|
||||
isAllowed('wowpress_edit_raids');
|
||||
if (isset($_POST['fixSKS_nonce']) && wp_verify_nonce($_POST['fixSKS_nonce'], 'fixSKS')) {
|
||||
if (isset($_POST['sks_id']) && isset($_POST['rank'])) {
|
||||
$sks = SKS::find($_POST['sks_id']);
|
||||
if ($sks->ID) {
|
||||
|
||||
$sks->rank = intval($_POST['rank']);
|
||||
$sks->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
header('Location: ' . $_SERVER['HTTP_REFERER']);
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
?>
|
||||
|
||||
<div class="bg-glass shadow p-auto order-last flex flex-col gap-2">
|
||||
<h3 class="text-xl font-bold text-center"><?= $this->title ?></h3>
|
||||
<h4 class="text-lg font-bold text-center"><?=$instance['raid_name']?></h4>
|
||||
<?php
|
||||
foreach ($instance['bosses'] as $boss) {
|
||||
if (!empty($boss['name'])) :
|
||||
?>
|
||||
<div class="flex flex-row gap-2 justify-around">
|
||||
<div><?= $boss['name'] ?></div>
|
||||
<div><?= $boss['date']?format_date($boss['date']):"Nicht besiegt" ?></div>
|
||||
</div>
|
||||
<?php
|
||||
endif;
|
||||
}
|
||||
?>
|
||||
</div>
|
|
@ -0,0 +1,5 @@
|
|||
<?php
|
||||
?>
|
||||
<div class="bg-glass shadow p-auto order-last">
|
||||
|
||||
</div>
|
|
@ -18,7 +18,7 @@ $character = $user->raiders->first();
|
|||
<?php foreach ($raids as $raid) : ?>
|
||||
<?php
|
||||
?>
|
||||
<div class="border shadow p-auto flex flex-col gap-2">
|
||||
<div class="border shadow p-auto flex flex-col gap-2" style="background-position:center;background-size: cover;background-image:url('<?=$raid->thumbnail?>')">
|
||||
<h1 class="text-xl font-bold text-center"><?= $raid->title ?></h1>
|
||||
<div class="text-center text-<?= $raid->color ?>"><?= $raid->difficulty ?></div>
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ class CreateRaidTable extends CreateTable
|
|||
'difficulty' => 'text NOT NULL',
|
||||
'start' => 'datetime NOT NULL',
|
||||
'end' => 'datetime NOT NULL',
|
||||
'status' => 'text',
|
||||
];
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
<?php
|
||||
|
||||
namespace WoWPress\Frontend\Widgets;
|
||||
|
||||
class BossKills extends Widget
|
||||
{
|
||||
|
||||
protected $template_path = "boss_kills.php";
|
||||
protected $title = "Boss-Kills";
|
||||
protected $base_id = "wowpress_boss_kills";
|
||||
public $name = "Boss-Kills";
|
||||
protected $restricted = false;
|
||||
|
||||
|
||||
|
||||
public function form($instance)
|
||||
{
|
||||
$raid_name = !empty($instance['raid_name']) ? $instance['raid_name'] : ""; ?>
|
||||
<p>
|
||||
<label for="<?php echo esc_attr($this->get_field_id("raid_name")); ?>"><?php echo esc_html__('Raid-Name', 'wowpress'); ?></label>
|
||||
<input type="text" class="widefat" id="<?php echo esc_attr($this->get_field_id("raid_name")); ?>" name="<?php echo esc_attr($this->get_field_name("raid_name")); ?>" value="<?php echo esc_attr($raid_name); ?>">
|
||||
</p>
|
||||
<?php
|
||||
for ($i = 0; $i <= 15; $i++) {
|
||||
$boss_name = !empty($instance['bosses'][$i]['name']) ? $instance['bosses'][$i]['name'] : "";
|
||||
$boss_kill = !empty($instance['bosses'][$i]['date']) ? $instance['bosses'][$i]['date'] : "";
|
||||
?>
|
||||
<p>
|
||||
<label for="<?php echo esc_attr($this->get_field_id("bosses[$i][name]")); ?>"><?php echo esc_html__('Boss-Name', 'wowpress'); ?></label>
|
||||
<input type="text" class="widefat" id="<?php echo esc_attr($this->get_field_id("bosses[$i][name]")); ?>" name="<?php echo esc_attr($this->get_field_name("bosses[$i][name]")); ?>" value="<?php echo esc_attr($boss_name); ?>">
|
||||
</p>
|
||||
<p>
|
||||
<label for="<?php echo esc_attr($this->get_field_id("bosses[$i][date]")); ?>"><?php echo esc_html__('Firstkill', 'wowpress'); ?></label>
|
||||
<input type="date" class="widefat" id="<?php echo esc_attr($this->get_field_id("bosses[$i][date]")); ?>" name="<?php echo esc_attr($this->get_field_name("bosses[$i][date]")); ?>" value="<?php echo esc_attr($boss_kill); ?>">
|
||||
</p>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
public function update($new_instance, $old_instance)
|
||||
{
|
||||
$instance = array();
|
||||
$instance['raid_name'] = (!empty($new_instance['raid_name'])) ? strip_tags($new_instance['raid_name']) : '';
|
||||
|
||||
for ($i = 0; $i <= 15; $i++) {
|
||||
$instance['bosses'][$i]['name'] = (!empty($new_instance['bosses'][$i]['name'])) ? strip_tags($new_instance['bosses'][$i]['name']) : '';
|
||||
$instance['bosses'][$i]['date'] = (!empty($new_instance['bosses'][$i]['date'])) ? strip_tags($new_instance['bosses'][$i]['date']) : '';
|
||||
}
|
||||
|
||||
return $instance;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
|
||||
namespace WoWPress\Frontend\Widgets;
|
||||
|
||||
class CharacterSearch extends Widget
|
||||
{
|
||||
|
||||
protected $template_path = "char_search.php";
|
||||
protected $title = "Charaktersuche";
|
||||
protected $base_id = "wowpress_char_search";
|
||||
public $name = "Charaktersuche";
|
||||
protected $restricted = false;
|
||||
|
||||
protected $classes = [
|
||||
'Death Knight' => [
|
||||
'Frost',
|
||||
'Unholy',
|
||||
'Blood'
|
||||
],
|
||||
'Demon Hunter' => [
|
||||
'Havoc',
|
||||
'Vengeance',
|
||||
],
|
||||
'Druid' => [
|
||||
'Feral',
|
||||
'Balance',
|
||||
'Guardian',
|
||||
'Restoration',
|
||||
]
|
||||
];
|
||||
|
||||
|
||||
public function form($instance)
|
||||
{
|
||||
|
||||
foreach ($this->classes as $class => $specs) {
|
||||
foreach ($specs as $spec) {
|
||||
?>
|
||||
<p>
|
||||
<label for="<?php echo esc_attr($this->get_field_id("classes[$class][$spec]")); ?>"><?php echo esc_html__("$spec - $class", 'wowpress'); ?></label>
|
||||
<input type="text" class="widefat" id="<?php echo esc_attr($this->get_field_id("classes[$class][$spec]")); ?>" name="<?php echo esc_attr($this->get_field_name("classes[$class][$spec]]")); ?>" value="<?php echo esc_attr($instance['classes'][$class][$spec]); ?>">
|
||||
</p>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function update($new_instance, $old_instance)
|
||||
{
|
||||
$instance = array();
|
||||
foreach ($this->classes as $class => $specs) {
|
||||
foreach ($specs as $spec) {
|
||||
$instance['classes'][$class][$spec] = (!empty($new_instance['classes'][$class][$spec])) ? strip_tags($new_instance['classes'][$class][$spec]) : '';
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return $instance;
|
||||
}
|
||||
}
|
|
@ -21,7 +21,6 @@ class Raid extends Model
|
|||
public $notes;
|
||||
|
||||
public $encounters;
|
||||
public $status;
|
||||
public $partial;
|
||||
|
||||
public function __construct($attrs = [])
|
||||
|
@ -124,7 +123,7 @@ class Raid extends Model
|
|||
$sup[$character->id_wowaudit] = $signup['status'];
|
||||
$s = new Signup();
|
||||
$s->character_id = $character->ID;
|
||||
$s->raid_ID = $this->ID;
|
||||
$s->raid_id = $this->ID;
|
||||
if ($this->partial) {
|
||||
foreach ($encounters as $encounter) {
|
||||
if ($signup['selected']) break;
|
||||
|
@ -154,7 +153,7 @@ class Raid extends Model
|
|||
|
||||
$s = new Signup();
|
||||
$s->character_id = $character->ID;
|
||||
$s->raid_ID = $this->ID;
|
||||
$s->raid_id = $this->ID;
|
||||
$s->boss_id = $encounter['id'];
|
||||
$s->status = $selection['selected'] ? "Selected" : $selection['status'];
|
||||
$s->role = $selection['role'];
|
||||
|
@ -212,27 +211,26 @@ class Raid extends Model
|
|||
|
||||
public function getPreviousAttribute()
|
||||
{
|
||||
$id = $this->ID;
|
||||
while ($id) {
|
||||
$raid = Raid::find(--$id);
|
||||
if (!empty($raid->ID)) {
|
||||
return $raid;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
$previous = Raid::where('start','<',$this->start)->orderBy('start','DESC')->first();
|
||||
return $previous;
|
||||
}
|
||||
|
||||
public function getThumbnailAttribute(){
|
||||
|
||||
$clean_name = str_replace([" ","'"],"-",$this->title);
|
||||
$clean_name = preg_replace('/[^a-zA-Z0-9_-]/', '', $clean_name);
|
||||
$clean_name = strtolower($clean_name);
|
||||
|
||||
return "https://data.wowaudit.com/img/$clean_name-small.jpeg";
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function getNextAttribute()
|
||||
{
|
||||
$id = $this->ID;
|
||||
while ($id <= Raid::max('ID')) {
|
||||
$raid = Raid::find(++$id);
|
||||
if (!empty($raid->ID)) {
|
||||
return $raid;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
$next = Raid::where('start','>',$this->start)->orderBy('start','ASC')->first();
|
||||
return $next;
|
||||
}
|
||||
|
||||
public function showSignup($character, $showRole = false, $showStatus = false, $vertical = false)
|
||||
|
|
|
@ -15,17 +15,22 @@ class SKS extends Model
|
|||
|
||||
|
||||
|
||||
public static function getList($name){
|
||||
return static::where('list_name',$name)->orderBy('rank')->get();
|
||||
public static function getList($name)
|
||||
{
|
||||
return static::where('list_name', $name)->orderBy('rank')->get();
|
||||
}
|
||||
|
||||
public static function getLists(){
|
||||
return static::distinct('list_name')->get();
|
||||
|
||||
|
||||
public static function getLists()
|
||||
{
|
||||
return static::groupBy('list_name')->get();
|
||||
}
|
||||
|
||||
public function getCharacterAttribute(){
|
||||
$char= Character::where('name',$this->char_name)->where('realm',$this->realm_name)->first();
|
||||
if(!empty($char->ID)){
|
||||
public function getCharacterAttribute()
|
||||
{
|
||||
$char = Character::where('name', $this->char_name)->where('realm', $this->realm_name)->first();
|
||||
if (!empty($char->ID)) {
|
||||
return $char;
|
||||
}
|
||||
|
||||
|
@ -37,6 +42,84 @@ class SKS extends Model
|
|||
|
||||
return $char;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
public function getAfter($active = true)
|
||||
{
|
||||
$list = static::where('list_name', $this->list_name)->where('rank', ">", $this->rank);
|
||||
if ($active) {
|
||||
$list = $list->where('active', true);
|
||||
}
|
||||
return $list->orderBy('rank')->get();
|
||||
}
|
||||
|
||||
public function getPrevious($active = true)
|
||||
{
|
||||
$prev = SKS::where('list_name', $this->list_name)->where('rank', '<', $this->rank);
|
||||
if ($active) {
|
||||
$prev = $prev->where('active', true);
|
||||
}
|
||||
$prev = $prev->orderBy('rank', 'DESC')->first();
|
||||
|
||||
if (!empty($prev->ID)) {
|
||||
return $prev->rank;
|
||||
} else {
|
||||
return $this->rank;
|
||||
}
|
||||
}
|
||||
|
||||
public function getLastRankAttribute()
|
||||
{
|
||||
$lastSK = SKS::where('list_name', $this->list_name)
|
||||
->where('active', true)
|
||||
->orderBy('rank', 'DESC')->get()->first();
|
||||
|
||||
if (!empty($lastSK->ID)) {
|
||||
return $lastSK->rank;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function roll()
|
||||
{
|
||||
$list = SKS::where('list_name', $this->list_name)->get();
|
||||
$ranks = range(1, count($list));
|
||||
shuffle($ranks);
|
||||
foreach ($list as $key => $sk) {
|
||||
$sk->rank = $ranks[$key];
|
||||
$sk->save();
|
||||
}
|
||||
}
|
||||
|
||||
public function loot()
|
||||
{
|
||||
$after = $this->getAfter();
|
||||
$last_rank = $this->last_rank;
|
||||
foreach ($after as $id => &$sk) {
|
||||
/**
|
||||
* Ignoriere inaktive Charaktere & Charaktere
|
||||
* die auf einem höheren Rang als der Looter sind
|
||||
* und überspringe die restlichen Anweisungen
|
||||
*/
|
||||
if (!$sk->active || $sk->rank < $this->rank) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setze den Rang des Charakters auf den Rang des vorherigen aktiven
|
||||
*/
|
||||
$after[$id]->rank = $sk->getPrevious(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setze den Rang des Looters auf den letzen aktiven Rang
|
||||
*/
|
||||
$this->rank = $last_rank;
|
||||
$this->save();
|
||||
|
||||
foreach ($after as $sk) {
|
||||
$sk->save();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -59,6 +59,12 @@ class Signup extends Model
|
|||
'icon' => 's-star',
|
||||
'color' => 'paladin',
|
||||
],
|
||||
'Too Late' => (object)[
|
||||
'selectable' => false,
|
||||
'name' => 'Anmeldung Vergessen',
|
||||
'icon' => 'o-face-frown',
|
||||
'color' => 'deathknight',
|
||||
],
|
||||
];
|
||||
|
||||
$this->roleList = [
|
||||
|
@ -104,38 +110,52 @@ class Signup extends Model
|
|||
$this->api = new WoWAudit(null, $key);
|
||||
}
|
||||
|
||||
public function character(){
|
||||
public function character()
|
||||
{
|
||||
return $this->belongsTo(Character::class);
|
||||
}
|
||||
|
||||
public function raid(){
|
||||
public function raid()
|
||||
{
|
||||
return $this->belongsTo(Raid::class);
|
||||
}
|
||||
|
||||
public function showForm($showRole = false, $showStatus = false,$vertical = false,$doSignup = true){
|
||||
require(get_template_directory()."/components/raid-signup.php");
|
||||
public function showForm($showRole = false, $showStatus = false, $vertical = false, $doSignup = true)
|
||||
{
|
||||
$tooLate = $this->raid->status == "Locked";
|
||||
$doSignup = $doSignup && !$tooLate;
|
||||
|
||||
if ($this->status == "Unknown" && $tooLate) {
|
||||
$this->setStatus('Too Late');
|
||||
$showStatus = true;
|
||||
$showRole = false;
|
||||
}
|
||||
|
||||
require(get_template_directory() . "/components/raid-signup.php");
|
||||
}
|
||||
|
||||
public function getStatusList($selectable = false){
|
||||
public function getStatusList($selectable = false)
|
||||
{
|
||||
$out = [];
|
||||
foreach($this->statusList as $key => $status){
|
||||
if($selectable){
|
||||
if($status->selectable){
|
||||
$out[$key] = $status;
|
||||
foreach ($this->statusList as $key => $status) {
|
||||
if ($selectable) {
|
||||
if ($status->selectable) {
|
||||
$out[$key] = $status;
|
||||
}
|
||||
}else{
|
||||
$out[$key] = $status;
|
||||
} else {
|
||||
$out[$key] = $status;
|
||||
}
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
public function getRoleList(){
|
||||
public function getRoleList()
|
||||
{
|
||||
$out = [];
|
||||
foreach($this->roleList as $key => $status){
|
||||
if($status->selectable){
|
||||
$out[$key] = $status;
|
||||
foreach ($this->roleList as $key => $status) {
|
||||
if ($status->selectable) {
|
||||
$out[$key] = $status;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -143,21 +163,24 @@ class Signup extends Model
|
|||
}
|
||||
|
||||
|
||||
public function getStatus(){
|
||||
public function getStatus()
|
||||
{
|
||||
if (key_exists($this->status, $this->statusList)) {
|
||||
return $this->statusList[$this->status];
|
||||
}
|
||||
return $this->statusList['Unknown'];
|
||||
}
|
||||
|
||||
public function getRole(){
|
||||
public function getRole()
|
||||
{
|
||||
if (key_exists($this->role, $this->roleList)) {
|
||||
return $this->roleList[$this->role];
|
||||
}
|
||||
return $this->roleList['Unknown'];
|
||||
}
|
||||
|
||||
public function setStatus($status){
|
||||
public function setStatus($status)
|
||||
{
|
||||
if (key_exists($status, $this->statusList)) {
|
||||
$this->status = $status;
|
||||
return true;
|
||||
|
@ -165,7 +188,8 @@ class Signup extends Model
|
|||
return false;
|
||||
}
|
||||
|
||||
public function setRole($role){
|
||||
public function setRole($role)
|
||||
{
|
||||
if (key_exists($role, $this->roleList)) {
|
||||
$this->role = $role;
|
||||
return true;
|
||||
|
@ -173,11 +197,12 @@ class Signup extends Model
|
|||
return false;
|
||||
}
|
||||
|
||||
public function updateAPI(Character $second_char = null){
|
||||
if($second_char->ID){
|
||||
return $this->api->changeSignup($this->raid,$this->character,$this->status,$this->role,$this->comment,$second_char);
|
||||
}else{
|
||||
return $this->api->changeSignup($this->raid,$this->character,$this->status,$this->role,$this->comment);
|
||||
public function updateAPI(Character $second_char = null)
|
||||
{
|
||||
if ($second_char->ID) {
|
||||
return $this->api->changeSignup($this->raid, $this->character, $this->status, $this->role, $this->comment, $second_char);
|
||||
} else {
|
||||
return $this->api->changeSignup($this->raid, $this->character, $this->status, $this->role, $this->comment);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue