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 @@
-