Funktions-Schalter je Mandant (app/features.php, tenant_features): der Betreiber schaltet FAQ, Selbsteintrag, PDF, PayPal-Eingang, CSV-Import, Mailversand, Jahresabschluss, Datenexport und eigenes Design pro Mandant frei. Gesperrte Funktionen verschwinden aus Menue und Schaltflaechen, ihre Seiten weisen Aufrufe und POSTs ab. Das Back-Office ist jetzt fuer Platform-Admins im Menue verlinkt statt nur per URL erreichbar. Eigenes Design je Mandant: Akzentfarbe und Logo in den Mandant- Einstellungen, eingebettet ueber app/branding.php; das Logo liegt geschuetzt in var/tenant_logos und wird nur ueber tenant-logo-anzeigen.php an den eigenen Mandanten ausgeliefert. Weniger Startinformationen: Startpaket neuer Mandanten auf zwei Beispielfragen gekuerzt, Anleitung von ~1400 auf ~750 Woerter gestrafft und um Abschnitte zu gesperrten Funktionen bereinigt. Vorder-/Rueckseite erst bei mehr als 50 Personen (vorher schon ab 50). Die Schwelle liegt jetzt gemeinsam in app/ledger.php und gilt auch fuer die Vorder-/Rueckseiten-Auswahl beim Erfassen, wo sie bisher unabhaengig von der Teamgroesse angeboten wurde. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
161 lines
4.7 KiB
PHP
161 lines
4.7 KiB
PHP
<?php
|
|
|
|
include "functions.php";
|
|
require_once __DIR__ . "/app/ledger.php";
|
|
require_once __DIR__ . "/app/faq.php";
|
|
require_once __DIR__ . "/app/audit.php";
|
|
require_once __DIR__ . "/app/features.php";
|
|
app_require_csrf();
|
|
include "header.php";
|
|
include "headerline.php";
|
|
include "nav.php";
|
|
|
|
?>
|
|
|
|
|
|
|
|
<!-- Banner -->
|
|
<section id="banner">
|
|
<div class="content">
|
|
|
|
<?php
|
|
|
|
$pdo = app_db_pdo();
|
|
$saasUser = saas_current_user($pdo);
|
|
$tenantId = 0;
|
|
$hasAccess = false;
|
|
$kannVerwalten = false;
|
|
|
|
if ($saasUser !== null) {
|
|
$tenantId = (int)$saasUser['tenant_id'];
|
|
$hasAccess = true;
|
|
$kannVerwalten = saas_user_has_role(['owner', 'admin'], $saasUser);
|
|
}
|
|
|
|
if (!$hasAccess) {
|
|
echo "<h2>Kein Zugriff</h2>";
|
|
include "footer.php";
|
|
exit;
|
|
}
|
|
|
|
if (!app_feature_enabled($pdo, $tenantId, 'faq')) {
|
|
echo app_feature_notice_html('faq');
|
|
include "footer.php";
|
|
exit;
|
|
}
|
|
|
|
$meldung = null;
|
|
$fehler = null;
|
|
$bearbeitenId = null;
|
|
|
|
if ($kannVerwalten && $_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
$aktion = $_POST['aktion'] ?? '';
|
|
$actorUserId = $saasUser['user_id'] ?? null;
|
|
|
|
if ($aktion === 'anlegen') {
|
|
if (faq_create($pdo, $tenantId, (string)($_POST['question'] ?? ''), (string)($_POST['answer'] ?? ''))) {
|
|
app_audit_log($pdo, $tenantId, $actorUserId, 'faq.created', 'faq_entry', null);
|
|
$meldung = 'Frage wurde hinzugefügt.';
|
|
} else {
|
|
$fehler = 'Bitte Frage und Antwort ausfüllen.';
|
|
}
|
|
} elseif ($aktion === 'bearbeiten') {
|
|
$bearbeitenId = (int)($_POST['id'] ?? 0);
|
|
} elseif ($aktion === 'speichern') {
|
|
$id = (int)($_POST['id'] ?? 0);
|
|
if (faq_update($pdo, $tenantId, $id, (string)($_POST['question'] ?? ''), (string)($_POST['answer'] ?? ''))) {
|
|
app_audit_log($pdo, $tenantId, $actorUserId, 'faq.updated', 'faq_entry', $id);
|
|
$meldung = 'Frage wurde aktualisiert.';
|
|
} else {
|
|
$fehler = 'Bitte Frage und Antwort ausfüllen.';
|
|
$bearbeitenId = $id;
|
|
}
|
|
} elseif ($aktion === 'loeschen') {
|
|
$id = (int)($_POST['id'] ?? 0);
|
|
if (faq_soft_delete($pdo, $tenantId, $id)) {
|
|
app_audit_log($pdo, $tenantId, $actorUserId, 'faq.deleted', 'faq_entry', $id);
|
|
$meldung = 'Frage wurde entfernt.';
|
|
}
|
|
}
|
|
}
|
|
|
|
$eintraege = faq_fetch_all($pdo, $tenantId);
|
|
$bearbeitenEintrag = null;
|
|
if ($bearbeitenId !== null) {
|
|
foreach ($eintraege as $eintrag) {
|
|
if ($eintrag['id'] === $bearbeitenId) {
|
|
$bearbeitenEintrag = $eintrag;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
?>
|
|
|
|
<h2>FAQ - Kaffeeliste</h2>
|
|
|
|
<?php if ($meldung !== null): ?>
|
|
<div class="hint-box success"><p><?php echo saas_html($meldung); ?></p></div>
|
|
<?php endif; ?>
|
|
<?php if ($fehler !== null): ?>
|
|
<div class="hint-box error"><p><?php echo saas_html($fehler); ?></p></div>
|
|
<?php endif; ?>
|
|
|
|
<?php if ($eintraege === []): ?>
|
|
<p>Für dieses Team wurden noch keine Fragen hinterlegt.</p>
|
|
<?php endif; ?>
|
|
|
|
<?php foreach ($eintraege as $eintrag): ?>
|
|
<div class="faq-entry">
|
|
<?php if ($kannVerwalten && $bearbeitenEintrag !== null && $bearbeitenEintrag['id'] === $eintrag['id']): ?>
|
|
<form method="post" action="faq.php">
|
|
<?php echo app_csrf_field(); ?>
|
|
<input type="hidden" name="aktion" value="speichern">
|
|
<input type="hidden" name="id" value="<?php echo (int)$eintrag['id']; ?>">
|
|
<label>Frage:</label>
|
|
<input type="text" name="question" value="<?php echo saas_html($eintrag['question']); ?>" required>
|
|
<label>Antwort:</label>
|
|
<textarea name="answer" required><?php echo saas_html($eintrag['answer']); ?></textarea>
|
|
<button type="submit">Speichern</button>
|
|
<a href="faq.php" class="button">Abbrechen</a>
|
|
</form>
|
|
<?php else: ?>
|
|
<p><b><?php echo saas_html($eintrag['question']); ?></b></p>
|
|
<p><?php echo nl2br(saas_html($eintrag['answer'])); ?></p>
|
|
<?php if ($kannVerwalten): ?>
|
|
<form method="post" action="faq.php" style="display:inline">
|
|
<?php echo app_csrf_field(); ?>
|
|
<input type="hidden" name="aktion" value="bearbeiten">
|
|
<input type="hidden" name="id" value="<?php echo (int)$eintrag['id']; ?>">
|
|
<button type="submit">Bearbeiten</button>
|
|
</form>
|
|
<form method="post" action="faq.php" style="display:inline" onsubmit="return confirm('Diese Frage wirklich entfernen?');">
|
|
<?php echo app_csrf_field(); ?>
|
|
<input type="hidden" name="aktion" value="loeschen">
|
|
<input type="hidden" name="id" value="<?php echo (int)$eintrag['id']; ?>">
|
|
<button type="submit">Entfernen</button>
|
|
</form>
|
|
<?php endif; ?>
|
|
<?php endif; ?>
|
|
</div>
|
|
<br>
|
|
<?php endforeach; ?>
|
|
|
|
<?php if ($kannVerwalten): ?>
|
|
<h3>Neue Frage hinzufügen</h3>
|
|
<form method="post" action="faq.php">
|
|
<?php echo app_csrf_field(); ?>
|
|
<input type="hidden" name="aktion" value="anlegen">
|
|
<label>Frage:</label>
|
|
<input type="text" name="question" required>
|
|
<label>Antwort:</label>
|
|
<textarea name="answer" required></textarea>
|
|
<button type="submit">Frage hinzufügen</button>
|
|
</form>
|
|
<?php endif; ?>
|
|
|
|
</div>
|
|
</section>
|
|
|
|
<?php include "footer.php"; ?>
|