From d4602368e75dc4205968bbbb8b6d5cb4384d8164 Mon Sep 17 00:00:00 2001 From: fds2610-bot Date: Thu, 2 Jul 2026 21:08:11 +0200 Subject: [PATCH] =?UTF-8?q?Fix=20#111:=20Zwei=20zus=C3=A4tzliche=20CC-E-Ma?= =?UTF-8?q?il-Adressen=20pro=20Kunde?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Changes.md | 10 +++++ docs/funktionen.md | 2 + migrations/084_customer_cc_emails.sql | 7 ++++ src/Controllers/InvoiceController.php | 6 +++ src/Models/Customer.php | 10 +++-- src/Views/customers/form.php | 16 ++++++++ src/Views/invoices/show.php | 6 ++- src/version.txt | 2 +- tests/48_CustomerCcEmailsTest.php | 57 +++++++++++++++++++++++++++ 9 files changed, 110 insertions(+), 6 deletions(-) create mode 100644 migrations/084_customer_cc_emails.sql create mode 100644 tests/48_CustomerCcEmailsTest.php diff --git a/Changes.md b/Changes.md index 1fa7536..bab3732 100644 --- a/Changes.md +++ b/Changes.md @@ -2,6 +2,16 @@ --- +## 2026-07-02 – Feature: Zusätzliche CC-E-Mail-Adressen pro Kunde (Issue #111) + +- **`migrations/084_customer_cc_emails.sql`:** Neue Spalten `email_cc1`, `email_cc2` in `customers` +- **`src/Models/Customer.php`:** `create()` und `update()` speichern die beiden CC-Adressen (Whitespace wird zu NULL normalisiert) +- **`src/Views/customers/form.php`:** Zwei neue Eingabefelder „E-Mail CC 1/2" unter der Haupt-E-Mail +- **`src/Controllers/InvoiceController.php`:** `show()` lädt den Kunden und übergibt ihn an die Detailansicht +- **`src/Views/invoices/show.php`:** CC-Felder im E-Mail-Sende-Modal werden mit den hinterlegten Kunden-CC-Adressen vorbelegt + +--- + ## 2026-06-29 – Feature: Ereignisse-Log für Nextcloud-Import (Issue #109) - **`migrations/083_system_events.sql`:** Neue Tabelle `system_events` (id, channel, message, created_at) diff --git a/docs/funktionen.md b/docs/funktionen.md index e436719..807b2b3 100644 --- a/docs/funktionen.md +++ b/docs/funktionen.md @@ -42,6 +42,8 @@ CRUD für Lieferantenstammdaten. Lieferanten können Belegen zugeordnet werden; CRUD für Kundenstammdaten. Kunden werden beim Erstellen von Ausgangsrechnungen ausgewählt. +- Pro Kunde können neben der Haupt-E-Mail-Adresse **zwei zusätzliche CC-Adressen** hinterlegt werden. Beim Rechnungsversand werden diese automatisch in die CC-Felder des E-Mail-Dialogs übernommen. + --- ## Ausgangsrechnungen diff --git a/migrations/084_customer_cc_emails.sql b/migrations/084_customer_cc_emails.sql new file mode 100644 index 0000000..5b5fc24 --- /dev/null +++ b/migrations/084_customer_cc_emails.sql @@ -0,0 +1,7 @@ +-- 084_customer_cc_emails.sql +-- Zwei zusätzliche CC-E-Mail-Adressen pro Kunde, die beim Rechnungsversand +-- automatisch in die CC-Felder übernommen werden. + +ALTER TABLE customers + ADD COLUMN IF NOT EXISTS email_cc1 VARCHAR(255) NULL DEFAULT NULL AFTER email, + ADD COLUMN IF NOT EXISTS email_cc2 VARCHAR(255) NULL DEFAULT NULL AFTER email_cc1; diff --git a/src/Controllers/InvoiceController.php b/src/Controllers/InvoiceController.php index 4060542..72d9384 100644 --- a/src/Controllers/InvoiceController.php +++ b/src/Controllers/InvoiceController.php @@ -131,6 +131,11 @@ class InvoiceController extends BaseController $accounts = Account::all(['aktiv' => 1]); } + // Kunde für CC-Vorbelegung im E-Mail-Modal + $customer = !empty($invoice['customer_id']) + ? \Steuerkram\Models\Customer::find((int)$invoice['customer_id']) + : null; + $view = new View(); $view->render('layout/base.php', [ 'pageTitle' => 'Rechnung ' . ($invoice['rechnungs_nr'] ?? 'Entwurf'), @@ -142,6 +147,7 @@ class InvoiceController extends BaseController 'originalrechnung' => $originalrechnung, 'bookings' => $bookings, 'accounts' => $accounts, + 'customer' => $customer ?: null, ]), ]); } diff --git a/src/Models/Customer.php b/src/Models/Customer.php index 44695c4..4814c16 100644 --- a/src/Models/Customer.php +++ b/src/Models/Customer.php @@ -39,8 +39,8 @@ class Customer $nr = self::generateKundennummer(); Database::execute( 'INSERT INTO customers (kundennummer, firma, anrede, vorname, nachname, strasse, plz, ort, land, - email, telefon, ust_id, steuernummer, payment_days, notes, mail_subject_template, mail_body_template) - VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', + email, email_cc1, email_cc2, telefon, ust_id, steuernummer, payment_days, notes, mail_subject_template, mail_body_template) + VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', [ $data['kundennummer'] ?? $nr, $data['firma'] ?? null, @@ -52,6 +52,8 @@ class Customer $data['ort'], $data['land'] ?? 'DE', $data['email'] ?? null, + trim($data['email_cc1'] ?? '') !== '' ? trim($data['email_cc1']) : null, + trim($data['email_cc2'] ?? '') !== '' ? trim($data['email_cc2']) : null, $data['telefon'] ?? null, $data['ust_id'] ?? null, $data['steuernummer'] ?? null, @@ -68,7 +70,7 @@ class Customer { Database::execute( 'UPDATE customers SET firma=?, anrede=?, vorname=?, nachname=?, strasse=?, plz=?, ort=?, land=?, - email=?, telefon=?, ust_id=?, steuernummer=?, payment_days=?, notes=?, + email=?, email_cc1=?, email_cc2=?, telefon=?, ust_id=?, steuernummer=?, payment_days=?, notes=?, mail_subject_template=?, mail_body_template=?, updated_at=NOW() WHERE id=?', [ @@ -81,6 +83,8 @@ class Customer $data['ort'], $data['land'] ?? 'DE', $data['email'] ?? null, + trim($data['email_cc1'] ?? '') !== '' ? trim($data['email_cc1']) : null, + trim($data['email_cc2'] ?? '') !== '' ? trim($data['email_cc2']) : null, $data['telefon'] ?? null, $data['ust_id'] ?? null, $data['steuernummer'] ?? null, diff --git a/src/Views/customers/form.php b/src/Views/customers/form.php index b0d664f..1a860f3 100644 --- a/src/Views/customers/form.php +++ b/src/Views/customers/form.php @@ -60,6 +60,22 @@ +
+
+ + +
+
+ + +
+
+

+ Zusätzliche CC-Adressen werden beim Rechnungsversand automatisch als Kopie vorgeschlagen. +

+
diff --git a/src/Views/invoices/show.php b/src/Views/invoices/show.php index 0267ebf..d56d065 100644 --- a/src/Views/invoices/show.php +++ b/src/Views/invoices/show.php @@ -370,11 +370,13 @@ $badgeClass = match($invoice['status']) {
- +
- +