Quelltext des aktuellen Standes
<?php
$this->layout('layouts/admin', [
'page_title' => 'Leihgeräte-Einstellungen',
'current_admin_page' => 'loans-settings',
]);
$flash = $this->flash();
$pdf = $pdf_templates ?? [];
$email = $email_templates ?? [];
$emailDesc = [
'loan_confirmation' => 'Wird an den Ausleiher gesendet, wenn ein Gerät ausgegeben oder reserviert wurde (Leihschein als PDF im Anhang).',
'loan_return_confirmation' => 'Wird an den Ausleiher gesendet, sobald ein Leihgerät zurückgenommen wurde (Rückgabeschein als Anhang).',
'loan_overdue' => 'Erinnerung, wenn ein Leihgerät nicht rechtzeitig zurückgegeben wurde.',
'loan_request_approved' => 'Wird gesendet, wenn eine Leihanfrage genehmigt wurde.',
'loan_request_rejected' => 'Wird gesendet, wenn eine Leihanfrage abgelehnt wurde.',
];
$fmt = static function ($d) {
return $d ? date('d.m.Y H:i', strtotime((string)$d)) : null;
};
?>
<div class="loans-admin">
<?php if (!empty($flash['success'])): ?>
<div class="alert alert-success"><?= $this->e($flash['success']) ?></div>
<?php endif; ?>
<?php if (!empty($flash['error'])): ?>
<div class="alert alert-danger"><?= $this->e($flash['error']) ?></div>
<?php endif; ?>
<!-- Unterschriften-Bedingungen -->
<section class="loans-section">
<h2><?= $this->te('Unterschriften-Seite') ?></h2>
<p class="section-desc"><?= $this->t('Bedingungen, die beim Unterschreiben eines Leihvorgangs auf dem Tablet angezeigt und (als <code>{{terms}}</code>) im Leihschein eingesetzt werden.') ?></p>
<div class="template-grid">
<div class="template-card">
<div class="tpl-header">
<span class="tpl-icon">📝</span>
<div class="tpl-info">
<h3><?= $this->te('Leihgeräte-Bedingungen') ?></h3>
<p class="tpl-key">loan_terms</p>
</div>
</div>
<p class="tpl-desc"><?= $this->te('Rechtliche Hinweise & Nutzungsbedingungen für die Geräteausleihe.') ?></p>
<div class="tpl-footer">
<span class="tpl-updated"><?= $fmt($terms_updated ?? null) ? 'Zuletzt: ' . $fmt($terms_updated) : '' ?></span>
<div class="tpl-actions">
<a href="/admin/loans/terms" class="btn btn-sm btn-primary"><?= $this->te('✎ Bearbeiten') ?></a>
<form action="/admin/loans/terms/reset" method="POST"
onsubmit="return confirm('Standard-Bedingungen wiederherstellen? Eigene Änderungen gehen verloren.')">
<input type="hidden" name="_csrf" value="<?= $this->csrf() ?>">
<button type="submit" class="btn btn-sm btn-reset" title="<?= $this->te('Standard wiederherstellen') ?>"><?= $this->te('↻ Standard') ?></button>
</form>
</div>
</div>
</div>
</div>
</section>
<!-- PDF-Vorlagen -->
<section class="loans-section">
<h2><?= $this->te('PDF-Vorlagen') ?></h2>
<p class="section-desc"><?= $this->te('Layout der generierten Leih- und Rückgabescheine (WYSIWYG, mit Platzhaltern).') ?></p>
<div class="template-grid">
<?php foreach ($pdf as $tpl): ?>
<div class="template-card">
<div class="tpl-header">
<span class="tpl-icon">📄</span>
<div class="tpl-info">
<h3><?= $this->e($tpl['label']) ?></h3>
<p class="tpl-key"><?= $this->e($tpl['key']) ?></p>
</div>
</div>
<div class="tpl-footer">
<span class="tpl-updated"><?= $fmt($tpl['updated_at']) ? 'Zuletzt: ' . $fmt($tpl['updated_at']) : '' ?></span>
<div class="tpl-actions">
<a href="/admin/loans/pdf/<?= urlencode($tpl['key']) ?>" class="btn btn-sm btn-primary"><?= $this->te('✎ Bearbeiten') ?></a>
<form action="/admin/loans/pdf/<?= urlencode($tpl['key']) ?>/reset" method="POST"
onsubmit="return confirm('Standard-Vorlage wiederherstellen? Eigene Änderungen gehen verloren.')">
<input type="hidden" name="_csrf" value="<?= $this->csrf() ?>">
<button type="submit" class="btn btn-sm btn-reset" title="<?= $this->te('Standard wiederherstellen') ?>"><?= $this->te('↻ Standard') ?></button>
</form>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
</section>
<!-- Benachrichtigungen (optional aktivierbar) -->
<section class="loans-section">
<h2><?= $this->te('Benachrichtigungen') ?></h2>
<p class="section-desc"><?= $this->te('Legt fest, welche automatischen E-Mails das Leihgeräte-Modul versendet. Deaktivierte Benachrichtigungen werden nicht verschickt (die Vorlagen bleiben erhalten).') ?></p>
<form action="/admin/loans/notifications" method="POST">
<input type="hidden" name="_csrf" value="<?= $this->csrf() ?>">
<div class="loan-notify-list">
<?php foreach (($notify_toggles ?? []) as $t): ?>
<label class="loan-notify-item">
<input type="checkbox" name="notify_<?= $this->e($t['key']) ?>" value="1" <?= !empty($t['enabled']) ? 'checked' : '' ?>>
<span><?= $this->e($t['label']) ?></span>
</label>
<?php endforeach; ?>
</div>
<div style="margin-top:1rem;">
<button type="submit" class="btn btn-sm btn-primary"><?= $this->te('Speichern') ?></button>
</div>
</form>
</section>
<!-- E-Mail-Vorlagen -->
<section class="loans-section">
<h2><?= $this->te('E-Mail-Vorlagen') ?></h2>
<p class="section-desc"><?= $this->te('E-Mails an den Ausleiher rund um Ausgabe, Rückgabe, Erinnerungen und Leihanfragen.') ?></p>
<div class="template-grid">
<?php foreach ($email as $tpl): ?>
<div class="template-card">
<div class="tpl-header">
<span class="tpl-icon">✉</span>
<div class="tpl-info">
<h3><?= $this->e($tpl['label']) ?></h3>
<p class="tpl-key"><?= $this->e($tpl['key']) ?></p>
</div>
</div>
<p class="tpl-desc"><?= $emailDesc[$tpl['key']] ?? '' ?></p>
<div class="tpl-preview"><strong><?= $this->te('Betreff:') ?></strong> <?= $this->e($tpl['subject']) ?></div>
<div class="tpl-footer">
<span class="tpl-updated"><?= $fmt($tpl['updated_at']) ? 'Zuletzt: ' . $fmt($tpl['updated_at']) : '' ?></span>
<div class="tpl-actions">
<form action="/admin/loans/email/<?= urlencode($tpl['key']) ?>/test" method="POST">
<input type="hidden" name="_csrf" value="<?= $this->csrf() ?>">
<button type="submit" class="btn btn-sm btn-secondary" title="<?= $this->te('Test-E-Mail an mich senden') ?>"><?= $this->te('✉ Test') ?></button>
</form>
<a href="/admin/loans/email/<?= urlencode($tpl['key']) ?>" class="btn btn-sm btn-primary"><?= $this->te('✎ Bearbeiten') ?></a>
<form action="/admin/loans/email/<?= urlencode($tpl['key']) ?>/reset" method="POST"
onsubmit="return confirm('Standard-Vorlage wiederherstellen? Eigene Änderungen gehen verloren.')">
<input type="hidden" name="_csrf" value="<?= $this->csrf() ?>">
<button type="submit" class="btn btn-sm btn-reset" title="<?= $this->te('Standard wiederherstellen') ?>"><?= $this->te('↻ Standard') ?></button>
</form>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
</section>
</div>
<style>
.loans-admin { display: flex; flex-direction: column; gap: 1.5rem; }
.loans-section { background: var(--color-bg); border-radius: .25rem; padding: 1.5rem; box-shadow: 0 1px 3px rgba(0,0,0,.05); }
.loans-section h2 { margin: 0 0 .25rem; font-size: 1.1rem; font-weight: 600; color: var(--gray-900); }
.section-desc { color: var(--gray-500); font-size: .85rem; margin: 0 0 1.25rem; }
.section-desc code { background: var(--gray-100); padding: .1rem .35rem; border-radius: .25rem; font-size: .8rem; }
.template-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 1rem; }
.template-card { border: 1px solid var(--gray-200); border-radius: .375rem; padding: 1.25rem; display: flex; flex-direction: column; gap: .75rem; }
.tpl-header { display: flex; align-items: center; gap: .75rem; }
.tpl-icon { font-size: 1.5rem; }
.tpl-info h3 { margin: 0; font-size: 1rem; font-weight: 600; color: var(--gray-900); }
.tpl-key { margin: 0; font-size: .7rem; color: var(--gray-400); font-family: monospace; }
.tpl-desc { font-size: .8rem; color: var(--gray-500); margin: 0; }
.tpl-preview { background: var(--gray-50); padding: .5rem .75rem; border-radius: .375rem; font-size: .8rem; color: var(--gray-700); }
.tpl-footer { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding-top: .5rem; border-top: 1px solid var(--gray-100); margin-top: auto; }
.tpl-updated { font-size: .72rem; color: var(--gray-400); }
.tpl-actions { display: flex; gap: .4rem; flex-wrap: wrap; }
.tpl-actions form { display: inline; margin: 0; }
.loan-notify-list { display: flex; flex-direction: column; gap: .6rem; }
.loan-notify-item { display: flex; align-items: center; gap: .6rem; font-size: .88rem; color: var(--gray-700); cursor: pointer; }
.loan-notify-item input[type=checkbox] { width: 16px; height: 16px; flex-shrink: 0; cursor: pointer; accent-color: var(--color-primary); }
.btn-reset { background: var(--orange-50); border: 1px solid var(--orange-200); color: var(--orange-700); }
@media (max-width: 768px) { .template-grid { grid-template-columns: 1fr; } }
</style>