93 lines
4.6 KiB
PHP
93 lines
4.6 KiB
PHP
<?php
|
|
|
|
require_once __DIR__ . '/functions.php';
|
|
require_once __DIR__ . '/app/platform-admin.php';
|
|
require_once __DIR__ . '/app/billing.php';
|
|
|
|
$pdo = app_db_pdo();
|
|
$user = app_require_platform_admin($pdo);
|
|
|
|
$tenants = app_backoffice_fetch_tenants($pdo);
|
|
$billingPlans = billing_plans();
|
|
$legalRequests = $pdo->query(
|
|
"SELECT lr.id, lr.reference_code, lr.request_type, lr.requester_name,
|
|
lr.requester_email, lr.contract_reference, lr.request_reason,
|
|
lr.requested_end, lr.status, lr.received_at, t.name AS tenant_name
|
|
FROM legal_requests lr
|
|
LEFT JOIN tenants t ON t.id = lr.tenant_id
|
|
WHERE lr.status <> 'processed'
|
|
ORDER BY lr.received_at ASC
|
|
LIMIT 100"
|
|
)->fetchAll();
|
|
|
|
include 'header.php';
|
|
include 'headerline.php';
|
|
include 'nav.php';
|
|
?>
|
|
|
|
<section id="banner">
|
|
<div class="content">
|
|
<h2>Back-Office</h2>
|
|
<p>Nur für Betreiber-Admins sichtbar: Übersicht aller Mandanten, unabhängig von deren eigener Mitgliedschaft.
|
|
Jeder Zugriff wird im Audit-Log des jeweiligen Mandanten protokolliert.</p>
|
|
|
|
<h3>Offene Kündigungen und Widerrufe</h3>
|
|
<?php if ($legalRequests === []): ?>
|
|
<div class="hint-box success"><p>Keine offenen Rechtserklärungen.</p></div>
|
|
<?php else: ?>
|
|
<table>
|
|
<tr><th>Eingang</th><th>Art / Referenz</th><th>Kunde</th><th>Erklärung</th><th>Status</th><th></th></tr>
|
|
<?php foreach ($legalRequests as $request): ?>
|
|
<tr>
|
|
<td><?php echo saas_html($request['received_at']); ?></td>
|
|
<td><?php echo $request['request_type'] === 'withdrawal' ? 'Widerruf' : 'Kündigung'; ?><br><small><?php echo saas_html($request['reference_code']); ?></small></td>
|
|
<td><?php echo saas_html($request['requester_name']); ?><br><a href="mailto:<?php echo saas_html($request['requester_email']); ?>"><?php echo saas_html($request['requester_email']); ?></a><br><small><?php echo saas_html($request['tenant_name'] ?? $request['contract_reference']); ?></small></td>
|
|
<td><?php echo $request['requested_end'] !== null ? 'Ende: ' . saas_html($request['requested_end']) . '<br>' : ''; ?><?php echo nl2br(saas_html($request['request_reason'] ?? '')); ?></td>
|
|
<td><?php echo saas_html($request['status']); ?></td>
|
|
<td>
|
|
<form method="post" action="rechtserklaerung-bearbeiten.php">
|
|
<?php echo app_csrf_field(); ?>
|
|
<input type="hidden" name="request_id" value="<?php echo (int)$request['id']; ?>">
|
|
<button type="submit" class="button small">Als erledigt markieren</button>
|
|
</form>
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</table>
|
|
<?php endif; ?>
|
|
|
|
<table>
|
|
<tr>
|
|
<th>Kunde</th>
|
|
<th>Kürzel</th>
|
|
<th>Status</th>
|
|
<th>Tarif</th>
|
|
<th>Erstellt</th>
|
|
<th>Teilnehmer (aktiv/gesamt)</th>
|
|
<th>Saldensumme</th>
|
|
<th></th>
|
|
</tr>
|
|
<?php foreach ($tenants as $tenant): ?>
|
|
<?php $tenantRequiredPlan = billing_required_plan_code((int)$tenant['active_participant_count']); ?>
|
|
<tr>
|
|
<td><?php echo saas_html($tenant['name']); ?></td>
|
|
<td><?php echo saas_html($tenant['slug']); ?></td>
|
|
<td><?php echo saas_html($tenant['status']); ?></td>
|
|
<td>
|
|
<?php echo saas_html($billingPlans[$tenant['plan_code']]['label'] ?? $tenant['plan_code']); ?>
|
|
<?php if ($tenantRequiredPlan !== $tenant['plan_code']): ?>
|
|
<br><small>benötigt: <?php echo saas_html($billingPlans[$tenantRequiredPlan]['label'] ?? $tenantRequiredPlan); ?></small>
|
|
<?php endif; ?>
|
|
</td>
|
|
<td><?php echo saas_html($tenant['created_at']); ?></td>
|
|
<td><?php echo (int)$tenant['active_participant_count']; ?> / <?php echo (int)$tenant['participant_count']; ?></td>
|
|
<td><?php echo saas_html(saas_format_money_cents((int)$tenant['balance_cents'])); ?> €</td>
|
|
<td><a href="backoffice-mandant.php?tenant_id=<?php echo (int)$tenant['id']; ?>" class="button">Ansehen</a></td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</table>
|
|
</div>
|
|
</section>
|
|
|
|
<?php include 'footer.php'; ?>
|