- Raids: "Max. Spieler" only whole numbers up to groups x 5 (max. 10 groups / 50), gearscore only a number; fixed +1 Lumipunkt per participation, other values only with the new raids.points permission; pick an existing premade per group when creating a raid; unchanged legacy values no longer block editing - Raid page updates itself every 15 s while visible (raids_live.php, cards rendered by includes/raid_card.php), open editors and confirm dialogs are kept - Restore takes the new raid_id from the bot (archived messages are now deleted in Discord) and moves settings, attendance and awards; website signups send the server display name - Premades: dissolve by leadership needs a reason, lead gets DMs on join/assign/decline/remove (source/actor_id sent to the bot), transfer picker skips players who already lead a group, website accept keeps the one-group rule, no commas in names - Site-wide Lumina dialog (assets/js/confirm-dialog.js) replaces confirm/prompt/alert via data-confirm; error flashes are a dialog you confirm with OK - Calendar: audience per entry (all / leadership takes part / internal) with the new calendar.leadership permission; day cells list all entries and scroll - Gear planner: main-hand picker filtered by the set's class, mismatches marked, "keine Klasse" option, link to an external skill/Daevanion plan per set - Map: correct kisk icons (Elyos on Verteron/Abyss, Altgard fixed), per-map max zoom and bounded panning, German texts, data source note - Tactics: toolbar as a uniform grid, whole-tactic copy, automatic versions with restore and a 90-day trash, official tactics protected - Global thin gold scrollbars, readable hover colours, "Sedes Luminis" spelling, patch notes and README, schema version 34 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
308 lines
18 KiB
PHP
308 lines
18 KiB
PHP
<?php
|
||
require_once __DIR__ . '/includes/bootstrap.php';
|
||
require_once __DIR__ . '/includes/shop.php';
|
||
require_permission('shop.manage');
|
||
|
||
warehouse_sync_catalog();
|
||
|
||
$categories = shop_categories();
|
||
$items = shop_items(false);
|
||
$pendingCount = shop_pending_count();
|
||
|
||
// Lagerhaus-Gegenstaende fuer die Vorschlagsliste (Bild/Verknuepfung) und zum Uebernehmen:
|
||
// alles, was auf Lager ist und noch nicht im Shop steht (ohne Kina).
|
||
$warehouseItems = db()->query('SELECT id, name, category, icon FROM warehouse_items ORDER BY name')->fetchAll();
|
||
$linkedIds = array_filter(array_map(static fn (array $i): int => (int) $i['warehouse_item_id'], $items));
|
||
$warehouseStock = warehouse_stock();
|
||
$importable = array_values(array_filter(
|
||
$warehouseStock,
|
||
static fn (array $row): bool => $row['category'] !== 'currency' && !in_array((int) $row['id'], $linkedIds, true)
|
||
));
|
||
|
||
// Eingaben nach einem Fehler (siehe shop_manage_action.php)
|
||
$old = $_SESSION['shop_item_form'] ?? null;
|
||
unset($_SESSION['shop_item_form']);
|
||
|
||
/** Daten eines Gegenstands fuer den Bearbeiten-Dialog. */
|
||
function shop_item_form_data(array $item): string
|
||
{
|
||
return (string) json_encode([
|
||
'id' => (int) $item['id'],
|
||
'name' => (string) $item['name'],
|
||
'category_id' => $item['category_id'] !== null ? (string) $item['category_id'] : '',
|
||
'description' => (string) ($item['description'] ?? ''),
|
||
'price' => (string) $item['price'],
|
||
'stock_mode' => (string) $item['stock_mode'],
|
||
'stock' => (string) $item['stock'],
|
||
'warehouse_item' => (string) ($item['warehouse_name'] ?? ''),
|
||
'active' => (bool) (int) $item['active'],
|
||
], JSON_UNESCAPED_UNICODE);
|
||
}
|
||
|
||
$pageTitle = 'Lumishop verwalten';
|
||
$containerWide = true;
|
||
include __DIR__ . '/includes/header.php';
|
||
?>
|
||
<div class="panel">
|
||
<div class="warehouse-head">
|
||
<div>
|
||
<h1>Lumishop verwalten</h1>
|
||
<p class="text-muted"><?= count($items) ?> Gegenstände, davon <?= count(array_filter($items, static fn (array $i): bool => (bool) (int) $i['active'])) ?> im Angebot.</p>
|
||
</div>
|
||
<div class="actions">
|
||
<a class="button button-secondary" href="/shop.php">Zum Shop</a>
|
||
<a class="button button-secondary" href="/shop_orders.php">Anträge<?= $pendingCount > 0 ? ' <span class="shop-count">' . $pendingCount . '</span>' : '' ?></a>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="panel">
|
||
<div class="warehouse-head">
|
||
<h2>Gegenstände</h2>
|
||
<div class="actions">
|
||
<button type="button" class="button-success" data-open-modal="shop-item-modal" data-item="">+ Gegenstand anlegen</button>
|
||
<button type="button" class="button-secondary" data-open-modal="shop-import-modal" <?= empty($importable) ? 'disabled title="Alles, was im Lagerhaus liegt, steht schon im Shop"' : '' ?>>Aus dem Lagerhaus übernehmen</button>
|
||
</div>
|
||
</div>
|
||
|
||
<?php if (empty($items)): ?>
|
||
<p class="text-muted">Noch keine Gegenstände. Lege einen an oder übernimm Gegenstände aus dem Lagerhaus – deren Bestand gleicht der Shop dann automatisch ab.</p>
|
||
<?php else: ?>
|
||
<div class="table-scroll">
|
||
<table class="table-actions shop-manage-table">
|
||
<thead>
|
||
<tr>
|
||
<th>Gegenstand</th>
|
||
<th>Kategorie</th>
|
||
<th class="num">Preis</th>
|
||
<th>Bestand</th>
|
||
<th>Aktionen</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<?php foreach ($items as $item): ?>
|
||
<?php $stock = shop_stock($item); ?>
|
||
<tr class="<?= (int) $item['active'] ? '' : 'is-inactive' ?>">
|
||
<td>
|
||
<span class="warehouse-item-inline">
|
||
<?= shop_icon_html($item, 32) ?>
|
||
<span>
|
||
<?= e((string) $item['name']) ?>
|
||
<?php if (!(int) $item['active']): ?><span class="badge">nicht im Angebot</span><?php endif; ?>
|
||
</span>
|
||
</span>
|
||
</td>
|
||
<td><?= $item['category_name'] !== null ? e((string) $item['category_name']) : '<span class="text-muted">-</span>' ?></td>
|
||
<td class="num"><?= contribution_coin(16) ?> <?= contribution_format((int) $item['price']) ?></td>
|
||
<td>
|
||
<?php if ($item['stock_mode'] === 'unlimited'): ?>
|
||
Unbegrenzt
|
||
<?php else: ?>
|
||
<?= number_format((int) $stock, 0, ',', '.') ?>
|
||
<?php if ($item['stock_mode'] === 'warehouse'): ?>
|
||
<span class="badge shop-badge-warehouse" title="Bestand kommt aus dem Lagerhaus (<?= e((string) ($item['warehouse_name'] ?? '?')) ?>)">Lagerhaus</span>
|
||
<?php endif; ?>
|
||
<?php endif; ?>
|
||
<?php if ((int) $item['reserved'] > 0): ?>
|
||
<span class="text-muted">· <?= (int) $item['reserved'] ?> beantragt</span>
|
||
<?php endif; ?>
|
||
</td>
|
||
<td>
|
||
<div class="actions">
|
||
<button type="button" class="icon-button" title="Bearbeiten" aria-label="Bearbeiten"
|
||
data-open-modal="shop-item-modal" data-item="<?= e(shop_item_form_data($item)) ?>"><?= icon('edit') ?></button>
|
||
<form class="inline-form" method="post" action="/shop_manage_action.php">
|
||
<?= csrf_field() ?>
|
||
<input type="hidden" name="action" value="item_toggle">
|
||
<input type="hidden" name="item_id" value="<?= (int) $item['id'] ?>">
|
||
<button type="submit" class="icon-button" title="<?= (int) $item['active'] ? 'Aus dem Angebot nehmen' : 'Ins Angebot aufnehmen' ?>"
|
||
aria-label="<?= (int) $item['active'] ? 'Aus dem Angebot nehmen' : 'Ins Angebot aufnehmen' ?>"><?= icon((int) $item['active'] ? 'archive' : 'restore') ?></button>
|
||
</form>
|
||
<?php if ($item['stock_mode'] === 'manual'): ?>
|
||
<form class="inline-form" method="post" action="/shop_manage_action.php"
|
||
data-confirm="<?= e('„' . $item['name'] . '“ mit dem Lagerhaus verknüpfen?' . ((int) $item['stock'] > 0 ? ' Der Shop-Bestand von ' . (int) $item['stock'] . ' Stück wird dort eingelagert.' : '') . ' Danach kommt der Bestand automatisch aus dem Lagerhaus.') ?>" data-confirm-title="Mit dem Lagerhaus verknüpfen" data-confirm-ok="Verknüpfen">
|
||
<?= csrf_field() ?>
|
||
<input type="hidden" name="action" value="to_warehouse">
|
||
<input type="hidden" name="item_id" value="<?= (int) $item['id'] ?>">
|
||
<button type="submit" class="icon-button" title="Ins Lagerhaus übertragen und verknüpfen" aria-label="Ins Lagerhaus übertragen"><?= icon('box') ?></button>
|
||
</form>
|
||
<?php endif; ?>
|
||
<form class="inline-form" method="post" action="/shop_manage_action.php"
|
||
data-confirm="<?= e('„' . $item['name'] . '“ aus dem Shop löschen? Bisherige Anträge bleiben erhalten.') ?>" data-confirm-title="Gegenstand löschen" data-confirm-danger data-confirm-ok="Löschen">
|
||
<?= csrf_field() ?>
|
||
<input type="hidden" name="action" value="item_delete">
|
||
<input type="hidden" name="item_id" value="<?= (int) $item['id'] ?>">
|
||
<button type="submit" class="icon-button icon-button-danger" title="Löschen" aria-label="Löschen"><?= icon('trash') ?></button>
|
||
</form>
|
||
</div>
|
||
</td>
|
||
</tr>
|
||
<?php endforeach; ?>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
<?php endif; ?>
|
||
</div>
|
||
|
||
<div class="panel">
|
||
<h2>Kategorien</h2>
|
||
<p class="text-muted">Die Reihenfolge bestimmt, wie die Kategorien im Shop sortiert sind (kleinere Zahl zuerst).</p>
|
||
<div class="shop-categories">
|
||
<?php foreach ($categories as $category): ?>
|
||
<div class="shop-category-row">
|
||
<form method="post" action="/shop_manage_action.php" class="shop-category-form">
|
||
<?= csrf_field() ?>
|
||
<input type="hidden" name="action" value="category_save">
|
||
<input type="hidden" name="category_id" value="<?= (int) $category['id'] ?>">
|
||
<input type="text" name="name" maxlength="80" required value="<?= e((string) $category['name']) ?>" aria-label="Name">
|
||
<input type="number" name="sort_order" value="<?= (int) $category['sort_order'] ?>" class="shop-sort-input" aria-label="Reihenfolge" title="Reihenfolge">
|
||
<button type="submit" class="button-secondary">Speichern</button>
|
||
</form>
|
||
<form method="post" action="/shop_manage_action.php" class="inline-form"
|
||
data-confirm="<?= e('Kategorie „' . $category['name'] . '“ löschen? Ihre Gegenstände bleiben ohne Kategorie im Shop.') ?>" data-confirm-title="Kategorie löschen" data-confirm-danger data-confirm-ok="Löschen">
|
||
<?= csrf_field() ?>
|
||
<input type="hidden" name="action" value="category_delete">
|
||
<input type="hidden" name="category_id" value="<?= (int) $category['id'] ?>">
|
||
<button type="submit" class="icon-button icon-button-danger" title="Kategorie löschen" aria-label="Kategorie löschen"><?= icon('trash') ?></button>
|
||
</form>
|
||
</div>
|
||
<?php endforeach; ?>
|
||
<form method="post" action="/shop_manage_action.php" class="shop-category-form shop-category-new">
|
||
<?= csrf_field() ?>
|
||
<input type="hidden" name="action" value="category_save">
|
||
<input type="text" name="name" maxlength="80" required placeholder="Neue Kategorie, z.B. Ausrüstung" aria-label="Neue Kategorie">
|
||
<input type="number" name="sort_order" value="<?= count($categories) * 10 + 10 ?>" class="shop-sort-input" aria-label="Reihenfolge" title="Reihenfolge">
|
||
<button type="submit">+ Anlegen</button>
|
||
</form>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- Gegenstand anlegen / bearbeiten -->
|
||
<div class="modal-overlay" id="shop-item-modal" <?= $old !== null ? '' : 'hidden' ?>
|
||
data-old="<?= $old !== null ? e((string) json_encode($old, JSON_UNESCAPED_UNICODE)) : '' ?>">
|
||
<div class="modal">
|
||
<button type="button" class="modal-close icon-button" title="Schließen"><?= icon('x') ?></button>
|
||
<h2 id="shop-item-title">Gegenstand anlegen</h2>
|
||
<form method="post" action="/shop_manage_action.php" id="shop-item-form">
|
||
<?= csrf_field() ?>
|
||
<input type="hidden" name="action" value="item_save">
|
||
<input type="hidden" name="item_id" value="">
|
||
<div>
|
||
<label for="shop-item-name">Name</label>
|
||
<div class="item-picker" data-picker-items="shop-warehouse-list" data-picker-empty="Kein Lagerhaus-Gegenstand mit diesem Namen - der Name ist frei wählbar.">
|
||
<label class="search-field">
|
||
<span class="item-picker-icon"><?= icon('search') ?></span>
|
||
<input type="text" class="item-picker-input" id="shop-item-name" name="name" maxlength="150" required placeholder="Name eingeben oder aus dem Lagerhaus wählen …">
|
||
</label>
|
||
</div>
|
||
</div>
|
||
<div class="warehouse-row">
|
||
<div>
|
||
<label for="shop-item-category">Kategorie</label>
|
||
<select id="shop-item-category" name="category_id">
|
||
<option value="">– ohne Kategorie –</option>
|
||
<?php foreach ($categories as $category): ?>
|
||
<option value="<?= (int) $category['id'] ?>"><?= e((string) $category['name']) ?></option>
|
||
<?php endforeach; ?>
|
||
</select>
|
||
</div>
|
||
<div>
|
||
<label for="shop-item-price">Preis in Lumipunkten</label>
|
||
<input type="number" id="shop-item-price" name="price" min="0" max="<?= SHOP_MAX_PRICE ?>" required>
|
||
</div>
|
||
</div>
|
||
<div>
|
||
<label for="shop-item-description">Beschreibung <span class="text-muted">(optional)</span></label>
|
||
<textarea id="shop-item-description" name="description" maxlength="500" rows="2"></textarea>
|
||
</div>
|
||
<div class="warehouse-row">
|
||
<div>
|
||
<label for="shop-item-mode">Bestand</label>
|
||
<select id="shop-item-mode" name="stock_mode">
|
||
<?php foreach (SHOP_STOCK_MODES as $value => $label): ?>
|
||
<option value="<?= e($value) ?>"><?= e($label) ?></option>
|
||
<?php endforeach; ?>
|
||
</select>
|
||
</div>
|
||
<div data-mode-field="manual">
|
||
<label for="shop-item-stock">Stückzahl im Shop</label>
|
||
<input type="number" id="shop-item-stock" name="stock" min="0" max="<?= SHOP_MAX_STOCK ?>" value="0">
|
||
</div>
|
||
</div>
|
||
<div>
|
||
<label for="shop-item-warehouse">Lagerhaus-Gegenstand <span class="text-muted" data-mode-hint>(optional, für das Bild)</span></label>
|
||
<div class="item-picker" data-picker-items="shop-warehouse-list" data-picker-empty="Kein Lagerhaus-Gegenstand mit diesem Namen.">
|
||
<label class="search-field">
|
||
<span class="item-picker-icon"><?= icon('search') ?></span>
|
||
<input type="text" class="item-picker-input" id="shop-item-warehouse" name="warehouse_item" maxlength="150"
|
||
placeholder="Leer lassen = gleicher Name wie oben, falls es ihn im Lagerhaus gibt">
|
||
</label>
|
||
</div>
|
||
<div class="field-hint" data-mode-field="warehouse">Der Bestand im Shop ist der Lagerbestand dieses Gegenstands. Beim Bewilligen wird die Entnahme automatisch im Lagerhaus gebucht.</div>
|
||
</div>
|
||
<label class="checkbox-label">
|
||
<input type="checkbox" name="active" value="1" checked> Im Shop anbieten
|
||
</label>
|
||
<div class="actions">
|
||
<button type="submit" class="button-success">Speichern</button>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
</div>
|
||
<script type="application/json" id="shop-warehouse-list"><?= warehouse_picker_json($warehouseItems, array_map('intval', array_column($warehouseStock, 'quantity', 'id'))) ?></script>
|
||
|
||
<!-- Aus dem Lagerhaus uebernehmen -->
|
||
<?php if (!empty($importable)): ?>
|
||
<div class="modal-overlay" id="shop-import-modal" hidden>
|
||
<div class="modal modal-wide">
|
||
<button type="button" class="modal-close icon-button" title="Schließen"><?= icon('x') ?></button>
|
||
<h2>Aus dem Lagerhaus übernehmen</h2>
|
||
<p class="text-muted">Die ausgewählten Gegenstände kommen in den Shop. Ihr Bestand wird laufend aus dem Lagerhaus übernommen, bewilligte Anträge werden dort automatisch als Entnahme gebucht.</p>
|
||
<form method="post" action="/shop_manage_action.php">
|
||
<?= csrf_field() ?>
|
||
<input type="hidden" name="action" value="import_warehouse">
|
||
<div class="warehouse-row">
|
||
<div>
|
||
<label for="shop-import-category">Kategorie für alle</label>
|
||
<select id="shop-import-category" name="category_id">
|
||
<option value="">– ohne Kategorie –</option>
|
||
<?php foreach ($categories as $category): ?>
|
||
<option value="<?= (int) $category['id'] ?>"><?= e((string) $category['name']) ?></option>
|
||
<?php endforeach; ?>
|
||
</select>
|
||
</div>
|
||
<div>
|
||
<label for="shop-import-price">Preis für alle ausgewählten</label>
|
||
<div class="shop-import-price">
|
||
<input type="number" id="shop-import-price" min="0" max="<?= SHOP_MAX_PRICE ?>" placeholder="z.B. 50">
|
||
<button type="button" class="button-secondary button-small" id="shop-import-apply">Übernehmen</button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="shop-import-list">
|
||
<label class="shop-import-row shop-import-all">
|
||
<input type="checkbox" id="shop-import-all"> <strong>Alle auswählen</strong>
|
||
</label>
|
||
<?php foreach ($importable as $row): ?>
|
||
<div class="shop-import-row">
|
||
<label>
|
||
<input type="checkbox" name="warehouse_ids[]" value="<?= (int) $row['id'] ?>" class="shop-import-check">
|
||
<?= warehouse_icon_html($row['icon'] ?? null, (string) $row['name'], 28) ?>
|
||
<span><?= e((string) $row['name']) ?></span>
|
||
<span class="text-muted"><?= number_format((int) $row['quantity'], 0, ',', '.') ?> auf Lager</span>
|
||
</label>
|
||
<input type="number" name="prices[<?= (int) $row['id'] ?>]" min="0" max="<?= SHOP_MAX_PRICE ?>" placeholder="Preis" class="shop-import-row-price" aria-label="Preis für <?= e((string) $row['name']) ?>">
|
||
</div>
|
||
<?php endforeach; ?>
|
||
</div>
|
||
<div class="actions">
|
||
<button type="submit" class="button-success">Ausgewählte übernehmen</button>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
</div>
|
||
<?php endif; ?>
|
||
|
||
<script src="<?= e(asset_url('/assets/js/item-picker.js')) ?>"></script>
|
||
<script src="<?= e(asset_url('/assets/js/shop.js')) ?>"></script>
|
||
<?php include __DIR__ . '/includes/footer.php'; ?>
|