From 6b1cecf465c7b6ed9f53a4da36a119dd988f9012 Mon Sep 17 00:00:00 2001 From: fds2610-bot Date: Sun, 26 Apr 2026 10:03:10 +0200 Subject: [PATCH] Fix #51: Belegsuche auf Lieferant, Datum, Bewirtungsgrund, Teilnehmer und Brutto erweitert --- src/Models/Beleg.php | 11 ++- src/Views/belege/list.php | 2 +- src/version.txt | 2 +- tests/21_BelegSucheErweitertTest.php | 106 +++++++++++++++++++++++++++ 4 files changed, 116 insertions(+), 5 deletions(-) create mode 100644 tests/21_BelegSucheErweitertTest.php diff --git a/src/Models/Beleg.php b/src/Models/Beleg.php index cbc8973..f833b8a 100644 --- a/src/Models/Beleg.php +++ b/src/Models/Beleg.php @@ -14,9 +14,14 @@ class Beleg $params = []; if (!empty($filter['search'])) { - $where[] = '(b.beleg_nr LIKE ? OR b.filename LIKE ? OR b.rechnungs_nr LIKE ? OR b.notes LIKE ?)'; + $where[] = '(b.beleg_nr LIKE ? OR b.filename LIKE ? OR b.rechnungs_nr LIKE ? OR b.notes LIKE ? + OR CAST(b.beleg_datum AS CHAR) LIKE ? + OR s.name LIKE ? + OR b.bewirtungsgrund LIKE ? OR b.teilnehmerliste LIKE ? + OR (SELECT CAST(SUM(bk2s.betrag_brutto) AS CHAR) FROM bookings bk2s + WHERE bk2s.beleg_id = b.id AND bk2s.is_reversal = 0) LIKE ?)'; $s = '%' . $filter['search'] . '%'; - $params = array_merge($params, [$s, $s, $s, $s]); + $params = array_merge($params, [$s, $s, $s, $s, $s, $s, $s, $s, $s]); } if (!empty($filter['year'])) { $where[] = '(YEAR(b.beleg_datum) = ? OR b.beleg_datum IS NULL)'; @@ -59,7 +64,7 @@ class Beleg $rows = Database::fetchAll($sql, $params); // Count total - $countSql = 'SELECT COUNT(*) as cnt FROM belege b WHERE ' . implode(' AND ', $where); + $countSql = 'SELECT COUNT(*) as cnt FROM belege b LEFT JOIN suppliers s ON b.supplier_id = s.id WHERE ' . implode(' AND ', $where); $countParams = array_slice($params, 0, -2); $total = (int)(Database::fetchOne($countSql, $countParams)['cnt'] ?? 0); diff --git a/src/Views/belege/list.php b/src/Views/belege/list.php index 7f30d08..268f264 100644 --- a/src/Views/belege/list.php +++ b/src/Views/belege/list.php @@ -92,7 +92,7 @@
-