Members request items from the shop. Their points and the stock are earmarked but not taken until someone with shop.manage approves. Approving books a negative "Lumishop" entry in the Lumipunkte history and takes the stock. For warehouse-backed items it also books a withdrawal to the member in the warehouse. Approved orders are then marked as handed over in the game, or can be reversed, which restores points, stock and the warehouse withdrawal. The management page handles categories and items (price, description, stock). Stock is either the shop's own count, unlimited, or live from a linked warehouse item. Items in stock can be imported from the warehouse, and an item's own stock can be moved into the warehouse to link it there. Warehouse cards show when an item is sold in the shop. Shop bookings can't be deleted from the Lumipunkte page, only reversed in the shop, so orders and points stay in sync. The new permissions go to the Administrator group only, so the shop stays hidden until it is assigned. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
105 lines
6.3 KiB
PHP
105 lines
6.3 KiB
PHP
<?php
|
||
/**
|
||
* Eine Bestellung als Zeile - fuer "Meine Antraege" (shop.php) und die Antragsliste der
|
||
* Verwaltung (shop_orders.php, dort mit $orderView = 'manage' und den Bearbeitungsknoepfen).
|
||
*
|
||
* @var array $order
|
||
* @var string|null $orderView
|
||
* @var string|null $orderReturn Ruecksprung nach einer Aktion
|
||
*/
|
||
$isManageView = ($orderView ?? 'member') === 'manage';
|
||
$status = (string) $order['status'];
|
||
$badgeClass = [
|
||
'pending' => 'badge-pending',
|
||
'approved' => 'shop-badge-approved',
|
||
'delivered' => 'badge-active',
|
||
'rejected' => 'badge-disabled',
|
||
'cancelled' => '',
|
||
][$status] ?? '';
|
||
$return = $orderReturn ?? '/shop.php#antraege';
|
||
?>
|
||
<article class="shop-order shop-order-<?= e($status) ?>">
|
||
<span class="shop-order-icon"><?= warehouse_icon_html($order['icon'] ?? null, (string) $order['item_name'], 44) ?></span>
|
||
<div class="shop-order-body">
|
||
<div class="shop-order-title">
|
||
<strong><?= e(shop_order_label($order)) ?></strong>
|
||
<span class="badge <?= e($badgeClass) ?>"><?= e(shop_status_label($status)) ?></span>
|
||
<span class="text-muted">#<?= (int) $order['id'] ?></span>
|
||
</div>
|
||
<div class="shop-order-meta text-muted">
|
||
<?php if ($isManageView): ?>
|
||
<strong class="shop-order-buyer"><?= e((string) $order['buyer']) ?></strong> ·
|
||
<?php endif; ?>
|
||
beantragt am <?= e(contribution_format_time($order['created_at'])) ?>
|
||
<?php if ((int) $order['quantity'] > 1): ?>
|
||
· <?= (int) $order['quantity'] ?> × <?= contribution_format((int) $order['unit_price']) ?>
|
||
<?php endif; ?>
|
||
</div>
|
||
<?php if (!empty($order['note'])): ?>
|
||
<div class="shop-order-note"><span class="text-muted">Bemerkung:</span> <?= e((string) $order['note']) ?></div>
|
||
<?php endif; ?>
|
||
<?php if ($order['decided_at'] !== null): ?>
|
||
<div class="shop-order-meta text-muted">
|
||
<?= $status === 'rejected' ? 'Abgelehnt' : ($status === 'cancelled' ? 'Storniert' : 'Bewilligt') ?>
|
||
am <?= e(contribution_format_time($order['decided_at'])) ?>
|
||
<?php if (!empty($order['decider'])): ?>von <?= e((string) $order['decider']) ?><?php endif; ?>
|
||
<?php if ($order['delivered_at'] !== null): ?>
|
||
· übergeben am <?= e(contribution_format_time($order['delivered_at'])) ?>
|
||
<?php if (!empty($order['deliverer'])): ?>von <?= e((string) $order['deliverer']) ?><?php endif; ?>
|
||
<?php endif; ?>
|
||
</div>
|
||
<?php elseif ($status === 'cancelled'): ?>
|
||
<div class="shop-order-meta text-muted">Vom Mitglied zurückgezogen.</div>
|
||
<?php endif; ?>
|
||
<?php if (!empty($order['decision_note'])): ?>
|
||
<div class="shop-order-note"><span class="text-muted">Grund:</span> <?= e((string) $order['decision_note']) ?></div>
|
||
<?php endif; ?>
|
||
</div>
|
||
<div class="shop-order-price<?= in_array($status, ['approved', 'delivered'], true) ? ' is-paid' : '' ?>" title="<?= in_array($status, ['approved', 'delivered'], true) ? 'Abgezogen' : ($status === 'pending' ? 'Vorgemerkt' : 'Nicht abgezogen') ?>">
|
||
<?= contribution_coin(18) ?> <?= contribution_format((int) $order['total_price']) ?>
|
||
</div>
|
||
<div class="shop-order-actions">
|
||
<?php if ($isManageView): ?>
|
||
<?php if ($status === 'pending'): ?>
|
||
<form method="post" action="/shop_action.php">
|
||
<?= csrf_field() ?>
|
||
<input type="hidden" name="action" value="approve">
|
||
<input type="hidden" name="order_id" value="<?= (int) $order['id'] ?>">
|
||
<input type="hidden" name="return" value="<?= e($return) ?>">
|
||
<button type="submit" class="button-success button-small" title="Lumipunkte abziehen und zur Übergabe freigeben"><?= icon('check') ?> Bewilligen</button>
|
||
</form>
|
||
<form method="post" action="/shop_action.php" data-prompt="Grund für die Ablehnung (optional, sieht das Mitglied):">
|
||
<?= csrf_field() ?>
|
||
<input type="hidden" name="action" value="reject">
|
||
<input type="hidden" name="order_id" value="<?= (int) $order['id'] ?>">
|
||
<input type="hidden" name="reason" value="">
|
||
<input type="hidden" name="return" value="<?= e($return) ?>">
|
||
<button type="submit" class="button-secondary button-small"><?= icon('x') ?> Ablehnen</button>
|
||
</form>
|
||
<?php elseif ($status === 'approved'): ?>
|
||
<form method="post" action="/shop_action.php">
|
||
<?= csrf_field() ?>
|
||
<input type="hidden" name="action" value="deliver">
|
||
<input type="hidden" name="order_id" value="<?= (int) $order['id'] ?>">
|
||
<input type="hidden" name="return" value="<?= e($return) ?>">
|
||
<button type="submit" class="button-small" title="Im Spiel übergeben"><?= icon('check') ?> Übergeben</button>
|
||
</form>
|
||
<form method="post" action="/shop_action.php" data-prompt="Bestellung stornieren? Die Lumipunkte gehen zurück an das Mitglied und der Bestand wird wieder aufgefüllt. Grund (optional):">
|
||
<?= csrf_field() ?>
|
||
<input type="hidden" name="action" value="revoke">
|
||
<input type="hidden" name="order_id" value="<?= (int) $order['id'] ?>">
|
||
<input type="hidden" name="reason" value="">
|
||
<input type="hidden" name="return" value="<?= e($return) ?>">
|
||
<button type="submit" class="icon-button icon-button-danger" title="Stornieren" aria-label="Stornieren"><?= icon('restore') ?></button>
|
||
</form>
|
||
<?php endif; ?>
|
||
<?php elseif ($status === 'pending'): ?>
|
||
<form method="post" action="/shop_action.php" onsubmit="return confirm('Antrag zurückziehen?');">
|
||
<?= csrf_field() ?>
|
||
<input type="hidden" name="action" value="cancel">
|
||
<input type="hidden" name="order_id" value="<?= (int) $order['id'] ?>">
|
||
<button type="submit" class="button-secondary button-small">Zurückziehen</button>
|
||
</form>
|
||
<?php endif; ?>
|
||
</div>
|
||
</article>
|