Quelltext des aktuellen Standes
<?php
$this->layout('layouts/main', [
'page_title' => $page_title,
'current_route' => $current_route,
'full_width' => true,
'extra_css' => ['/assets/css/catalog.css?v=' . filemtime(dirname(__DIR__, 2) . '/public/assets/css/catalog.css')],
]);
$categories = $categories ?? [];
?>
<div class="cat-wrap">
<div class="content-header">
<div>
<h1><?= $this->te('Katalog-Einstellungen') ?></h1>
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="/"><?= $this->te('Home') ?></a></li>
<li class="breadcrumb-item"><a href="/catalog"><?= $this->te('Ausstattung & Preise') ?></a></li>
<li class="breadcrumb-item active"><?= $this->te('Einstellungen') ?></li>
</ol>
</div>
<div class="content-header-actions">
<a href="/catalog" class="btn btn-default"><i class="fas fa-arrow-left"></i> <?= $this->te('Zurück') ?></a>
</div>
</div>
<div class="page-body">
<!-- Grundeinstellungen -->
<form method="post" action="/catalog/settings" style="margin-bottom:1.25rem;">
<input type="hidden" name="_csrf" value="<?= $this->e($this->csrf()) ?>">
<div class="detail-card">
<div class="detail-card-header">
<span class="detail-card-title"><i class="fas fa-sliders-h"></i> <?= $this->te('Grundeinstellungen') ?></span>
</div>
<div class="detail-card-body">
<div class="form-row-2">
<div class="form-group">
<label for="vat"><?= $this->te('Standard-MwSt.-Satz (%)') ?></label>
<input type="text" inputmode="decimal" id="vat" name="vat_default" class="form-control" value="<?= number_format((float)($vat_default ?? 19), 0) ?>">
<small class="form-hint"><?= $this->te('Vorbelegung beim Erfassen neuer Preise; je Eintrag überschreibbar.') ?></small>
</div>
<div class="form-group">
<label><?= $this->te('Währung') ?></label>
<div><strong><?= $this->e($this->currency()) ?></strong></div>
<small class="form-hint"><?= $this->te('Gilt für die ganze Installation und wird unter Administration → Einstellungen gepflegt.') ?></small>
</div>
</div>
<div class="form-row-2">
<div class="form-group">
<label for="display"><?= $this->te('Standard-Preisanzeige') ?></label>
<select id="display" name="price_display" class="form-control" data-searchable>
<option value="net" <?= ($price_display ?? 'net') !== 'gross' ? 'selected' : '' ?>><?= $this->te('Netto') ?></option>
<option value="gross" <?= ($price_display ?? 'net') === 'gross' ? 'selected' : '' ?>><?= $this->te('Brutto') ?></option>
</select>
</div>
<div class="form-group">
<label for="stale"><?= $this->te('Preis „veraltet" nach (Monaten)') ?></label>
<input type="number" id="stale" name="stale_months" class="form-control" min="0" max="120" value="<?= (int)($stale_months ?? 12) ?>">
<small class="form-hint"><?= $this->te('Ältere Preise werden markiert. 0 = keine Markierung.') ?></small>
</div>
</div>
<button type="submit" class="btn btn-primary"><i class="fas fa-save"></i> <?= $this->te('Einstellungen speichern') ?></button>
</div>
</div>
</form>
<!-- Kategorien -->
<div class="detail-card">
<div class="detail-card-header">
<span class="detail-card-title"><i class="fas fa-folder"></i> <?= $this->te('Kategorien') ?></span>
</div>
<div class="detail-card-body">
<p class="text-muted" style="margin-top:0;"><?= $this->te('Gruppierung der Artikel (z. B. Notebooks, Monitore, Lizenzen).') ?></p>
<?php if (!empty($categories)): ?>
<?php // Formulare per HTML5 form-Attribut mit den Zellen-Feldern verknüpft (kein Form-Span über <td>). ?>
<?php foreach ($categories as $c): ?>
<form id="catcat-<?= (int)$c['id'] ?>" method="post" action="/catalog/categories">
<input type="hidden" name="_csrf" value="<?= $this->e($this->csrf()) ?>">
<input type="hidden" name="id" value="<?= (int)$c['id'] ?>">
</form>
<form id="catdel-<?= (int)$c['id'] ?>" method="post" action="/catalog/categories/<?= (int)$c['id'] ?>/delete"
onsubmit="return confirm('Kategorie löschen? Artikel bleiben erhalten (ohne Kategorie).');">
<input type="hidden" name="_csrf" value="<?= $this->e($this->csrf()) ?>">
</form>
<?php endforeach; ?>
<div class="table-wrapper">
<table class="data-table">
<thead><tr><th scope="col"><?= $this->te('Name') ?></th><th scope="col" class="cat-col-num"><?= $this->te('Reihenfolge') ?></th><th scope="col"></th></tr></thead>
<tbody>
<?php foreach ($categories as $c): ?>
<tr>
<td><input type="text" form="catcat-<?= (int)$c['id'] ?>" name="name" class="form-control form-control-sm" value="<?= $this->e($c['name']) ?>" maxlength="150"></td>
<td class="cat-col-num"><input type="number" form="catcat-<?= (int)$c['id'] ?>" name="sort_order" class="form-control form-control-sm" value="<?= (int)$c['sort_order'] ?>" style="width:5rem;"></td>
<td>
<button type="submit" form="catcat-<?= (int)$c['id'] ?>" class="btn btn-default btn-xs" title="<?= $this->te('Speichern') ?>"><i class="fas fa-save"></i></button>
<button type="submit" form="catdel-<?= (int)$c['id'] ?>" class="btn btn-outline-danger btn-xs" title="<?= $this->te('Löschen') ?>"><i class="fas fa-times"></i></button>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php else: ?>
<div class="empty-state"><p><?= $this->te('Noch keine Kategorien.') ?></p></div>
<?php endif; ?>
<form method="post" action="/catalog/categories" class="cat-cat-add">
<input type="hidden" name="_csrf" value="<?= $this->e($this->csrf()) ?>">
<div class="form-group">
<label for="new-cat"><?= $this->te('Neue Kategorie') ?></label>
<input type="text" id="new-cat" name="name" class="form-control" maxlength="150" placeholder="<?= $this->te('z. B. Notebooks') ?>" required>
</div>
<div class="form-group">
<label for="new-cat-sort"><?= $this->te('Reihenfolge') ?></label>
<input type="number" id="new-cat-sort" name="sort_order" class="form-control" value="0">
</div>
<button type="submit" class="btn btn-primary"><i class="fas fa-plus"></i> <?= $this->te('Anlegen') ?></button>
</form>
</div>
</div>
</div>
</div>