Kaffeeliste-Ausdruck: adaptives Layout nach Mitgliederzahl
Der PDF-Export war bisher immer zweiseitig (Vieltrinker-/Wenigtrinker) mit fester Mindestzeilenzahl, unabhängig von der tatsächlichen Mitgliederzahl. Umgestellt auf: - Bis 49 aktive Mitglieder: eine Seite ohne Trennung. - Ab 50 Mitgliedern: weiterhin zwei Seiten (Vorder-/Rückseite). - Zeilenhöhe richtet sich nach der Mitgliederzahl (16-40px), statt fest 16px für alle. - Neue Mandanten-Einstellungen: freie Zeilen für neue Mitglieder an/aus, Trennmodus bei zwei Seiten (Trinkverhalten oder alphabetisch). Migration 0015 ergänzt die dafür nötigen tenant_settings-Spalten. Gegen die Dev-DB verifiziert: 8 Mitglieder -> einseitiges PDF, 53 Mitglieder (temporäre Testdaten) -> zweiseitiges PDF, Einstellungen inkl. Validierung geprüft.
This commit is contained in:
+18
-4
@@ -273,7 +273,9 @@ function saas_fetch_tenant_settings(PDO $pdo, int $tenantId): ?array
|
||||
ts.paypal_enabled,
|
||||
ts.paypal_url_template,
|
||||
ts.sheet_window_days,
|
||||
ts.negative_warning_cents
|
||||
ts.negative_warning_cents,
|
||||
ts.pdf_show_empty_rows,
|
||||
ts.pdf_split_mode
|
||||
FROM tenants t
|
||||
LEFT JOIN tenant_settings ts ON ts.tenant_id = t.id
|
||||
WHERE t.id = ?
|
||||
@@ -306,6 +308,8 @@ function saas_fetch_tenant_settings(PDO $pdo, int $tenantId): ?array
|
||||
'paypal_url_template' => (string)$settings['paypal_url_template'],
|
||||
'sheet_window_days' => (int)$settings['sheet_window_days'],
|
||||
'negative_warning_cents' => (int)$settings['negative_warning_cents'],
|
||||
'pdf_show_empty_rows' => (int)$settings['pdf_show_empty_rows'],
|
||||
'pdf_split_mode' => (string)$settings['pdf_split_mode'],
|
||||
];
|
||||
}
|
||||
|
||||
@@ -319,6 +323,7 @@ function saas_update_tenant_settings(PDO $pdo, int $tenantId, array $input): arr
|
||||
$sheetWindowDays = filter_var($input['sheet_window_days'] ?? null, FILTER_VALIDATE_INT);
|
||||
$negativeWarningCents = saas_parse_money_cents($input['negative_warning'] ?? '');
|
||||
$paypalUrlTemplate = trim((string)($input['paypal_url_template'] ?? ''));
|
||||
$pdfSplitMode = trim((string)($input['pdf_split_mode'] ?? 'drinking_behavior'));
|
||||
|
||||
$errors = [];
|
||||
if (strlen($tenantName) < 3 || strlen($tenantName) > 255) {
|
||||
@@ -345,6 +350,9 @@ function saas_update_tenant_settings(PDO $pdo, int $tenantId, array $input): arr
|
||||
if (strlen($paypalUrlTemplate) > 1000) {
|
||||
$errors[] = 'Der PayPal-Link ist zu lang.';
|
||||
}
|
||||
if (!in_array($pdfSplitMode, ['drinking_behavior', 'alphabetical'], true)) {
|
||||
$errors[] = 'Die Sortierung für den Ausdruck ist ungültig.';
|
||||
}
|
||||
|
||||
if ($errors !== []) {
|
||||
return ['ok' => false, 'errors' => $errors];
|
||||
@@ -352,6 +360,7 @@ function saas_update_tenant_settings(PDO $pdo, int $tenantId, array $input): arr
|
||||
|
||||
$selfEntryEnabled = !empty($input['self_entry_enabled']) ? 1 : 0;
|
||||
$paypalEnabled = !empty($input['paypal_enabled']) ? 1 : 0;
|
||||
$pdfShowEmptyRows = !empty($input['pdf_show_empty_rows']) ? 1 : 0;
|
||||
|
||||
try {
|
||||
$pdo->beginTransaction();
|
||||
@@ -366,15 +375,18 @@ function saas_update_tenant_settings(PDO $pdo, int $tenantId, array $input): arr
|
||||
$stmt = $pdo->prepare(
|
||||
'INSERT INTO tenant_settings
|
||||
(tenant_id, mark_price_cents, self_entry_enabled, paypal_enabled,
|
||||
paypal_url_template, sheet_window_days, negative_warning_cents)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?)
|
||||
paypal_url_template, sheet_window_days, negative_warning_cents,
|
||||
pdf_show_empty_rows, pdf_split_mode)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
ON DUPLICATE KEY UPDATE
|
||||
mark_price_cents = VALUES(mark_price_cents),
|
||||
self_entry_enabled = VALUES(self_entry_enabled),
|
||||
paypal_enabled = VALUES(paypal_enabled),
|
||||
paypal_url_template = VALUES(paypal_url_template),
|
||||
sheet_window_days = VALUES(sheet_window_days),
|
||||
negative_warning_cents = VALUES(negative_warning_cents)'
|
||||
negative_warning_cents = VALUES(negative_warning_cents),
|
||||
pdf_show_empty_rows = VALUES(pdf_show_empty_rows),
|
||||
pdf_split_mode = VALUES(pdf_split_mode)'
|
||||
);
|
||||
$stmt->execute([
|
||||
$tenantId,
|
||||
@@ -384,6 +396,8 @@ function saas_update_tenant_settings(PDO $pdo, int $tenantId, array $input): arr
|
||||
$paypalUrlTemplate,
|
||||
(int)$sheetWindowDays,
|
||||
-abs($negativeWarningCents),
|
||||
$pdfShowEmptyRows,
|
||||
$pdfSplitMode,
|
||||
]);
|
||||
|
||||
$pdo->commit();
|
||||
|
||||
Reference in New Issue
Block a user