Betreiber-Zentralstelle, Mandanten-Design und schlankerer Einstieg

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>
This commit is contained in:
2026-08-17 22:52:55 +02:00
co-authored by Claude Opus 5
parent a93e067e04
commit d24ee9bf91
30 changed files with 881 additions and 172 deletions
+57 -1
View File
@@ -4,10 +4,12 @@ require_once __DIR__ . '/functions.php';
require_once __DIR__ . '/app/audit.php';
require_once __DIR__ . '/app/billing.php';
require_once __DIR__ . '/app/tenant-logo.php';
require_once __DIR__ . '/app/features.php';
$pdo = app_db_pdo();
$user = saas_require_login();
$canManageSettings = saas_can_manage_tenant_settings($user);
$brandingEnabled = app_feature_enabled($pdo, (int)$user['tenant_id'], 'branding');
$errors = [];
$saved = false;
$settings = null;
@@ -15,12 +17,39 @@ $settings = null;
if ($canManageSettings) {
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
app_require_csrf();
$result = saas_update_tenant_settings($pdo, (int)$user['tenant_id'], $_POST);
$eingaben = $_POST;
// Ohne freigeschaltetes Design fehlt das Farbfeld im Formular. Der
// gespeicherte Wert wird dann durchgereicht statt geleert, damit eine
// spaetere Freischaltung die alte Farbe wiederfindet.
if (!$brandingEnabled) {
$bestehend = saas_fetch_tenant_settings($pdo, (int)$user['tenant_id']);
$eingaben['brand_color'] = (string)($bestehend['brand_color'] ?? '');
}
$result = saas_update_tenant_settings($pdo, (int)$user['tenant_id'], $eingaben);
if ($result['ok']) {
$saved = true;
$settings = $result['settings'];
app_audit_log($pdo, (int)$user['tenant_id'], (int)$user['user_id'], 'tenant_settings.updated', 'tenant', (int)$user['tenant_id']);
$tenantIdLogo = (int)$user['tenant_id'];
// Marken-Logo der App-Oberflaeche: nur wenn der Betreiber das
// eigene Design fuer diesen Mandanten freigeschaltet hat.
if ($brandingEnabled) {
if (!empty($_POST['brand_logo_remove'])) {
tenant_logo_delete((string)($settings['brand_logo'] ?? ''));
$pdo->prepare("UPDATE tenant_settings SET brand_logo = '' WHERE tenant_id = ?")->execute([$tenantIdLogo]);
$settings['brand_logo'] = '';
} elseif (isset($_FILES['brand_logo_file']) && ($_FILES['brand_logo_file']['error'] ?? UPLOAD_ERR_NO_FILE) === UPLOAD_ERR_OK) {
$brandResult = tenant_logo_store($tenantIdLogo, $_FILES['brand_logo_file'], 'brand');
if ($brandResult['ok']) {
$pdo->prepare('UPDATE tenant_settings SET brand_logo = ? WHERE tenant_id = ?')->execute([$brandResult['filename'], $tenantIdLogo]);
$settings['brand_logo'] = $brandResult['filename'];
} else {
$errors[] = $brandResult['error'];
}
}
}
if (!empty($_POST['pdf_watermark_logo_remove'])) {
tenant_logo_delete((string)($settings['pdf_watermark_logo'] ?? ''));
$pdo->prepare("UPDATE tenant_settings SET pdf_watermark_logo = '' WHERE tenant_id = ?")->execute([$tenantIdLogo]);
@@ -59,6 +88,8 @@ if ($canManageSettings) {
'pdf_footer_text' => $_POST['pdf_footer_text'] ?? '',
'payment_reminder_enabled' => !empty($_POST['payment_reminder_enabled']) ? 1 : 0,
'payment_reminder_interval_days' => $_POST['payment_reminder_interval_days'] ?? 7,
'brand_color' => $_POST['brand_color'] ?? '',
'brand_logo' => (string)(saas_fetch_tenant_settings($pdo, (int)$user['tenant_id'])['brand_logo'] ?? ''),
];
}
} else {
@@ -200,6 +231,31 @@ include 'nav.php';
<label for="pdf_footer_text">Hinweis in der Fußzeile des Ausdrucks (leer = keine Fußzeile)</label>
<input type="text" name="pdf_footer_text" id="pdf_footer_text" maxlength="500" value="<?php echo saas_html($settings['pdf_footer_text']); ?>">
</div>
<?php if ($brandingEnabled): ?>
<div class="col-12">
<h3>Eigenes Design</h3>
<p>Logo und Akzentfarbe für die Oberfläche eurer Kaffeeliste. Leere Felder =
Standarddesign. Das Logo hier erscheint sichtbar in der Kopfzeile jeder Seite
das Wasserzeichen weiter oben betrifft nur den Ausdruck.</p>
</div>
<div class="col-6 col-12-small">
<label for="brand_color">Akzentfarbe</label>
<input type="color" name="brand_color" id="brand_color"
value="<?php echo saas_html($settings['brand_color'] !== '' ? $settings['brand_color'] : '#38761d'); ?>">
</div>
<div class="col-6 col-12-small">
<label for="brand_logo_file">Logo für die Kopfzeile (PNG/JPEG)</label>
<input type="file" name="brand_logo_file" id="brand_logo_file" accept="image/png,image/jpeg">
<?php if (trim((string)($settings['brand_logo'] ?? '')) !== ''): ?>
<div class="form-check">
<input class="form-check-input" type="checkbox" name="brand_logo_remove" id="brand_logo_remove" value="1">
<label class="form-check-label" for="brand_logo_remove">Hinterlegtes Logo entfernen</label>
</div>
<?php else: ?>
<small>Aktuell kein Logo hinterlegt.</small>
<?php endif; ?>
</div>
<?php endif; ?>
<div class="col-6 col-12-small">
<input type="checkbox" id="payment_reminder_enabled" name="payment_reminder_enabled" value="1" <?php echo (int)$settings['payment_reminder_enabled'] === 1 ? 'checked' : ''; ?>>
<label for="payment_reminder_enabled">Automatische Zahlungserinnerung ab Warnschwelle</label>