diff --git a/Website/modules/emailservice/email.py b/Website/modules/emailservice/email.py index e434100..88da174 100644 --- a/Website/modules/emailservice/email.py +++ b/Website/modules/emailservice/email.py @@ -330,7 +330,7 @@ def generate_main_contract_pdf( pdf.set_x(start_x) pdf.cell(col_width, 5, f"{datetime.today().strftime('%d.%m.%Y')} ________________________", align="C", ln=False) - pdf.cell(col_width, 5, f"{datetime.today().strftime('%d.%m.%Y')} ________________________", align="C", ln=True) + pdf.cell(col_width, 5, f"{datetime.today().strftime('%d.%m.%Y')} ___________ _____________", align="C", ln=True) pdf.set_x(start_x) pdf.cell(col_width, 5, "(Verantwortlicher)", align="C", ln=False) @@ -345,36 +345,35 @@ def send_accreditation_email( domain: str, username: str, password: str, - school_name: str, - address: str, - price: str, - date: str, - software_name: str, - invoice_pdf_path: str = None + invoice_pdf_path: str, + contract_pdf_path: str, + school_name: str = "[Name der Schule / des Auftraggebers]", + address: str = "[Straße, Hausnummer] [PLZ, Ort]", + price: str = "250,00", + date: str = "[Ort, Datum]" ) -> bool: - """Sends an accreditation email with login credentials and generated contract PDF.""" + """Generiert den Hauptvertrag und sendet diesen zusammen mit Rechnung, AGB und AVV per E-Mail.""" - # 1. Temporären Pfad für das generierte PDF festlegen - contract_filename = f"Vertrag_{school_name.replace(' ', '_')}.pdf" - contract_pdf_path = os.path.join(tempfile.gettempdir(), contract_filename) - - # 2. Hauptvertrag als PDF generieren + # 1. Hauptvertrag generieren generate_main_contract_pdf( school_name=school_name, address=address, price=price, date=date, - software_name=software_name, output_path=contract_pdf_path ) - # 3. E-Mail Inhalt vorbereiten + # 2. Pfade zu den statischen Dokumenten + agb_pdf_path = os.path.join("static", "download", "AGB Invario.pdf") + avv_pdf_path = os.path.join("static", "download", "AVV Invario.pdf") + + # 3. E-Mail Texte subject = "Ihre Zugangsdaten und Unterlagen für Invario" text_note = ( f"Sehr geehrte/r {username},\n\n" "Vielen Dank für Ihre Akkreditierung bei Invario. " - "Im Anhang finden Sie Ihre Rechnung und den Vertrag.\n\n" + "Im Anhang finden Sie Ihre Rechnung, den Hauptvertrag sowie die AGB und den AVV.\n\n" f"Ihre Zugangsdaten:\n" f"Domain: https://{domain}\n" f"Benutzername: {username}\n" @@ -386,7 +385,7 @@ def send_accreditation_email(

Willkommen bei Invario!

- Vielen Dank für Ihre Akkreditierung. Im Anhang finden Sie Ihre Rechnung und den Vertrag. + Vielen Dank für Ihre Akkreditierung. Im Anhang finden Sie Ihre Rechnung, den Hauptvertrag sowie die AGB und den AVV.

Ihre Zugangsdaten:

@@ -402,18 +401,25 @@ def send_accreditation_email(
""" - # 4. Anhänge zusammenstellen - attachments = [contract_pdf_path] + # 4. Alle existierenden Anhänge sammeln + attachments = [] + + # Generierter Hauptvertrag & Rechnung + if contract_pdf_path and os.path.exists(contract_pdf_path): + attachments.append(contract_pdf_path) if invoice_pdf_path and os.path.exists(invoice_pdf_path): attachments.append(invoice_pdf_path) - - # 5. E-Mail versenden - result = send(recipient, subject, text_body=text_note, html_body=html_note, attachments=attachments) - - # 6. Temporäre PDF-Datei nach dem Versand wieder löschen - try: - os.remove(contract_pdf_path) - except OSError: - pass - return result \ No newline at end of file + # Statische Dokumente aus static/download/ + if os.path.exists(agb_pdf_path): + attachments.append(agb_pdf_path) + else: + print(f"Warnung: AGB unter {agb_pdf_path} nicht gefunden.") + + if os.path.exists(avv_pdf_path): + attachments.append(avv_pdf_path) + else: + print(f"Warnung: AVV unter {avv_pdf_path} nicht gefunden.") + + # 5. E-Mail mit allen 4 Anhängen versenden + return send(recipient, subject, text_body=text_note, html_body=html_note, attachments=attachments) \ No newline at end of file diff --git a/Website/static/downloads/AGB Invario.pdf b/Website/static/downloads/AGB Invario.pdf new file mode 100644 index 0000000..e6ffc9d Binary files /dev/null and b/Website/static/downloads/AGB Invario.pdf differ diff --git a/Website/static/downloads/AVV Invario.pdf b/Website/static/downloads/AVV Invario.pdf new file mode 100644 index 0000000..db05dee Binary files /dev/null and b/Website/static/downloads/AVV Invario.pdf differ