diff --git a/frontend/src/components/PDFGenerator.js b/frontend/src/components/PDFGenerator.js index 5173e68..f0b9ddd 100644 --- a/frontend/src/components/PDFGenerator.js +++ b/frontend/src/components/PDFGenerator.js @@ -192,12 +192,14 @@ class PDFGenerator { } addPhoneListHeaders() { + this.pdf.setFontSize(10); this.pdf.setFont('helvetica', 'bold'); this.pdf.text('Name, Vorname', this.margin, this.yPos); this.pdf.text('Geburtsdatum', this.margin + 60, this.yPos); this.pdf.text('Telefon-Nr.', this.margin + 120, this.yPos); this.yPos += this.LINE_HEIGHT; this.pdf.setFont('helvetica', 'normal'); + this.pdf.setFontSize(10); // Sicherstellen, dass die Schriftgröße für die Einträge korrekt ist } addPhoneListRow(member) { @@ -205,9 +207,9 @@ class PDFGenerator { const birthDate = member.birthDate ? new Date(member.birthDate).toLocaleDateString('de-DE') : ''; // Sammle alle Telefonnummern aus contacts - let phoneNumbers = []; + let phoneContacts = []; if (member.contacts && Array.isArray(member.contacts)) { - const phoneContacts = member.contacts + phoneContacts = member.contacts .filter(c => c.type === 'phone' && c.value && String(c.value).trim() !== '') .sort((a, b) => { // Primäre Telefonnummer zuerst @@ -215,33 +217,76 @@ class PDFGenerator { if (!a.isPrimary && b.isPrimary) return 1; return 0; }); - - phoneContacts.forEach(contact => { - let phoneText = contact.value; - if (contact.isParent) { - // Bei Elternteil-Nummern: Name des Elternteils + Name des Mitglieds - if (contact.parentName) { - phoneText += ` (${contact.parentName} von ${member.firstName} ${member.lastName})`; - } else { - phoneText += ` (Elternteil von ${member.firstName} ${member.lastName})`; - } - } - // Bei eigenen Nummern wird nur die Nummer angezeigt (Name steht bereits in erster Spalte) - phoneNumbers.push(phoneText); - }); } // Fallback auf altes phone-Feld für Rückwärtskompatibilität - if (phoneNumbers.length === 0 && member.phone) { - phoneNumbers.push(member.phone); + if (phoneContacts.length === 0 && member.phone) { + phoneContacts.push({ + value: member.phone, + isParent: false, + parentName: null + }); } - const phoneNumber = phoneNumbers.join(', ') || ''; - - this.pdf.text(fullName, this.margin, this.yPos); - this.pdf.text(birthDate, this.margin + 60, this.yPos); - this.pdf.text(phoneNumber, this.margin + 120, this.yPos); - this.yPos += this.LINE_HEIGHT; + // Startposition für Name und Geburtsdatum + const startYPos = this.yPos; + + // Sicherstellen, dass die Schriftgröße korrekt ist + this.pdf.setFontSize(10); + this.pdf.setFont('helvetica', 'normal'); + + // Zeige Name und Geburtsdatum nur einmal am Anfang + this.pdf.text(fullName, this.margin, startYPos); + this.pdf.text(birthDate, this.margin + 60, startYPos); + + // Zeige alle Telefonnummern untereinander + if (phoneContacts.length > 0) { + let currentYPos = startYPos; + + phoneContacts.forEach((contact, index) => { + // Telefonnummer in normaler Schriftgröße + this.pdf.setFont('helvetica', 'normal'); + this.pdf.setFontSize(10); + this.pdf.text(contact.value, this.margin + 120, currentYPos); + + // Y-Position nach der Telefonnummer erhöhen + currentYPos += 4; // Höhe der Telefonnummer + + // Bei Elternteil-Nummern: Name in kleiner Schrift darunter + if (contact.isParent) { + // Name in kleiner Schrift + this.pdf.setFont('helvetica', 'normal'); + this.pdf.setFontSize(7); // Deutlich kleinere Schrift + let parentText = ''; + if (contact.parentName) { + parentText = contact.parentName; // Nur der Name des Elternteils + } else { + parentText = 'Elternteil'; + } + this.pdf.text(parentText, this.margin + 120, currentYPos); + + // Y-Position nach dem Namen erhöhen + currentYPos += 3; // Höhe des Namens + + // Zurück zur normalen Schriftgröße + this.pdf.setFontSize(10); + } + + // Kleiner Abstand zur nächsten Nummer (nur wenn nicht die letzte) + if (index < phoneContacts.length - 1) { + currentYPos += 1; // Minimaler Abstand zwischen Nummern + } + }); + + // Aktualisiere yPos + this.yPos = currentYPos; + } else { + // Keine Telefonnummern vorhanden + this.yPos += this.LINE_HEIGHT; + } + + // Zusätzlicher Abstand zwischen Mitgliedern + this.yPos += 2; } addAddress(clubName, addressLines) {