314 lines
17 KiB
Twig
314 lines
17 KiB
Twig
<!DOCTYPE html>
|
|
<html lang="de">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title><?= $title ?></title>
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
|
|
<style>
|
|
.sidebar {
|
|
min-height: 100vh;
|
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
}
|
|
.sidebar .nav-link {
|
|
color: rgba(255,255,255,0.8);
|
|
padding: 0.75rem 1rem;
|
|
border-radius: 0.375rem;
|
|
margin: 0.25rem 0;
|
|
}
|
|
.sidebar .nav-link:hover,
|
|
.sidebar .nav-link.active {
|
|
color: white;
|
|
background: rgba(255,255,255,0.1);
|
|
}
|
|
.main-content {
|
|
background-color: #f8f9fa;
|
|
min-height: 100vh;
|
|
}
|
|
.card {
|
|
border: none;
|
|
box-shadow: 0 0.125rem 0.25rem rgba(0,0,0,0.075);
|
|
}
|
|
.form-control:focus {
|
|
border-color: #667eea;
|
|
box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
|
|
}
|
|
.category-tree {
|
|
max-height: 300px;
|
|
overflow-y: auto;
|
|
border: 1px solid #dee2e6;
|
|
border-radius: 0.375rem;
|
|
padding: 1rem;
|
|
}
|
|
.category-item {
|
|
padding: 0.5rem;
|
|
border-radius: 0.375rem;
|
|
margin-bottom: 0.25rem;
|
|
background: #f8f9fa;
|
|
border: 1px solid #e9ecef;
|
|
}
|
|
.category-item.subcategory {
|
|
background: #e9ecef;
|
|
border-left: 3px solid #667eea;
|
|
margin-left: 1rem;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="container-fluid">
|
|
<div class="row">
|
|
<!-- Sidebar -->
|
|
<div class="col-md-3 col-lg-2 px-0">
|
|
<div class="sidebar p-3">
|
|
<div class="d-flex align-items-center mb-4">
|
|
<i class="fas fa-shopping-cart text-white me-2"></i>
|
|
<h5 class="text-white mb-0">Webshop Admin</h5>
|
|
</div>
|
|
|
|
<nav class="nav flex-column">
|
|
<a class="nav-link" href="/admin/dashboard">
|
|
<i class="fas fa-tachometer-alt me-2"></i> Dashboard
|
|
</a>
|
|
<a class="nav-link" href="/admin/products">
|
|
<i class="fas fa-box me-2"></i> Produkte
|
|
</a>
|
|
<a class="nav-link" href="/admin/customers">
|
|
<i class="fas fa-users me-2"></i> Kunden
|
|
</a>
|
|
<a class="nav-link" href="/admin/orders">
|
|
<i class="fas fa-shopping-bag me-2"></i> Bestellungen
|
|
</a>
|
|
<a class="nav-link active" href="/admin/categories">
|
|
<i class="fas fa-tags me-2"></i> Kategorien
|
|
</a>
|
|
<a class="nav-link" href="/admin/settings">
|
|
<i class="fas fa-cog me-2"></i> Einstellungen
|
|
</a>
|
|
<hr class="text-white-50">
|
|
<a class="nav-link" href="/admin/logout">
|
|
<i class="fas fa-sign-out-alt me-2"></i> Abmelden
|
|
</a>
|
|
</nav>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Main Content -->
|
|
<div class="col-md-9 col-lg-10">
|
|
<div class="main-content p-4">
|
|
<!-- Header -->
|
|
<div class="d-flex justify-content-between align-items-center mb-4">
|
|
<div>
|
|
<nav aria-label="breadcrumb">
|
|
<ol class="breadcrumb mb-0">
|
|
<li class="breadcrumb-item"><a href="/admin/categories">Kategorien</a></li>
|
|
<li class="breadcrumb-item active">Neue Kategorie</li>
|
|
</ol>
|
|
</nav>
|
|
<h1 class="h3 mb-0">Neue Kategorie erstellen</h1>
|
|
</div>
|
|
<div class="d-flex align-items-center">
|
|
<span class="text-muted me-3">Willkommen, <?= htmlspecialchars($user_name) ?></span>
|
|
<a href="/admin/categories" class="btn btn-secondary">
|
|
<i class="fas fa-arrow-left me-2"></i>Zurück
|
|
</a>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Alerts -->
|
|
<?php if (isset($_GET['error'])): ?>
|
|
<div class="alert alert-danger alert-dismissible fade show" role="alert">
|
|
<i class="fas fa-exclamation-circle me-2"></i><?= htmlspecialchars($_GET['error']) ?>
|
|
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<!-- Create Category Form -->
|
|
<div class="row justify-content-center">
|
|
<div class="col-lg-8">
|
|
<div class="card">
|
|
<div class="card-header bg-white">
|
|
<h5 class="mb-0">
|
|
<i class="fas fa-plus me-2"></i>
|
|
Kategorieinformationen
|
|
</h5>
|
|
</div>
|
|
<div class="card-body">
|
|
<form method="POST" action="/admin/categories/create">
|
|
<div class="row">
|
|
<div class="col-md-8 mb-3">
|
|
<label for="name" class="form-label">
|
|
Kategoriename <span class="text-danger">*</span>
|
|
</label>
|
|
<input type="text"
|
|
class="form-control"
|
|
id="name"
|
|
name="name"
|
|
value="<?= htmlspecialchars($_POST['name'] ?? '') ?>"
|
|
required>
|
|
<div class="form-text">Der Name der Kategorie (wird für Navigation verwendet)</div>
|
|
</div>
|
|
|
|
<div class="col-md-4 mb-3">
|
|
<label for="sort_order" class="form-label">Sortierung</label>
|
|
<input type="number"
|
|
class="form-control"
|
|
id="sort_order"
|
|
name="sort_order"
|
|
value="<?= htmlspecialchars($_POST['sort_order'] ?? '0') ?>"
|
|
min="0">
|
|
<div class="form-text">Niedrigere Zahlen werden zuerst angezeigt</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
<label for="description" class="form-label">Beschreibung</label>
|
|
<textarea class="form-control"
|
|
id="description"
|
|
name="description"
|
|
rows="3"><?= htmlspecialchars($_POST['description'] ?? '') ?></textarea>
|
|
<div class="form-text">Optionale Beschreibung der Kategorie</div>
|
|
</div>
|
|
|
|
<div class="row">
|
|
<div class="col-md-6 mb-3">
|
|
<label for="parent_id" class="form-label">Übergeordnete Kategorie</label>
|
|
<select class="form-select" name="parent_id" id="parent_id">
|
|
<option value="">Hauptkategorie (keine Überkategorie)</option>
|
|
<?php foreach ($categories as $cat): ?>
|
|
<option value="<?= $cat['id'] ?>"
|
|
<?= ($_POST['parent_id'] ?? '') == $cat['id'] ? 'selected' : '' ?>>
|
|
<?= htmlspecialchars($cat['name']) ?>
|
|
</option>
|
|
<?php endforeach; ?>
|
|
</select>
|
|
<div class="form-text">Wählen Sie eine übergeordnete Kategorie für Unterkategorien</div>
|
|
</div>
|
|
|
|
<div class="col-md-6 mb-3">
|
|
<label class="form-label">Status</label>
|
|
<div class="form-check">
|
|
<input class="form-check-input"
|
|
type="checkbox"
|
|
name="active"
|
|
id="active"
|
|
value="1"
|
|
<?= isset($_POST['active']) ? 'checked' : '' ?>>
|
|
<label class="form-check-label" for="active">
|
|
Kategorie ist aktiv
|
|
</label>
|
|
</div>
|
|
<div class="form-text">Inaktive Kategorien werden nicht angezeigt</div>
|
|
</div>
|
|
</div>
|
|
|
|
<hr class="my-4">
|
|
|
|
<div class="alert alert-info">
|
|
<i class="fas fa-info-circle me-2"></i>
|
|
<strong>Hinweis:</strong> Kategorien können später jederzeit bearbeitet werden.
|
|
Die Hierarchie kann nachträglich geändert werden.
|
|
</div>
|
|
|
|
<div class="d-flex justify-content-between">
|
|
<a href="/admin/categories" class="btn btn-secondary">
|
|
<i class="fas fa-times me-2"></i>Abbrechen
|
|
</a>
|
|
<button type="submit" class="btn btn-primary">
|
|
<i class="fas fa-save me-2"></i>Kategorie erstellen
|
|
</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Existing Categories -->
|
|
<div class="card mt-4">
|
|
<div class="card-header bg-white">
|
|
<h6 class="mb-0">
|
|
<i class="fas fa-sitemap me-2"></i>
|
|
Bestehende Kategorien
|
|
</h6>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="category-tree">
|
|
<?php if (empty($categories)): ?>
|
|
<p class="text-muted text-center mb-0">Keine Kategorien vorhanden</p>
|
|
<?php else: ?>
|
|
<?php
|
|
function renderCategoryTree($categories, $parent_id = null, $level = 0) {
|
|
foreach ($categories as $category) {
|
|
if ($category['parent_id'] == $parent_id) {
|
|
$indent = str_repeat(' ', $level);
|
|
$class = $level > 0 ? 'subcategory' : '';
|
|
echo '<div class="category-item ' . $class . '">';
|
|
echo $indent . '<i class="fas fa-tag me-2"></i>';
|
|
echo htmlspecialchars($category['name']);
|
|
echo '</div>';
|
|
renderCategoryTree($categories, $category['id'], $level + 1);
|
|
}
|
|
}
|
|
}
|
|
renderCategoryTree($categories);
|
|
?>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Help Card -->
|
|
<div class="card mt-4">
|
|
<div class="card-header bg-light">
|
|
<h6 class="mb-0">
|
|
<i class="fas fa-question-circle me-2"></i>
|
|
Hilfe
|
|
</h6>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="row">
|
|
<div class="col-md-6">
|
|
<h6>Pflichtfelder</h6>
|
|
<ul class="list-unstyled">
|
|
<li><i class="fas fa-check text-success me-2"></i>Kategoriename</li>
|
|
</ul>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<h6>Optionale Felder</h6>
|
|
<ul class="list-unstyled">
|
|
<li><i class="fas fa-info text-info me-2"></i>Beschreibung</li>
|
|
<li><i class="fas fa-info text-info me-2"></i>Übergeordnete Kategorie</li>
|
|
<li><i class="fas fa-info text-info me-2"></i>Sortierung</li>
|
|
<li><i class="fas fa-info text-info me-2"></i>Status</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<hr>
|
|
<div class="alert alert-warning mb-0">
|
|
<i class="fas fa-exclamation-triangle me-2"></i>
|
|
<strong>Wichtig:</strong> Der Kategoriename muss eindeutig sein.
|
|
Eine Kategorie mit demselben Namen kann nicht erstellt werden.
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
|
<script>
|
|
// Form validation
|
|
document.querySelector('form').addEventListener('submit', function(e) {
|
|
const name = document.getElementById('name').value;
|
|
|
|
if (!name.trim()) {
|
|
e.preventDefault();
|
|
alert('Bitte geben Sie einen Kategorienamen ein.');
|
|
return false;
|
|
}
|
|
});
|
|
</script>
|
|
</body>
|
|
</html> |