Rechtstexte und B2C-Vertragsabläufe absichern

This commit is contained in:
2026-08-22 14:31:56 +02:00
parent d320a4fd7a
commit a31a235422
58 changed files with 2502 additions and 316 deletions
+54 -1
View File
@@ -3,6 +3,7 @@
declare(strict_types=1);
require_once __DIR__ . '/bootstrap.php';
require_once __DIR__ . '/tenant-logo.php';
/**
* Assembles a full export of everything stored for one tenant (data
@@ -13,7 +14,7 @@ require_once __DIR__ . '/bootstrap.php';
*/
function app_export_tenant_data(PDO $pdo, int $tenantId): array
{
$stmt = $pdo->prepare('SELECT id, slug, name, status, timezone, locale, currency_code, created_at, updated_at FROM tenants WHERE id = ?');
$stmt = $pdo->prepare('SELECT id, slug, paypal_inbox_token, name, customer_type, status, timezone, locale, currency_code, created_at, updated_at FROM tenants WHERE id = ?');
$stmt->execute([$tenantId]);
$tenant = $stmt->fetch();
@@ -66,6 +67,51 @@ function app_export_tenant_data(PDO $pdo, int $tenantId): array
$stmt->execute([$tenantId]);
$auditLog = $stmt->fetchAll();
$stmt = $pdo->prepare('SELECT * FROM faq_entries WHERE tenant_id = ? ORDER BY id');
$stmt->execute([$tenantId]);
$faqEntries = $stmt->fetchAll();
$stmt = $pdo->prepare('SELECT * FROM paypal_payments WHERE tenant_id = ? ORDER BY id');
$stmt->execute([$tenantId]);
$paypalPayments = $stmt->fetchAll();
$stmt = $pdo->prepare('SELECT * FROM tenant_billing WHERE tenant_id = ?');
$stmt->execute([$tenantId]);
$billing = $stmt->fetch();
$stmt = $pdo->prepare('SELECT * FROM tenant_features WHERE tenant_id = ? ORDER BY id');
$stmt->execute([$tenantId]);
$features = $stmt->fetchAll();
$stmt = $pdo->prepare(
'SELECT document_type, document_version, context, metadata_json, accepted_at
FROM legal_acceptances WHERE tenant_id = ? ORDER BY id'
);
$stmt->execute([$tenantId]);
$legalAcceptances = $stmt->fetchAll();
$stmt = $pdo->prepare(
'SELECT reference_code, request_type, requester_name, requester_email,
contract_reference, request_reason, requested_end, status,
metadata_json, received_at, processed_at
FROM legal_requests WHERE tenant_id = ? ORDER BY id'
);
$stmt->execute([$tenantId]);
$legalRequests = $stmt->fetchAll();
$logos = [];
foreach (['brand_logo', 'pdf_watermark_logo'] as $logoField) {
$filename = (string)($settings[$logoField] ?? '');
$path = tenant_logo_path($filename);
if ($path !== null) {
$logos[$logoField] = [
'filename' => $filename,
'mime_type' => mime_content_type($path) ?: 'application/octet-stream',
'base64' => base64_encode((string)file_get_contents($path)),
];
}
}
return [
'exported_at' => date('c'),
'tenant' => $tenant ?: null,
@@ -78,5 +124,12 @@ function app_export_tenant_data(PDO $pdo, int $tenantId): array
'payment_import_rows' => $importRows,
'outbound_emails' => $outboundEmails,
'audit_log' => $auditLog,
'faq_entries' => $faqEntries,
'paypal_payments' => $paypalPayments,
'billing' => $billing ?: null,
'features' => $features,
'legal_acceptances' => $legalAcceptances,
'legal_requests' => $legalRequests,
'logos' => $logos,
];
}