Compare commits
34 Commits
v1.0.7
...
feature/pw
Author | SHA1 | Date | |
---|---|---|---|
57d6daa298 | |||
80281d1c2c | |||
4c69478fa8 | |||
35645fc671 | |||
fab869eb58 | |||
6cd8f199c4 | |||
948a17b739 | |||
f2290cf77f | |||
0627b6ff33 | |||
24ba040537 | |||
997786be54 | |||
c4974787d4 | |||
a42bdaa721 | |||
49938a1085 | |||
d0a27fe095 | |||
d388bce528 | |||
aabb4540c9 | |||
ffde078238 | |||
9e320c4eb2 | |||
58ed5fe867 | |||
72676edc10 | |||
d5954eac89 | |||
68a2db28a1 | |||
13709de515 | |||
2c65d5f651 | |||
33ecb79e0b | |||
00bb197620 | |||
8e7d3da07f | |||
35e0d0a783 | |||
40196fa28f | |||
7b5e90e3bd | |||
3c48988e88 | |||
869acdcb18 | |||
91af1dfca0 |
16
.env.example
Normal file
16
.env.example
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
# Flask-Konfiguration
|
||||||
|
FLASK_APP=app.py
|
||||||
|
FLASK_ENV=development
|
||||||
|
SECRET_KEY=your-secret-key-here
|
||||||
|
|
||||||
|
# Datenbank-Konfiguration
|
||||||
|
DATABASE_URL=sqlite:///customers.db
|
||||||
|
|
||||||
|
# Authentifizierung
|
||||||
|
STATIC_PASSWORD=your-static-password-here
|
||||||
|
|
||||||
|
# IP-Bereiche für direkten Zugriff (ohne Login)
|
||||||
|
ALLOWED_IP_RANGES=192.168.0.0/24,192.168.177.0/24,213.178.68.218/29
|
||||||
|
|
||||||
|
# Logging-Konfiguration
|
||||||
|
LOG_LEVEL=INFO
|
6
.gitignore
vendored
6
.gitignore
vendored
@@ -46,3 +46,9 @@ coverage.xml
|
|||||||
|
|
||||||
# Daten
|
# Daten
|
||||||
spezexpo.csv
|
spezexpo.csv
|
||||||
|
|
||||||
|
# Database
|
||||||
|
*.db
|
||||||
|
data/customers.db
|
||||||
|
data/customers.csv
|
||||||
|
docker-compose.yml
|
111
CHANGELOG.md
111
CHANGELOG.md
@@ -5,54 +5,83 @@ Alle wichtigen Änderungen an diesem Projekt werden in dieser Datei dokumentiert
|
|||||||
Das Format basiert auf [Keep a Changelog](https://keepachangelog.com/de/1.0.0/),
|
Das Format basiert auf [Keep a Changelog](https://keepachangelog.com/de/1.0.0/),
|
||||||
und dieses Projekt adhäriert zu [Semantic Versioning](https://semver.org/lang/de/).
|
und dieses Projekt adhäriert zu [Semantic Versioning](https://semver.org/lang/de/).
|
||||||
|
|
||||||
## [v1.2.0] - 2024-03-17
|
## [1.2.6] - 2024-03-19
|
||||||
|
### Geändert
|
||||||
|
- Verbesserte Suchfunktion: Keine Ergebnisse mehr bei leeren Suchfeldern
|
||||||
|
- Optimiertes Highlighting der Suchergebnisse für alle Suchfelder
|
||||||
|
- Fachrichtung wird jetzt in den Suchergebnissen hervorgehoben
|
||||||
|
|
||||||
|
## [1.2.5] - 2024-03-19
|
||||||
|
### Hinzugefügt
|
||||||
|
- Neues Suchfeld für Fachrichtung
|
||||||
|
- Index für das Fachrichtung-Feld in der Datenbank
|
||||||
|
- Fachrichtung in der allgemeinen Suche integriert
|
||||||
|
|
||||||
|
## [1.2.4] - 2024-03-19
|
||||||
|
### Geändert
|
||||||
|
- Performance-Optimierung: Indizes für alle Suchfelder hinzugefügt
|
||||||
|
- Verbesserte Suchgeschwindigkeit durch optimierte Datenbankindizes
|
||||||
|
- Zusammengesetzter Index für die häufigste Suchkombination (Name + Ort) hinzugefügt
|
||||||
|
|
||||||
|
## [1.2.3] - 2024-03-19
|
||||||
|
### Geändert
|
||||||
|
- Performance-Optimierung: Entfernung aller console.log Anweisungen
|
||||||
|
- Verbesserte Code-Qualität durch Entfernung von Debug-Ausgaben
|
||||||
|
|
||||||
|
## [1.2.2] - 2024-03-19
|
||||||
|
### Geändert
|
||||||
|
- Verbesserte Telefonnummern-Formatierung: Führende "0" wird immer hinzugefügt, wenn der Benutzer von einer erlaubten IP-Adresse zugreift
|
||||||
|
- Debug-Logging für Telefonnummern-Formatierung hinzugefügt
|
||||||
|
- Verbesserte Benutzerfreundlichkeit bei der Anzeige von Telefonnummern
|
||||||
|
|
||||||
|
### Behoben
|
||||||
|
- Problem mit fehlender führender "0" bei Telefonnummern für autorisierte Benutzer
|
||||||
|
|
||||||
|
## [1.2.1] - 2024-03-18
|
||||||
|
### Geändert
|
||||||
|
- Verbesserte CSV-Import-Funktionalität mit pandas
|
||||||
|
- Korrektur des Login-Prozesses
|
||||||
|
- Verbesserte Fehlerbehandlung und Logging
|
||||||
|
- Anpassung der Spaltennamen für den CSV-Import
|
||||||
|
|
||||||
|
### Behoben
|
||||||
|
- Login-Prozess funktioniert jetzt korrekt mit dem Passwort aus der .env Datei
|
||||||
|
- CSV-Import verarbeitet Anführungszeichen korrekt
|
||||||
|
- Verbesserte Fehlerbehandlung beim Datenbankimport
|
||||||
|
|
||||||
|
## [1.2.0] - 2024-03-18
|
||||||
|
|
||||||
|
### Geändert
|
||||||
|
- IP-Subnetz-Prüfung korrigiert (CIDR-Notation wird jetzt korrekt ausgewertet)
|
||||||
|
- Debug-Logging für IP-Adressen hinzugefügt
|
||||||
|
- Beispiel-Umgebungsvariablen (.env.example) hinzugefügt
|
||||||
|
|
||||||
### Hinzugefügt
|
### Hinzugefügt
|
||||||
- Benutzer-Login-Funktionalität
|
- IP-basierte Zugriffssteuerung für medisoftware-Links
|
||||||
- Login-Seite mit Passwortüberprüfung
|
- IP-basierte Zugriffssteuerung für Telefonnummern-Links
|
||||||
- Umgebungsvariable für Login-Passwort
|
- Google Maps Integration für Adressen
|
||||||
|
- Version im Footer angezeigt
|
||||||
|
|
||||||
|
### Verbessert
|
||||||
|
- Verbesserte Fehlerbehandlung bei der IP-Überprüfung
|
||||||
|
- Bessere Dokumentation der Konfigurationsmöglichkeiten
|
||||||
|
|
||||||
## [v1.1.0] - 2024-03-17
|
## [v1.1.0] - 2024-03-17
|
||||||
|
|
||||||
### Geändert
|
|
||||||
- Verbesserte Darstellung der Telefonnummern:
|
|
||||||
- Separate Felder für private Telefonnummer, Firmennummer und Mobilfunknummer
|
|
||||||
- Entfernung der Faxnummer aus der Anzeige
|
|
||||||
- Übersichtlichere Darstellung der Kontaktinformationen
|
|
||||||
|
|
||||||
## [1.0.6] - 2024-03-17
|
|
||||||
### Geändert
|
|
||||||
- Verbesserte Suchfunktion: Kombinierte Suche über mehrere Felder möglich
|
|
||||||
- Dokumentation: Beispiele für kombinierte Suche hinzugefügt
|
|
||||||
|
|
||||||
## [1.0.5] - 2024-03-17
|
|
||||||
### Geändert
|
|
||||||
- Verbesserte Suchfunktion: Ergebnisliste wird gelöscht, wenn alle Suchfelder leer sind
|
|
||||||
|
|
||||||
## [1.0.4] - 2024-03-17
|
|
||||||
### Geändert
|
|
||||||
- Verbesserte Adressanzeige: Location-Icon neben der Adresse
|
|
||||||
- Entfernung des Google Maps Links aus dem Adresstext
|
|
||||||
|
|
||||||
## [1.0.3] - 2024-03-17
|
|
||||||
### Geändert
|
|
||||||
- Hervorhebung der Suchbegriffe in den Ergebnissen
|
|
||||||
- Verbesserte Benutzeroberfläche
|
|
||||||
|
|
||||||
## [1.0.2] - 2024-03-17
|
|
||||||
### Geändert
|
|
||||||
- Entfernung der Wetterinformationen
|
|
||||||
- Optimierung der Suchfunktion
|
|
||||||
|
|
||||||
## [1.0.1] - 2024-03-17
|
|
||||||
### Hinzugefügt
|
### Hinzugefügt
|
||||||
- Wetterinformationen für Kundensitz
|
- Benutzer-Login für nicht-autorisierte IPs
|
||||||
- Caching für Wetterdaten
|
- Verbesserte Darstellung der Telefonnummern
|
||||||
|
- Responsive Design für mobile Geräte
|
||||||
|
|
||||||
|
### Verbessert
|
||||||
|
- Optimierte Suchfunktion
|
||||||
|
- Verbesserte Benutzeroberfläche
|
||||||
|
|
||||||
## [v1.0.0] - 2024-03-17
|
## [v1.0.0] - 2024-03-17
|
||||||
|
|
||||||
### Hinzugefügt
|
### Hinzugefügt
|
||||||
- Erste Version der Kundensuche
|
- Erste Version mit grundlegenden Suchfunktionen
|
||||||
- Grundlegende Suchfunktionen
|
- Echtzeit-Suche über Kundendaten
|
||||||
- Responsive Design
|
- Hervorhebung von Suchbegriffen in den Ergebnissen
|
||||||
- Docker-Integration
|
- Klickbare Links für Telefonnummern, E-Mail-Adressen und Adressen
|
||||||
|
- Docker-Container für einfache Installation und Deployment
|
@@ -10,8 +10,12 @@ COPY requirements.txt .
|
|||||||
# Installiere Abhängigkeiten
|
# Installiere Abhängigkeiten
|
||||||
RUN pip install --no-cache-dir -r requirements.txt
|
RUN pip install --no-cache-dir -r requirements.txt
|
||||||
|
|
||||||
# Kopiere den Anwendungscode
|
# Erstelle das data Verzeichnis und setze Berechtigungen
|
||||||
COPY . .
|
RUN mkdir -p /app/data && \
|
||||||
|
chmod 755 /app/data
|
||||||
|
|
||||||
|
# Kopiere die Anwendungsdateien
|
||||||
|
COPY . /app/
|
||||||
|
|
||||||
# Exponiere Port 5000
|
# Exponiere Port 5000
|
||||||
EXPOSE 5000
|
EXPOSE 5000
|
||||||
|
50
README.md
50
README.md
@@ -1,14 +1,15 @@
|
|||||||
# medisoftware Kundensuche
|
# Medi-Customers
|
||||||
|
|
||||||
Eine webbasierte Suchanwendung für medisoftware Kunden, die eine schnelle und effiziente Suche nach Kundendaten ermöglicht.
|
Eine Flask-basierte Webanwendung zur Verwaltung von Kundenkontakten für medizinische Einrichtungen.
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
- Echtzeit-Suche über Kundendaten
|
- Kundensuche nach verschiedenen Kriterien (Name, Ort, Kundennummer, etc.)
|
||||||
- Hervorhebung von Suchbegriffen in den Ergebnissen
|
- Direkte Links zu Kundendaten in medisoftware (für autorisierte IPs)
|
||||||
- Klickbare Links für Telefonnummern, E-Mail-Adressen und Adressen
|
- Telefonnummern-Links für autorisierte IPs
|
||||||
- Responsive Design für mobile Geräte
|
- Adress-Links mit Google Maps Integration
|
||||||
- Docker-Container für einfache Installation und Deployment
|
- IP-basierte Zugriffssteuerung
|
||||||
|
- Responsive Design
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
@@ -18,18 +19,39 @@ git clone https://gitea.elpatron.me/elpatron/medi-customers.git
|
|||||||
cd medi-customers
|
cd medi-customers
|
||||||
```
|
```
|
||||||
|
|
||||||
2. Docker Container starten:
|
2. Umgebungsvariablen einrichten:
|
||||||
|
```bash
|
||||||
|
cp .env.example .env
|
||||||
|
# Bearbeiten Sie die .env-Datei mit Ihren Einstellungen
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Docker Container starten:
|
||||||
```bash
|
```bash
|
||||||
docker-compose up -d
|
docker-compose up -d
|
||||||
```
|
```
|
||||||
|
|
||||||
Die Anwendung ist dann unter `http://localhost:5000` erreichbar.
|
## Konfiguration
|
||||||
|
|
||||||
## Versionen
|
Die Anwendung kann über folgende Umgebungsvariablen konfiguriert werden:
|
||||||
|
|
||||||
- v1.2.0 (2024-03-17): Benutzer-Login hinzugefügt
|
- `FLASK_APP`: Die Hauptanwendungsdatei (Standard: app.py)
|
||||||
- v1.1.0 (2024-03-17): Verbesserte Darstellung der Telefonnummern
|
- `FLASK_ENV`: Die Flask-Umgebung (development/production)
|
||||||
- v1.0.0 (2024-03-17): Erste Version mit grundlegenden Suchfunktionen
|
- `SECRET_KEY`: Der geheime Schlüssel für Flask-Sessions
|
||||||
|
- `DATABASE_URL`: Die URL zur SQLite-Datenbank
|
||||||
|
- `STATIC_PASSWORD`: Das Passwort für die Login-Seite
|
||||||
|
- `ALLOWED_IP_RANGES`: Komma-getrennte Liste von IP-Bereichen, die direkten Zugriff haben
|
||||||
|
- `LOG_LEVEL`: Das Logging-Level (INFO/DEBUG)
|
||||||
|
|
||||||
|
## IP-Bereiche
|
||||||
|
|
||||||
|
Die Anwendung unterstützt CIDR-Notation für IP-Bereiche. Beispiele:
|
||||||
|
- Einzelne IP: 192.168.1.1/32
|
||||||
|
- Subnetz: 192.168.1.0/24
|
||||||
|
- Größeres Netzwerk: 10.0.0.0/8
|
||||||
|
|
||||||
|
## Version
|
||||||
|
|
||||||
|
Aktuelle Version: v1.2.6
|
||||||
|
|
||||||
## Lizenz
|
## Lizenz
|
||||||
|
|
||||||
@@ -81,4 +103,4 @@ curl "http://localhost:5001/search?fachrichtung=Zahnarzt&ort=Berlin&name=Schmidt
|
|||||||
|
|
||||||
## Version
|
## Version
|
||||||
|
|
||||||
Aktuelle Version: [v1.2.0](CHANGELOG.md#v120---2024-03-17)
|
Aktuelle Version: [v1.2.4](CHANGELOG.md#v124---2024-03-19)
|
343
app.py
343
app.py
@@ -1,4 +1,4 @@
|
|||||||
from flask import Flask, render_template, request, jsonify, url_for, redirect, session
|
from flask import Flask, render_template, request, jsonify, url_for, redirect, session, make_response, send_from_directory
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
import os
|
import os
|
||||||
import logging
|
import logging
|
||||||
@@ -8,23 +8,211 @@ from dotenv import load_dotenv
|
|||||||
import requests
|
import requests
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
import ipaddress
|
import ipaddress
|
||||||
|
import csv
|
||||||
|
import sqlite3
|
||||||
|
from functools import wraps
|
||||||
|
|
||||||
app = Flask(__name__, static_folder='static')
|
app = Flask(__name__, static_folder='static')
|
||||||
app.secret_key = 'your_secret_key' # Setzen Sie einen sicheren geheimen Schlüssel für die Session
|
app.secret_key = os.getenv('SECRET_KEY', 'default-secret-key')
|
||||||
logging.basicConfig(level=logging.DEBUG)
|
logging.basicConfig(level=logging.INFO)
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
# Version der Anwendung
|
# Version der Anwendung
|
||||||
VERSION = "1.0.6"
|
VERSION = "1.2.1"
|
||||||
|
|
||||||
# Pfad zur CSV-Datei
|
# Pfad zur CSV-Datei
|
||||||
CSV_FILE = "data/customers.csv"
|
CSV_FILE = 'data/customers.csv'
|
||||||
|
|
||||||
|
# Pfad zur Datenbank
|
||||||
|
DB_FILE = 'data/customers.db'
|
||||||
|
|
||||||
# Lade Umgebungsvariablen
|
# Lade Umgebungsvariablen
|
||||||
load_dotenv()
|
load_dotenv()
|
||||||
|
|
||||||
# Statisches Passwort aus der .env Datei
|
# Statisches Passwort aus der .env Datei
|
||||||
STATIC_PASSWORD = os.getenv('LOGIN_PASSWORD', 'changeme')
|
STATIC_PASSWORD = os.getenv('LOGIN_PASSWORD', 'default-password')
|
||||||
|
ALLOWED_IP_RANGES = os.getenv('ALLOWED_IP_RANGES', '').split(',')
|
||||||
|
|
||||||
|
def init_db():
|
||||||
|
"""Initialisiert die SQLite-Datenbank mit der notwendigen Tabelle."""
|
||||||
|
conn = sqlite3.connect(DB_FILE)
|
||||||
|
c = conn.cursor()
|
||||||
|
|
||||||
|
# Erstelle die Tabelle
|
||||||
|
c.execute('''
|
||||||
|
CREATE TABLE IF NOT EXISTS customers (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
nummer TEXT,
|
||||||
|
name TEXT,
|
||||||
|
strasse TEXT,
|
||||||
|
plz TEXT,
|
||||||
|
ort TEXT,
|
||||||
|
telefon TEXT,
|
||||||
|
mobil TEXT,
|
||||||
|
email TEXT,
|
||||||
|
bemerkung TEXT,
|
||||||
|
fachrichtung TEXT
|
||||||
|
)
|
||||||
|
''')
|
||||||
|
|
||||||
|
# Erstelle Indizes für alle Suchfelder
|
||||||
|
c.execute('CREATE INDEX IF NOT EXISTS idx_customers_nummer ON customers(nummer)')
|
||||||
|
c.execute('CREATE INDEX IF NOT EXISTS idx_customers_name ON customers(name)')
|
||||||
|
c.execute('CREATE INDEX IF NOT EXISTS idx_customers_strasse ON customers(strasse)')
|
||||||
|
c.execute('CREATE INDEX IF NOT EXISTS idx_customers_plz ON customers(plz)')
|
||||||
|
c.execute('CREATE INDEX IF NOT EXISTS idx_customers_ort ON customers(ort)')
|
||||||
|
c.execute('CREATE INDEX IF NOT EXISTS idx_customers_telefon ON customers(telefon)')
|
||||||
|
c.execute('CREATE INDEX IF NOT EXISTS idx_customers_mobil ON customers(mobil)')
|
||||||
|
c.execute('CREATE INDEX IF NOT EXISTS idx_customers_email ON customers(email)')
|
||||||
|
c.execute('CREATE INDEX IF NOT EXISTS idx_customers_fachrichtung ON customers(fachrichtung)')
|
||||||
|
|
||||||
|
# Erstelle einen zusammengesetzten Index für die häufigste Suchkombination
|
||||||
|
c.execute('CREATE INDEX IF NOT EXISTS idx_customers_name_ort ON customers(name, ort)')
|
||||||
|
|
||||||
|
conn.commit()
|
||||||
|
conn.close()
|
||||||
|
logger.info('Datenbank initialisiert')
|
||||||
|
|
||||||
|
def import_csv():
|
||||||
|
"""Importiert die Daten aus der CSV-Datei in die SQLite-Datenbank."""
|
||||||
|
conn = sqlite3.connect(DB_FILE)
|
||||||
|
c = conn.cursor()
|
||||||
|
|
||||||
|
# Lösche bestehende Daten
|
||||||
|
c.execute('DELETE FROM customers')
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Lese die CSV-Datei mit pandas
|
||||||
|
df = pd.read_csv(CSV_FILE, sep=',', encoding='utf-8', quotechar='"')
|
||||||
|
|
||||||
|
# Entferne Anführungszeichen aus den Spaltennamen
|
||||||
|
df.columns = df.columns.str.strip('"')
|
||||||
|
|
||||||
|
# Entferne Anführungszeichen aus den Werten
|
||||||
|
for col in df.columns:
|
||||||
|
if df[col].dtype == 'object':
|
||||||
|
df[col] = df[col].str.strip('"')
|
||||||
|
|
||||||
|
# Kombiniere Vorname und Nachname
|
||||||
|
df['name'] = df['Vorname'] + ' ' + df['Nachname']
|
||||||
|
|
||||||
|
# Importiere die Daten
|
||||||
|
for _, row in df.iterrows():
|
||||||
|
c.execute('''
|
||||||
|
INSERT INTO customers (nummer, name, strasse, plz, ort, telefon, mobil, email, bemerkung, fachrichtung)
|
||||||
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||||
|
''', (
|
||||||
|
row['Nummer'],
|
||||||
|
row['name'],
|
||||||
|
row['Strasse'],
|
||||||
|
row['PLZ'],
|
||||||
|
row['Ort'],
|
||||||
|
row['Tel'],
|
||||||
|
row['Handy'],
|
||||||
|
row['mail'],
|
||||||
|
f"Fachrichtung: {row['Fachrichtung']}",
|
||||||
|
row['Fachrichtung']
|
||||||
|
))
|
||||||
|
|
||||||
|
conn.commit()
|
||||||
|
logger.info('CSV-Daten erfolgreich in die Datenbank importiert')
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f'Fehler beim Import der CSV-Daten: {str(e)}')
|
||||||
|
raise
|
||||||
|
finally:
|
||||||
|
conn.close()
|
||||||
|
|
||||||
|
def search_customers(search_params):
|
||||||
|
"""Sucht nach Kunden basierend auf den Suchparametern."""
|
||||||
|
# Prüfe, ob alle Suchfelder leer sind
|
||||||
|
if not any([
|
||||||
|
search_params.get('q'),
|
||||||
|
search_params.get('name'),
|
||||||
|
search_params.get('ort'),
|
||||||
|
search_params.get('nummer'),
|
||||||
|
search_params.get('plz'),
|
||||||
|
search_params.get('telefon'),
|
||||||
|
search_params.get('email'),
|
||||||
|
search_params.get('fachrichtung')
|
||||||
|
]):
|
||||||
|
return []
|
||||||
|
|
||||||
|
conn = sqlite3.connect(DB_FILE)
|
||||||
|
c = conn.cursor()
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Baue die SQL-Abfrage dynamisch auf
|
||||||
|
query = "SELECT * FROM customers WHERE 1=1"
|
||||||
|
params = []
|
||||||
|
|
||||||
|
# Allgemeine Suche über alle Felder
|
||||||
|
if search_params.get('q'):
|
||||||
|
search_term = f"%{search_params['q']}%"
|
||||||
|
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'):
|
||||||
|
query += " AND name LIKE ?"
|
||||||
|
params.append(f"%{search_params['name']}%")
|
||||||
|
|
||||||
|
if search_params.get('ort'):
|
||||||
|
query += " AND ort LIKE ?"
|
||||||
|
params.append(f"%{search_params['ort']}%")
|
||||||
|
|
||||||
|
if search_params.get('nummer'):
|
||||||
|
query += " AND nummer LIKE ?"
|
||||||
|
params.append(f"%{search_params['nummer']}%")
|
||||||
|
|
||||||
|
if search_params.get('plz'):
|
||||||
|
query += " AND plz LIKE ?"
|
||||||
|
params.append(f"%{search_params['plz']}%")
|
||||||
|
|
||||||
|
if search_params.get('fachrichtung'):
|
||||||
|
query += " AND fachrichtung LIKE ?"
|
||||||
|
params.append(f"%{search_params['fachrichtung']}%")
|
||||||
|
|
||||||
|
# Führe die Abfrage aus
|
||||||
|
c.execute(query, params)
|
||||||
|
results = c.fetchall()
|
||||||
|
|
||||||
|
# Formatiere die Ergebnisse
|
||||||
|
customers = []
|
||||||
|
for row in results:
|
||||||
|
customer = {
|
||||||
|
'id': row[0],
|
||||||
|
'nummer': row[1],
|
||||||
|
'name': row[2],
|
||||||
|
'strasse': row[3],
|
||||||
|
'plz': row[4],
|
||||||
|
'ort': row[5],
|
||||||
|
'telefon': row[6],
|
||||||
|
'mobil': row[7],
|
||||||
|
'email': row[8],
|
||||||
|
'bemerkung': row[9],
|
||||||
|
'fachrichtung': row[10]
|
||||||
|
}
|
||||||
|
customers.append(customer)
|
||||||
|
|
||||||
|
return customers
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"Fehler bei der Kundensuche: {str(e)}")
|
||||||
|
raise
|
||||||
|
finally:
|
||||||
|
conn.close()
|
||||||
|
|
||||||
def clean_dataframe(df):
|
def clean_dataframe(df):
|
||||||
"""Konvertiert NaN-Werte in None für JSON-Kompatibilität"""
|
"""Konvertiert NaN-Werte in None für JSON-Kompatibilität"""
|
||||||
@@ -61,6 +249,7 @@ def login():
|
|||||||
|
|
||||||
logger.info(f"Client-IP: {client_ip}")
|
logger.info(f"Client-IP: {client_ip}")
|
||||||
logger.info(f"Erlaubte IP-Bereiche: {allowed_ip_ranges}")
|
logger.info(f"Erlaubte IP-Bereiche: {allowed_ip_ranges}")
|
||||||
|
logger.info(f"Session Status: {session}")
|
||||||
|
|
||||||
# Überprüfen, ob die IP-Adresse in einem der erlaubten Subnetze liegt
|
# Überprüfen, ob die IP-Adresse in einem der erlaubten Subnetze liegt
|
||||||
client_ip_obj = ipaddress.ip_address(client_ip)
|
client_ip_obj = ipaddress.ip_address(client_ip)
|
||||||
@@ -71,92 +260,114 @@ def login():
|
|||||||
if client_ip_obj in network:
|
if client_ip_obj in network:
|
||||||
logger.info("Client-IP ist im erlaubten Bereich.")
|
logger.info("Client-IP ist im erlaubten Bereich.")
|
||||||
session['logged_in'] = True
|
session['logged_in'] = True
|
||||||
|
session.permanent = True # Session bleibt bestehen
|
||||||
return redirect(url_for('index'))
|
return redirect(url_for('index'))
|
||||||
except ValueError:
|
except ValueError:
|
||||||
logger.error(f"Ungültiges Netzwerkformat: {ip_range}")
|
logger.error(f"Ungültiges Netzwerkformat: {ip_range}")
|
||||||
|
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
password = request.form.get('password')
|
password = request.form.get('password')
|
||||||
|
logger.info(f"Login-Versuch mit Passwort: {'*' * len(password) if password else 'None'}")
|
||||||
if password == STATIC_PASSWORD:
|
if password == STATIC_PASSWORD:
|
||||||
session['logged_in'] = True
|
session['logged_in'] = True
|
||||||
|
session.permanent = True # Session bleibt bestehen
|
||||||
|
logger.info("Login erfolgreich, Session gesetzt")
|
||||||
return redirect(url_for('index'))
|
return redirect(url_for('index'))
|
||||||
else:
|
else:
|
||||||
|
logger.warning("Falsches Passwort eingegeben")
|
||||||
return render_template('login.html', error="Falsches Passwort")
|
return render_template('login.html', error="Falsches Passwort")
|
||||||
|
|
||||||
|
logger.info("Zeige Login-Seite")
|
||||||
return render_template('login.html')
|
return render_template('login.html')
|
||||||
|
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
def index():
|
def index():
|
||||||
|
logger.info(f"Index-Route aufgerufen. Session Status: {session}")
|
||||||
if not session.get('logged_in'):
|
if not session.get('logged_in'):
|
||||||
|
logger.info("Benutzer nicht eingeloggt, Weiterleitung zum Login")
|
||||||
return redirect(url_for('login'))
|
return redirect(url_for('login'))
|
||||||
return render_template('index.html')
|
|
||||||
|
allowed_ip_ranges = os.getenv('ALLOWED_IP_RANGES', '')
|
||||||
|
client_ip = request.headers.get('X-Forwarded-For', request.remote_addr)
|
||||||
|
logger.info(f"Client-IP: {client_ip}")
|
||||||
|
logger.info(f"Erlaubte IP-Bereiche: {allowed_ip_ranges}")
|
||||||
|
return render_template('index.html', allowed_ip_ranges=allowed_ip_ranges)
|
||||||
|
|
||||||
@app.route('/search')
|
@app.route('/search')
|
||||||
def search():
|
def search():
|
||||||
if not session.get('logged_in'):
|
|
||||||
return redirect(url_for('login'))
|
|
||||||
try:
|
try:
|
||||||
# CSV-Datei laden
|
# Hole die Suchparameter aus der Anfrage
|
||||||
df = load_data()
|
search_params = {
|
||||||
if df is None:
|
'name': request.args.get('name', ''),
|
||||||
return jsonify({"error": "Datenbank konnte nicht geladen werden"}), 500
|
'ort': request.args.get('ort', ''),
|
||||||
|
'nummer': request.args.get('nummer', ''),
|
||||||
|
'plz': request.args.get('plz', ''),
|
||||||
|
'telefon': request.args.get('telefon', ''),
|
||||||
|
'email': request.args.get('email', ''),
|
||||||
|
'q': request.args.get('q', ''),
|
||||||
|
'fachrichtung': request.args.get('fachrichtung', ''),
|
||||||
|
'operator': request.args.get('operator', 'or')
|
||||||
|
}
|
||||||
|
|
||||||
# Suchparameter aus der URL holen
|
# Führe die Suche in der Datenbank durch
|
||||||
name = request.args.get('name', '').strip()
|
results = search_customers(search_params)
|
||||||
ort = request.args.get('ort', '').strip()
|
|
||||||
kundennummer = request.args.get('kundennummer', '').strip()
|
|
||||||
fachrichtung = request.args.get('fachrichtung', '').strip()
|
|
||||||
telefon = request.args.get('telefon', '').strip()
|
|
||||||
query = request.args.get('q', '').strip()
|
|
||||||
|
|
||||||
# Initialisiere die Maske für die Filterung
|
# Protokolliere die Anzahl der gefundenen Ergebnisse
|
||||||
mask = pd.Series(True, index=df.index)
|
logger.info(f'Suchergebnisse gefunden: {len(results)}')
|
||||||
|
|
||||||
# Wenn eine allgemeine Suche angegeben ist
|
return jsonify(results)
|
||||||
if query:
|
|
||||||
query_mask = (
|
|
||||||
df['Vorname'].str.contains(query, case=False, na=False) |
|
|
||||||
df['Nachname'].str.contains(query, case=False, na=False) |
|
|
||||||
df['Ort'].str.contains(query, case=False, na=False) |
|
|
||||||
df['Nummer'].astype(str).str.contains(query, case=False, na=False) |
|
|
||||||
df['Fachrichtung'].str.contains(query, case=False, na=False) |
|
|
||||||
df['Tel'].astype(str).str.contains(query, case=False, na=False)
|
|
||||||
)
|
|
||||||
mask &= query_mask
|
|
||||||
|
|
||||||
# Spezifische Suchkriterien anwenden
|
|
||||||
if name:
|
|
||||||
name_mask = (
|
|
||||||
df['Vorname'].str.contains(name, case=False, na=False) |
|
|
||||||
df['Nachname'].str.contains(name, case=False, na=False)
|
|
||||||
)
|
|
||||||
mask &= name_mask
|
|
||||||
|
|
||||||
if ort:
|
|
||||||
ort_mask = df['Ort'].str.contains(ort, case=False, na=False)
|
|
||||||
mask &= ort_mask
|
|
||||||
|
|
||||||
if kundennummer:
|
|
||||||
kundennummer_mask = df['Nummer'].astype(str).str.contains(kundennummer, case=False, na=False)
|
|
||||||
mask &= kundennummer_mask
|
|
||||||
|
|
||||||
if fachrichtung:
|
|
||||||
fachrichtung_mask = df['Fachrichtung'].str.contains(fachrichtung, case=False, na=False)
|
|
||||||
mask &= fachrichtung_mask
|
|
||||||
|
|
||||||
if telefon:
|
|
||||||
telefon_mask = df['Tel'].astype(str).str.contains(telefon, case=False, na=False)
|
|
||||||
mask &= telefon_mask
|
|
||||||
|
|
||||||
results = df[mask].to_dict('records')
|
|
||||||
logger.info(f"{len(results)} Ergebnisse gefunden")
|
|
||||||
|
|
||||||
return jsonify({
|
|
||||||
'results': results,
|
|
||||||
'total': len(results)
|
|
||||||
})
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Fehler bei der Suche: {str(e)}")
|
logger.error(f'Fehler bei der Suche: {str(e)}')
|
||||||
return jsonify({"error": str(e)}), 500
|
return jsonify({"error": str(e)}), 500
|
||||||
|
|
||||||
|
@app.route('/sw.js')
|
||||||
|
def sw():
|
||||||
|
response = make_response(send_from_directory('static', 'sw.js'))
|
||||||
|
response.headers['Content-Type'] = 'application/javascript'
|
||||||
|
return response
|
||||||
|
|
||||||
|
@app.route('/offline')
|
||||||
|
def offline():
|
||||||
|
return render_template('offline.html')
|
||||||
|
|
||||||
|
@app.route('/api/search', methods=['POST'])
|
||||||
|
def api_search():
|
||||||
|
"""API-Endpunkt für die Kundensuche"""
|
||||||
|
try:
|
||||||
|
search_params = request.get_json()
|
||||||
|
results = search_customers(search_params)
|
||||||
|
return jsonify(results)
|
||||||
|
except Exception as e:
|
||||||
|
return jsonify({"error": str(e)}), 500
|
||||||
|
|
||||||
|
@app.route('/api/customers')
|
||||||
|
def api_customers():
|
||||||
|
"""API-Endpunkt für alle Kunden"""
|
||||||
|
try:
|
||||||
|
conn = sqlite3.connect(DB_FILE)
|
||||||
|
c = conn.cursor()
|
||||||
|
c.execute('SELECT * FROM customers')
|
||||||
|
columns = [description[0] for description in c.description]
|
||||||
|
results = []
|
||||||
|
for row in c.fetchall():
|
||||||
|
customer = dict(zip(columns, row))
|
||||||
|
results.append(customer)
|
||||||
|
conn.close()
|
||||||
|
return jsonify(results)
|
||||||
|
except Exception as e:
|
||||||
|
return jsonify({"error": str(e)}), 500
|
||||||
|
|
||||||
|
def init_app(app):
|
||||||
|
"""Initialisiert die Anwendung mit allen notwendigen Einstellungen."""
|
||||||
|
with app.app_context():
|
||||||
|
# Initialisiere die Datenbank
|
||||||
|
init_db()
|
||||||
|
# Importiere die CSV-Daten
|
||||||
|
import_csv()
|
||||||
|
logger.info("Anwendung erfolgreich initialisiert")
|
||||||
|
|
||||||
|
# Initialisiere die App
|
||||||
|
init_app(app)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
app.run(debug=True, port=5001)
|
app.run(debug=True, port=5001)
|
@@ -1,12 +0,0 @@
|
|||||||
services:
|
|
||||||
web:
|
|
||||||
build: .
|
|
||||||
ports:
|
|
||||||
- "5001:5000"
|
|
||||||
volumes:
|
|
||||||
- .:/app
|
|
||||||
environment:
|
|
||||||
- FLASK_APP=app.py
|
|
||||||
- FLASK_ENV=development
|
|
||||||
- FLASK_DEBUG=1
|
|
||||||
command: flask run --host=0.0.0.0
|
|
13
docker-compose.yml.example
Normal file
13
docker-compose.yml.example
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
services:
|
||||||
|
web:
|
||||||
|
build: .
|
||||||
|
ports:
|
||||||
|
- "5001:5000"
|
||||||
|
volumes:
|
||||||
|
- ./data:/app/data
|
||||||
|
environment:
|
||||||
|
- FLASK_APP=app.py
|
||||||
|
- FLASK_ENV=production
|
||||||
|
- LOGIN_PASSWORD=changeme
|
||||||
|
- ALLOWED_IP_RANGES=213.178.68.218/29,192.168.0.0/24,192.168.177.0/24
|
||||||
|
command: flask run --host=0.0.0.0
|
39
scripts/generate_icons.py
Normal file
39
scripts/generate_icons.py
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
from PIL import Image, ImageDraw, ImageFont
|
||||||
|
import os
|
||||||
|
|
||||||
|
def create_icon(size):
|
||||||
|
# Erstelle ein neues Bild mit grünem Hintergrund
|
||||||
|
image = Image.new('RGB', (size, size), '#4CAF50')
|
||||||
|
draw = ImageDraw.Draw(image)
|
||||||
|
|
||||||
|
# Versuche, eine Schriftart zu laden
|
||||||
|
try:
|
||||||
|
font = ImageFont.truetype("arial.ttf", size // 3)
|
||||||
|
except:
|
||||||
|
font = ImageFont.load_default()
|
||||||
|
|
||||||
|
# Text "MEDI" zeichnen
|
||||||
|
text = "MEDI"
|
||||||
|
text_bbox = draw.textbbox((0, 0), text, font=font)
|
||||||
|
text_width = text_bbox[2] - text_bbox[0]
|
||||||
|
text_height = text_bbox[3] - text_bbox[1]
|
||||||
|
x = (size - text_width) // 2
|
||||||
|
y = (size - text_height) // 2
|
||||||
|
draw.text((x, y), text, fill='white', font=font)
|
||||||
|
|
||||||
|
# Speichere das Icon
|
||||||
|
output_file = f'static/images/icon-{size}x{size}.png'
|
||||||
|
image.save(output_file, 'PNG')
|
||||||
|
print(f'Icon {size}x{size} generiert: {output_file}')
|
||||||
|
|
||||||
|
def main():
|
||||||
|
# Erstelle das Verzeichnis, falls es nicht existiert
|
||||||
|
os.makedirs('static/images', exist_ok=True)
|
||||||
|
|
||||||
|
# Generiere Icons in verschiedenen Größen
|
||||||
|
sizes = [192, 512]
|
||||||
|
for size in sizes:
|
||||||
|
create_icon(size)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
334
static/css/styles.css
Normal file
334
static/css/styles.css
Normal file
@@ -0,0 +1,334 @@
|
|||||||
|
body {
|
||||||
|
min-height: 100vh;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.main-content {
|
||||||
|
flex: 1 0 auto;
|
||||||
|
padding: 2rem 0;
|
||||||
|
margin-bottom: 4rem; /* Platz für die fixierte Fußzeile */
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-container {
|
||||||
|
max-width: 800px;
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.result-card {
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.result-card:hover {
|
||||||
|
transform: translateY(-2px);
|
||||||
|
box-shadow: 0 4px 8px rgba(0,0,0,0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.loading {
|
||||||
|
display: none;
|
||||||
|
text-align: center;
|
||||||
|
margin: 2rem 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.phone-link, .email-link, .address-link, .customer-link {
|
||||||
|
text-decoration: none;
|
||||||
|
color: #0d6efd;
|
||||||
|
}
|
||||||
|
|
||||||
|
.phone-link:hover, .email-link:hover, .address-link:hover, .customer-link:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-icon, .reset-icon {
|
||||||
|
position: absolute;
|
||||||
|
top: 50%;
|
||||||
|
transform: translateY(-50%);
|
||||||
|
color: #6c757d;
|
||||||
|
cursor: pointer;
|
||||||
|
display: none;
|
||||||
|
z-index: 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
.reset-icon {
|
||||||
|
right: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-icon {
|
||||||
|
right: 35px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.reset-icon.visible {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-icon.visible {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.customer-number {
|
||||||
|
color: #6c757d;
|
||||||
|
font-size: 0.9em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footer {
|
||||||
|
flex-shrink: 0;
|
||||||
|
text-align: center;
|
||||||
|
padding: 1rem;
|
||||||
|
background-color: #f8f9fa;
|
||||||
|
border-top: 1px solid #dee2e6;
|
||||||
|
width: 100%;
|
||||||
|
position: fixed;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
z-index: 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
.share-feedback {
|
||||||
|
position: fixed;
|
||||||
|
bottom: 20px;
|
||||||
|
right: 20px;
|
||||||
|
background: #28a745;
|
||||||
|
color: white;
|
||||||
|
padding: 8px 16px;
|
||||||
|
border-radius: 4px;
|
||||||
|
display: none;
|
||||||
|
animation: fadeOut 2s forwards;
|
||||||
|
z-index: 1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes fadeOut {
|
||||||
|
0% { opacity: 1; }
|
||||||
|
70% { opacity: 1; }
|
||||||
|
100% { opacity: 0; }
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-actions {
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-end;
|
||||||
|
margin-top: 1rem;
|
||||||
|
padding-top: 1rem;
|
||||||
|
border-top: 1px solid #e9ecef;
|
||||||
|
}
|
||||||
|
|
||||||
|
.share-button {
|
||||||
|
padding: 0.5rem 1rem;
|
||||||
|
border-radius: 20px;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
background-color: #0d6efd;
|
||||||
|
color: white;
|
||||||
|
border: none;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.share-button:hover {
|
||||||
|
background-color: #0b5ed7;
|
||||||
|
transform: translateY(-1px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.share-button i {
|
||||||
|
font-size: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-fields {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
||||||
|
gap: 1rem;
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-field {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-group {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.result-counts {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
padding: 0.5rem;
|
||||||
|
background-color: #f8f9fa;
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.result-count {
|
||||||
|
background-color: #e9ecef;
|
||||||
|
padding: 4px 12px;
|
||||||
|
border-radius: 12px;
|
||||||
|
font-size: 0.9em;
|
||||||
|
color: #6c757d;
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.result-count.visible {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.location-pin {
|
||||||
|
color: #dc3545;
|
||||||
|
margin-left: 4px;
|
||||||
|
font-size: 1.2em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.customer-card {
|
||||||
|
background: white;
|
||||||
|
border-radius: 8px;
|
||||||
|
padding: 1.5rem;
|
||||||
|
margin-bottom: 1.5rem;
|
||||||
|
box-shadow: 0 2px 4px rgba(0,0,0,0.05);
|
||||||
|
border-bottom: 1px solid #e9ecef;
|
||||||
|
}
|
||||||
|
|
||||||
|
.customer-card:last-child {
|
||||||
|
border-bottom: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.customer-info {
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footer-content {
|
||||||
|
padding: 1rem;
|
||||||
|
background-color: #f8f9fa;
|
||||||
|
border-top: 1px solid #dee2e6;
|
||||||
|
width: 100%;
|
||||||
|
position: fixed;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
z-index: 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footer-link {
|
||||||
|
color: #0d6efd;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footer-link:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
.general-search {
|
||||||
|
max-width: 800px;
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.general-search .input-group {
|
||||||
|
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.general-search .form-control {
|
||||||
|
height: 3.5rem;
|
||||||
|
font-size: 1.2rem;
|
||||||
|
padding: 0.75rem 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.general-search .search-icon,
|
||||||
|
.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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Offline-Indikator */
|
||||||
|
.offline-indicator {
|
||||||
|
position: fixed;
|
||||||
|
bottom: 20px;
|
||||||
|
right: 20px;
|
||||||
|
background-color: #ff9800;
|
||||||
|
color: white;
|
||||||
|
padding: 10px 20px;
|
||||||
|
border-radius: 5px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
box-shadow: 0 2px 5px rgba(0,0,0,0.2);
|
||||||
|
z-index: 1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
.offline-icon {
|
||||||
|
font-size: 1.2em;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Synchronisations-Status */
|
||||||
|
.sync-status {
|
||||||
|
position: fixed;
|
||||||
|
bottom: 20px;
|
||||||
|
right: 20px;
|
||||||
|
background-color: #4CAF50;
|
||||||
|
color: white;
|
||||||
|
padding: 10px 20px;
|
||||||
|
border-radius: 5px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
box-shadow: 0 2px 5px rgba(0,0,0,0.2);
|
||||||
|
z-index: 1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sync-icon {
|
||||||
|
font-size: 1.2em;
|
||||||
|
animation: spin 1s linear infinite;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes spin {
|
||||||
|
from { transform: rotate(0deg); }
|
||||||
|
to { transform: rotate(360deg); }
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Offline-Modus Styling */
|
||||||
|
body.offline {
|
||||||
|
filter: grayscale(20%);
|
||||||
|
}
|
||||||
|
|
||||||
|
body.offline .search-container {
|
||||||
|
opacity: 0.9;
|
||||||
|
}
|
||||||
|
|
||||||
|
body.offline .footer::after {
|
||||||
|
content: "Offline-Modus";
|
||||||
|
display: block;
|
||||||
|
text-align: center;
|
||||||
|
color: #ff9800;
|
||||||
|
font-size: 0.8em;
|
||||||
|
margin-top: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Offline-Fallback für Bilder */
|
||||||
|
.offline img {
|
||||||
|
opacity: 0.8;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Verbesserte Sichtbarkeit im Offline-Modus */
|
||||||
|
.offline .search-field input {
|
||||||
|
background-color: rgba(255, 255, 255, 0.9);
|
||||||
|
}
|
||||||
|
|
||||||
|
.offline .result-count {
|
||||||
|
color: #666;
|
||||||
|
}
|
BIN
static/images/icon-192x192.png
Normal file
BIN
static/images/icon-192x192.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.5 KiB |
BIN
static/images/icon-512x512.png
Normal file
BIN
static/images/icon-512x512.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.9 KiB |
25
static/images/icon.svg
Normal file
25
static/images/icon.svg
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<svg width="512" height="512" viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<!-- Hintergrund -->
|
||||||
|
<rect width="512" height="512" fill="#4CAF50"/>
|
||||||
|
|
||||||
|
<!-- MEDI Text -->
|
||||||
|
<text x="256" y="300"
|
||||||
|
font-family="Arial, sans-serif"
|
||||||
|
font-size="200"
|
||||||
|
font-weight="bold"
|
||||||
|
fill="white"
|
||||||
|
text-anchor="middle">
|
||||||
|
MEDI
|
||||||
|
</text>
|
||||||
|
|
||||||
|
<!-- Herz-Symbol -->
|
||||||
|
<path d="M256 150
|
||||||
|
C 256 150, 200 100, 150 100
|
||||||
|
C 100 100, 50 150, 50 200
|
||||||
|
C 50 250, 256 350, 256 350
|
||||||
|
C 256 350, 462 250, 462 200
|
||||||
|
C 462 150, 412 100, 362 100
|
||||||
|
C 312 100, 256 150, 256 150"
|
||||||
|
fill="white"/>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 775 B |
144
static/js/db.js
Normal file
144
static/js/db.js
Normal file
@@ -0,0 +1,144 @@
|
|||||||
|
// IndexedDB Konfiguration
|
||||||
|
const DB_NAME = 'mediCustomersDB';
|
||||||
|
const DB_VERSION = 1;
|
||||||
|
const STORE_NAME = 'customers';
|
||||||
|
|
||||||
|
// Datenbank initialisieren
|
||||||
|
const initDB = () => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const request = indexedDB.open(DB_NAME, DB_VERSION);
|
||||||
|
|
||||||
|
request.onerror = () => {
|
||||||
|
console.error('Fehler beim Öffnen der Datenbank:', request.error);
|
||||||
|
reject(request.error);
|
||||||
|
};
|
||||||
|
|
||||||
|
request.onsuccess = () => {
|
||||||
|
console.log('Datenbank erfolgreich geöffnet');
|
||||||
|
resolve(request.result);
|
||||||
|
};
|
||||||
|
|
||||||
|
request.onupgradeneeded = (event) => {
|
||||||
|
const db = event.target.result;
|
||||||
|
if (!db.objectStoreNames.contains(STORE_NAME)) {
|
||||||
|
const store = db.createObjectStore(STORE_NAME, { keyPath: 'nummer' });
|
||||||
|
// Indizes für die Suche erstellen
|
||||||
|
store.createIndex('name', 'name', { unique: false });
|
||||||
|
store.createIndex('ort', 'ort', { unique: false });
|
||||||
|
store.createIndex('plz', 'plz', { unique: false });
|
||||||
|
store.createIndex('fachrichtung', 'fachrichtung', { unique: false });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// Kunden in IndexedDB speichern
|
||||||
|
const saveCustomers = async (customers) => {
|
||||||
|
const db = await initDB();
|
||||||
|
const tx = db.transaction(STORE_NAME, 'readwrite');
|
||||||
|
const store = tx.objectStore(STORE_NAME);
|
||||||
|
|
||||||
|
return Promise.all(customers.map(customer => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const request = store.put(customer);
|
||||||
|
request.onsuccess = () => resolve();
|
||||||
|
request.onerror = () => reject(request.error);
|
||||||
|
});
|
||||||
|
}));
|
||||||
|
};
|
||||||
|
|
||||||
|
// Kunden aus IndexedDB suchen
|
||||||
|
const searchCustomersOffline = async (searchParams) => {
|
||||||
|
const db = await initDB();
|
||||||
|
const tx = db.transaction(STORE_NAME, 'readonly');
|
||||||
|
const store = tx.objectStore(STORE_NAME);
|
||||||
|
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const request = store.getAll();
|
||||||
|
|
||||||
|
request.onsuccess = () => {
|
||||||
|
let results = request.result;
|
||||||
|
|
||||||
|
// Filtern basierend auf den Suchparametern
|
||||||
|
if (searchParams.q) {
|
||||||
|
const searchTerms = searchParams.q.toLowerCase().split(' ');
|
||||||
|
const operator = searchParams.operator || 'or';
|
||||||
|
|
||||||
|
results = results.filter(customer => {
|
||||||
|
const searchableText = `${customer.name} ${customer.ort} ${customer.nummer} ${customer.plz} ${customer.fachrichtung}`.toLowerCase();
|
||||||
|
|
||||||
|
if (operator === 'and') {
|
||||||
|
return searchTerms.every(term => searchableText.includes(term));
|
||||||
|
} else {
|
||||||
|
return searchTerms.some(term => searchableText.includes(term));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Spezifische Feldsuche
|
||||||
|
if (searchParams.name) {
|
||||||
|
results = results.filter(c => c.name.toLowerCase().includes(searchParams.name.toLowerCase()));
|
||||||
|
}
|
||||||
|
if (searchParams.ort) {
|
||||||
|
results = results.filter(c => c.ort.toLowerCase().includes(searchParams.ort.toLowerCase()));
|
||||||
|
}
|
||||||
|
if (searchParams.nummer) {
|
||||||
|
results = results.filter(c => c.nummer.toString().includes(searchParams.nummer));
|
||||||
|
}
|
||||||
|
if (searchParams.plz) {
|
||||||
|
results = results.filter(c => c.plz.includes(searchParams.plz));
|
||||||
|
}
|
||||||
|
if (searchParams.fachrichtung) {
|
||||||
|
results = results.filter(c => c.fachrichtung.toLowerCase().includes(searchParams.fachrichtung.toLowerCase()));
|
||||||
|
}
|
||||||
|
|
||||||
|
resolve(results);
|
||||||
|
};
|
||||||
|
|
||||||
|
request.onerror = () => {
|
||||||
|
reject(request.error);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// Synchronisationsstatus speichern
|
||||||
|
const syncStatus = {
|
||||||
|
lastSync: null,
|
||||||
|
isOnline: navigator.onLine
|
||||||
|
};
|
||||||
|
|
||||||
|
// Event Listener für Online/Offline Status
|
||||||
|
window.addEventListener('online', () => {
|
||||||
|
syncStatus.isOnline = true;
|
||||||
|
document.body.classList.remove('offline');
|
||||||
|
synchronizeData();
|
||||||
|
});
|
||||||
|
|
||||||
|
window.addEventListener('offline', () => {
|
||||||
|
syncStatus.isOnline = false;
|
||||||
|
document.body.classList.add('offline');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Daten mit dem Server synchronisieren
|
||||||
|
const synchronizeData = async () => {
|
||||||
|
if (!syncStatus.isOnline) return;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await fetch('/api/customers');
|
||||||
|
const customers = await response.json();
|
||||||
|
await saveCustomers(customers);
|
||||||
|
syncStatus.lastSync = new Date();
|
||||||
|
console.log('Daten erfolgreich synchronisiert');
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Fehler bei der Synchronisation:', error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Export der Funktionen
|
||||||
|
window.dbHelper = {
|
||||||
|
initDB,
|
||||||
|
saveCustomers,
|
||||||
|
searchCustomersOffline,
|
||||||
|
synchronizeData,
|
||||||
|
syncStatus
|
||||||
|
};
|
28
static/manifest.json
Normal file
28
static/manifest.json
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
{
|
||||||
|
"name": "MEDI Kunden",
|
||||||
|
"short_name": "MEDI",
|
||||||
|
"description": "MEDI Kundenverwaltung - Offline-fähige PWA",
|
||||||
|
"start_url": "/",
|
||||||
|
"display": "standalone",
|
||||||
|
"background_color": "#ffffff",
|
||||||
|
"theme_color": "#4CAF50",
|
||||||
|
"orientation": "portrait",
|
||||||
|
"icons": [
|
||||||
|
{
|
||||||
|
"src": "/static/images/icon-192x192.png",
|
||||||
|
"sizes": "192x192",
|
||||||
|
"type": "image/png",
|
||||||
|
"purpose": "any maskable"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"src": "/static/images/icon-512x512.png",
|
||||||
|
"sizes": "512x512",
|
||||||
|
"type": "image/png",
|
||||||
|
"purpose": "any maskable"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"categories": ["business", "productivity"],
|
||||||
|
"lang": "de-DE",
|
||||||
|
"dir": "ltr",
|
||||||
|
"prefer_related_applications": false
|
||||||
|
}
|
75
static/sw.js
Normal file
75
static/sw.js
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
const CACHE_NAME = 'medi-customers-v1';
|
||||||
|
const urlsToCache = [
|
||||||
|
'/',
|
||||||
|
'/static/css/styles.css',
|
||||||
|
'/static/js/script.js',
|
||||||
|
'/static/images/logo.png',
|
||||||
|
'/static/images/icon-192x192.png',
|
||||||
|
'/static/images/icon-512x512.png'
|
||||||
|
];
|
||||||
|
|
||||||
|
// Installation des Service Workers
|
||||||
|
self.addEventListener('install', event => {
|
||||||
|
event.waitUntil(
|
||||||
|
caches.open(CACHE_NAME)
|
||||||
|
.then(cache => {
|
||||||
|
console.log('Cache geöffnet');
|
||||||
|
return cache.addAll(urlsToCache);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Aktivierung des Service Workers
|
||||||
|
self.addEventListener('activate', event => {
|
||||||
|
event.waitUntil(
|
||||||
|
caches.keys().then(cacheNames => {
|
||||||
|
return Promise.all(
|
||||||
|
cacheNames.map(cacheName => {
|
||||||
|
if (cacheName !== CACHE_NAME) {
|
||||||
|
console.log('Lösche alten Cache:', cacheName);
|
||||||
|
return caches.delete(cacheName);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Fetch-Event-Handler
|
||||||
|
self.addEventListener('fetch', event => {
|
||||||
|
event.respondWith(
|
||||||
|
caches.match(event.request)
|
||||||
|
.then(response => {
|
||||||
|
// Cache-Treffer - gib die Antwort zurück
|
||||||
|
if (response) {
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Kein Cache-Treffer - führe Netzwerkanfrage durch
|
||||||
|
return fetch(event.request)
|
||||||
|
.then(response => {
|
||||||
|
// Prüfe, ob wir eine gültige Antwort erhalten haben
|
||||||
|
if (!response || response.status !== 200 || response.type !== 'basic') {
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Klone die Antwort
|
||||||
|
const responseToCache = response.clone();
|
||||||
|
|
||||||
|
// Speichere die Antwort im Cache
|
||||||
|
caches.open(CACHE_NAME)
|
||||||
|
.then(cache => {
|
||||||
|
cache.put(event.request, responseToCache);
|
||||||
|
});
|
||||||
|
|
||||||
|
return response;
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
// Fallback für Offline-Zugriff
|
||||||
|
if (event.request.mode === 'navigate') {
|
||||||
|
return caches.match('/offline.html');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})
|
||||||
|
);
|
||||||
|
});
|
@@ -5,232 +5,88 @@
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>medisoftware Kundensuche</title>
|
<title>medisoftware Kundensuche</title>
|
||||||
<link rel="icon" type="image/x-icon" href="{{ url_for('static', filename='favicon.ico') }}">
|
<link rel="icon" type="image/x-icon" href="{{ url_for('static', filename='favicon.ico') }}">
|
||||||
|
<link rel="manifest" href="{{ url_for('static', filename='manifest.json') }}">
|
||||||
|
<meta name="theme-color" content="#4CAF50">
|
||||||
|
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||||
|
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
||||||
|
<meta name="apple-mobile-web-app-title" content="MEDI">
|
||||||
|
<link rel="apple-touch-icon" href="{{ url_for('static', filename='images/icon-192x192.png') }}">
|
||||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css" rel="stylesheet">
|
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css" rel="stylesheet">
|
||||||
<style>
|
<link href="{{ url_for('static', filename='css/styles.css') }}" rel="stylesheet">
|
||||||
body {
|
<script src="{{ url_for('static', filename='js/db.js') }}"></script>
|
||||||
min-height: 100vh;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
.main-content {
|
|
||||||
flex: 1 0 auto;
|
|
||||||
padding: 2rem 0;
|
|
||||||
margin-bottom: 4rem; /* Platz für die fixierte Fußzeile */
|
|
||||||
}
|
|
||||||
.search-container {
|
|
||||||
max-width: 800px;
|
|
||||||
margin: 0 auto;
|
|
||||||
}
|
|
||||||
.result-card {
|
|
||||||
margin-bottom: 1rem;
|
|
||||||
transition: all 0.3s ease;
|
|
||||||
}
|
|
||||||
.result-card:hover {
|
|
||||||
transform: translateY(-2px);
|
|
||||||
box-shadow: 0 4px 8px rgba(0,0,0,0.1);
|
|
||||||
}
|
|
||||||
.loading {
|
|
||||||
display: none;
|
|
||||||
text-align: center;
|
|
||||||
margin: 2rem 0;
|
|
||||||
}
|
|
||||||
.phone-link, .email-link, .address-link, .customer-link {
|
|
||||||
text-decoration: none;
|
|
||||||
color: #0d6efd;
|
|
||||||
}
|
|
||||||
.phone-link:hover, .email-link:hover, .address-link:hover, .customer-link:hover {
|
|
||||||
text-decoration: underline;
|
|
||||||
}
|
|
||||||
.search-icon, .reset-icon {
|
|
||||||
position: absolute;
|
|
||||||
top: 50%;
|
|
||||||
transform: translateY(-50%);
|
|
||||||
color: #6c757d;
|
|
||||||
cursor: pointer;
|
|
||||||
display: none;
|
|
||||||
z-index: 10;
|
|
||||||
}
|
|
||||||
.reset-icon {
|
|
||||||
right: 10px;
|
|
||||||
}
|
|
||||||
.search-icon {
|
|
||||||
right: 35px;
|
|
||||||
}
|
|
||||||
.reset-icon.visible {
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
.search-icon.visible {
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
.customer-number {
|
|
||||||
color: #6c757d;
|
|
||||||
font-size: 0.9em;
|
|
||||||
}
|
|
||||||
.footer {
|
|
||||||
flex-shrink: 0;
|
|
||||||
text-align: center;
|
|
||||||
padding: 1rem;
|
|
||||||
background-color: #f8f9fa;
|
|
||||||
border-top: 1px solid #dee2e6;
|
|
||||||
width: 100%;
|
|
||||||
position: fixed;
|
|
||||||
bottom: 0;
|
|
||||||
left: 0;
|
|
||||||
z-index: 100;
|
|
||||||
}
|
|
||||||
.share-feedback {
|
|
||||||
position: fixed;
|
|
||||||
bottom: 20px;
|
|
||||||
right: 20px;
|
|
||||||
background: #28a745;
|
|
||||||
color: white;
|
|
||||||
padding: 8px 16px;
|
|
||||||
border-radius: 4px;
|
|
||||||
display: none;
|
|
||||||
animation: fadeOut 2s forwards;
|
|
||||||
z-index: 1000;
|
|
||||||
}
|
|
||||||
@keyframes fadeOut {
|
|
||||||
0% { opacity: 1; }
|
|
||||||
70% { opacity: 1; }
|
|
||||||
100% { opacity: 0; }
|
|
||||||
}
|
|
||||||
.card-actions {
|
|
||||||
display: flex;
|
|
||||||
justify-content: flex-end;
|
|
||||||
margin-top: 1rem;
|
|
||||||
}
|
|
||||||
.share-button {
|
|
||||||
padding: 5px 10px;
|
|
||||||
border-radius: 15px;
|
|
||||||
font-size: 0.9em;
|
|
||||||
background-color: #0d6efd;
|
|
||||||
color: white;
|
|
||||||
border: none;
|
|
||||||
cursor: pointer;
|
|
||||||
transition: background-color 0.2s;
|
|
||||||
}
|
|
||||||
.share-button:hover {
|
|
||||||
background-color: #0b5ed7;
|
|
||||||
}
|
|
||||||
.search-fields {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
|
||||||
gap: 1rem;
|
|
||||||
margin-bottom: 1rem;
|
|
||||||
}
|
|
||||||
.search-field {
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
.input-group {
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
.result-counts {
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
margin-bottom: 1rem;
|
|
||||||
padding: 0.5rem;
|
|
||||||
background-color: #f8f9fa;
|
|
||||||
border-radius: 4px;
|
|
||||||
}
|
|
||||||
.result-count {
|
|
||||||
background-color: #e9ecef;
|
|
||||||
padding: 4px 12px;
|
|
||||||
border-radius: 12px;
|
|
||||||
font-size: 0.9em;
|
|
||||||
color: #6c757d;
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
.result-count.visible {
|
|
||||||
display: inline-block;
|
|
||||||
}
|
|
||||||
.location-pin {
|
|
||||||
color: #dc3545;
|
|
||||||
margin-left: 4px;
|
|
||||||
font-size: 1.2em;
|
|
||||||
}
|
|
||||||
.customer-card {
|
|
||||||
background: white;
|
|
||||||
border-radius: 8px;
|
|
||||||
padding: 1.5rem;
|
|
||||||
margin-bottom: 1.5rem;
|
|
||||||
box-shadow: 0 2px 4px rgba(0,0,0,0.05);
|
|
||||||
border-bottom: 1px solid #e9ecef;
|
|
||||||
}
|
|
||||||
.customer-card:last-child {
|
|
||||||
border-bottom: none;
|
|
||||||
}
|
|
||||||
.customer-info {
|
|
||||||
margin-bottom: 1rem;
|
|
||||||
}
|
|
||||||
.footer-content {
|
|
||||||
padding: 1rem;
|
|
||||||
background-color: #f8f9fa;
|
|
||||||
border-top: 1px solid #dee2e6;
|
|
||||||
width: 100%;
|
|
||||||
position: fixed;
|
|
||||||
bottom: 0;
|
|
||||||
left: 0;
|
|
||||||
z-index: 100;
|
|
||||||
}
|
|
||||||
.footer-link {
|
|
||||||
color: #0d6efd;
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
.footer-link:hover {
|
|
||||||
text-decoration: underline;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="main-content">
|
<div class="main-content">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="text-center mb-4">
|
<div class="text-center mb-4">
|
||||||
<img src="{{ url_for('static', filename='medisoftware_logo_rb_200.png') }}" alt="medisoftware Logo" class="img-fluid" style="max-width: 200px;">
|
<a href="https://medisoftware.de" target="_blank" rel="noopener noreferrer"><img src="{{ url_for('static', filename='medisoftware_logo_rb_200.png') }}" alt="medisoftware Logo" class="img-fluid" style="max-width: 200px;"></a>
|
||||||
</div>
|
</div>
|
||||||
<div class="search-container">
|
<div class="search-container">
|
||||||
<h1 class="text-center mb-4">medisoftware Kundensuche</h1>
|
<h1 class="text-center mb-4">Kundensuche</h1>
|
||||||
|
|
||||||
<div class="input-group mb-4 position-relative">
|
<div class="general-search mb-4">
|
||||||
<input type="text" id="searchInput" class="form-control form-control-lg"
|
<div class="input-group">
|
||||||
placeholder="Allgemeine Suche...">
|
<input type="text" id="q" class="form-control form-control-lg" placeholder="Allgemeine Suche" oninput="searchCustomers()">
|
||||||
<i class="fa-solid fa-xmark reset-icon" id="searchReset"></i>
|
<i class="fas fa-times reset-icon" onclick="clearInput('q')"></i>
|
||||||
<span class="search-icon">🔍</span>
|
<i class="fas fa-search search-icon"></i>
|
||||||
|
</div>
|
||||||
|
<div class="search-options mt-2">
|
||||||
|
<div class="form-check form-check-inline">
|
||||||
|
<input class="form-check-input" type="radio" name="searchOperator" id="searchOr" value="or" checked>
|
||||||
|
<label class="form-check-label" for="searchOr">ODER</label>
|
||||||
|
</div>
|
||||||
|
<div class="form-check form-check-inline">
|
||||||
|
<input class="form-check-input" type="radio" name="searchOperator" id="searchAnd" value="and">
|
||||||
|
<label class="form-check-label" for="searchAnd">UND</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="search-fields">
|
<div class="search-fields">
|
||||||
<div class="search-field">
|
<div class="search-field">
|
||||||
<input type="text" id="nameInput" class="form-control"
|
<div class="input-group">
|
||||||
placeholder="Name...">
|
<input type="text" id="nameInput" class="form-control" placeholder="Name" oninput="searchCustomers()">
|
||||||
<i class="fa-solid fa-xmark reset-icon" id="nameReset"></i>
|
<i class="fas fa-times reset-icon" onclick="clearInput('nameInput')"></i>
|
||||||
|
<i class="fas fa-search search-icon"></i>
|
||||||
</div>
|
</div>
|
||||||
<div class="search-field">
|
|
||||||
<input type="text" id="ortInput" class="form-control"
|
|
||||||
placeholder="Ort...">
|
|
||||||
<i class="fa-solid fa-xmark reset-icon" id="ortReset"></i>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="search-field">
|
<div class="search-field">
|
||||||
<input type="text" id="kundennummerInput" class="form-control"
|
<div class="input-group">
|
||||||
placeholder="Kundennummer...">
|
<input type="text" id="ortInput" class="form-control" placeholder="Ort" oninput="searchCustomers()">
|
||||||
<i class="fa-solid fa-xmark reset-icon" id="kundennummerReset"></i>
|
<i class="fas fa-times reset-icon" onclick="clearInput('ortInput')"></i>
|
||||||
|
<i class="fas fa-search search-icon"></i>
|
||||||
</div>
|
</div>
|
||||||
<div class="search-field">
|
|
||||||
<input type="text" id="fachrichtungInput" class="form-control"
|
|
||||||
placeholder="Fachrichtung...">
|
|
||||||
<i class="fa-solid fa-xmark reset-icon" id="fachrichtungReset"></i>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="search-field">
|
<div class="search-field">
|
||||||
<input type="text" id="telefonInput" class="form-control"
|
<div class="input-group">
|
||||||
placeholder="Telefon...">
|
<input type="text" id="nummerInput" class="form-control" placeholder="Kundennummer" oninput="searchCustomers()">
|
||||||
<i class="fa-solid fa-xmark reset-icon" id="telefonReset"></i>
|
<i class="fas fa-times reset-icon" onclick="clearInput('nummerInput')"></i>
|
||||||
|
<i class="fas fa-search search-icon"></i>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="search-field">
|
||||||
|
<div class="input-group">
|
||||||
|
<input type="text" id="plzInput" class="form-control" placeholder="PLZ" oninput="searchCustomers()">
|
||||||
|
<i class="fas fa-times reset-icon" onclick="clearInput('plzInput')"></i>
|
||||||
|
<i class="fas fa-search search-icon"></i>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="search-field">
|
||||||
|
<div class="input-group">
|
||||||
|
<input type="text" id="fachrichtungInput" class="form-control" placeholder="Fachrichtung" oninput="searchCustomers()">
|
||||||
|
<i class="fas fa-times reset-icon" onclick="clearInput('fachrichtungInput')"></i>
|
||||||
|
<i class="fas fa-search search-icon"></i>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="result-counts">
|
<div class="result-counts">
|
||||||
<span id="generalCount" class="result-count"></span>
|
<span id="resultCount" class="result-count"></span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="loading" class="loading">
|
<div id="loading" class="loading">
|
||||||
@@ -239,33 +95,96 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="results" class="mt-4">
|
<div id="results"></div>
|
||||||
<!-- Hier werden die Suchergebnisse angezeigt -->
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="shareFeedback" class="share-feedback">
|
<div id="shareFeedback" class="share-feedback">
|
||||||
Link kopiert!
|
Link in die Zwischenablage kopiert!
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<footer class="footer">
|
<footer class="footer">
|
||||||
<div class="footer-content">
|
<div class="footer-content">
|
||||||
Made with ❤️ and 🍺 by <a href="https://www.medisoftware.de" target="_blank" class="footer-link">medisoftware</a>
|
Proudly made with ❤️ and 🍺 by <a href="https://www.medisoftware.de" target="_blank" class="footer-link">medisoftware</a>
|
||||||
<div style="font-size: 0.8em;">Version: v1.2.0</div>
|
<div style="font-size: 0.8em;">Version: v1.2.6</div>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
|
<div id="syncStatus" class="sync-status" style="display: none;">
|
||||||
|
<span class="sync-icon">🔄</span>
|
||||||
|
<span class="sync-text">Synchronisiere Daten...</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="offlineIndicator" class="offline-indicator" style="display: none;">
|
||||||
|
<span class="offline-icon">📡</span>
|
||||||
|
<span class="offline-text">Offline-Modus</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
// Service Worker und IndexedDB initialisieren
|
||||||
|
if ('serviceWorker' in navigator) {
|
||||||
|
window.addEventListener('load', async () => {
|
||||||
|
try {
|
||||||
|
const registration = await navigator.serviceWorker.register('/sw.js');
|
||||||
|
console.log('ServiceWorker registration successful');
|
||||||
|
|
||||||
|
// IndexedDB initialisieren und erste Synchronisation starten
|
||||||
|
await window.dbHelper.initDB();
|
||||||
|
await window.dbHelper.synchronizeData();
|
||||||
|
} catch (err) {
|
||||||
|
console.log('ServiceWorker registration failed: ', err);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Offline-Status-Anzeige aktualisieren
|
||||||
|
const updateOfflineStatus = () => {
|
||||||
|
const offlineIndicator = document.getElementById('offlineIndicator');
|
||||||
|
const syncStatus = document.getElementById('syncStatus');
|
||||||
|
|
||||||
|
if (!navigator.onLine) {
|
||||||
|
offlineIndicator.style.display = 'block';
|
||||||
|
syncStatus.style.display = 'none';
|
||||||
|
} else {
|
||||||
|
offlineIndicator.style.display = 'none';
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
window.addEventListener('online', updateOfflineStatus);
|
||||||
|
window.addEventListener('offline', updateOfflineStatus);
|
||||||
|
updateOfflineStatus();
|
||||||
|
|
||||||
let searchTimeout;
|
let searchTimeout;
|
||||||
let lastResults = [];
|
let lastResults = [];
|
||||||
|
|
||||||
function createPhoneLink(phone) {
|
function createPhoneLink(phone) {
|
||||||
if (!phone) return 'N/A';
|
if (!phone) return 'N/A';
|
||||||
const cleaned = phone.replace(/[^\d+\s]/g, '');
|
|
||||||
const telLink = cleaned.startsWith('+') ? cleaned : '0' + cleaned.replace(/\s/g, '');
|
const clientIP = '{{ request.headers.get("X-Forwarded-For", request.remote_addr) }}';
|
||||||
return `<a href="tel:${telLink}" class="phone-link">${phone}</a>`;
|
const allowedIPRanges = '{{ allowed_ip_ranges }}'.split(',');
|
||||||
|
|
||||||
|
// Überprüfen, ob die Client-IP in einem der erlaubten Bereiche liegt
|
||||||
|
const isAllowed = allowedIPRanges.some(range => isIPInSubnet(clientIP, range.trim()));
|
||||||
|
|
||||||
|
// Entferne alle nicht-numerischen Zeichen
|
||||||
|
let cleanNumber = phone.replace(/\D/g, '');
|
||||||
|
|
||||||
|
// Füge eine führende 0 hinzu, wenn isAllowed true ist
|
||||||
|
if (isAllowed) {
|
||||||
|
cleanNumber = '0' + cleanNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Formatiere die Nummer
|
||||||
|
let formattedNumber = cleanNumber;
|
||||||
|
if (cleanNumber.length === 11) {
|
||||||
|
formattedNumber = cleanNumber.replace(/(\d{4})(\d{7})/, '$1-$2');
|
||||||
|
} else if (cleanNumber.length === 10) {
|
||||||
|
formattedNumber = cleanNumber.replace(/(\d{3})(\d{7})/, '$1-$2');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Erstelle den Link
|
||||||
|
return `<a href="tel:${cleanNumber}" class="phone-link">${formattedNumber}</a>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function createEmailLink(email) {
|
function createEmailLink(email) {
|
||||||
@@ -273,58 +192,26 @@
|
|||||||
return `<a href="mailto:${email}" class="email-link">${email}</a>`;
|
return `<a href="mailto:${email}" class="email-link">${email}</a>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function highlightText(text, searchTerms) {
|
function highlightText(text, searchTerm) {
|
||||||
// Konvertiere text zu String und prüfe auf null/undefined
|
if (!searchTerm) return text;
|
||||||
const textStr = String(text || '');
|
const regex = new RegExp(`(${searchTerm})`, 'gi');
|
||||||
if (!textStr || !searchTerms || searchTerms.length === 0) return textStr;
|
return text.replace(regex, '<mark>$1</mark>');
|
||||||
|
|
||||||
// Escapen der Suchbegriffe für reguläre Ausdrücke
|
|
||||||
const escapedTerms = searchTerms.map(term =>
|
|
||||||
String(term || '').replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
|
||||||
).filter(term => term.length > 0);
|
|
||||||
|
|
||||||
if (escapedTerms.length === 0) return textStr;
|
|
||||||
|
|
||||||
// Erstelle einen temporären div-Element
|
|
||||||
const tempDiv = document.createElement('div');
|
|
||||||
tempDiv.innerHTML = textStr;
|
|
||||||
|
|
||||||
// Funktion zum Hervorheben von Text
|
|
||||||
function highlightNode(node) {
|
|
||||||
if (node.nodeType === 3) { // Text node
|
|
||||||
const text = node.textContent;
|
|
||||||
let newText = text;
|
|
||||||
|
|
||||||
escapedTerms.forEach(term => {
|
|
||||||
const regex = new RegExp(`(${term})`, 'gi');
|
|
||||||
newText = newText.replace(regex, '<mark>$1</mark>');
|
|
||||||
});
|
|
||||||
|
|
||||||
if (newText !== text) {
|
|
||||||
const span = document.createElement('span');
|
|
||||||
span.innerHTML = newText;
|
|
||||||
node.parentNode.replaceChild(span, node);
|
|
||||||
}
|
|
||||||
} else if (node.nodeType === 1) { // Element node
|
|
||||||
// Überspringe mark-Tags und Links
|
|
||||||
if (node.tagName !== 'MARK' && node.tagName !== 'A') {
|
|
||||||
Array.from(node.childNodes).forEach(highlightNode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
highlightNode(tempDiv);
|
|
||||||
return tempDiv.innerHTML;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function createAddressLink(street, plz, city) {
|
function createAddressLink(street, plz, city) {
|
||||||
if (!street || !plz || !city) return 'N/A';
|
if (!street || !plz || !city) return 'N/A';
|
||||||
const address = `${street}, ${plz} ${city}`;
|
const address = `${street}, ${plz} ${city}`;
|
||||||
const searchQuery = encodeURIComponent(address);
|
const searchQuery = encodeURIComponent(address);
|
||||||
|
const routeQuery = encodeURIComponent(address);
|
||||||
|
const clientIP = '{{ request.headers.get("X-Forwarded-For", request.remote_addr) }}';
|
||||||
return `<span class="address-text">${address}</span>
|
return `<span class="address-text">${address}</span>
|
||||||
<a href="https://www.google.com/maps/search/?api=1&query=${searchQuery}"
|
<a href="https://www.google.com/maps/search/?api=1&query=${searchQuery}"
|
||||||
class="address-link" target="_blank" rel="noopener noreferrer">
|
class="address-link" target="_blank" rel="noopener noreferrer">
|
||||||
<i class="fa-solid fa-location-pin location-pin"></i>
|
<i class="fa-solid fa-location-pin location-pin"></i>
|
||||||
|
</a>
|
||||||
|
<a href="https://www.google.com/maps/dir/?api=1&destination=${routeQuery}"
|
||||||
|
class="route-link" target="_blank" rel="noopener noreferrer">
|
||||||
|
<i class="fa-solid fa-car route-pin"></i>
|
||||||
</a>`;
|
</a>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -332,9 +219,39 @@
|
|||||||
return number - 12000;
|
return number - 12000;
|
||||||
}
|
}
|
||||||
|
|
||||||
function createCustomerLink(number) {
|
function isIPInSubnet(ip, subnet) {
|
||||||
const adjustedNumber = adjustCustomerNumber(number);
|
// Teile die IP und das Subnetz in ihre Komponenten
|
||||||
return `<a href="medisw:openkkbefe/P${adjustedNumber}?NetGrp=4" class="customer-link">${adjustedNumber}</a>`;
|
const [subnetIP, bits] = subnet.split('/');
|
||||||
|
const ipParts = ip.split('.').map(Number);
|
||||||
|
const subnetParts = subnetIP.split('.').map(Number);
|
||||||
|
|
||||||
|
// Konvertiere IPs in 32-bit Zahlen
|
||||||
|
const ipNum = (ipParts[0] << 24) | (ipParts[1] << 16) | (ipParts[2] << 8) | ipParts[3];
|
||||||
|
const subnetNum = (subnetParts[0] << 24) | (subnetParts[1] << 16) | (subnetParts[2] << 8) | subnetParts[3];
|
||||||
|
|
||||||
|
// Erstelle die Subnetzmaske
|
||||||
|
const mask = ~((1 << (32 - bits)) - 1);
|
||||||
|
|
||||||
|
// Prüfe, ob die IP im Subnetz liegt
|
||||||
|
return (ipNum & mask) === (subnetNum & mask);
|
||||||
|
}
|
||||||
|
|
||||||
|
function createCustomerLink(nummer) {
|
||||||
|
const clientIP = '{{ request.headers.get("X-Forwarded-For", request.remote_addr) }}';
|
||||||
|
const allowedIPRanges = '{{ allowed_ip_ranges }}'.split(',');
|
||||||
|
|
||||||
|
// Überprüfe, ob die Client-IP in einem der erlaubten Bereiche liegt
|
||||||
|
const isAllowed = allowedIPRanges.some(range => {
|
||||||
|
const trimmedRange = range.trim();
|
||||||
|
return isIPInSubnet(clientIP, trimmedRange);
|
||||||
|
});
|
||||||
|
|
||||||
|
const adjustedNumber = adjustCustomerNumber(nummer);
|
||||||
|
if (isAllowed) {
|
||||||
|
return `<a href="medisw:openkkbefe/P${adjustedNumber}?NetGrp=4" class="customer-link">${nummer}</a>`;
|
||||||
|
} else {
|
||||||
|
return nummer;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function showCopyFeedback() {
|
function showCopyFeedback() {
|
||||||
@@ -355,161 +272,126 @@
|
|||||||
await navigator.clipboard.writeText(url.toString());
|
await navigator.clipboard.writeText(url.toString());
|
||||||
showCopyFeedback();
|
showCopyFeedback();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Fehler beim Kopieren:', err);
|
// Fehlerbehandlung ohne console.log
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateResultCounts() {
|
function updateResultCounts() {
|
||||||
// Nur Gesamtzahl anzeigen
|
// Nur Gesamtzahl anzeigen
|
||||||
const generalCount = lastResults.length;
|
const generalCount = lastResults.length;
|
||||||
document.getElementById('generalCount').textContent =
|
document.getElementById('resultCount').textContent =
|
||||||
generalCount > 0 ? `${generalCount} Treffer gefunden` : '';
|
generalCount > 0 ? `${generalCount} Treffer gefunden` : '';
|
||||||
document.getElementById('generalCount').classList.toggle('visible', generalCount > 0);
|
document.getElementById('resultCount').classList.toggle('visible', generalCount > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
function searchCustomers() {
|
function displayResults(results) {
|
||||||
const query = document.getElementById('searchInput').value.trim();
|
|
||||||
const fachrichtung = document.getElementById('fachrichtungInput').value.trim();
|
|
||||||
const ort = document.getElementById('ortInput').value.trim();
|
|
||||||
const name = document.getElementById('nameInput').value.trim();
|
|
||||||
const telefon = document.getElementById('telefonInput').value.trim();
|
|
||||||
const kundennummer = document.getElementById('kundennummerInput')?.value.trim() || '';
|
|
||||||
|
|
||||||
// Sammle alle nicht-leeren Suchbegriffe
|
|
||||||
const searchTerms = [query, fachrichtung, ort, name, telefon, kundennummer]
|
|
||||||
.filter(term => term && term.length > 0);
|
|
||||||
|
|
||||||
// Prüfe, ob alle Suchfelder leer sind
|
|
||||||
if (searchTerms.length === 0) {
|
|
||||||
const resultsDiv = document.getElementById('results');
|
const resultsDiv = document.getElementById('results');
|
||||||
const generalCount = document.getElementById('generalCount');
|
|
||||||
resultsDiv.innerHTML = '';
|
|
||||||
generalCount.textContent = '';
|
|
||||||
generalCount.classList.remove('visible');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const resultsDiv = document.getElementById('results');
|
|
||||||
const loadingDiv = document.getElementById('loading');
|
|
||||||
loadingDiv.style.display = 'block';
|
|
||||||
resultsDiv.innerHTML = '';
|
resultsDiv.innerHTML = '';
|
||||||
|
|
||||||
const searchParams = new URLSearchParams();
|
|
||||||
if (query) searchParams.append('q', query);
|
|
||||||
if (fachrichtung) searchParams.append('fachrichtung', fachrichtung);
|
|
||||||
if (ort) searchParams.append('ort', ort);
|
|
||||||
if (name) searchParams.append('name', name);
|
|
||||||
if (telefon) searchParams.append('telefon', telefon);
|
|
||||||
if (kundennummer) searchParams.append('kundennummer', kundennummer);
|
|
||||||
|
|
||||||
fetch(`/search?${searchParams.toString()}`)
|
|
||||||
.then(response => response.json())
|
|
||||||
.then(data => {
|
|
||||||
resultsDiv.innerHTML = '';
|
|
||||||
|
|
||||||
// Prüfe, ob data ein Objekt mit results-Array ist
|
|
||||||
if (!data || !data.results || !Array.isArray(data.results)) {
|
|
||||||
console.error('Unerwartetes Datenformat:', data);
|
|
||||||
resultsDiv.innerHTML = '<div class="error">Unerwartetes Datenformat vom Server</div>';
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const results = data.results;
|
|
||||||
if (results.length === 0) {
|
if (results.length === 0) {
|
||||||
resultsDiv.innerHTML = '<div class="no-results">Keine Ergebnisse gefunden</div>';
|
resultsDiv.innerHTML = '<p>Keine Ergebnisse gefunden.</p>';
|
||||||
} else {
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hole alle Suchbegriffe
|
||||||
|
const searchTerms = {
|
||||||
|
general: document.getElementById('q').value,
|
||||||
|
name: document.getElementById('nameInput').value,
|
||||||
|
ort: document.getElementById('ortInput').value,
|
||||||
|
nummer: document.getElementById('nummerInput').value,
|
||||||
|
plz: document.getElementById('plzInput').value,
|
||||||
|
fachrichtung: document.getElementById('fachrichtungInput').value
|
||||||
|
};
|
||||||
|
|
||||||
results.forEach(customer => {
|
results.forEach(customer => {
|
||||||
const card = document.createElement('div');
|
const card = document.createElement('div');
|
||||||
card.className = 'customer-card';
|
card.className = 'customer-card';
|
||||||
|
|
||||||
// Debug-Ausgabe für die Kundendaten
|
|
||||||
console.log('Kundendaten:', customer);
|
|
||||||
console.log('Alle verfügbaren Felder:', Object.keys(customer));
|
|
||||||
console.log('Telefon-bezogene Felder:', {
|
|
||||||
Telefon: customer.Telefon,
|
|
||||||
Telefonnummer: customer.Telefonnummer,
|
|
||||||
telefon: customer.telefon,
|
|
||||||
telefonnummer: customer.telefonnummer,
|
|
||||||
phone: customer.phone,
|
|
||||||
'phone.number': customer.phone?.number
|
|
||||||
});
|
|
||||||
|
|
||||||
// Erstelle die Adresse mit Hervorhebung
|
|
||||||
const address = `${customer.Strasse || ''}, ${customer.PLZ || ''} ${customer.Ort || ''}`;
|
|
||||||
const addressLink = createAddressLink(customer.Strasse, customer.PLZ, customer.Ort);
|
|
||||||
const highlightedAddress = highlightText(addressLink, searchTerms);
|
|
||||||
|
|
||||||
// Erstelle die Kundennummer mit Hervorhebung
|
|
||||||
const highlightedNumber = highlightText(customer.Nummer, searchTerms);
|
|
||||||
const customerLink = createCustomerLink(customer.Nummer);
|
|
||||||
|
|
||||||
// Erstelle die Telefonnummern mit Hervorhebung
|
|
||||||
let phoneNumber = '';
|
|
||||||
let companyPhone = '';
|
|
||||||
let mobilePhone = '';
|
|
||||||
|
|
||||||
if (typeof customer === 'object') {
|
|
||||||
phoneNumber = customer.Tel || '';
|
|
||||||
companyPhone = customer['Tele Firma'] || '';
|
|
||||||
mobilePhone = customer.Handy || '';
|
|
||||||
}
|
|
||||||
|
|
||||||
const phoneLink = createPhoneLink(phoneNumber);
|
|
||||||
const companyPhoneLink = createPhoneLink(companyPhone);
|
|
||||||
const mobilePhoneLink = createPhoneLink(mobilePhone);
|
|
||||||
|
|
||||||
const highlightedPhone = highlightText(phoneLink, searchTerms);
|
|
||||||
const highlightedCompanyPhone = highlightText(companyPhoneLink, searchTerms);
|
|
||||||
const highlightedMobilePhone = highlightText(mobilePhoneLink, searchTerms);
|
|
||||||
|
|
||||||
card.innerHTML = `
|
card.innerHTML = `
|
||||||
<div class="customer-info">
|
<div class="customer-info">
|
||||||
<strong>Kundennummer:</strong> ${customerLink}<br>
|
<h5 class="mb-1">${highlightText(customer.name, searchTerms.general || searchTerms.name)}</h5>
|
||||||
<strong>Name:</strong> ${highlightText(`${customer.Vorname || ''} ${customer.Nachname || ''}`, searchTerms)}<br>
|
<p class="mb-1 customer-number">${createCustomerLink(customer.nummer)}</p>
|
||||||
<strong>Fachrichtung:</strong> ${highlightText(customer.Fachrichtung || '', searchTerms)}<br>
|
<p class="mb-1">${createAddressLink(
|
||||||
<strong>Adresse:</strong> ${highlightedAddress}<br>
|
customer.strasse,
|
||||||
<strong>Telefon:</strong> ${highlightedPhone}<br>
|
highlightText(customer.plz, searchTerms.general || searchTerms.plz),
|
||||||
<strong>Firma:</strong> ${highlightedCompanyPhone}<br>
|
highlightText(customer.ort, searchTerms.general || searchTerms.ort)
|
||||||
<strong>Mobil:</strong> ${highlightedMobilePhone}
|
)}</p>
|
||||||
|
<p class="mb-1">Tel: ${createPhoneLink(customer.telefon)}</p>
|
||||||
|
${customer.mobil ? `<p class="mb-1">Mobil: ${createPhoneLink(customer.mobil)}</p>` : ''}
|
||||||
|
${customer.email ? `<p class="mb-1">E-Mail: ${createEmailLink(customer.email)}</p>` : ''}
|
||||||
|
${customer.bemerkung ? `<p class="mb-1">Bemerkung: ${customer.bemerkung}</p>` : ''}
|
||||||
|
${customer.fachrichtung ? `<p class="mb-1">Fachrichtung: ${highlightText(customer.fachrichtung, searchTerms.general || searchTerms.fachrichtung)}</p>` : ''}
|
||||||
</div>
|
</div>
|
||||||
<button class="share-button" onclick="copyCustomerLink('${customer.Nummer}')">
|
<div class="card-actions">
|
||||||
|
<button class="share-button" onclick="copyCustomerLink('${customer.nummer}')">
|
||||||
<i class="fas fa-share-alt"></i> Teilen
|
<i class="fas fa-share-alt"></i> Teilen
|
||||||
</button>
|
</button>
|
||||||
|
</div>
|
||||||
`;
|
`;
|
||||||
resultsDiv.appendChild(card);
|
resultsDiv.appendChild(card);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// Aktualisiere die Anzahl der Treffer
|
|
||||||
const generalCount = document.getElementById('generalCount');
|
async function searchCustomers() {
|
||||||
generalCount.textContent = results.length > 0 ? `${results.length} Treffer gefunden` : '';
|
const searchParams = {
|
||||||
generalCount.classList.toggle('visible', results.length > 0);
|
q: document.getElementById('q').value,
|
||||||
})
|
name: document.getElementById('nameInput').value,
|
||||||
.catch(error => {
|
ort: document.getElementById('ortInput').value,
|
||||||
console.error('Fehler bei der Suche:', error);
|
nummer: document.getElementById('nummerInput').value,
|
||||||
resultsDiv.innerHTML = '<div class="error">Ein Fehler ist aufgetreten</div>';
|
plz: document.getElementById('plzInput').value,
|
||||||
})
|
fachrichtung: document.getElementById('fachrichtungInput').value,
|
||||||
.finally(() => {
|
operator: document.querySelector('input[name="searchOperator"]:checked').value
|
||||||
loadingDiv.style.display = 'none';
|
};
|
||||||
|
|
||||||
|
document.getElementById('loading').style.display = 'block';
|
||||||
|
|
||||||
|
try {
|
||||||
|
let results;
|
||||||
|
if (navigator.onLine) {
|
||||||
|
// Online: Server-Suche
|
||||||
|
const response = await fetch('/api/search', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
},
|
||||||
|
body: JSON.stringify(searchParams)
|
||||||
});
|
});
|
||||||
|
results = await response.json();
|
||||||
|
|
||||||
|
// Speichere die Ergebnisse in IndexedDB
|
||||||
|
await window.dbHelper.saveCustomers(results);
|
||||||
|
} else {
|
||||||
|
// Offline: Lokale Suche
|
||||||
|
results = await window.dbHelper.searchCustomersOffline(searchParams);
|
||||||
|
}
|
||||||
|
|
||||||
|
lastResults = results;
|
||||||
|
displayResults(results);
|
||||||
|
updateResultCounts();
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Fehler bei der Suche:', error);
|
||||||
|
document.getElementById('results').innerHTML = '<p>Ein Fehler ist aufgetreten. Bitte versuchen Sie es später erneut.</p>';
|
||||||
|
} finally {
|
||||||
|
document.getElementById('loading').style.display = 'none';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Event-Listener für die Live-Suche
|
// Event-Listener für die Live-Suche
|
||||||
const searchInputs = [
|
const searchInputs = [
|
||||||
|
document.getElementById('q'),
|
||||||
document.getElementById('nameInput'),
|
document.getElementById('nameInput'),
|
||||||
document.getElementById('ortInput'),
|
document.getElementById('ortInput'),
|
||||||
document.getElementById('kundennummerInput'),
|
document.getElementById('nummerInput'),
|
||||||
document.getElementById('fachrichtungInput'),
|
document.getElementById('plzInput'),
|
||||||
document.getElementById('telefonInput'),
|
document.getElementById('fachrichtungInput')
|
||||||
document.getElementById('searchInput')
|
|
||||||
];
|
];
|
||||||
|
|
||||||
const resetIcons = [
|
const resetIcons = [
|
||||||
document.getElementById('nameReset'),
|
document.querySelector('.reset-icon[onclick="clearInput(\'q\')"]'),
|
||||||
document.getElementById('ortReset'),
|
document.querySelector('.reset-icon[onclick="clearInput(\'nameInput\')"]'),
|
||||||
document.getElementById('kundennummerReset'),
|
document.querySelector('.reset-icon[onclick="clearInput(\'ortInput\')"]'),
|
||||||
document.getElementById('fachrichtungReset'),
|
document.querySelector('.reset-icon[onclick="clearInput(\'nummerInput\')"]'),
|
||||||
document.getElementById('telefonReset'),
|
document.querySelector('.reset-icon[onclick="clearInput(\'plzInput\')"]'),
|
||||||
document.getElementById('searchReset')
|
document.querySelector('.reset-icon[onclick="clearInput(\'fachrichtungInput\')"]')
|
||||||
];
|
];
|
||||||
|
|
||||||
searchInputs.forEach((input, index) => {
|
searchInputs.forEach((input, index) => {
|
||||||
@@ -534,18 +416,14 @@
|
|||||||
const name = urlParams.get('name');
|
const name = urlParams.get('name');
|
||||||
const ort = urlParams.get('ort');
|
const ort = urlParams.get('ort');
|
||||||
const kundennummer = urlParams.get('kundennummer');
|
const kundennummer = urlParams.get('kundennummer');
|
||||||
const fachrichtung = urlParams.get('fachrichtung');
|
const plz = urlParams.get('plz');
|
||||||
const telefon = urlParams.get('telefon');
|
|
||||||
const query = urlParams.get('q');
|
|
||||||
|
|
||||||
if (name) document.getElementById('nameInput').value = name;
|
if (name) document.getElementById('nameInput').value = name;
|
||||||
if (ort) document.getElementById('ortInput').value = ort;
|
if (ort) document.getElementById('ortInput').value = ort;
|
||||||
if (kundennummer) document.getElementById('kundennummerInput').value = kundennummer;
|
if (kundennummer) document.getElementById('nummerInput').value = kundennummer;
|
||||||
if (fachrichtung) document.getElementById('fachrichtungInput').value = fachrichtung;
|
if (plz) document.getElementById('plzInput').value = plz;
|
||||||
if (telefon) document.getElementById('telefonInput').value = telefon;
|
|
||||||
if (query) document.getElementById('searchInput').value = query;
|
|
||||||
|
|
||||||
if (name || ort || kundennummer || fachrichtung || telefon || query) {
|
if (name || ort || kundennummer || plz) {
|
||||||
searchCustomers();
|
searchCustomers();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@@ -52,8 +52,8 @@
|
|||||||
</div>
|
</div>
|
||||||
<footer class="footer">
|
<footer class="footer">
|
||||||
<div class="footer-content">
|
<div class="footer-content">
|
||||||
Made with ❤️ and 🍺 by <a href="https://www.medisoftware.de" target="_blank" class="footer-link">medisoftware</a>
|
Proudly made with ❤️ and 🍺 by <a href="https://www.medisoftware.de" target="_blank" class="footer-link">medisoftware</a>
|
||||||
<div style="font-size: 0.8em;">Version: v1.2.0</div>
|
<div style="font-size: 0.8em;">Version: v1.2.3</div>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
</body>
|
</body>
|
||||||
|
58
templates/offline.html
Normal file
58
templates/offline.html
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="de">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Offline - MEDI Kunden</title>
|
||||||
|
<link rel="stylesheet" href="{{ url_for('static', filename='css/styles.css') }}">
|
||||||
|
<style>
|
||||||
|
.offline-container {
|
||||||
|
text-align: center;
|
||||||
|
padding: 2rem;
|
||||||
|
max-width: 600px;
|
||||||
|
margin: 2rem auto;
|
||||||
|
}
|
||||||
|
.offline-icon {
|
||||||
|
font-size: 4rem;
|
||||||
|
color: #666;
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
}
|
||||||
|
.offline-message {
|
||||||
|
font-size: 1.2rem;
|
||||||
|
color: #333;
|
||||||
|
margin-bottom: 1.5rem;
|
||||||
|
}
|
||||||
|
.retry-button {
|
||||||
|
background-color: #4CAF50;
|
||||||
|
color: white;
|
||||||
|
padding: 0.8rem 1.5rem;
|
||||||
|
border: none;
|
||||||
|
border-radius: 4px;
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 1rem;
|
||||||
|
}
|
||||||
|
.retry-button:hover {
|
||||||
|
background-color: #45a049;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="offline-container">
|
||||||
|
<div class="offline-icon">📡</div>
|
||||||
|
<h1>Sie sind offline</h1>
|
||||||
|
<p class="offline-message">
|
||||||
|
Es scheint, dass Sie keine Internetverbindung haben.
|
||||||
|
Bitte überprüfen Sie Ihre Verbindung und versuchen Sie es erneut.
|
||||||
|
</p>
|
||||||
|
<button class="retry-button" onclick="window.location.reload()">
|
||||||
|
Erneut versuchen
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<script>
|
||||||
|
// Automatische Überprüfung der Verbindung
|
||||||
|
window.addEventListener('online', function() {
|
||||||
|
window.location.reload();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
Reference in New Issue
Block a user