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>
159 lines
7.1 KiB
PHP
159 lines
7.1 KiB
PHP
<?php
|
|
|
|
require_once __DIR__ . '/functions.php';
|
|
require_once __DIR__ . '/app/platform-admin.php';
|
|
require_once __DIR__ . '/app/features.php';
|
|
|
|
$pdo = app_db_pdo();
|
|
$user = app_require_platform_admin($pdo);
|
|
|
|
// Die Mandanten-ID kommt beim Speichern der Funktions-Schalter aus dem
|
|
// Formular, sonst aus der URL.
|
|
$tenantId = filter_input(INPUT_POST, 'tenant_id', FILTER_VALIDATE_INT)
|
|
?: filter_input(INPUT_GET, 'tenant_id', FILTER_VALIDATE_INT);
|
|
if ($tenantId === null || $tenantId === false || $tenantId <= 0) {
|
|
http_response_code(400);
|
|
exit('Ungültige Mandanten-ID.');
|
|
}
|
|
|
|
$featureMeldung = null;
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST' && ($_POST['aktion'] ?? '') === 'features_speichern') {
|
|
app_require_csrf();
|
|
|
|
$geaendert = app_features_update($pdo, $tenantId, (array)($_POST['features'] ?? []));
|
|
if ($geaendert !== []) {
|
|
app_audit_log($pdo, $tenantId, (int)$user['user_id'], 'backoffice.features_updated', 'tenant', $tenantId, [
|
|
'changed' => $geaendert,
|
|
]);
|
|
}
|
|
$featureMeldung = $geaendert === []
|
|
? 'Keine Änderung an den Funktionen.'
|
|
: 'Die Funktionen wurden gespeichert.';
|
|
}
|
|
|
|
$detail = app_backoffice_fetch_tenant_detail($pdo, $tenantId);
|
|
if ($detail === null) {
|
|
http_response_code(404);
|
|
exit('Mandant wurde nicht gefunden.');
|
|
}
|
|
|
|
// Jede Ansicht eines Mandanten durch das Back-Office wird im Audit-Log
|
|
// dieses Mandanten protokolliert, damit der Zugriff fuer den Kunden
|
|
// nachvollziehbar bleibt (siehe AVV-Transparenzpflicht).
|
|
app_audit_log($pdo, $tenantId, (int)$user['user_id'], 'backoffice.tenant_viewed', 'tenant', $tenantId);
|
|
|
|
$tenantFeatures = app_features_for_tenant($pdo, $tenantId);
|
|
|
|
$rollenLabels = ['owner' => 'Inhaber', 'admin' => 'Administrator', 'treasurer' => 'Kassenwart', 'member' => 'Mitglied', 'viewer' => 'Betrachter'];
|
|
|
|
include 'header.php';
|
|
include 'headerline.php';
|
|
include 'nav.php';
|
|
?>
|
|
|
|
<section id="banner">
|
|
<div class="content">
|
|
<h2>Back-Office: <?php echo saas_html($detail['tenant']['name']); ?></h2>
|
|
<p><a href="backoffice.php">← Zurück zur Mandantenübersicht</a></p>
|
|
|
|
<table>
|
|
<tr><th>Kürzel</th><td><?php echo saas_html($detail['tenant']['slug']); ?></td></tr>
|
|
<tr><th>Status</th><td><?php echo saas_html($detail['tenant']['status']); ?></td></tr>
|
|
<tr><th>Erstellt</th><td><?php echo saas_html($detail['tenant']['created_at']); ?></td></tr>
|
|
<?php if ($detail['settings'] !== null): ?>
|
|
<tr><th>Preis pro Strich</th><td><?php echo saas_html(saas_format_money_cents((int)$detail['settings']['mark_price_cents'])); ?> €</td></tr>
|
|
<tr><th>PayPal aktiv</th><td><?php echo (int)$detail['settings']['paypal_enabled'] === 1 ? 'ja' : 'nein'; ?></td></tr>
|
|
<?php endif; ?>
|
|
</table>
|
|
|
|
<form method="post" action="backoffice-export.php">
|
|
<?php echo app_csrf_field(); ?>
|
|
<input type="hidden" name="tenant_id" value="<?php echo (int)$tenantId; ?>">
|
|
<button type="submit">Datenexport dieses Mandanten herunterladen</button>
|
|
</form>
|
|
|
|
<h3>Freigeschaltete Funktionen</h3>
|
|
<p>Zentral vom Betreiber gesteuert: abgehakte Funktionen sind für diesen Mandanten
|
|
gesperrt und verschwinden dort aus Menü und Seiten. Die Einstellungen des Kunden
|
|
bleiben dabei erhalten.</p>
|
|
|
|
<?php if ($featureMeldung !== null): ?>
|
|
<div class="hint-box success"><p><?php echo saas_html($featureMeldung); ?></p></div>
|
|
<?php endif; ?>
|
|
|
|
<form method="post" action="backoffice-mandant.php?tenant_id=<?php echo (int)$tenantId; ?>">
|
|
<?php echo app_csrf_field(); ?>
|
|
<input type="hidden" name="aktion" value="features_speichern">
|
|
<input type="hidden" name="tenant_id" value="<?php echo (int)$tenantId; ?>">
|
|
<div class="row">
|
|
<?php foreach (app_feature_catalog() as $featureKey => $feature): ?>
|
|
<div class="col-6 col-12-small">
|
|
<input type="checkbox"
|
|
id="feature_<?php echo saas_html($featureKey); ?>"
|
|
name="features[<?php echo saas_html($featureKey); ?>]"
|
|
value="1"
|
|
<?php echo ($tenantFeatures[$featureKey] ?? true) ? 'checked' : ''; ?>>
|
|
<label for="feature_<?php echo saas_html($featureKey); ?>">
|
|
<?php echo saas_html($feature['label']); ?>
|
|
</label>
|
|
<small><?php echo saas_html($feature['description']); ?></small>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
<ul class="actions">
|
|
<li><button type="submit">Funktionen speichern</button></li>
|
|
</ul>
|
|
</form>
|
|
|
|
<h3>Mitglieder mit Zugang</h3>
|
|
<table>
|
|
<tr><th>Name</th><th>E-Mail</th><th>Rolle</th><th>Status</th></tr>
|
|
<?php if ($detail['members'] === []): ?>
|
|
<tr><td colspan="4">Kein Mitglied mit Login-Zugang.</td></tr>
|
|
<?php endif; ?>
|
|
<?php foreach ($detail['members'] as $member): ?>
|
|
<tr>
|
|
<td><?php echo saas_html($member['display_name']); ?></td>
|
|
<td><?php echo saas_html($member['email']); ?></td>
|
|
<td><?php echo saas_html($rollenLabels[$member['role']] ?? $member['role']); ?></td>
|
|
<td><?php echo saas_html($member['membership_status']); ?></td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</table>
|
|
|
|
<h3>Letzte Buchungen</h3>
|
|
<table>
|
|
<tr><th>Datum</th><th>Mitglied</th><th>Typ</th><th>Betrag</th><th>Quelle</th></tr>
|
|
<?php if ($detail['recent_entries'] === []): ?>
|
|
<tr><td colspan="5">Keine Buchungen vorhanden.</td></tr>
|
|
<?php endif; ?>
|
|
<?php foreach ($detail['recent_entries'] as $entry): ?>
|
|
<tr>
|
|
<td><?php echo saas_html($entry['booked_at']); ?></td>
|
|
<td><?php echo saas_html($entry['display_name']); ?></td>
|
|
<td><?php echo saas_html($entry['type']); ?></td>
|
|
<td><?php echo saas_html(saas_format_money_cents((int)$entry['amount_cents'])); ?> €</td>
|
|
<td><?php echo saas_html($entry['source']); ?></td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</table>
|
|
|
|
<h3>Letzte Admin-Aktionen</h3>
|
|
<table>
|
|
<tr><th>Datum</th><th>Wer</th><th>Aktion</th></tr>
|
|
<?php if ($detail['recent_audit'] === []): ?>
|
|
<tr><td colspan="3">Noch keine protokollierten Aktionen.</td></tr>
|
|
<?php endif; ?>
|
|
<?php foreach ($detail['recent_audit'] as $entry): ?>
|
|
<tr>
|
|
<td><?php echo saas_html($entry['created_at']); ?></td>
|
|
<td><?php echo saas_html($entry['actor_name'] ?? '—'); ?></td>
|
|
<td><?php echo saas_html($entry['action']); ?></td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</table>
|
|
</div>
|
|
</section>
|
|
|
|
<?php include 'footer.php'; ?>
|