305 lines
17 KiB
Twig
305 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);
|
|
}
|
|
.settings-section {
|
|
border-left: 4px solid #667eea;
|
|
padding-left: 1rem;
|
|
margin-bottom: 2rem;
|
|
}
|
|
.nav-pills .nav-link {
|
|
color: #495057;
|
|
border-radius: 0.375rem;
|
|
margin-bottom: 0.5rem;
|
|
}
|
|
.nav-pills .nav-link.active {
|
|
background-color: #667eea;
|
|
color: white;
|
|
}
|
|
</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" href="/admin/categories">
|
|
<i class="fas fa-tags me-2"></i> Kategorien
|
|
</a>
|
|
<a class="nav-link active" 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/settings">Einstellungen</a></li>
|
|
<li class="breadcrumb-item active">Bearbeiten</li>
|
|
</ol>
|
|
</nav>
|
|
<h1 class="h3 mb-0">Einstellungen bearbeiten</h1>
|
|
</div>
|
|
<div class="d-flex align-items-center">
|
|
<span class="text-muted me-3">Willkommen, <?= htmlspecialchars($user_name) ?></span>
|
|
<a href="/admin/settings" 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; ?>
|
|
|
|
<!-- Settings Form -->
|
|
<div class="row">
|
|
<div class="col-lg-3">
|
|
<!-- Navigation -->
|
|
<div class="card">
|
|
<div class="card-header bg-white">
|
|
<h6 class="mb-0">
|
|
<i class="fas fa-list me-2"></i>
|
|
Einstellungskategorien
|
|
</h6>
|
|
</div>
|
|
<div class="card-body p-0">
|
|
<nav class="nav flex-column nav-pills">
|
|
<?php
|
|
$firstCategory = true;
|
|
foreach ($settings as $category => $categorySettings):
|
|
?>
|
|
<a class="nav-link <?= $firstCategory ? 'active' : '' ?>"
|
|
href="#<?= strtolower(str_replace(' ', '-', $category)) ?>"
|
|
data-bs-toggle="pill">
|
|
<i class="fas fa-<?= getCategoryIcon($category) ?> me-2"></i>
|
|
<?= htmlspecialchars($category) ?>
|
|
</a>
|
|
<?php
|
|
$firstCategory = false;
|
|
endforeach;
|
|
?>
|
|
</nav>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="col-lg-9">
|
|
<div class="card">
|
|
<div class="card-header bg-white">
|
|
<h5 class="mb-0">
|
|
<i class="fas fa-edit me-2"></i>
|
|
Einstellungen bearbeiten
|
|
</h5>
|
|
</div>
|
|
<div class="card-body">
|
|
<form method="POST" action="/admin/settings/edit">
|
|
<div class="tab-content">
|
|
<?php
|
|
$firstCategory = true;
|
|
foreach ($settings as $category => $categorySettings):
|
|
?>
|
|
<div class="tab-pane fade <?= $firstCategory ? 'show active' : '' ?>"
|
|
id="<?= strtolower(str_replace(' ', '-', $category)) ?>">
|
|
|
|
<div class="settings-section">
|
|
<h6 class="mb-3">
|
|
<i class="fas fa-<?= getCategoryIcon($category) ?> me-2"></i>
|
|
<?= htmlspecialchars($category) ?>
|
|
</h6>
|
|
|
|
<?php foreach ($categorySettings as $setting): ?>
|
|
<div class="mb-3">
|
|
<label for="setting_<?= $setting['name'] ?>" class="form-label">
|
|
<?= htmlspecialchars($setting['name']) ?>
|
|
<?php if (!empty($setting['description'])): ?>
|
|
<i class="fas fa-info-circle text-muted ms-1"
|
|
title="<?= htmlspecialchars($setting['description']) ?>"></i>
|
|
<?php endif; ?>
|
|
</label>
|
|
|
|
<?php if ($setting['type'] === 'boolean'): ?>
|
|
<div class="form-check">
|
|
<input class="form-check-input"
|
|
type="checkbox"
|
|
name="setting_<?= $setting['name'] ?>"
|
|
id="setting_<?= $setting['name'] ?>"
|
|
value="1"
|
|
<?= $setting['value'] ? 'checked' : '' ?>>
|
|
<label class="form-check-label" for="setting_<?= $setting['name'] ?>">
|
|
Aktiviert
|
|
</label>
|
|
</div>
|
|
<?php elseif ($setting['type'] === 'textarea'): ?>
|
|
<textarea class="form-control"
|
|
name="setting_<?= $setting['name'] ?>"
|
|
id="setting_<?= $setting['name'] ?>"
|
|
rows="3"><?= htmlspecialchars($setting['value']) ?></textarea>
|
|
<?php elseif ($setting['type'] === 'select'): ?>
|
|
<select class="form-select"
|
|
name="setting_<?= $setting['name'] ?>"
|
|
id="setting_<?= $setting['name'] ?>">
|
|
<?php
|
|
$options = json_decode($setting['options'] ?? '[]', true);
|
|
foreach ($options as $option):
|
|
?>
|
|
<option value="<?= $option['value'] ?>"
|
|
<?= $setting['value'] == $option['value'] ? 'selected' : '' ?>>
|
|
<?= htmlspecialchars($option['label']) ?>
|
|
</option>
|
|
<?php endforeach; ?>
|
|
</select>
|
|
<?php else: ?>
|
|
<input type="<?= $setting['type'] ?? 'text' ?>"
|
|
class="form-control"
|
|
name="setting_<?= $setting['name'] ?>"
|
|
id="setting_<?= $setting['name'] ?>"
|
|
value="<?= htmlspecialchars($setting['value']) ?>">
|
|
<?php endif; ?>
|
|
|
|
<?php if (!empty($setting['description'])): ?>
|
|
<div class="form-text"><?= htmlspecialchars($setting['description']) ?></div>
|
|
<?php endif; ?>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
</div>
|
|
<?php
|
|
$firstCategory = false;
|
|
endforeach;
|
|
?>
|
|
</div>
|
|
|
|
<hr class="my-4">
|
|
|
|
<div class="alert alert-info">
|
|
<i class="fas fa-info-circle me-2"></i>
|
|
<strong>Hinweis:</strong> Änderungen werden sofort gespeichert.
|
|
Einige Einstellungen können einen Neustart des Systems erfordern.
|
|
</div>
|
|
|
|
<div class="d-flex justify-content-between">
|
|
<a href="/admin/settings" 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>Einstellungen speichern
|
|
</button>
|
|
</div>
|
|
</form>
|
|
</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 requiredFields = document.querySelectorAll('input[required], select[required], textarea[required]');
|
|
let isValid = true;
|
|
|
|
requiredFields.forEach(field => {
|
|
if (!field.value.trim()) {
|
|
isValid = false;
|
|
field.classList.add('is-invalid');
|
|
} else {
|
|
field.classList.remove('is-invalid');
|
|
}
|
|
});
|
|
|
|
if (!isValid) {
|
|
e.preventDefault();
|
|
alert('Bitte füllen Sie alle Pflichtfelder aus.');
|
|
return false;
|
|
}
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|
|
|
|
<?php
|
|
// Helper function for category icons
|
|
function getCategoryIcon($category) {
|
|
$icons = [
|
|
'Shop Settings' => 'store',
|
|
'Payment Settings' => 'credit-card',
|
|
'Shipping Settings' => 'shipping-fast',
|
|
'Email Settings' => 'envelope',
|
|
'System Settings' => 'cogs',
|
|
'Security Settings' => 'shield-alt'
|
|
];
|
|
|
|
return $icons[$category] ?? 'cog';
|
|
}
|
|
?> |