From 35645fc6711bbfc7fe8bfcf0c515f1b621e361a7 Mon Sep 17 00:00:00 2001 From: elpatron Date: Tue, 18 Mar 2025 16:11:10 +0100 Subject: [PATCH] =?UTF-8?q?Fix:=20Login-Funktionalit=C3=A4t=20wiederherges?= =?UTF-8?q?tellt=20und=20Passwort=20aktualisiert?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.py | 20 +++++++++++++++++--- static/css/styles.css | 18 ++++++++++++++++++ templates/index.html | 12 ++++++++++++ 3 files changed, 47 insertions(+), 3 deletions(-) diff --git a/app.py b/app.py index b096550..accc008 100644 --- a/app.py +++ b/app.py @@ -148,8 +148,21 @@ def search_customers(search_params): # Allgemeine Suche über alle Felder if search_params.get('q'): search_term = f"%{search_params['q']}%" - query += " AND (name LIKE ? OR ort LIKE ? OR nummer LIKE ? OR telefon LIKE ? OR mobil LIKE ? OR email LIKE ? OR bemerkung LIKE ? OR fachrichtung LIKE ?)" - params.extend([search_term] * 8) + operator = search_params.get('operator', 'or').upper() + + if operator == 'AND': + # Bei UND-Verknüpfung müssen alle Begriffe in mindestens einem Feld vorkommen + terms = search_params['q'].split() + conditions = [] + for term in terms: + term = f"%{term}%" + conditions.append("(name LIKE ? OR ort LIKE ? OR nummer LIKE ? OR telefon LIKE ? OR mobil LIKE ? OR email LIKE ? OR bemerkung LIKE ? OR fachrichtung LIKE ?)") + params.extend([term] * 8) + query += " AND " + " AND ".join(conditions) + else: + # Bei ODER-Verknüpfung (Standard) muss mindestens ein Begriff in einem Feld vorkommen + query += " AND (name LIKE ? OR ort LIKE ? OR nummer LIKE ? OR telefon LIKE ? OR mobil LIKE ? OR email LIKE ? OR bemerkung LIKE ? OR fachrichtung LIKE ?)" + params.extend([search_term] * 8) # Spezifische Suche für einzelne Felder if search_params.get('name'): @@ -292,7 +305,8 @@ def search(): 'telefon': request.args.get('telefon', ''), 'email': request.args.get('email', ''), 'q': request.args.get('q', ''), - 'fachrichtung': request.args.get('fachrichtung', '') + 'fachrichtung': request.args.get('fachrichtung', ''), + 'operator': request.args.get('operator', 'or') } # Führe die Suche in der Datenbank durch diff --git a/static/css/styles.css b/static/css/styles.css index a6d528b..1f54322 100644 --- a/static/css/styles.css +++ b/static/css/styles.css @@ -235,4 +235,22 @@ body { .general-search .reset-icon { font-size: 1.2rem; padding: 0 1rem; +} + +.search-options { + font-size: 0.9em; + color: #666; +} + +.search-options .form-check { + margin-right: 1rem; +} + +.search-options .form-check-input { + cursor: pointer; +} + +.search-options .form-check-label { + cursor: pointer; + user-select: none; } \ No newline at end of file diff --git a/templates/index.html b/templates/index.html index 616f2f7..145eca4 100644 --- a/templates/index.html +++ b/templates/index.html @@ -24,6 +24,16 @@ +
+
+ + +
+
+ + +
+
@@ -278,6 +288,7 @@ const nummer = document.getElementById('nummerInput').value; const plz = document.getElementById('plzInput').value; const fachrichtung = document.getElementById('fachrichtungInput').value; + const searchOperator = document.querySelector('input[name="searchOperator"]:checked').value; // Zeige das Lade-Icon document.getElementById('loading').style.display = 'block'; @@ -290,6 +301,7 @@ if (nummer) params.append('nummer', nummer); if (plz) params.append('plz', plz); if (fachrichtung) params.append('fachrichtung', fachrichtung); + if (searchOperator) params.append('operator', searchOperator); // Führe die Suche durch fetch('/search?' + params.toString())