prepare("UPDATE tenant_settings SET pdf_watermark_logo = '' WHERE tenant_id = ?")->execute([$tenantIdLogo]); $settings['pdf_watermark_logo'] = ''; } elseif (isset($_FILES['pdf_watermark_logo_file']) && ($_FILES['pdf_watermark_logo_file']['error'] ?? UPLOAD_ERR_NO_FILE) === UPLOAD_ERR_OK) { $logoResult = tenant_logo_store($tenantIdLogo, $_FILES['pdf_watermark_logo_file']); if ($logoResult['ok']) { $pdo->prepare('UPDATE tenant_settings SET pdf_watermark_logo = ? WHERE tenant_id = ?')->execute([$logoResult['filename'], $tenantIdLogo]); $settings['pdf_watermark_logo'] = $logoResult['filename']; } else { $errors[] = $logoResult['error']; } } } else { $errors = $result['errors']; $settings = [ 'name' => $_POST['tenant_name'] ?? '', 'timezone' => $_POST['timezone'] ?? 'Europe/Berlin', 'locale' => $_POST['locale'] ?? 'de-DE', 'currency_code' => $_POST['currency_code'] ?? 'EUR', 'mark_price_cents' => saas_parse_money_cents($_POST['mark_price'] ?? '') ?? 0, 'self_entry_enabled' => !empty($_POST['self_entry_enabled']) ? 1 : 0, 'paypal_enabled' => !empty($_POST['paypal_enabled']) ? 1 : 0, 'paypal_url_template' => $_POST['paypal_url_template'] ?? '', 'sheet_window_days' => $_POST['sheet_window_days'] ?? 100, 'negative_warning_cents' => -abs(saas_parse_money_cents($_POST['negative_warning'] ?? '') ?? 0), 'pdf_show_empty_rows' => !empty($_POST['pdf_show_empty_rows']) ? 1 : 0, 'pdf_split_mode' => $_POST['pdf_split_mode'] ?? 'drinking_behavior', 'pdf_row_height_px' => $_POST['pdf_row_height_px'] ?? 16, 'pdf_watermark_text' => $_POST['pdf_watermark_text'] ?? '', '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, ]; } } else { $settings = saas_fetch_tenant_settings($pdo, (int)$user['tenant_id']); } $auditLog = app_fetch_audit_log($pdo, (int)$user['tenant_id'], 50); $billingCheck = billing_check_tenant($pdo, (int)$user['tenant_id']); $billingPlans = billing_plans(); $billing = billing_fetch_or_init($pdo, (int)$user['tenant_id']); } include 'header.php'; include 'headerline.php'; include 'nav.php'; ?>