Compare commits
29 Commits
feature/pw
...
d14ac5d9af
Author | SHA1 | Date | |
---|---|---|---|
d14ac5d9af | |||
b4939147c4 | |||
2a33fc45de | |||
3a317de8f0 | |||
f626cd52fd | |||
6283ccff6d | |||
3893e148ab | |||
65fbde845e | |||
57d3a05a5a | |||
dfd50d5e78 | |||
73541796f6 | |||
e3e9900482 | |||
156078ff3a | |||
5d56c7128e | |||
98f887f51e | |||
f46947b6d4 | |||
c1b55c3579 | |||
6a2e290d54 | |||
7263464b89 | |||
7b88e62de0 | |||
d50ea60af9 | |||
ec559f5c72 | |||
c454620ae1 | |||
94c381fbfc | |||
06576b08d9 | |||
465a6f058a | |||
daf7499b4e | |||
fade9b8d62 | |||
611a5dd906 |
22
.gitignore
vendored
22
.gitignore
vendored
@@ -17,6 +17,7 @@ pip-delete-this-directory.txt
|
|||||||
.vscode/
|
.vscode/
|
||||||
*.swp
|
*.swp
|
||||||
*.swo
|
*.swo
|
||||||
|
*.bak
|
||||||
|
|
||||||
# Logs
|
# Logs
|
||||||
*.log
|
*.log
|
||||||
@@ -43,12 +44,21 @@ coverage.xml
|
|||||||
|
|
||||||
# Docker
|
# Docker
|
||||||
.docker/
|
.docker/
|
||||||
|
docker-compose.yml
|
||||||
|
|
||||||
# Daten
|
# Daten
|
||||||
spezexpo.csv
|
data/
|
||||||
|
|
||||||
# Database
|
# Virtual Environment
|
||||||
*.db
|
develop-eggs/
|
||||||
data/customers.db
|
downloads/
|
||||||
data/customers.csv
|
eggs/
|
||||||
docker-compose.yml
|
.eggs/
|
||||||
|
lib/
|
||||||
|
lib64/
|
||||||
|
parts/
|
||||||
|
sdist/
|
||||||
|
var/
|
||||||
|
wheels/
|
||||||
|
.installed.cfg
|
||||||
|
*.egg
|
||||||
|
127
CHANGELOG.md
127
CHANGELOG.md
@@ -5,6 +5,133 @@ 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/).
|
||||||
|
|
||||||
|
## [Unreleased]
|
||||||
|
### Hinzugefügt
|
||||||
|
- CSV-Export-Funktion für Suchergebnisse
|
||||||
|
- Export-Button in der Benutzeroberfläche
|
||||||
|
- Automatische Formatierung der CSV-Datei mit allen relevanten Kundendaten
|
||||||
|
|
||||||
|
## [1.2.16] - 2024-03-21
|
||||||
|
### Geändert
|
||||||
|
- Verbesserte Darstellung der Suchergebnisse mit rechtsbündigen Aktionen
|
||||||
|
- Optimierte CSS-Styles für bessere Lesbarkeit und Layout
|
||||||
|
- JavaScript-Code in separate Datei ausgelagert für bessere Wartbarkeit
|
||||||
|
|
||||||
|
## [1.2.15] - 2024-03-20
|
||||||
|
### Hinzugefügt
|
||||||
|
- Autovervollständigung für das Ort-Feld
|
||||||
|
- Neue API-Route für Ortsvorschläge
|
||||||
|
- Optimierte SQL-Abfragen für die Ortssuche
|
||||||
|
|
||||||
|
## [1.2.14] - 2024-03-20
|
||||||
|
### Hinzugefügt
|
||||||
|
- Autovervollständigung für das Fachrichtungsfeld
|
||||||
|
- Neue API-Route für Fachrichtungsvorschläge
|
||||||
|
- Optimierte SQL-Abfragen für die Fachrichtungssuche
|
||||||
|
|
||||||
|
## [1.2.13] - 2024-03-20
|
||||||
|
### Fixed
|
||||||
|
- Korrektur der Parameteranzahl in der SQL-Abfrage für die allgemeine Suche
|
||||||
|
- Behebung des Fehlers bei der Suche in allen Datenbankfeldern
|
||||||
|
|
||||||
|
## [v1.2.12] - 2024-03-19
|
||||||
|
### Geändert
|
||||||
|
- Performance-Optimierung der Suchfunktion durch Reduzierung der Suchfelder
|
||||||
|
- Verbesserte Suchgeschwindigkeit durch LIMIT in SQL-Abfragen
|
||||||
|
- Optimiertes Debounce-Intervall für Live-Suche
|
||||||
|
- Verbessertes Highlighting für Teilstrings in Suchergebnissen
|
||||||
|
|
||||||
|
## [v1.2.11] - 2024-03-19
|
||||||
|
### Geändert
|
||||||
|
- Einträge mit der Fachrichtung "intern" werden aus den Suchergebnissen gefiltert
|
||||||
|
- Verbesserte SQL-Abfrage für die Suchergebnisse
|
||||||
|
|
||||||
|
## [v1.2.10] - 2024-03-19
|
||||||
|
### Geändert
|
||||||
|
- Verbesserte Darstellung der Adress-Links mit Location- und Route-Icons
|
||||||
|
- Korrektur des Docker-Port-Mappings für bessere Erreichbarkeit
|
||||||
|
|
||||||
|
## [v1.2.9] - 2024-03-19
|
||||||
|
### Geändert
|
||||||
|
- Verbesserte Darstellung der Adress-Links mit Location- und Route-Icons
|
||||||
|
- Korrektur des Docker-Port-Mappings für bessere Erreichbarkeit
|
||||||
|
|
||||||
|
## [v1.2.8] - 2024-03-19
|
||||||
|
### Geändert
|
||||||
|
- Verbesserte Tag-Anzeige: Badge neben dem Teilen-Button mit farblicher Hervorhebung (blau für MEDISOFT, orange für MEDICONSULT)
|
||||||
|
|
||||||
|
## [v1.2.7] - 2024-03-19
|
||||||
|
### Geändert
|
||||||
|
- Korrektur der Feldreihenfolge in den Suchergebnissen
|
||||||
|
- Verbesserung der Tag-Anzeige
|
||||||
|
|
||||||
|
## [v1.2.6] - 2024-03-19
|
||||||
|
### Geändert
|
||||||
|
- Verbesserte Darstellung der Kundennummern in den Suchergebnissen
|
||||||
|
- Optimierte Anzeige der Kundennummern in der Detailansicht
|
||||||
|
- Anpassung der Kundennummernberechnung für die MEDISOFT-Integration
|
||||||
|
- Verbesserte Formatierung der Kundennummern in der Benutzeroberfläche
|
||||||
|
|
||||||
|
## [v1.2.5] - 2024-03-19
|
||||||
|
### Geändert
|
||||||
|
- Verbesserte Darstellung der Kundennummern in den Suchergebnissen
|
||||||
|
- Optimierte Anzeige der Kundennummern in der Detailansicht
|
||||||
|
- Anpassung der Kundennummernberechnung für die MEDISOFT-Integration
|
||||||
|
- Verbesserte Formatierung der Kundennummern in der Benutzeroberfläche
|
||||||
|
|
||||||
|
## [v1.2.4] - 2024-03-19
|
||||||
|
### Geändert
|
||||||
|
- Verbesserte Darstellung der Kundennummern in den Suchergebnissen
|
||||||
|
- Optimierte Anzeige der Kundennummern in der Detailansicht
|
||||||
|
- Anpassung der Kundennummernberechnung für die MEDISOFT-Integration
|
||||||
|
- Verbesserte Formatierung der Kundennummern in der Benutzeroberfläche
|
||||||
|
|
||||||
|
## [v1.2.3] - 2024-03-19
|
||||||
|
### Geändert
|
||||||
|
- Verbesserte Darstellung der Kundennummern in den Suchergebnissen
|
||||||
|
- Optimierte Anzeige der Kundennummern in der Detailansicht
|
||||||
|
- Anpassung der Kundennummernberechnung für die MEDISOFT-Integration
|
||||||
|
- Verbesserte Formatierung der Kundennummern in der Benutzeroberfläche
|
||||||
|
|
||||||
|
## [v1.2.2] - 2024-03-19
|
||||||
|
### Geändert
|
||||||
|
- Verbesserte Darstellung der Kundennummern in den Suchergebnissen
|
||||||
|
- Optimierte Anzeige der Kundennummern in der Detailansicht
|
||||||
|
- Anpassung der Kundennummernberechnung für die MEDISOFT-Integration
|
||||||
|
- Verbesserte Formatierung der Kundennummern in der Benutzeroberfläche
|
||||||
|
|
||||||
|
## [v1.2.1] - 2024-03-19
|
||||||
|
### Geändert
|
||||||
|
- Verbesserte Darstellung der Kundennummern in den Suchergebnissen
|
||||||
|
- Optimierte Anzeige der Kundennummern in der Detailansicht
|
||||||
|
- Anpassung der Kundennummernberechnung für die MEDISOFT-Integration
|
||||||
|
- Verbesserte Formatierung der Kundennummern in der Benutzeroberfläche
|
||||||
|
|
||||||
|
## [v1.2.0] - 2024-03-19
|
||||||
|
### Hinzugefügt
|
||||||
|
- Neue Spalte "Tag" in der Kundendatenbank
|
||||||
|
- Unterscheidung zwischen MEDISOFT und MEDICONSULT Kunden
|
||||||
|
- Filteroption für die Anzeige von MEDISOFT oder MEDICONSULT Kunden
|
||||||
|
- Verbesserte Darstellung der Kundennummern in den Suchergebnissen
|
||||||
|
- Optimierte Anzeige der Kundennummern in der Detailansicht
|
||||||
|
- Anpassung der Kundennummernberechnung für die MEDISOFT-Integration
|
||||||
|
- Verbesserte Formatierung der Kundennummern in der Benutzeroberfläche
|
||||||
|
|
||||||
|
## [v1.1.0] - 2024-03-19
|
||||||
|
### Hinzugefügt
|
||||||
|
- Neue Spalte "Tag" in der Kundendatenbank
|
||||||
|
- Unterscheidung zwischen MEDISOFT und MEDICONSULT Kunden
|
||||||
|
- Filteroption für die Anzeige von MEDISOFT oder MEDICONSULT Kunden
|
||||||
|
|
||||||
|
## [v1.0.0] - 2024-03-19
|
||||||
|
### Hinzugefügt
|
||||||
|
- Erste Version der Anwendung
|
||||||
|
- Grundlegende Suchfunktionalität
|
||||||
|
- Anzeige von Kundendetails
|
||||||
|
- Integration mit MEDISOFT
|
||||||
|
- Responsive Design
|
||||||
|
- IP-basierte Zugriffskontrolle
|
||||||
|
|
||||||
## [1.2.6] - 2024-03-19
|
## [1.2.6] - 2024-03-19
|
||||||
### Geändert
|
### Geändert
|
||||||
- Verbesserte Suchfunktion: Keine Ergebnisse mehr bei leeren Suchfeldern
|
- Verbesserte Suchfunktion: Keine Ergebnisse mehr bei leeren Suchfeldern
|
||||||
|
67
README.md
67
README.md
@@ -1,35 +1,49 @@
|
|||||||
# Medi-Customers
|
# medisoftware Kundensuche
|
||||||
|
|
||||||
Eine Flask-basierte Webanwendung zur Verwaltung von Kundenkontakten für medizinische Einrichtungen.
|
Eine einfache und effiziente Kundensuche für medisoftware Kunden.
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
- Kundensuche nach verschiedenen Kriterien (Name, Ort, Kundennummer, etc.)
|
- 🔍 Echtzeit-Suche über alle Kundendaten
|
||||||
- Direkte Links zu Kundendaten in medisoftware (für autorisierte IPs)
|
- 📱 Responsive Design für alle Geräte
|
||||||
- Telefonnummern-Links für autorisierte IPs
|
- 🔒 IP-basierte Zugriffskontrolle
|
||||||
- Adress-Links mit Google Maps Integration
|
- 🔗 Direkte Integration mit MEDISOFT
|
||||||
- IP-basierte Zugriffssteuerung
|
- 🏥 Unterscheidung zwischen MEDISOFT und MEDICONSULT Kunden
|
||||||
- Responsive Design
|
- 🎨 Farbliche Hervorhebung der Kundentypen (blau für MEDISOFT, orange für MEDICONSULT)
|
||||||
|
- 📍 Verbesserte Adress-Links mit Location- und Route-Icons
|
||||||
|
|
||||||
|
## Version
|
||||||
|
|
||||||
|
Aktuelle Version: 1.2.16
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
1. Repository klonen:
|
1. Klonen Sie das Repository:
|
||||||
```bash
|
```bash
|
||||||
git clone https://gitea.elpatron.me/elpatron/medi-customers.git
|
git clone https://gitea.elpatron.me/elpatron/medi-customers.git
|
||||||
cd medi-customers
|
cd medi-customers
|
||||||
```
|
```
|
||||||
|
|
||||||
2. Umgebungsvariablen einrichten:
|
2. Erstellen Sie die erforderlichen Verzeichnisse:
|
||||||
```bash
|
```bash
|
||||||
cp .env.example .env
|
mkdir -p data
|
||||||
# Bearbeiten Sie die .env-Datei mit Ihren Einstellungen
|
|
||||||
```
|
```
|
||||||
|
|
||||||
3. Docker Container starten:
|
3. Starten Sie die Anwendung mit Docker Compose:
|
||||||
```bash
|
```bash
|
||||||
docker-compose up -d
|
docker-compose up --build
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Die Anwendung ist dann unter `http://localhost:5000` erreichbar.
|
||||||
|
|
||||||
|
## Entwicklung
|
||||||
|
|
||||||
|
Die Anwendung ist in Python mit Flask entwickelt und verwendet SQLite als Datenbank. Das Frontend wurde mit HTML, CSS und JavaScript implementiert.
|
||||||
|
|
||||||
|
## Lizenz
|
||||||
|
|
||||||
|
Alle Rechte vorbehalten. © 2024 medisoftware
|
||||||
|
|
||||||
## Konfiguration
|
## Konfiguration
|
||||||
|
|
||||||
Die Anwendung kann über folgende Umgebungsvariablen konfiguriert werden:
|
Die Anwendung kann über folgende Umgebungsvariablen konfiguriert werden:
|
||||||
@@ -49,14 +63,6 @@ Die Anwendung unterstützt CIDR-Notation für IP-Bereiche. Beispiele:
|
|||||||
- Subnetz: 192.168.1.0/24
|
- Subnetz: 192.168.1.0/24
|
||||||
- Größeres Netzwerk: 10.0.0.0/8
|
- Größeres Netzwerk: 10.0.0.0/8
|
||||||
|
|
||||||
## Version
|
|
||||||
|
|
||||||
Aktuelle Version: v1.2.6
|
|
||||||
|
|
||||||
## Lizenz
|
|
||||||
|
|
||||||
Alle Rechte vorbehalten. © 2025 medisoftware
|
|
||||||
|
|
||||||
## API-Beispiele
|
## API-Beispiele
|
||||||
|
|
||||||
### Suche nach Name
|
### Suche nach Name
|
||||||
@@ -104,3 +110,20 @@ curl "http://localhost:5001/search?fachrichtung=Zahnarzt&ort=Berlin&name=Schmidt
|
|||||||
## Version
|
## Version
|
||||||
|
|
||||||
Aktuelle Version: [v1.2.4](CHANGELOG.md#v124---2024-03-19)
|
Aktuelle Version: [v1.2.4](CHANGELOG.md#v124---2024-03-19)
|
||||||
|
|
||||||
|
## Code-Statistiken
|
||||||
|
|
||||||
|
Language|files|blank|comment|code
|
||||||
|
:-------|-------:|-------:|-------:|-------:
|
||||||
|
HTML|2|56|0|416
|
||||||
|
CSS|2|51|1|265
|
||||||
|
Markdown|2|66|0|236
|
||||||
|
Python|1|51|103|225
|
||||||
|
YAML|1|0|0|13
|
||||||
|
Dockerfile|1|8|9|11
|
||||||
|
Text|1|0|0|5
|
||||||
|
--------|--------|--------|--------|--------
|
||||||
|
SUM:|10|232|113|1171
|
||||||
|
|
||||||
|
## Lizenz
|
||||||
|
Alle Rechte vorbehalten. © 2025 medisoftware
|
532
app.py
532
app.py
@@ -1,4 +1,4 @@
|
|||||||
from flask import Flask, render_template, request, jsonify, url_for, redirect, session, make_response, send_from_directory
|
from flask import Flask, render_template, request, jsonify, url_for, redirect, session
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
import os
|
import os
|
||||||
import logging
|
import logging
|
||||||
@@ -13,16 +13,12 @@ import sqlite3
|
|||||||
from functools import wraps
|
from functools import wraps
|
||||||
|
|
||||||
app = Flask(__name__, static_folder='static')
|
app = Flask(__name__, static_folder='static')
|
||||||
app.secret_key = os.getenv('SECRET_KEY', 'default-secret-key')
|
app.config['SECRET_KEY'] = os.getenv('SECRET_KEY', 'dev')
|
||||||
|
app.config['ALLOWED_IP_RANGES'] = os.getenv('ALLOWED_IP_RANGES', '192.168.0.0/16,10.0.0.0/8').split(',')
|
||||||
|
app.config['VERSION'] = '1.2.16'
|
||||||
logging.basicConfig(level=logging.INFO)
|
logging.basicConfig(level=logging.INFO)
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
# Version der Anwendung
|
|
||||||
VERSION = "1.2.1"
|
|
||||||
|
|
||||||
# Pfad zur CSV-Datei
|
|
||||||
CSV_FILE = 'data/customers.csv'
|
|
||||||
|
|
||||||
# Pfad zur Datenbank
|
# Pfad zur Datenbank
|
||||||
DB_FILE = 'data/customers.db'
|
DB_FILE = 'data/customers.db'
|
||||||
|
|
||||||
@@ -31,14 +27,41 @@ load_dotenv()
|
|||||||
|
|
||||||
# Statisches Passwort aus der .env Datei
|
# Statisches Passwort aus der .env Datei
|
||||||
STATIC_PASSWORD = os.getenv('LOGIN_PASSWORD', 'default-password')
|
STATIC_PASSWORD = os.getenv('LOGIN_PASSWORD', 'default-password')
|
||||||
ALLOWED_IP_RANGES = os.getenv('ALLOWED_IP_RANGES', '').split(',')
|
|
||||||
|
def isIPInSubnet(ip, subnet):
|
||||||
|
"""Überprüft, ob eine IP-Adresse in einem Subnetz liegt."""
|
||||||
|
try:
|
||||||
|
# Teile die IP und das Subnetz in ihre Komponenten
|
||||||
|
subnet_ip, bits = subnet.split('/')
|
||||||
|
ip_parts = [int(x) for x in ip.split('.')]
|
||||||
|
subnet_parts = [int(x) for x in subnet_ip.split('.')]
|
||||||
|
|
||||||
|
# Konvertiere IPs in 32-bit Zahlen
|
||||||
|
ip_num = (ip_parts[0] << 24) | (ip_parts[1] << 16) | (ip_parts[2] << 8) | ip_parts[3]
|
||||||
|
subnet_num = (subnet_parts[0] << 24) | (subnet_parts[1] << 16) | (subnet_parts[2] << 8) | subnet_parts[3]
|
||||||
|
|
||||||
|
# Erstelle die Subnetzmaske
|
||||||
|
mask = ~((1 << (32 - int(bits))) - 1)
|
||||||
|
|
||||||
|
# Prüfe, ob die IP im Subnetz liegt
|
||||||
|
return (ip_num & mask) == (subnet_num & mask)
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"Fehler bei der IP-Überprüfung: {str(e)}")
|
||||||
|
return False
|
||||||
|
|
||||||
|
def get_db_connection():
|
||||||
|
"""Erstellt eine neue Datenbankverbindung mit Timeout"""
|
||||||
|
conn = sqlite3.connect(DB_FILE, timeout=20)
|
||||||
|
conn.row_factory = sqlite3.Row
|
||||||
|
return conn
|
||||||
|
|
||||||
def init_db():
|
def init_db():
|
||||||
"""Initialisiert die SQLite-Datenbank mit der notwendigen Tabelle."""
|
"""Initialisiert die SQLite-Datenbank mit der notwendigen Tabelle."""
|
||||||
conn = sqlite3.connect(DB_FILE)
|
conn = get_db_connection()
|
||||||
c = conn.cursor()
|
c = conn.cursor()
|
||||||
|
|
||||||
# Erstelle die Tabelle
|
try:
|
||||||
|
# Erstelle die Kunden-Tabelle
|
||||||
c.execute('''
|
c.execute('''
|
||||||
CREATE TABLE IF NOT EXISTS customers (
|
CREATE TABLE IF NOT EXISTS customers (
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
@@ -51,7 +74,13 @@ def init_db():
|
|||||||
mobil TEXT,
|
mobil TEXT,
|
||||||
email TEXT,
|
email TEXT,
|
||||||
bemerkung TEXT,
|
bemerkung TEXT,
|
||||||
fachrichtung TEXT
|
fachrichtung TEXT,
|
||||||
|
tag TEXT,
|
||||||
|
handy TEXT,
|
||||||
|
tele_firma TEXT,
|
||||||
|
kontakt1 TEXT,
|
||||||
|
kontakt2 TEXT,
|
||||||
|
kontakt3 TEXT
|
||||||
)
|
)
|
||||||
''')
|
''')
|
||||||
|
|
||||||
@@ -65,213 +94,106 @@ def init_db():
|
|||||||
c.execute('CREATE INDEX IF NOT EXISTS idx_customers_mobil ON customers(mobil)')
|
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_email ON customers(email)')
|
||||||
c.execute('CREATE INDEX IF NOT EXISTS idx_customers_fachrichtung ON customers(fachrichtung)')
|
c.execute('CREATE INDEX IF NOT EXISTS idx_customers_fachrichtung ON customers(fachrichtung)')
|
||||||
|
c.execute('CREATE INDEX IF NOT EXISTS idx_customers_tag ON customers(tag)')
|
||||||
|
c.execute('CREATE INDEX IF NOT EXISTS idx_customers_handy ON customers(handy)')
|
||||||
|
c.execute('CREATE INDEX IF NOT EXISTS idx_customers_tele_firma ON customers(tele_firma)')
|
||||||
|
|
||||||
# Erstelle einen zusammengesetzten Index für die häufigste Suchkombination
|
# 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)')
|
c.execute('CREATE INDEX IF NOT EXISTS idx_customers_name_ort ON customers(name, ort)')
|
||||||
|
|
||||||
conn.commit()
|
conn.commit()
|
||||||
conn.close()
|
|
||||||
logger.info('Datenbank initialisiert')
|
logger.info('Datenbank initialisiert')
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f'Fehler bei der Datenbankinitialisierung: {str(e)}')
|
||||||
|
raise
|
||||||
|
finally:
|
||||||
|
conn.close()
|
||||||
|
|
||||||
def import_csv():
|
def import_csv():
|
||||||
"""Importiert die Daten aus der CSV-Datei in die SQLite-Datenbank."""
|
"""Importiert die CSV-Datei in die Datenbank"""
|
||||||
conn = sqlite3.connect(DB_FILE)
|
conn = None
|
||||||
|
try:
|
||||||
|
conn = get_db_connection()
|
||||||
c = conn.cursor()
|
c = conn.cursor()
|
||||||
|
|
||||||
# Lösche bestehende Daten
|
# Lösche bestehende Daten
|
||||||
c.execute('DELETE FROM customers')
|
c.execute('DELETE FROM customers')
|
||||||
|
|
||||||
try:
|
# Importiere MEDISOFT-Daten
|
||||||
# Lese die CSV-Datei mit pandas
|
if os.path.exists('data/customers.csv'):
|
||||||
df = pd.read_csv(CSV_FILE, sep=',', encoding='utf-8', quotechar='"')
|
logger.info("Importiere MEDISOFT-Daten...")
|
||||||
|
df = pd.read_csv('data/customers.csv', encoding='iso-8859-1')
|
||||||
|
df.columns = df.columns.str.strip().str.replace('"', '')
|
||||||
|
df = df.apply(lambda x: x.str.strip().str.replace('"', '') if x.dtype == "object" else x)
|
||||||
|
|
||||||
# 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():
|
for _, row in df.iterrows():
|
||||||
c.execute('''
|
c.execute('''
|
||||||
INSERT INTO customers (nummer, name, strasse, plz, ort, telefon, mobil, email, bemerkung, fachrichtung)
|
INSERT INTO customers (
|
||||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
name, nummer, strasse, plz, ort, telefon, mobil, email,
|
||||||
|
fachrichtung, tag, handy, tele_firma, kontakt1, kontakt2, kontakt3
|
||||||
|
)
|
||||||
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||||
''', (
|
''', (
|
||||||
row['Nummer'],
|
row['VorNachname'], row['Nummer'], row['Strasse'], row['PLZ'], row['Ort'],
|
||||||
row['name'],
|
row['Tel'], row['Tel'], row['mail'], row['Fachrichtung'], 'medisoft',
|
||||||
row['Strasse'],
|
row['Handy'], row['Tele Firma'], row['Kontakt1'], row['Kontakt2'], row['Kontakt3']
|
||||||
row['PLZ'],
|
|
||||||
row['Ort'],
|
|
||||||
row['Tel'],
|
|
||||||
row['Handy'],
|
|
||||||
row['mail'],
|
|
||||||
f"Fachrichtung: {row['Fachrichtung']}",
|
|
||||||
row['Fachrichtung']
|
|
||||||
))
|
))
|
||||||
|
else:
|
||||||
|
logger.warning("MEDISOFT CSV-Datei nicht gefunden")
|
||||||
|
|
||||||
|
# Importiere MEDICONSULT-Daten
|
||||||
|
if os.path.exists('data/customers_snk.csv'):
|
||||||
|
logger.info("Importiere MEDICONSULT-Daten...")
|
||||||
|
df_snk = pd.read_csv('data/customers_snk.csv', encoding='iso-8859-1')
|
||||||
|
df_snk.columns = df_snk.columns.str.strip().str.replace('"', '')
|
||||||
|
df_snk = df_snk.apply(lambda x: x.str.strip().str.replace('"', '') if x.dtype == "object" else x)
|
||||||
|
|
||||||
|
for _, row in df_snk.iterrows():
|
||||||
|
c.execute('''
|
||||||
|
INSERT INTO customers (
|
||||||
|
name, nummer, strasse, plz, ort, telefon, mobil, email,
|
||||||
|
fachrichtung, tag, handy, tele_firma, kontakt1, kontakt2, kontakt3
|
||||||
|
)
|
||||||
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||||
|
''', (
|
||||||
|
row['VorNachname'], row['Nummer'], row['Strasse'], row['PLZ'], row['Ort'],
|
||||||
|
row['Tel'], row['Tel'], row['mail'], row['Fachrichtung'], 'mediconsult',
|
||||||
|
row['Handy'], row['Tele Firma'], row['Kontakt1'], row['Kontakt2'], row['Kontakt3']
|
||||||
|
))
|
||||||
|
else:
|
||||||
|
logger.warning("MEDICONSULT CSV-Datei nicht gefunden")
|
||||||
|
|
||||||
conn.commit()
|
conn.commit()
|
||||||
logger.info('CSV-Daten erfolgreich in die Datenbank importiert')
|
logger.info("CSV-Daten erfolgreich in die Datenbank importiert")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f'Fehler beim Import der CSV-Daten: {str(e)}')
|
logger.error(f"Fehler beim Importieren der CSV-Datei: {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
|
raise
|
||||||
finally:
|
finally:
|
||||||
|
if conn:
|
||||||
conn.close()
|
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"""
|
||||||
return df.replace({np.nan: None})
|
return df.replace({np.nan: None})
|
||||||
|
|
||||||
# CSV-Datei laden
|
|
||||||
def load_data():
|
|
||||||
try:
|
|
||||||
logger.info("Versuche CSV-Datei zu laden...")
|
|
||||||
if not os.path.exists(CSV_FILE):
|
|
||||||
logger.error(f"CSV-Datei '{CSV_FILE}' nicht gefunden!")
|
|
||||||
return None
|
|
||||||
|
|
||||||
# Lade CSV mit Komma als Trennzeichen
|
|
||||||
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('"')
|
|
||||||
df = clean_dataframe(df)
|
|
||||||
logger.info(f"CSV-Datei erfolgreich geladen. {len(df)} Einträge gefunden.")
|
|
||||||
return df
|
|
||||||
except Exception as e:
|
|
||||||
logger.error(f"Fehler beim Laden der CSV-Datei: {str(e)}")
|
|
||||||
return None
|
|
||||||
|
|
||||||
@app.route('/login', methods=['GET', 'POST'])
|
@app.route('/login', methods=['GET', 'POST'])
|
||||||
def login():
|
def login():
|
||||||
# Versuche, die tatsächliche Client-IP aus dem X-Forwarded-For-Header zu erhalten
|
# Überprüfe, ob die Client-IP in einem der erlaubten Bereiche liegt
|
||||||
client_ip = request.headers.get('X-Forwarded-For', request.remote_addr)
|
client_ip = request.headers.get('X-Forwarded-For', request.remote_addr)
|
||||||
allowed_ip_ranges = os.getenv('ALLOWED_IP_RANGES', '').split(',')
|
|
||||||
|
|
||||||
logger.info(f"Client-IP: {client_ip}")
|
# Überprüfe, ob die Client-IP in einem der erlaubten Bereichen liegt
|
||||||
logger.info(f"Erlaubte IP-Bereiche: {allowed_ip_ranges}")
|
is_allowed = any(isIPInSubnet(client_ip, range.strip()) for range in app.config['ALLOWED_IP_RANGES'] if range.strip())
|
||||||
logger.info(f"Session Status: {session}")
|
|
||||||
|
|
||||||
# Überprüfen, ob die IP-Adresse in einem der erlaubten Subnetze liegt
|
if is_allowed:
|
||||||
client_ip_obj = ipaddress.ip_address(client_ip)
|
logger.info(f"Client-IP {client_ip} ist in einem erlaubten Bereich, automatischer Login")
|
||||||
for ip_range in allowed_ip_ranges:
|
|
||||||
try:
|
|
||||||
network = ipaddress.ip_network(ip_range.strip(), strict=False)
|
|
||||||
logger.info(f"Überprüfe Netzwerk: {network}")
|
|
||||||
if client_ip_obj in network:
|
|
||||||
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:
|
|
||||||
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("Erfolgreicher Login")
|
||||||
logger.info("Login erfolgreich, Session gesetzt")
|
|
||||||
return redirect(url_for('index'))
|
return redirect(url_for('index'))
|
||||||
else:
|
else:
|
||||||
logger.warning("Falsches Passwort eingegeben")
|
logger.warning("Falsches Passwort eingegeben")
|
||||||
@@ -287,84 +209,218 @@ def index():
|
|||||||
logger.info("Benutzer nicht eingeloggt, Weiterleitung zum Login")
|
logger.info("Benutzer nicht eingeloggt, Weiterleitung zum Login")
|
||||||
return redirect(url_for('login'))
|
return redirect(url_for('login'))
|
||||||
|
|
||||||
allowed_ip_ranges = os.getenv('ALLOWED_IP_RANGES', '')
|
|
||||||
client_ip = request.headers.get('X-Forwarded-For', request.remote_addr)
|
client_ip = request.headers.get('X-Forwarded-For', request.remote_addr)
|
||||||
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: {app.config['ALLOWED_IP_RANGES']}")
|
||||||
return render_template('index.html', allowed_ip_ranges=allowed_ip_ranges)
|
return render_template('index.html', allowed_ip_ranges=','.join(app.config['ALLOWED_IP_RANGES']), version=app.config['VERSION'])
|
||||||
|
|
||||||
@app.route('/search')
|
@app.route('/search', methods=['GET', 'POST'])
|
||||||
def search():
|
def search():
|
||||||
|
if not session.get('logged_in'):
|
||||||
|
return jsonify({'error': 'Nicht eingeloggt'}), 401
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Hole die Suchparameter aus der Anfrage
|
if request.method == 'POST':
|
||||||
search_params = {
|
data = request.get_json()
|
||||||
'name': request.args.get('name', ''),
|
search_query = data.get('query', '')
|
||||||
'ort': request.args.get('ort', ''),
|
tag = data.get('tag', 'medisoft')
|
||||||
'nummer': request.args.get('nummer', ''),
|
else:
|
||||||
'plz': request.args.get('plz', ''),
|
search_query = request.args.get('q', '')
|
||||||
'telefon': request.args.get('telefon', ''),
|
name = request.args.get('name', '')
|
||||||
'email': request.args.get('email', ''),
|
ort = request.args.get('ort', '')
|
||||||
'q': request.args.get('q', ''),
|
nummer = request.args.get('nummer', '')
|
||||||
'fachrichtung': request.args.get('fachrichtung', ''),
|
plz = request.args.get('plz', '')
|
||||||
'operator': request.args.get('operator', 'or')
|
fachrichtung = request.args.get('fachrichtung', '')
|
||||||
}
|
tag = request.args.get('tag', 'medisoft')
|
||||||
|
|
||||||
# Führe die Suche in der Datenbank durch
|
conn = get_db_connection()
|
||||||
results = search_customers(search_params)
|
|
||||||
|
|
||||||
# Protokolliere die Anzahl der gefundenen Ergebnisse
|
|
||||||
logger.info(f'Suchergebnisse gefunden: {len(results)}')
|
|
||||||
|
|
||||||
return jsonify(results)
|
|
||||||
except Exception as e:
|
|
||||||
logger.error(f'Fehler bei der Suche: {str(e)}')
|
|
||||||
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 = conn.cursor()
|
||||||
c.execute('SELECT * FROM customers')
|
|
||||||
columns = [description[0] for description in c.description]
|
# Baue die SQL-Abfrage
|
||||||
results = []
|
sql_query = '''
|
||||||
for row in c.fetchall():
|
SELECT
|
||||||
customer = dict(zip(columns, row))
|
nummer,
|
||||||
results.append(customer)
|
name,
|
||||||
|
strasse,
|
||||||
|
plz,
|
||||||
|
ort,
|
||||||
|
telefon,
|
||||||
|
mobil,
|
||||||
|
email,
|
||||||
|
fachrichtung,
|
||||||
|
tag,
|
||||||
|
handy,
|
||||||
|
tele_firma,
|
||||||
|
kontakt1,
|
||||||
|
kontakt2,
|
||||||
|
kontakt3
|
||||||
|
FROM customers
|
||||||
|
WHERE 1=1
|
||||||
|
'''
|
||||||
|
params = []
|
||||||
|
|
||||||
|
# Füge die Suchbedingungen hinzu
|
||||||
|
if search_query:
|
||||||
|
# Optimierte Suche mit FTS (Full Text Search)
|
||||||
|
sql_query += """
|
||||||
|
AND (
|
||||||
|
name LIKE ? OR
|
||||||
|
nummer LIKE ? OR
|
||||||
|
fachrichtung LIKE ? OR
|
||||||
|
ort LIKE ? OR
|
||||||
|
plz LIKE ? OR
|
||||||
|
strasse LIKE ? OR
|
||||||
|
telefon LIKE ? OR
|
||||||
|
mobil LIKE ? OR
|
||||||
|
email LIKE ? OR
|
||||||
|
bemerkung LIKE ? OR
|
||||||
|
tag LIKE ? OR
|
||||||
|
handy LIKE ? OR
|
||||||
|
tele_firma LIKE ? OR
|
||||||
|
kontakt1 LIKE ? OR
|
||||||
|
kontakt2 LIKE ? OR
|
||||||
|
kontakt3 LIKE ?
|
||||||
|
)
|
||||||
|
"""
|
||||||
|
search_term = f"%{search_query}%"
|
||||||
|
params.extend([search_term] * 16) # 16 Felder für die allgemeine Suche
|
||||||
|
|
||||||
|
if name:
|
||||||
|
sql_query += " AND name LIKE ?"
|
||||||
|
params.append(f"%{name}%")
|
||||||
|
|
||||||
|
if ort:
|
||||||
|
sql_query += " AND ort LIKE ?"
|
||||||
|
params.append(f"%{ort}%")
|
||||||
|
|
||||||
|
if nummer:
|
||||||
|
sql_query += " AND nummer LIKE ?"
|
||||||
|
params.append(f"%{nummer}%")
|
||||||
|
|
||||||
|
if plz:
|
||||||
|
sql_query += " AND plz LIKE ?"
|
||||||
|
params.append(f"%{plz}%")
|
||||||
|
|
||||||
|
if fachrichtung:
|
||||||
|
sql_query += " AND fachrichtung LIKE ?"
|
||||||
|
params.append(f"%{fachrichtung}%")
|
||||||
|
|
||||||
|
# Filter nach Tag
|
||||||
|
if tag != 'all':
|
||||||
|
sql_query += " AND tag = ?"
|
||||||
|
params.append(tag)
|
||||||
|
|
||||||
|
# Füge LIMIT hinzu und optimiere die Sortierung
|
||||||
|
sql_query += " ORDER BY name LIMIT 100"
|
||||||
|
|
||||||
|
# Führe die Abfrage aus
|
||||||
|
cursor = conn.cursor()
|
||||||
|
cursor.execute(sql_query, params)
|
||||||
|
results = cursor.fetchall()
|
||||||
|
|
||||||
|
formatted_results = []
|
||||||
|
for row in results:
|
||||||
|
customer = {
|
||||||
|
'nummer': row[0],
|
||||||
|
'name': row[1],
|
||||||
|
'strasse': row[2],
|
||||||
|
'plz': row[3],
|
||||||
|
'ort': row[4],
|
||||||
|
'telefon': row[5],
|
||||||
|
'mobil': row[6],
|
||||||
|
'email': row[7],
|
||||||
|
'fachrichtung': row[8],
|
||||||
|
'tag': row[9],
|
||||||
|
'handy': row[10],
|
||||||
|
'tele_firma': row[11],
|
||||||
|
'kontakt1': row[12],
|
||||||
|
'kontakt2': row[13],
|
||||||
|
'kontakt3': row[14]
|
||||||
|
}
|
||||||
|
formatted_results.append(customer)
|
||||||
|
|
||||||
conn.close()
|
conn.close()
|
||||||
return jsonify(results)
|
return jsonify(formatted_results)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return jsonify({"error": str(e)}), 500
|
logger.error(f"Fehler bei der Suche: {str(e)}")
|
||||||
|
return jsonify({'error': str(e)}), 500
|
||||||
|
|
||||||
|
@app.route('/api/fachrichtungen')
|
||||||
|
def get_fachrichtungen():
|
||||||
|
try:
|
||||||
|
search_term = request.args.get('q', '').lower()
|
||||||
|
conn = get_db_connection()
|
||||||
|
c = conn.cursor()
|
||||||
|
|
||||||
|
# Hole alle eindeutigen Fachrichtungen, die mit dem Suchbegriff übereinstimmen
|
||||||
|
c.execute('''
|
||||||
|
SELECT DISTINCT fachrichtung
|
||||||
|
FROM customers
|
||||||
|
WHERE fachrichtung IS NOT NULL
|
||||||
|
AND fachrichtung != ''
|
||||||
|
AND LOWER(fachrichtung) LIKE ?
|
||||||
|
ORDER BY fachrichtung
|
||||||
|
LIMIT 10
|
||||||
|
''', (f'%{search_term}%',))
|
||||||
|
|
||||||
|
fachrichtungen = [row[0] for row in c.fetchall()]
|
||||||
|
conn.close()
|
||||||
|
|
||||||
|
return jsonify(fachrichtungen)
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"Fehler beim Abrufen der Fachrichtungen: {str(e)}")
|
||||||
|
return jsonify([])
|
||||||
|
|
||||||
|
@app.route('/api/orte')
|
||||||
|
def get_orte():
|
||||||
|
try:
|
||||||
|
search_term = request.args.get('q', '').lower()
|
||||||
|
conn = get_db_connection()
|
||||||
|
c = conn.cursor()
|
||||||
|
|
||||||
|
# Hole alle eindeutigen Orte, die mit dem Suchbegriff übereinstimmen
|
||||||
|
c.execute('''
|
||||||
|
SELECT DISTINCT ort
|
||||||
|
FROM customers
|
||||||
|
WHERE ort IS NOT NULL
|
||||||
|
AND ort != ''
|
||||||
|
AND LOWER(ort) LIKE ?
|
||||||
|
ORDER BY ort
|
||||||
|
LIMIT 10
|
||||||
|
''', (f'%{search_term}%',))
|
||||||
|
|
||||||
|
orte = [row[0] for row in c.fetchall()]
|
||||||
|
conn.close()
|
||||||
|
|
||||||
|
return jsonify(orte)
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"Fehler beim Abrufen der Orte: {str(e)}")
|
||||||
|
return jsonify([])
|
||||||
|
|
||||||
def init_app(app):
|
def init_app(app):
|
||||||
"""Initialisiert die Anwendung mit allen notwendigen Einstellungen."""
|
"""Initialisiert die Anwendung mit allen notwendigen Einstellungen."""
|
||||||
with app.app_context():
|
with app.app_context():
|
||||||
|
try:
|
||||||
|
# Stelle sicher, dass der data-Ordner existiert
|
||||||
|
os.makedirs('data', exist_ok=True)
|
||||||
|
|
||||||
|
# Lösche die alte Datenbank, falls sie existiert
|
||||||
|
if os.path.exists(DB_FILE):
|
||||||
|
try:
|
||||||
|
os.remove(DB_FILE)
|
||||||
|
logger.info(f"Alte Datenbank {DB_FILE} wurde gelöscht")
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"Fehler beim Löschen der alten Datenbank: {str(e)}")
|
||||||
|
|
||||||
# Initialisiere die Datenbank
|
# Initialisiere die Datenbank
|
||||||
init_db()
|
init_db()
|
||||||
# Importiere die CSV-Daten
|
# Importiere die CSV-Daten
|
||||||
import_csv()
|
import_csv()
|
||||||
logger.info("Anwendung erfolgreich initialisiert")
|
logger.info("Anwendung erfolgreich initialisiert")
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"Fehler bei der Initialisierung: {str(e)}")
|
||||||
|
raise
|
||||||
|
|
||||||
# Initialisiere die App
|
# Initialisiere die App
|
||||||
init_app(app)
|
init_app(app)
|
||||||
|
1172
data/customers.csv
1172
data/customers.csv
File diff suppressed because it is too large
Load Diff
@@ -1,39 +0,0 @@
|
|||||||
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()
|
|
@@ -182,18 +182,78 @@ body {
|
|||||||
.customer-card {
|
.customer-card {
|
||||||
background: white;
|
background: white;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
padding: 1.5rem;
|
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
||||||
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;
|
margin-bottom: 1rem;
|
||||||
|
padding: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.customer-header {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: flex-start;
|
||||||
|
margin-bottom: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.customer-name {
|
||||||
|
margin: 0;
|
||||||
|
font-size: 1.2rem;
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
|
||||||
|
.customer-actions {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.customer-details {
|
||||||
|
font-size: 0.9rem;
|
||||||
|
color: #666;
|
||||||
|
}
|
||||||
|
|
||||||
|
.customer-details p {
|
||||||
|
margin: 0.25rem 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.customer-details strong {
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
|
||||||
|
.phone-link, .email-link, .customer-link {
|
||||||
|
color: #007bff;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.phone-link:hover, .email-link:hover, .customer-link:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
.address-text {
|
||||||
|
margin-right: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.address-link, .route-link {
|
||||||
|
color: #6c757d;
|
||||||
|
text-decoration: none;
|
||||||
|
margin-left: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.address-link:hover, .route-link:hover {
|
||||||
|
color: #343a40;
|
||||||
|
}
|
||||||
|
|
||||||
|
.location-pin, .route-pin {
|
||||||
|
font-size: 0.9rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.badge {
|
||||||
|
font-size: 0.8rem;
|
||||||
|
padding: 0.35em 0.65em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-sm {
|
||||||
|
padding: 0.25rem 0.5rem;
|
||||||
|
font-size: 0.875rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.footer-content {
|
.footer-content {
|
||||||
@@ -255,80 +315,43 @@ body {
|
|||||||
user-select: none;
|
user-select: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Offline-Indikator */
|
.result-tag {
|
||||||
.offline-indicator {
|
padding: 4px 8px;
|
||||||
position: fixed;
|
border-radius: 4px;
|
||||||
bottom: 20px;
|
font-size: 0.9em;
|
||||||
right: 20px;
|
font-weight: 500;
|
||||||
|
text-transform: uppercase;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tag-medisoft {
|
||||||
|
background-color: #1976d2;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tag-mediconsult {
|
||||||
background-color: #ff9800;
|
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 {
|
.autocomplete-items {
|
||||||
font-size: 1.2em;
|
position: absolute;
|
||||||
|
border: 1px solid #d4d4d4;
|
||||||
|
border-top: none;
|
||||||
|
z-index: 99;
|
||||||
|
top: 100%;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
background-color: white;
|
||||||
|
max-height: 200px;
|
||||||
|
overflow-y: auto;
|
||||||
|
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Synchronisations-Status */
|
.autocomplete-items div {
|
||||||
.sync-status {
|
padding: 8px 12px;
|
||||||
position: fixed;
|
cursor: pointer;
|
||||||
bottom: 20px;
|
background-color: white;
|
||||||
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 {
|
.autocomplete-items div:hover {
|
||||||
font-size: 1.2em;
|
background-color: #f8f9fa;
|
||||||
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;
|
|
||||||
}
|
}
|
Binary file not shown.
Before Width: | Height: | Size: 2.5 KiB |
Binary file not shown.
Before Width: | Height: | Size: 6.9 KiB |
@@ -1,25 +0,0 @@
|
|||||||
<?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>
|
|
Before Width: | Height: | Size: 775 B |
144
static/js/db.js
144
static/js/db.js
@@ -1,144 +0,0 @@
|
|||||||
// 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
|
|
||||||
};
|
|
445
static/js/main.js
Normal file
445
static/js/main.js
Normal file
@@ -0,0 +1,445 @@
|
|||||||
|
let searchTimeout;
|
||||||
|
let lastResults = [];
|
||||||
|
let fachrichtungTimeout;
|
||||||
|
let ortTimeout;
|
||||||
|
|
||||||
|
function createPhoneLink(phone) {
|
||||||
|
if (!phone) return '';
|
||||||
|
|
||||||
|
const clientIP = document.querySelector('meta[name="client-ip"]').content;
|
||||||
|
const allowedIPRanges = document.querySelector('meta[name="allowed-ip-ranges"]').content.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, '');
|
||||||
|
|
||||||
|
// 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) {
|
||||||
|
if (!email) return '';
|
||||||
|
return `<a href="mailto:${email}" class="email-link">${email}</a>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function highlightText(text, searchTerm) {
|
||||||
|
if (!searchTerm || !text) return text;
|
||||||
|
// Escapen von Sonderzeichen im Suchbegriff
|
||||||
|
const escapedSearchTerm = searchTerm.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
||||||
|
// Erstelle einen regulären Ausdruck ohne Wortgrenzen
|
||||||
|
const regex = new RegExp(escapedSearchTerm, 'gi');
|
||||||
|
return text.replace(regex, '<mark>$&</mark>');
|
||||||
|
}
|
||||||
|
|
||||||
|
function createAddressLink(street, plz, city) {
|
||||||
|
if (!street || !plz || !city) return '';
|
||||||
|
const address = `${street}, ${plz} ${city}`;
|
||||||
|
const searchQuery = encodeURIComponent(address);
|
||||||
|
const routeQuery = encodeURIComponent(address);
|
||||||
|
return `<span class="address-text">${address}</span>
|
||||||
|
<a href="https://www.google.com/maps/search/?api=1&query=${searchQuery}"
|
||||||
|
class="address-link" target="_blank" rel="noopener noreferrer">
|
||||||
|
<i class="fa-solid fa-location-dot 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-route route-pin"></i>
|
||||||
|
</a>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function adjustCustomerNumber(number) {
|
||||||
|
return number - 12000;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isIPInSubnet(ip, subnet) {
|
||||||
|
// Teile die IP und das Subnetz in ihre Komponenten
|
||||||
|
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 = document.querySelector('meta[name="client-ip"]').content;
|
||||||
|
const allowedIPRanges = document.querySelector('meta[name="allowed-ip-ranges"]').content.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);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (isAllowed) {
|
||||||
|
const adjustedNumber = adjustCustomerNumber(nummer);
|
||||||
|
return `<a href="medisw:openkkbefe/P${adjustedNumber}?NetGrp=4" class="customer-link">${nummer}</a>`;
|
||||||
|
} else {
|
||||||
|
return nummer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function showCopyFeedback() {
|
||||||
|
const feedback = document.getElementById('shareFeedback');
|
||||||
|
feedback.style.display = 'block';
|
||||||
|
feedback.style.opacity = '1';
|
||||||
|
|
||||||
|
feedback.addEventListener('animationend', () => {
|
||||||
|
feedback.style.display = 'none';
|
||||||
|
}, { once: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
async function copyCustomerLink(customerNumber) {
|
||||||
|
const url = new URL(window.location.href);
|
||||||
|
url.searchParams.set('kundennummer', customerNumber);
|
||||||
|
|
||||||
|
try {
|
||||||
|
await navigator.clipboard.writeText(url.toString());
|
||||||
|
showCopyFeedback();
|
||||||
|
} catch (err) {
|
||||||
|
// Fehlerbehandlung ohne console.log
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateResultCounts() {
|
||||||
|
// Nur Gesamtzahl anzeigen
|
||||||
|
const generalCount = lastResults.length;
|
||||||
|
document.getElementById('resultCount').textContent =
|
||||||
|
generalCount > 0 ? `${generalCount} Treffer gefunden` : '';
|
||||||
|
document.getElementById('resultCount').classList.toggle('visible', generalCount > 0);
|
||||||
|
|
||||||
|
// Export-Button anzeigen/verstecken
|
||||||
|
document.getElementById('exportButton').style.display = generalCount > 0 ? 'inline-block' : 'none';
|
||||||
|
}
|
||||||
|
|
||||||
|
function exportToCSV() {
|
||||||
|
if (!lastResults || lastResults.length === 0) return;
|
||||||
|
|
||||||
|
// CSV-Header definieren
|
||||||
|
const headers = [
|
||||||
|
'Nummer',
|
||||||
|
'Name',
|
||||||
|
'Fachrichtung',
|
||||||
|
'Straße',
|
||||||
|
'PLZ',
|
||||||
|
'Ort',
|
||||||
|
'Telefon',
|
||||||
|
'Mobil',
|
||||||
|
'Handy',
|
||||||
|
'Telefon Firma',
|
||||||
|
'E-Mail',
|
||||||
|
'Kontakt 1',
|
||||||
|
'Kontakt 2',
|
||||||
|
'Kontakt 3',
|
||||||
|
'Tags'
|
||||||
|
];
|
||||||
|
|
||||||
|
// CSV-Daten erstellen
|
||||||
|
const csvRows = [headers];
|
||||||
|
|
||||||
|
lastResults.forEach(customer => {
|
||||||
|
const row = [
|
||||||
|
customer.nummer,
|
||||||
|
customer.name,
|
||||||
|
customer.fachrichtung,
|
||||||
|
customer.strasse,
|
||||||
|
customer.plz,
|
||||||
|
customer.ort,
|
||||||
|
customer.telefon,
|
||||||
|
customer.mobil,
|
||||||
|
customer.handy,
|
||||||
|
customer.tele_firma,
|
||||||
|
customer.email,
|
||||||
|
customer.kontakt1,
|
||||||
|
customer.kontakt2,
|
||||||
|
customer.kontakt3,
|
||||||
|
(customer.tags || []).join(';')
|
||||||
|
].map(value => {
|
||||||
|
// Werte mit Kommas oder Anführungszeichen in Anführungszeichen setzen
|
||||||
|
if (value && (value.includes(',') || value.includes('"') || value.includes('\n'))) {
|
||||||
|
return `"${value.replace(/"/g, '""')}"`;
|
||||||
|
}
|
||||||
|
return value || '';
|
||||||
|
});
|
||||||
|
|
||||||
|
csvRows.push(row);
|
||||||
|
});
|
||||||
|
|
||||||
|
// CSV-String erstellen
|
||||||
|
const csvContent = csvRows.map(row => row.join(',')).join('\n');
|
||||||
|
|
||||||
|
// Blob erstellen und Download starten
|
||||||
|
const blob = new Blob([csvContent], { type: 'text/csv;charset=utf-8;' });
|
||||||
|
const link = document.createElement('a');
|
||||||
|
const url = URL.createObjectURL(blob);
|
||||||
|
|
||||||
|
link.setAttribute('href', url);
|
||||||
|
link.setAttribute('download', `kundensuche_${new Date().toISOString().split('T')[0]}.csv`);
|
||||||
|
link.style.visibility = 'hidden';
|
||||||
|
document.body.appendChild(link);
|
||||||
|
link.click();
|
||||||
|
document.body.removeChild(link);
|
||||||
|
}
|
||||||
|
|
||||||
|
function displayResults(results) {
|
||||||
|
const resultsDiv = document.getElementById('results');
|
||||||
|
const resultCount = document.getElementById('resultCount');
|
||||||
|
const generalSearchTerm = document.getElementById('q').value;
|
||||||
|
const nameSearchTerm = document.getElementById('nameInput').value;
|
||||||
|
const fachrichtungSearchTerm = document.getElementById('fachrichtungInput').value;
|
||||||
|
|
||||||
|
if (!results || results.length === 0) {
|
||||||
|
resultsDiv.innerHTML = '<p>Keine Ergebnisse gefunden.</p>';
|
||||||
|
resultCount.textContent = '0 Ergebnisse';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
resultCount.textContent = `${results.length} Ergebnisse`;
|
||||||
|
lastResults = results;
|
||||||
|
|
||||||
|
const resultsHTML = results.map(customer => {
|
||||||
|
const highlightedName = highlightText(customer.name, nameSearchTerm);
|
||||||
|
const highlightedFachrichtung = highlightText(customer.fachrichtung, fachrichtungSearchTerm);
|
||||||
|
const highlightedGeneral = highlightText(customer.name, generalSearchTerm) ||
|
||||||
|
highlightText(customer.fachrichtung, generalSearchTerm) ||
|
||||||
|
highlightText(customer.ort, generalSearchTerm);
|
||||||
|
|
||||||
|
// Hilfsfunktion zum Erstellen von Feldern nur wenn sie Werte haben
|
||||||
|
const createFieldIfValue = (label, value, formatter = (v) => v) => {
|
||||||
|
if (!value || value === 'N/A' || value === 'n/a' || value === 'N/a' || (typeof value === 'string' && value.trim() === '')) return '';
|
||||||
|
const formattedValue = formatter(value);
|
||||||
|
return `<p class="mb-1"><strong>${label}:</strong> ${formattedValue}</p>`;
|
||||||
|
};
|
||||||
|
|
||||||
|
return `
|
||||||
|
<div class="customer-card">
|
||||||
|
<div class="customer-header">
|
||||||
|
<h3 class="customer-name">${highlightedName || highlightedGeneral}</h3>
|
||||||
|
<div class="customer-actions">
|
||||||
|
<span class="badge ${(customer.tag || 'medisoft') === 'medisoft' ? 'bg-primary' : 'bg-warning text-dark'}">${(customer.tag || 'medisoft').toUpperCase()}</span>
|
||||||
|
<button class="btn btn-sm btn-outline-primary" onclick="copyCustomerLink('${customer.nummer}')">
|
||||||
|
<i class="fas fa-link"></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="customer-details">
|
||||||
|
${createFieldIfValue('Nummer', highlightText(customer.nummer, generalSearchTerm), createCustomerLink)}
|
||||||
|
${createFieldIfValue('Adresse', (customer.strasse && customer.plz && customer.ort) ? true : false,
|
||||||
|
() => createAddressLink(
|
||||||
|
highlightText(customer.strasse, generalSearchTerm),
|
||||||
|
highlightText(customer.plz, generalSearchTerm),
|
||||||
|
highlightText(customer.ort, generalSearchTerm)
|
||||||
|
))}
|
||||||
|
${createFieldIfValue('Telefon', highlightText(customer.telefon, generalSearchTerm), createPhoneLink)}
|
||||||
|
${createFieldIfValue('Mobil', highlightText(customer.mobil, generalSearchTerm), createPhoneLink)}
|
||||||
|
${createFieldIfValue('Handy', highlightText(customer.handy, generalSearchTerm), createPhoneLink)}
|
||||||
|
${createFieldIfValue('Telefon Firma', highlightText(customer.tele_firma, generalSearchTerm), createPhoneLink)}
|
||||||
|
${createFieldIfValue('E-Mail', highlightText(customer.email, generalSearchTerm), createEmailLink)}
|
||||||
|
${createFieldIfValue('Fachrichtung', highlightText(customer.fachrichtung, generalSearchTerm || fachrichtungSearchTerm))}
|
||||||
|
${createFieldIfValue('Kontakt 1', highlightText(customer.kontakt1, generalSearchTerm), createPhoneLink)}
|
||||||
|
${createFieldIfValue('Kontakt 2', highlightText(customer.kontakt2, generalSearchTerm), createPhoneLink)}
|
||||||
|
${createFieldIfValue('Kontakt 3', highlightText(customer.kontakt3, generalSearchTerm), createPhoneLink)}
|
||||||
|
${customer.tags && customer.tags.length > 0 ? `
|
||||||
|
<p class="mb-0"><strong>Tags:</strong>
|
||||||
|
${customer.tags.map(tag => `<span class="badge bg-primary me-1">${tag}</span>`).join('')}
|
||||||
|
</p>
|
||||||
|
` : ''}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
}).join('');
|
||||||
|
|
||||||
|
resultsDiv.innerHTML = resultsHTML;
|
||||||
|
updateResultCounts();
|
||||||
|
}
|
||||||
|
|
||||||
|
function clearInput(inputId) {
|
||||||
|
document.getElementById(inputId).value = '';
|
||||||
|
searchCustomers();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function searchCustomers() {
|
||||||
|
const loading = document.getElementById('loading');
|
||||||
|
const results = document.getElementById('results');
|
||||||
|
const generalSearch = document.getElementById('q').value;
|
||||||
|
const nameSearch = document.getElementById('nameInput').value;
|
||||||
|
const ortSearch = document.getElementById('ortInput').value;
|
||||||
|
const nummerSearch = document.getElementById('nummerInput').value;
|
||||||
|
const plzSearch = document.getElementById('plzInput').value;
|
||||||
|
const fachrichtungSearch = document.getElementById('fachrichtungInput').value;
|
||||||
|
const tagFilter = document.getElementById('tagFilter').value;
|
||||||
|
|
||||||
|
// Zeige Ladeanimation
|
||||||
|
loading.style.display = 'block';
|
||||||
|
results.innerHTML = '';
|
||||||
|
|
||||||
|
// Setze Timeout zurück
|
||||||
|
clearTimeout(searchTimeout);
|
||||||
|
|
||||||
|
// Verzögerte Suche
|
||||||
|
searchTimeout = setTimeout(async () => {
|
||||||
|
try {
|
||||||
|
// Baue die Suchanfrage
|
||||||
|
const params = new URLSearchParams();
|
||||||
|
if (generalSearch) params.append('q', generalSearch);
|
||||||
|
if (nameSearch) params.append('name', nameSearch);
|
||||||
|
if (ortSearch) params.append('ort', ortSearch);
|
||||||
|
if (nummerSearch) params.append('nummer', nummerSearch);
|
||||||
|
if (plzSearch) params.append('plz', plzSearch);
|
||||||
|
if (fachrichtungSearch) params.append('fachrichtung', fachrichtungSearch);
|
||||||
|
if (tagFilter) params.append('tag', tagFilter);
|
||||||
|
|
||||||
|
const response = await fetch('/search?' + params.toString());
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error('Netzwerkantwort war nicht ok');
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = await response.json();
|
||||||
|
displayResults(data);
|
||||||
|
} catch (error) {
|
||||||
|
results.innerHTML = '<p>Ein Fehler ist aufgetreten. Bitte versuchen Sie es später erneut.</p>';
|
||||||
|
} finally {
|
||||||
|
loading.style.display = 'none';
|
||||||
|
}
|
||||||
|
}, 300);
|
||||||
|
}
|
||||||
|
|
||||||
|
function setupFachrichtungAutocomplete() {
|
||||||
|
const fachrichtungInput = document.getElementById('fachrichtungInput');
|
||||||
|
const autocompleteList = document.createElement('div');
|
||||||
|
autocompleteList.className = 'autocomplete-items';
|
||||||
|
fachrichtungInput.parentNode.appendChild(autocompleteList);
|
||||||
|
|
||||||
|
fachrichtungInput.addEventListener('input', function() {
|
||||||
|
clearTimeout(fachrichtungTimeout);
|
||||||
|
const searchTerm = this.value;
|
||||||
|
|
||||||
|
if (searchTerm.length < 2) {
|
||||||
|
autocompleteList.style.display = 'none';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
fachrichtungTimeout = setTimeout(() => {
|
||||||
|
fetch(`/api/fachrichtungen?q=${encodeURIComponent(searchTerm)}`)
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
autocompleteList.innerHTML = '';
|
||||||
|
if (data.length > 0) {
|
||||||
|
data.forEach(item => {
|
||||||
|
const div = document.createElement('div');
|
||||||
|
div.textContent = item;
|
||||||
|
div.addEventListener('click', () => {
|
||||||
|
fachrichtungInput.value = item;
|
||||||
|
autocompleteList.style.display = 'none';
|
||||||
|
searchCustomers();
|
||||||
|
});
|
||||||
|
autocompleteList.appendChild(div);
|
||||||
|
});
|
||||||
|
autocompleteList.style.display = 'block';
|
||||||
|
} else {
|
||||||
|
autocompleteList.style.display = 'none';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, 300);
|
||||||
|
});
|
||||||
|
|
||||||
|
document.addEventListener('click', function(e) {
|
||||||
|
if (!fachrichtungInput.contains(e.target) && !autocompleteList.contains(e.target)) {
|
||||||
|
autocompleteList.style.display = 'none';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function setupOrtAutocomplete() {
|
||||||
|
const ortInput = document.getElementById('ortInput');
|
||||||
|
const autocompleteList = document.createElement('div');
|
||||||
|
autocompleteList.className = 'autocomplete-items';
|
||||||
|
ortInput.parentNode.appendChild(autocompleteList);
|
||||||
|
|
||||||
|
ortInput.addEventListener('input', function() {
|
||||||
|
clearTimeout(ortTimeout);
|
||||||
|
const searchTerm = this.value;
|
||||||
|
|
||||||
|
if (searchTerm.length < 2) {
|
||||||
|
autocompleteList.style.display = 'none';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ortTimeout = setTimeout(() => {
|
||||||
|
fetch(`/api/orte?q=${encodeURIComponent(searchTerm)}`)
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
autocompleteList.innerHTML = '';
|
||||||
|
if (data.length > 0) {
|
||||||
|
data.forEach(item => {
|
||||||
|
const div = document.createElement('div');
|
||||||
|
div.textContent = item;
|
||||||
|
div.addEventListener('click', () => {
|
||||||
|
ortInput.value = item;
|
||||||
|
autocompleteList.style.display = 'none';
|
||||||
|
searchCustomers();
|
||||||
|
});
|
||||||
|
autocompleteList.appendChild(div);
|
||||||
|
});
|
||||||
|
autocompleteList.style.display = 'block';
|
||||||
|
} else {
|
||||||
|
autocompleteList.style.display = 'none';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, 300);
|
||||||
|
});
|
||||||
|
|
||||||
|
document.addEventListener('click', function(e) {
|
||||||
|
if (!ortInput.contains(e.target) && !autocompleteList.contains(e.target)) {
|
||||||
|
autocompleteList.style.display = 'none';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Event-Listener für die URL-Parameter und Autocomplete-Setup
|
||||||
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
|
const urlParams = new URLSearchParams(window.location.search);
|
||||||
|
const kundennummer = urlParams.get('kundennummer');
|
||||||
|
const name = urlParams.get('name');
|
||||||
|
const ort = urlParams.get('ort');
|
||||||
|
const plz = urlParams.get('plz');
|
||||||
|
|
||||||
|
if (kundennummer) {
|
||||||
|
document.getElementById('nummerInput').value = kundennummer;
|
||||||
|
searchCustomers();
|
||||||
|
}
|
||||||
|
if (name) {
|
||||||
|
document.getElementById('nameInput').value = name;
|
||||||
|
searchCustomers();
|
||||||
|
}
|
||||||
|
if (ort) {
|
||||||
|
document.getElementById('ortInput').value = ort;
|
||||||
|
searchCustomers();
|
||||||
|
}
|
||||||
|
if (plz) {
|
||||||
|
document.getElementById('plzInput').value = plz;
|
||||||
|
searchCustomers();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Setup Autocomplete
|
||||||
|
setupFachrichtungAutocomplete();
|
||||||
|
setupOrtAutocomplete();
|
||||||
|
});
|
@@ -1,28 +0,0 @@
|
|||||||
{
|
|
||||||
"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
75
static/sw.js
@@ -1,75 +0,0 @@
|
|||||||
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');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
})
|
|
||||||
);
|
|
||||||
});
|
|
@@ -3,18 +3,13 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<meta name="client-ip" content="{{ request.headers.get('X-Forwarded-For', request.remote_addr) }}">
|
||||||
|
<meta name="allowed-ip-ranges" content="{{ allowed_ip_ranges }}">
|
||||||
<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">
|
||||||
<link href="{{ url_for('static', filename='css/styles.css') }}" rel="stylesheet">
|
<link href="{{ url_for('static', filename='css/styles.css') }}" rel="stylesheet">
|
||||||
<script src="{{ url_for('static', filename='js/db.js') }}"></script>
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="main-content">
|
<div class="main-content">
|
||||||
@@ -31,16 +26,6 @@
|
|||||||
<i class="fas fa-times reset-icon" onclick="clearInput('q')"></i>
|
<i class="fas fa-times reset-icon" onclick="clearInput('q')"></i>
|
||||||
<i class="fas fa-search search-icon"></i>
|
<i class="fas fa-search search-icon"></i>
|
||||||
</div>
|
</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">
|
||||||
@@ -83,10 +68,23 @@
|
|||||||
<i class="fas fa-search search-icon"></i>
|
<i class="fas fa-search search-icon"></i>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="search-field">
|
||||||
|
<div class="input-group">
|
||||||
|
<select id="tagFilter" class="form-select" onchange="searchCustomers()">
|
||||||
|
<option value="medisoft" selected>MEDISOFT</option>
|
||||||
|
<option value="mediconsult">MEDICONSULT</option>
|
||||||
|
<option value="all">Alle</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="result-counts">
|
<div class="result-counts">
|
||||||
<span id="resultCount" class="result-count"></span>
|
<span id="resultCount" class="result-count"></span>
|
||||||
|
<button id="exportButton" class="btn btn-sm btn-outline-success ms-2" onclick="exportToCSV()" style="display: none;">
|
||||||
|
<i class="fas fa-file-csv"></i> CSV Export
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="loading" class="loading">
|
<div id="loading" class="loading">
|
||||||
@@ -107,326 +105,10 @@
|
|||||||
<footer class="footer">
|
<footer class="footer">
|
||||||
<div class="footer-content">
|
<div class="footer-content">
|
||||||
Proudly 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.6</div>
|
<div style="font-size: 0.8em;">Version: {{ version }}</div>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
<div id="syncStatus" class="sync-status" style="display: none;">
|
<script src="{{ url_for('static', filename='js/main.js') }}"></script>
|
||||||
<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>
|
|
||||||
// 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 lastResults = [];
|
|
||||||
|
|
||||||
function createPhoneLink(phone) {
|
|
||||||
if (!phone) return 'N/A';
|
|
||||||
|
|
||||||
const clientIP = '{{ request.headers.get("X-Forwarded-For", request.remote_addr) }}';
|
|
||||||
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) {
|
|
||||||
if (!email) return 'N/A';
|
|
||||||
return `<a href="mailto:${email}" class="email-link">${email}</a>`;
|
|
||||||
}
|
|
||||||
|
|
||||||
function highlightText(text, searchTerm) {
|
|
||||||
if (!searchTerm) return text;
|
|
||||||
const regex = new RegExp(`(${searchTerm})`, 'gi');
|
|
||||||
return text.replace(regex, '<mark>$1</mark>');
|
|
||||||
}
|
|
||||||
|
|
||||||
function createAddressLink(street, plz, city) {
|
|
||||||
if (!street || !plz || !city) return 'N/A';
|
|
||||||
const address = `${street}, ${plz} ${city}`;
|
|
||||||
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>
|
|
||||||
<a href="https://www.google.com/maps/search/?api=1&query=${searchQuery}"
|
|
||||||
class="address-link" target="_blank" rel="noopener noreferrer">
|
|
||||||
<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>`;
|
|
||||||
}
|
|
||||||
|
|
||||||
function adjustCustomerNumber(number) {
|
|
||||||
return number - 12000;
|
|
||||||
}
|
|
||||||
|
|
||||||
function isIPInSubnet(ip, subnet) {
|
|
||||||
// Teile die IP und das Subnetz in ihre Komponenten
|
|
||||||
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() {
|
|
||||||
const feedback = document.getElementById('shareFeedback');
|
|
||||||
feedback.style.display = 'block';
|
|
||||||
feedback.style.opacity = '1';
|
|
||||||
|
|
||||||
feedback.addEventListener('animationend', () => {
|
|
||||||
feedback.style.display = 'none';
|
|
||||||
}, { once: true });
|
|
||||||
}
|
|
||||||
|
|
||||||
async function copyCustomerLink(customerNumber) {
|
|
||||||
const url = new URL(window.location.href);
|
|
||||||
url.searchParams.set('kundennummer', customerNumber);
|
|
||||||
|
|
||||||
try {
|
|
||||||
await navigator.clipboard.writeText(url.toString());
|
|
||||||
showCopyFeedback();
|
|
||||||
} catch (err) {
|
|
||||||
// Fehlerbehandlung ohne console.log
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateResultCounts() {
|
|
||||||
// Nur Gesamtzahl anzeigen
|
|
||||||
const generalCount = lastResults.length;
|
|
||||||
document.getElementById('resultCount').textContent =
|
|
||||||
generalCount > 0 ? `${generalCount} Treffer gefunden` : '';
|
|
||||||
document.getElementById('resultCount').classList.toggle('visible', generalCount > 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
function displayResults(results) {
|
|
||||||
const resultsDiv = document.getElementById('results');
|
|
||||||
resultsDiv.innerHTML = '';
|
|
||||||
|
|
||||||
if (results.length === 0) {
|
|
||||||
resultsDiv.innerHTML = '<p>Keine Ergebnisse gefunden.</p>';
|
|
||||||
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 => {
|
|
||||||
const card = document.createElement('div');
|
|
||||||
card.className = 'customer-card';
|
|
||||||
card.innerHTML = `
|
|
||||||
<div class="customer-info">
|
|
||||||
<h5 class="mb-1">${highlightText(customer.name, searchTerms.general || searchTerms.name)}</h5>
|
|
||||||
<p class="mb-1 customer-number">${createCustomerLink(customer.nummer)}</p>
|
|
||||||
<p class="mb-1">${createAddressLink(
|
|
||||||
customer.strasse,
|
|
||||||
highlightText(customer.plz, searchTerms.general || searchTerms.plz),
|
|
||||||
highlightText(customer.ort, searchTerms.general || searchTerms.ort)
|
|
||||||
)}</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 class="card-actions">
|
|
||||||
<button class="share-button" onclick="copyCustomerLink('${customer.nummer}')">
|
|
||||||
<i class="fas fa-share-alt"></i> Teilen
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
`;
|
|
||||||
resultsDiv.appendChild(card);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async function searchCustomers() {
|
|
||||||
const searchParams = {
|
|
||||||
q: 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,
|
|
||||||
operator: document.querySelector('input[name="searchOperator"]:checked').value
|
|
||||||
};
|
|
||||||
|
|
||||||
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
|
|
||||||
const searchInputs = [
|
|
||||||
document.getElementById('q'),
|
|
||||||
document.getElementById('nameInput'),
|
|
||||||
document.getElementById('ortInput'),
|
|
||||||
document.getElementById('nummerInput'),
|
|
||||||
document.getElementById('plzInput'),
|
|
||||||
document.getElementById('fachrichtungInput')
|
|
||||||
];
|
|
||||||
|
|
||||||
const resetIcons = [
|
|
||||||
document.querySelector('.reset-icon[onclick="clearInput(\'q\')"]'),
|
|
||||||
document.querySelector('.reset-icon[onclick="clearInput(\'nameInput\')"]'),
|
|
||||||
document.querySelector('.reset-icon[onclick="clearInput(\'ortInput\')"]'),
|
|
||||||
document.querySelector('.reset-icon[onclick="clearInput(\'nummerInput\')"]'),
|
|
||||||
document.querySelector('.reset-icon[onclick="clearInput(\'plzInput\')"]'),
|
|
||||||
document.querySelector('.reset-icon[onclick="clearInput(\'fachrichtungInput\')"]')
|
|
||||||
];
|
|
||||||
|
|
||||||
searchInputs.forEach((input, index) => {
|
|
||||||
input.addEventListener('input', function() {
|
|
||||||
clearTimeout(searchTimeout);
|
|
||||||
searchTimeout = setTimeout(searchCustomers, 300);
|
|
||||||
|
|
||||||
// Reset-Icon anzeigen/verstecken
|
|
||||||
resetIcons[index].classList.toggle('visible', this.value.length > 0);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Reset-Funktionalität
|
|
||||||
resetIcons[index].addEventListener('click', function() {
|
|
||||||
searchInputs[index].value = '';
|
|
||||||
searchCustomers();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// URL-Parameter beim Laden der Seite prüfen
|
|
||||||
window.addEventListener('load', function() {
|
|
||||||
const urlParams = new URLSearchParams(window.location.search);
|
|
||||||
const name = urlParams.get('name');
|
|
||||||
const ort = urlParams.get('ort');
|
|
||||||
const kundennummer = urlParams.get('kundennummer');
|
|
||||||
const plz = urlParams.get('plz');
|
|
||||||
|
|
||||||
if (name) document.getElementById('nameInput').value = name;
|
|
||||||
if (ort) document.getElementById('ortInput').value = ort;
|
|
||||||
if (kundennummer) document.getElementById('nummerInput').value = kundennummer;
|
|
||||||
if (plz) document.getElementById('plzInput').value = plz;
|
|
||||||
|
|
||||||
if (name || ort || kundennummer || plz) {
|
|
||||||
searchCustomers();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
@@ -1,58 +0,0 @@
|
|||||||
<!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