Compare commits
27 Commits
Author | SHA1 | Date | |
---|---|---|---|
33ecb79e0b | |||
00bb197620 | |||
8e7d3da07f | |||
35e0d0a783 | |||
40196fa28f | |||
7b5e90e3bd | |||
3c48988e88 | |||
869acdcb18 | |||
91af1dfca0 | |||
c271bc1f60 | |||
9c04bb973e | |||
6d7298548b | |||
42a11abe61 | |||
3c6d2f7c45 | |||
d143d6c7b6 | |||
e6638b737d | |||
1f493e0a37 | |||
469ad0ce05 | |||
8a8c13e407 | |||
18974eb69b | |||
9e406ed7a3 | |||
8b82a44ad8 | |||
528baff7b5 | |||
e105dc4663 | |||
3f69ba6198 | |||
7e812eb835 | |||
ece7f984f7 |
16
.env.example
Normal file
16
.env.example
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
# Flask-Konfiguration
|
||||||
|
FLASK_APP=app.py
|
||||||
|
FLASK_ENV=development
|
||||||
|
SECRET_KEY=your-secret-key-here
|
||||||
|
|
||||||
|
# Datenbank-Konfiguration
|
||||||
|
DATABASE_URL=sqlite:///customers.db
|
||||||
|
|
||||||
|
# Authentifizierung
|
||||||
|
STATIC_PASSWORD=your-static-password-here
|
||||||
|
|
||||||
|
# IP-Bereiche für direkten Zugriff (ohne Login)
|
||||||
|
ALLOWED_IP_RANGES=192.168.0.0/24,192.168.177.0/24,213.178.68.218/29
|
||||||
|
|
||||||
|
# Logging-Konfiguration
|
||||||
|
LOG_LEVEL=INFO
|
54
CHANGELOG.md
54
CHANGELOG.md
@@ -5,37 +5,39 @@ 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/).
|
||||||
|
|
||||||
## [1.0.6] - 2024-03-17
|
## [v1.2.0] - 2024-03-18
|
||||||
### Geändert
|
|
||||||
- Verbesserte Suchfunktion: Kombinierte Suche über mehrere Felder möglich
|
|
||||||
- Dokumentation: Beispiele für kombinierte Suche hinzugefügt
|
|
||||||
|
|
||||||
## [1.0.5] - 2024-03-17
|
|
||||||
### Geändert
|
### Geändert
|
||||||
- Verbesserte Suchfunktion: Ergebnisliste wird gelöscht, wenn alle Suchfelder leer sind
|
- IP-Subnetz-Prüfung korrigiert (CIDR-Notation wird jetzt korrekt ausgewertet)
|
||||||
|
- Debug-Logging für IP-Adressen hinzugefügt
|
||||||
|
- Beispiel-Umgebungsvariablen (.env.example) hinzugefügt
|
||||||
|
|
||||||
## [1.0.4] - 2024-03-17
|
### Hinzugefügt
|
||||||
### Geändert
|
- IP-basierte Zugriffssteuerung für medisoftware-Links
|
||||||
- Verbesserte Adressanzeige: Location-Icon neben der Adresse
|
- IP-basierte Zugriffssteuerung für Telefonnummern-Links
|
||||||
- Entfernung des Google Maps Links aus dem Adresstext
|
- Google Maps Integration für Adressen
|
||||||
|
- Version im Footer angezeigt
|
||||||
|
|
||||||
## [1.0.3] - 2024-03-17
|
### Verbessert
|
||||||
### Geändert
|
- Verbesserte Fehlerbehandlung bei der IP-Überprüfung
|
||||||
- Hervorhebung der Suchbegriffe in den Ergebnissen
|
- Bessere Dokumentation der Konfigurationsmöglichkeiten
|
||||||
|
|
||||||
|
## [v1.1.0] - 2024-03-17
|
||||||
|
|
||||||
|
### Hinzugefügt
|
||||||
|
- Benutzer-Login für nicht-autorisierte IPs
|
||||||
|
- Verbesserte Darstellung der Telefonnummern
|
||||||
|
- Responsive Design für mobile Geräte
|
||||||
|
|
||||||
|
### Verbessert
|
||||||
|
- Optimierte Suchfunktion
|
||||||
- Verbesserte Benutzeroberfläche
|
- Verbesserte Benutzeroberfläche
|
||||||
|
|
||||||
## [1.0.2] - 2024-03-17
|
## [v1.0.0] - 2024-03-17
|
||||||
### Geändert
|
|
||||||
- Entfernung der Wetterinformationen
|
|
||||||
- Optimierung der Suchfunktion
|
|
||||||
|
|
||||||
## [1.0.1] - 2024-03-17
|
|
||||||
### Hinzugefügt
|
### Hinzugefügt
|
||||||
- Wetterinformationen für Kundensitz
|
- Erste Version mit grundlegenden Suchfunktionen
|
||||||
- Caching für Wetterdaten
|
- Echtzeit-Suche über Kundendaten
|
||||||
|
- Hervorhebung von Suchbegriffen in den Ergebnissen
|
||||||
## [1.0.0] - 2024-03-17
|
- Klickbare Links für Telefonnummern, E-Mail-Adressen und Adressen
|
||||||
### Hinzugefügt
|
- Docker-Container für einfache Installation und Deployment
|
||||||
- Erste Version der Kundensuche
|
|
||||||
- Grundlegende Suchfunktionen
|
|
||||||
- Responsive Design
|
|
63
README.md
63
README.md
@@ -1,27 +1,15 @@
|
|||||||
# medisoftware Kundensuche
|
# medisoftware Kundensuche
|
||||||
|
|
||||||
Eine webbasierte Kundensuche für medisoftware mit erweiterten Suchfunktionen.
|
Eine einfache Webanwendung zur Suche nach medisoftware Kunden mit IP-basierter Zugriffssteuerung.
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
- Schnelle und präzise Kundensuche
|
- Kundensuche nach verschiedenen Kriterien (Name, Ort, Kundennummer, etc.)
|
||||||
- Mehrere Suchfelder für gezielte Suche:
|
- Direkte Links zu Kundendaten in medisoftware (für autorisierte IPs)
|
||||||
- Name (Vor- und Nachname)
|
- Telefonnummern-Links für autorisierte IPs
|
||||||
- Ort
|
- Adress-Links mit Google Maps Integration
|
||||||
- Kundennummer
|
- IP-basierte Zugriffssteuerung
|
||||||
- Fachrichtung
|
- Responsive Design
|
||||||
- Telefon
|
|
||||||
- Allgemeine Suche über alle Felder
|
|
||||||
- Kombinierte Suche über mehrere Felder
|
|
||||||
- Hervorhebung der Suchbegriffe in den Ergebnissen
|
|
||||||
- Direkte Links zu:
|
|
||||||
- medisoftware Kundenkartei (Kundennummer)
|
|
||||||
- Google Maps (Adresse)
|
|
||||||
- Telefon (Klick zum Anrufen)
|
|
||||||
- E-Mail (Klick zum Mailen)
|
|
||||||
- Responsive Design für alle Geräte
|
|
||||||
- Automatische Aktualisierung der Ergebnisse
|
|
||||||
- Leere Ergebnisliste bei leeren Suchfeldern
|
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
@@ -31,20 +19,39 @@ git clone https://gitea.elpatron.me/elpatron/medi-customers.git
|
|||||||
cd medi-customers
|
cd medi-customers
|
||||||
```
|
```
|
||||||
|
|
||||||
2. Docker Container starten:
|
2. Umgebungsvariablen einrichten:
|
||||||
|
```bash
|
||||||
|
cp .env.example .env
|
||||||
|
# Bearbeiten Sie die .env-Datei mit Ihren Einstellungen
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Docker Container starten:
|
||||||
```bash
|
```bash
|
||||||
docker-compose up -d
|
docker-compose up -d
|
||||||
```
|
```
|
||||||
|
|
||||||
3. Die Anwendung ist unter `http://localhost:5001` erreichbar.
|
## Konfiguration
|
||||||
|
|
||||||
## Entwicklung
|
Die Anwendung kann über folgende Umgebungsvariablen konfiguriert werden:
|
||||||
|
|
||||||
- Python 3.11
|
- `FLASK_APP`: Die Hauptanwendungsdatei (Standard: app.py)
|
||||||
- Flask
|
- `FLASK_ENV`: Die Flask-Umgebung (development/production)
|
||||||
- Docker
|
- `SECRET_KEY`: Der geheime Schlüssel für Flask-Sessions
|
||||||
- Bootstrap 5
|
- `DATABASE_URL`: Die URL zur SQLite-Datenbank
|
||||||
- Font Awesome
|
- `STATIC_PASSWORD`: Das Passwort für die Login-Seite
|
||||||
|
- `ALLOWED_IP_RANGES`: Komma-getrennte Liste von IP-Bereichen, die direkten Zugriff haben
|
||||||
|
- `LOG_LEVEL`: Das Logging-Level (INFO/DEBUG)
|
||||||
|
|
||||||
|
## IP-Bereiche
|
||||||
|
|
||||||
|
Die Anwendung unterstützt CIDR-Notation für IP-Bereiche. Beispiele:
|
||||||
|
- Einzelne IP: 192.168.1.1/32
|
||||||
|
- Subnetz: 192.168.1.0/24
|
||||||
|
- Größeres Netzwerk: 10.0.0.0/8
|
||||||
|
|
||||||
|
## Version
|
||||||
|
|
||||||
|
Aktuelle Version: v1.2.0
|
||||||
|
|
||||||
## Lizenz
|
## Lizenz
|
||||||
|
|
||||||
@@ -96,4 +103,4 @@ curl "http://localhost:5001/search?fachrichtung=Zahnarzt&ort=Berlin&name=Schmidt
|
|||||||
|
|
||||||
## Version
|
## Version
|
||||||
|
|
||||||
Aktuelle Version: [1.0.5](CHANGELOG.md#105---2024-03-17)
|
Aktuelle Version: [v1.2.0](CHANGELOG.md#v120---2024-03-17)
|
263
app.py
263
app.py
@@ -1,4 +1,4 @@
|
|||||||
from flask import Flask, render_template, request, jsonify, url_for
|
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
|
||||||
@@ -7,13 +7,18 @@ from datetime import datetime, timedelta
|
|||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
import requests
|
import requests
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
import ipaddress
|
||||||
|
import csv
|
||||||
|
import sqlite3
|
||||||
|
from functools import wraps
|
||||||
|
|
||||||
app = Flask(__name__, static_folder='static')
|
app = Flask(__name__, static_folder='static')
|
||||||
logging.basicConfig(level=logging.DEBUG)
|
app.secret_key = os.getenv('SECRET_KEY', 'default-secret-key')
|
||||||
|
logging.basicConfig(level=logging.INFO)
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
# Version der Anwendung
|
# Version der Anwendung
|
||||||
VERSION = "1.0.6"
|
VERSION = "1.2.1"
|
||||||
|
|
||||||
# Pfad zur CSV-Datei
|
# Pfad zur CSV-Datei
|
||||||
CSV_FILE = "data/customers.csv"
|
CSV_FILE = "data/customers.csv"
|
||||||
@@ -21,6 +26,126 @@ CSV_FILE = "data/customers.csv"
|
|||||||
# Lade Umgebungsvariablen
|
# Lade Umgebungsvariablen
|
||||||
load_dotenv()
|
load_dotenv()
|
||||||
|
|
||||||
|
# Statisches Passwort aus der .env Datei
|
||||||
|
STATIC_PASSWORD = os.getenv('LOGIN_PASSWORD', 'default-password')
|
||||||
|
ALLOWED_IP_RANGES = os.getenv('ALLOWED_IP_RANGES', '').split(',')
|
||||||
|
|
||||||
|
def init_db():
|
||||||
|
"""Initialisiert die SQLite-Datenbank und erstellt die notwendigen Tabellen."""
|
||||||
|
conn = sqlite3.connect('customers.db')
|
||||||
|
c = conn.cursor()
|
||||||
|
|
||||||
|
# Erstelle die Kunden-Tabelle
|
||||||
|
c.execute('''
|
||||||
|
CREATE TABLE IF NOT EXISTS customers (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
nummer TEXT,
|
||||||
|
name TEXT,
|
||||||
|
strasse TEXT,
|
||||||
|
plz TEXT,
|
||||||
|
ort TEXT,
|
||||||
|
telefon TEXT,
|
||||||
|
mobil TEXT,
|
||||||
|
email TEXT,
|
||||||
|
bemerkung TEXT
|
||||||
|
)
|
||||||
|
''')
|
||||||
|
|
||||||
|
conn.commit()
|
||||||
|
conn.close()
|
||||||
|
|
||||||
|
def import_csv():
|
||||||
|
"""Importiert die Daten aus der CSV-Datei in die SQLite-Datenbank."""
|
||||||
|
conn = sqlite3.connect('customers.db')
|
||||||
|
c = conn.cursor()
|
||||||
|
|
||||||
|
# Lösche bestehende Daten
|
||||||
|
c.execute('DELETE FROM customers')
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Lese die CSV-Datei mit pandas
|
||||||
|
df = pd.read_csv('data/customers.csv', sep=',', encoding='utf-8', quotechar='"')
|
||||||
|
|
||||||
|
# Entferne Anführungszeichen aus den Spaltennamen
|
||||||
|
df.columns = df.columns.str.strip('"')
|
||||||
|
|
||||||
|
# Entferne Anführungszeichen aus den Werten
|
||||||
|
for col in df.columns:
|
||||||
|
if df[col].dtype == 'object':
|
||||||
|
df[col] = df[col].str.strip('"')
|
||||||
|
|
||||||
|
# Kombiniere Vorname und Nachname
|
||||||
|
df['name'] = df['Vorname'] + ' ' + df['Nachname']
|
||||||
|
|
||||||
|
# Importiere die Daten
|
||||||
|
for _, row in df.iterrows():
|
||||||
|
c.execute('''
|
||||||
|
INSERT INTO customers (nummer, name, strasse, plz, ort, telefon, mobil, email, bemerkung)
|
||||||
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||||
|
''', (
|
||||||
|
row['Nummer'],
|
||||||
|
row['name'],
|
||||||
|
row['Strasse'],
|
||||||
|
row['PLZ'],
|
||||||
|
row['Ort'],
|
||||||
|
row['Tel'],
|
||||||
|
row['Handy'],
|
||||||
|
row['mail'],
|
||||||
|
f"Fachrichtung: {row['Fachrichtung']}"
|
||||||
|
))
|
||||||
|
|
||||||
|
conn.commit()
|
||||||
|
logger.info('CSV-Daten erfolgreich in die Datenbank importiert')
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f'Fehler beim Import der CSV-Daten: {str(e)}')
|
||||||
|
raise
|
||||||
|
finally:
|
||||||
|
conn.close()
|
||||||
|
|
||||||
|
def search_customers(search_params):
|
||||||
|
"""Sucht Kunden in der Datenbank basierend auf den Suchparametern."""
|
||||||
|
conn = sqlite3.connect('customers.db')
|
||||||
|
c = conn.cursor()
|
||||||
|
|
||||||
|
# Erstelle die WHERE-Bedingungen basierend auf den Suchparametern
|
||||||
|
conditions = []
|
||||||
|
params = []
|
||||||
|
|
||||||
|
if search_params.get('name'):
|
||||||
|
conditions.append('name LIKE ?')
|
||||||
|
params.append(f'%{search_params["name"]}%')
|
||||||
|
|
||||||
|
if search_params.get('ort'):
|
||||||
|
conditions.append('ort LIKE ?')
|
||||||
|
params.append(f'%{search_params["ort"]}%')
|
||||||
|
|
||||||
|
if search_params.get('nummer'):
|
||||||
|
conditions.append('nummer LIKE ?')
|
||||||
|
params.append(f'%{search_params["nummer"]}%')
|
||||||
|
|
||||||
|
if search_params.get('plz'):
|
||||||
|
conditions.append('plz LIKE ?')
|
||||||
|
params.append(f'%{search_params["plz"]}%')
|
||||||
|
|
||||||
|
# Erstelle die SQL-Abfrage
|
||||||
|
sql = 'SELECT * FROM customers'
|
||||||
|
if conditions:
|
||||||
|
sql += ' WHERE ' + ' AND '.join(conditions)
|
||||||
|
|
||||||
|
# Führe die Abfrage aus
|
||||||
|
c.execute(sql, params)
|
||||||
|
results = c.fetchall()
|
||||||
|
|
||||||
|
# Konvertiere die Ergebnisse in ein Dictionary
|
||||||
|
columns = ['id', 'nummer', 'name', 'strasse', 'plz', 'ort', 'telefon', 'mobil', 'email', 'bemerkung']
|
||||||
|
customers = []
|
||||||
|
for row in results:
|
||||||
|
customer = dict(zip(columns, row))
|
||||||
|
customers.append(customer)
|
||||||
|
|
||||||
|
conn.close()
|
||||||
|
return customers
|
||||||
|
|
||||||
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})
|
||||||
@@ -48,75 +173,91 @@ def load_data():
|
|||||||
logger.error(f"Fehler beim Laden der CSV-Datei: {str(e)}")
|
logger.error(f"Fehler beim Laden der CSV-Datei: {str(e)}")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@app.route('/login', methods=['GET', 'POST'])
|
||||||
|
def login():
|
||||||
|
# Versuche, die tatsächliche Client-IP aus dem X-Forwarded-For-Header zu erhalten
|
||||||
|
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}")
|
||||||
|
logger.info(f"Erlaubte IP-Bereiche: {allowed_ip_ranges}")
|
||||||
|
logger.info(f"Session Status: {session}")
|
||||||
|
|
||||||
|
# Überprüfen, ob die IP-Adresse in einem der erlaubten Subnetze liegt
|
||||||
|
client_ip_obj = ipaddress.ip_address(client_ip)
|
||||||
|
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.permanent = True # Session bleibt bestehen
|
||||||
|
return redirect(url_for('index'))
|
||||||
|
except ValueError:
|
||||||
|
logger.error(f"Ungültiges Netzwerkformat: {ip_range}")
|
||||||
|
|
||||||
|
if request.method == 'POST':
|
||||||
|
password = request.form.get('password')
|
||||||
|
logger.info(f"Login-Versuch mit Passwort: {'*' * len(password) if password else 'None'}")
|
||||||
|
if password == STATIC_PASSWORD:
|
||||||
|
session['logged_in'] = True
|
||||||
|
session.permanent = True # Session bleibt bestehen
|
||||||
|
logger.info("Login erfolgreich, Session gesetzt")
|
||||||
|
return redirect(url_for('index'))
|
||||||
|
else:
|
||||||
|
logger.warning("Falsches Passwort eingegeben")
|
||||||
|
return render_template('login.html', error="Falsches Passwort")
|
||||||
|
|
||||||
|
logger.info("Zeige Login-Seite")
|
||||||
|
return render_template('login.html')
|
||||||
|
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
def index():
|
def index():
|
||||||
return render_template('index.html')
|
logger.info(f"Index-Route aufgerufen. Session Status: {session}")
|
||||||
|
if not session.get('logged_in'):
|
||||||
|
logger.info("Benutzer nicht eingeloggt, Weiterleitung zum 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)
|
||||||
|
logger.info(f"Client-IP: {client_ip}")
|
||||||
|
logger.info(f"Erlaubte IP-Bereiche: {allowed_ip_ranges}")
|
||||||
|
return render_template('index.html', allowed_ip_ranges=allowed_ip_ranges)
|
||||||
|
|
||||||
@app.route('/search')
|
@app.route('/search')
|
||||||
def search():
|
def search():
|
||||||
try:
|
try:
|
||||||
# CSV-Datei laden
|
# Hole die Suchparameter aus der Anfrage
|
||||||
df = load_data()
|
search_params = {
|
||||||
if df is None:
|
'name': request.args.get('name', ''),
|
||||||
return jsonify({"error": "Datenbank konnte nicht geladen werden"}), 500
|
'ort': request.args.get('ort', ''),
|
||||||
|
'nummer': request.args.get('nummer', ''),
|
||||||
# Suchparameter aus der URL holen
|
'plz': request.args.get('plz', '')
|
||||||
name = request.args.get('name', '').strip()
|
}
|
||||||
ort = request.args.get('ort', '').strip()
|
|
||||||
kundennummer = request.args.get('kundennummer', '').strip()
|
|
||||||
fachrichtung = request.args.get('fachrichtung', '').strip()
|
|
||||||
telefon = request.args.get('telefon', '').strip()
|
|
||||||
query = request.args.get('q', '').strip()
|
|
||||||
|
|
||||||
# Initialisiere die Maske für die Filterung
|
|
||||||
mask = pd.Series(True, index=df.index)
|
|
||||||
|
|
||||||
# Wenn eine allgemeine Suche angegeben ist
|
# Führe die Suche in der Datenbank durch
|
||||||
if query:
|
results = search_customers(search_params)
|
||||||
query_mask = (
|
|
||||||
df['Vorname'].str.contains(query, case=False, na=False) |
|
|
||||||
df['Nachname'].str.contains(query, case=False, na=False) |
|
|
||||||
df['Ort'].str.contains(query, case=False, na=False) |
|
|
||||||
df['Nummer'].astype(str).str.contains(query, case=False, na=False) |
|
|
||||||
df['Fachrichtung'].str.contains(query, case=False, na=False) |
|
|
||||||
df['Tel'].astype(str).str.contains(query, case=False, na=False)
|
|
||||||
)
|
|
||||||
mask &= query_mask
|
|
||||||
|
|
||||||
# Spezifische Suchkriterien anwenden
|
# Protokolliere die Anzahl der gefundenen Ergebnisse
|
||||||
if name:
|
logger.info(f'Suchergebnisse gefunden: {len(results)}')
|
||||||
name_mask = (
|
|
||||||
df['Vorname'].str.contains(name, case=False, na=False) |
|
|
||||||
df['Nachname'].str.contains(name, case=False, na=False)
|
|
||||||
)
|
|
||||||
mask &= name_mask
|
|
||||||
|
|
||||||
if ort:
|
return jsonify(results)
|
||||||
ort_mask = df['Ort'].str.contains(ort, case=False, na=False)
|
|
||||||
mask &= ort_mask
|
|
||||||
|
|
||||||
if kundennummer:
|
|
||||||
kundennummer_mask = df['Nummer'].astype(str).str.contains(kundennummer, case=False, na=False)
|
|
||||||
mask &= kundennummer_mask
|
|
||||||
|
|
||||||
if fachrichtung:
|
|
||||||
fachrichtung_mask = df['Fachrichtung'].str.contains(fachrichtung, case=False, na=False)
|
|
||||||
mask &= fachrichtung_mask
|
|
||||||
|
|
||||||
if telefon:
|
|
||||||
telefon_mask = df['Tel'].astype(str).str.contains(telefon, case=False, na=False)
|
|
||||||
mask &= telefon_mask
|
|
||||||
|
|
||||||
results = df[mask].to_dict('records')
|
|
||||||
logger.info(f"{len(results)} Ergebnisse gefunden")
|
|
||||||
|
|
||||||
return jsonify({
|
|
||||||
'results': results,
|
|
||||||
'total': len(results)
|
|
||||||
})
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Fehler bei der Suche: {str(e)}")
|
logger.error(f'Fehler bei der Suche: {str(e)}')
|
||||||
return jsonify({"error": str(e)}), 500
|
return jsonify({"error": str(e)}), 500
|
||||||
|
|
||||||
|
def init_app(app):
|
||||||
|
"""Initialisiert die Anwendung mit allen notwendigen Einstellungen."""
|
||||||
|
with app.app_context():
|
||||||
|
# Initialisiere die Datenbank
|
||||||
|
init_db()
|
||||||
|
# Importiere die CSV-Daten
|
||||||
|
import_csv()
|
||||||
|
logger.info("Anwendung erfolgreich initialisiert")
|
||||||
|
|
||||||
|
# Initialisiere die App
|
||||||
|
init_app(app)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
app.run(debug=True, port=5001)
|
app.run(debug=True, port=5001)
|
@@ -1,5 +1,3 @@
|
|||||||
version: '3.8'
|
|
||||||
|
|
||||||
services:
|
services:
|
||||||
web:
|
web:
|
||||||
build: .
|
build: .
|
||||||
|
207
static/css/styles.css
Normal file
207
static/css/styles.css
Normal file
@@ -0,0 +1,207 @@
|
|||||||
|
body {
|
||||||
|
min-height: 100vh;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.main-content {
|
||||||
|
flex: 1 0 auto;
|
||||||
|
padding: 2rem 0;
|
||||||
|
margin-bottom: 4rem; /* Platz für die fixierte Fußzeile */
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-container {
|
||||||
|
max-width: 800px;
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.result-card {
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.result-card:hover {
|
||||||
|
transform: translateY(-2px);
|
||||||
|
box-shadow: 0 4px 8px rgba(0,0,0,0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.loading {
|
||||||
|
display: none;
|
||||||
|
text-align: center;
|
||||||
|
margin: 2rem 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.phone-link, .email-link, .address-link, .customer-link {
|
||||||
|
text-decoration: none;
|
||||||
|
color: #0d6efd;
|
||||||
|
}
|
||||||
|
|
||||||
|
.phone-link:hover, .email-link:hover, .address-link:hover, .customer-link:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-icon, .reset-icon {
|
||||||
|
position: absolute;
|
||||||
|
top: 50%;
|
||||||
|
transform: translateY(-50%);
|
||||||
|
color: #6c757d;
|
||||||
|
cursor: pointer;
|
||||||
|
display: none;
|
||||||
|
z-index: 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
.reset-icon {
|
||||||
|
right: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-icon {
|
||||||
|
right: 35px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.reset-icon.visible {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-icon.visible {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.customer-number {
|
||||||
|
color: #6c757d;
|
||||||
|
font-size: 0.9em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footer {
|
||||||
|
flex-shrink: 0;
|
||||||
|
text-align: center;
|
||||||
|
padding: 1rem;
|
||||||
|
background-color: #f8f9fa;
|
||||||
|
border-top: 1px solid #dee2e6;
|
||||||
|
width: 100%;
|
||||||
|
position: fixed;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
z-index: 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
.share-feedback {
|
||||||
|
position: fixed;
|
||||||
|
bottom: 20px;
|
||||||
|
right: 20px;
|
||||||
|
background: #28a745;
|
||||||
|
color: white;
|
||||||
|
padding: 8px 16px;
|
||||||
|
border-radius: 4px;
|
||||||
|
display: none;
|
||||||
|
animation: fadeOut 2s forwards;
|
||||||
|
z-index: 1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes fadeOut {
|
||||||
|
0% { opacity: 1; }
|
||||||
|
70% { opacity: 1; }
|
||||||
|
100% { opacity: 0; }
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-actions {
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-end;
|
||||||
|
margin-top: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.share-button {
|
||||||
|
padding: 5px 10px;
|
||||||
|
border-radius: 15px;
|
||||||
|
font-size: 0.9em;
|
||||||
|
background-color: #0d6efd;
|
||||||
|
color: white;
|
||||||
|
border: none;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: background-color 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.share-button:hover {
|
||||||
|
background-color: #0b5ed7;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-fields {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
||||||
|
gap: 1rem;
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-field {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-group {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.result-counts {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
padding: 0.5rem;
|
||||||
|
background-color: #f8f9fa;
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.result-count {
|
||||||
|
background-color: #e9ecef;
|
||||||
|
padding: 4px 12px;
|
||||||
|
border-radius: 12px;
|
||||||
|
font-size: 0.9em;
|
||||||
|
color: #6c757d;
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.result-count.visible {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.location-pin {
|
||||||
|
color: #dc3545;
|
||||||
|
margin-left: 4px;
|
||||||
|
font-size: 1.2em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.customer-card {
|
||||||
|
background: white;
|
||||||
|
border-radius: 8px;
|
||||||
|
padding: 1.5rem;
|
||||||
|
margin-bottom: 1.5rem;
|
||||||
|
box-shadow: 0 2px 4px rgba(0,0,0,0.05);
|
||||||
|
border-bottom: 1px solid #e9ecef;
|
||||||
|
}
|
||||||
|
|
||||||
|
.customer-card:last-child {
|
||||||
|
border-bottom: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.customer-info {
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footer-content {
|
||||||
|
padding: 1rem;
|
||||||
|
background-color: #f8f9fa;
|
||||||
|
border-top: 1px solid #dee2e6;
|
||||||
|
width: 100%;
|
||||||
|
position: fixed;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
z-index: 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footer-link {
|
||||||
|
color: #0d6efd;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footer-link:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
BIN
static/medisoftware_logo_rb_200.png
Normal file
BIN
static/medisoftware_logo_rb_200.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.4 KiB |
@@ -7,192 +7,65 @@
|
|||||||
<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 href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css" rel="stylesheet">
|
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css" rel="stylesheet">
|
||||||
<style>
|
<link href="{{ url_for('static', filename='css/styles.css') }}" rel="stylesheet">
|
||||||
body {
|
|
||||||
min-height: 100vh;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
.main-content {
|
|
||||||
flex: 1 0 auto;
|
|
||||||
padding: 2rem 0;
|
|
||||||
}
|
|
||||||
.search-container {
|
|
||||||
max-width: 800px;
|
|
||||||
margin: 0 auto;
|
|
||||||
}
|
|
||||||
.result-card {
|
|
||||||
margin-bottom: 1rem;
|
|
||||||
transition: all 0.3s ease;
|
|
||||||
}
|
|
||||||
.result-card:hover {
|
|
||||||
transform: translateY(-2px);
|
|
||||||
box-shadow: 0 4px 8px rgba(0,0,0,0.1);
|
|
||||||
}
|
|
||||||
.loading {
|
|
||||||
display: none;
|
|
||||||
text-align: center;
|
|
||||||
margin: 2rem 0;
|
|
||||||
}
|
|
||||||
.phone-link, .email-link, .address-link, .customer-link {
|
|
||||||
text-decoration: none;
|
|
||||||
color: #0d6efd;
|
|
||||||
}
|
|
||||||
.phone-link:hover, .email-link:hover, .address-link:hover, .customer-link:hover {
|
|
||||||
text-decoration: underline;
|
|
||||||
}
|
|
||||||
.search-icon, .reset-icon {
|
|
||||||
position: absolute;
|
|
||||||
top: 50%;
|
|
||||||
transform: translateY(-50%);
|
|
||||||
color: #6c757d;
|
|
||||||
cursor: pointer;
|
|
||||||
display: none;
|
|
||||||
z-index: 10;
|
|
||||||
}
|
|
||||||
.reset-icon {
|
|
||||||
right: 10px;
|
|
||||||
}
|
|
||||||
.search-icon {
|
|
||||||
right: 35px;
|
|
||||||
}
|
|
||||||
.reset-icon.visible {
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
.search-icon.visible {
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
.customer-number {
|
|
||||||
color: #6c757d;
|
|
||||||
font-size: 0.9em;
|
|
||||||
}
|
|
||||||
.footer {
|
|
||||||
flex-shrink: 0;
|
|
||||||
text-align: center;
|
|
||||||
padding: 1rem;
|
|
||||||
background-color: #f8f9fa;
|
|
||||||
border-top: 1px solid #dee2e6;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
.share-feedback {
|
|
||||||
position: fixed;
|
|
||||||
bottom: 20px;
|
|
||||||
right: 20px;
|
|
||||||
background: #28a745;
|
|
||||||
color: white;
|
|
||||||
padding: 8px 16px;
|
|
||||||
border-radius: 4px;
|
|
||||||
display: none;
|
|
||||||
animation: fadeOut 2s forwards;
|
|
||||||
z-index: 1000;
|
|
||||||
}
|
|
||||||
@keyframes fadeOut {
|
|
||||||
0% { opacity: 1; }
|
|
||||||
70% { opacity: 1; }
|
|
||||||
100% { opacity: 0; }
|
|
||||||
}
|
|
||||||
.card-actions {
|
|
||||||
display: flex;
|
|
||||||
justify-content: flex-end;
|
|
||||||
margin-top: 1rem;
|
|
||||||
}
|
|
||||||
.share-button {
|
|
||||||
padding: 5px 10px;
|
|
||||||
border-radius: 15px;
|
|
||||||
font-size: 0.9em;
|
|
||||||
}
|
|
||||||
.search-fields {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
|
||||||
gap: 1rem;
|
|
||||||
margin-bottom: 1rem;
|
|
||||||
}
|
|
||||||
.search-field {
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
.input-group {
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
.result-counts {
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
margin-bottom: 1rem;
|
|
||||||
padding: 0.5rem;
|
|
||||||
background-color: #f8f9fa;
|
|
||||||
border-radius: 4px;
|
|
||||||
}
|
|
||||||
.result-count {
|
|
||||||
background-color: #e9ecef;
|
|
||||||
padding: 4px 12px;
|
|
||||||
border-radius: 12px;
|
|
||||||
font-size: 0.9em;
|
|
||||||
color: #6c757d;
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
.result-count.visible {
|
|
||||||
display: inline-block;
|
|
||||||
}
|
|
||||||
.location-pin {
|
|
||||||
color: #dc3545;
|
|
||||||
margin-left: 4px;
|
|
||||||
font-size: 1.2em;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="main-content">
|
<div class="main-content">
|
||||||
<div class="container search-container">
|
<div class="container">
|
||||||
<h1 class="text-center mb-4">medisoftware Kundensuche</h1>
|
<div class="text-center mb-4">
|
||||||
|
<img src="{{ url_for('static', filename='medisoftware_logo_rb_200.png') }}" alt="medisoftware Logo" class="img-fluid" style="max-width: 200px;">
|
||||||
<div class="input-group mb-4 position-relative">
|
|
||||||
<input type="text" id="searchInput" class="form-control form-control-lg"
|
|
||||||
placeholder="Allgemeine Suche...">
|
|
||||||
<i class="fa-solid fa-xmark reset-icon" id="searchReset"></i>
|
|
||||||
<span class="search-icon">🔍</span>
|
|
||||||
</div>
|
</div>
|
||||||
|
<div class="search-container">
|
||||||
|
<h1 class="text-center mb-4">medisoftware Kundensuche</h1>
|
||||||
|
|
||||||
|
<div class="input-group mb-4 position-relative">
|
||||||
|
<input type="text" id="searchInput" class="form-control form-control-lg"
|
||||||
|
placeholder="Allgemeine Suche...">
|
||||||
|
<i class="fa-solid fa-xmark reset-icon" id="searchReset"></i>
|
||||||
|
<span class="search-icon">🔍</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="search-fields">
|
<div class="search-fields">
|
||||||
<div class="search-field">
|
<div class="search-field">
|
||||||
<input type="text" id="nameInput" class="form-control"
|
<input type="text" id="nameInput" class="form-control"
|
||||||
placeholder="Name...">
|
placeholder="Name...">
|
||||||
<i class="fa-solid fa-xmark reset-icon" id="nameReset"></i>
|
<i class="fa-solid fa-xmark reset-icon" id="nameReset"></i>
|
||||||
|
</div>
|
||||||
|
<div class="search-field">
|
||||||
|
<input type="text" id="ortInput" class="form-control"
|
||||||
|
placeholder="Ort...">
|
||||||
|
<i class="fa-solid fa-xmark reset-icon" id="ortReset"></i>
|
||||||
|
</div>
|
||||||
|
<div class="search-field">
|
||||||
|
<input type="text" id="kundennummerInput" class="form-control"
|
||||||
|
placeholder="Kundennummer...">
|
||||||
|
<i class="fa-solid fa-xmark reset-icon" id="kundennummerReset"></i>
|
||||||
|
</div>
|
||||||
|
<div class="search-field">
|
||||||
|
<input type="text" id="fachrichtungInput" class="form-control"
|
||||||
|
placeholder="Fachrichtung...">
|
||||||
|
<i class="fa-solid fa-xmark reset-icon" id="fachrichtungReset"></i>
|
||||||
|
</div>
|
||||||
|
<div class="search-field">
|
||||||
|
<input type="text" id="telefonInput" class="form-control"
|
||||||
|
placeholder="Telefon...">
|
||||||
|
<i class="fa-solid fa-xmark reset-icon" id="telefonReset"></i>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="search-field">
|
|
||||||
<input type="text" id="ortInput" class="form-control"
|
|
||||||
placeholder="Ort...">
|
|
||||||
<i class="fa-solid fa-xmark reset-icon" id="ortReset"></i>
|
|
||||||
</div>
|
|
||||||
<div class="search-field">
|
|
||||||
<input type="text" id="kundennummerInput" class="form-control"
|
|
||||||
placeholder="Kundennummer...">
|
|
||||||
<i class="fa-solid fa-xmark reset-icon" id="kundennummerReset"></i>
|
|
||||||
</div>
|
|
||||||
<div class="search-field">
|
|
||||||
<input type="text" id="fachrichtungInput" class="form-control"
|
|
||||||
placeholder="Fachrichtung...">
|
|
||||||
<i class="fa-solid fa-xmark reset-icon" id="fachrichtungReset"></i>
|
|
||||||
</div>
|
|
||||||
<div class="search-field">
|
|
||||||
<input type="text" id="telefonInput" class="form-control"
|
|
||||||
placeholder="Telefon...">
|
|
||||||
<i class="fa-solid fa-xmark reset-icon" id="telefonReset"></i>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="result-counts">
|
<div class="result-counts">
|
||||||
<span id="generalCount" class="result-count"></span>
|
<span id="generalCount" class="result-count"></span>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="loading" class="loading">
|
|
||||||
<div class="spinner-border text-primary" role="status">
|
|
||||||
<span class="visually-hidden">Laden...</span>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="results" class="mt-4">
|
<div id="loading" class="loading">
|
||||||
<!-- Hier werden die Suchergebnisse angezeigt -->
|
<div class="spinner-border text-primary" role="status">
|
||||||
|
<span class="visually-hidden">Laden...</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="results" class="mt-4">
|
||||||
|
<!-- Hier werden die Suchergebnisse angezeigt -->
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -202,7 +75,10 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<footer class="footer">
|
<footer class="footer">
|
||||||
<p class="mb-0">(c) 2025 <a href="https://medisoftware.de" target="_blank" rel="noopener noreferrer" class="text-decoration-none">medisoftware</a></p>
|
<div class="footer-content">
|
||||||
|
Made with ❤️ and 🍺 by <a href="https://www.medisoftware.de" target="_blank" class="footer-link">medisoftware</a>
|
||||||
|
<div style="font-size: 0.8em;">Version: v1.2.0</div>
|
||||||
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@@ -211,8 +87,14 @@
|
|||||||
|
|
||||||
function createPhoneLink(phone) {
|
function createPhoneLink(phone) {
|
||||||
if (!phone) return 'N/A';
|
if (!phone) return 'N/A';
|
||||||
const cleaned = phone.replace(/\D/g, '');
|
const cleaned = phone.replace(/[^\d+\s]/g, '');
|
||||||
const telLink = '0' + cleaned;
|
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 => clientIP.startsWith(range.trim()));
|
||||||
|
|
||||||
|
const telLink = cleaned.startsWith('+') ? cleaned : (isAllowed ? '0' + cleaned.replace(/\s/g, '') : cleaned.replace(/\s/g, ''));
|
||||||
return `<a href="tel:${telLink}" class="phone-link">${phone}</a>`;
|
return `<a href="tel:${telLink}" class="phone-link">${phone}</a>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -221,20 +103,112 @@
|
|||||||
return `<a href="mailto:${email}" class="email-link">${email}</a>`;
|
return `<a href="mailto:${email}" class="email-link">${email}</a>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function highlightText(text, searchTerms) {
|
||||||
|
// Konvertiere text zu String und prüfe auf null/undefined
|
||||||
|
const textStr = String(text || '');
|
||||||
|
if (!textStr || !searchTerms || searchTerms.length === 0) return textStr;
|
||||||
|
|
||||||
|
// Escapen der Suchbegriffe für reguläre Ausdrücke
|
||||||
|
const escapedTerms = searchTerms.map(term =>
|
||||||
|
String(term || '').replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
||||||
|
).filter(term => term.length > 0);
|
||||||
|
|
||||||
|
if (escapedTerms.length === 0) return textStr;
|
||||||
|
|
||||||
|
// Erstelle einen temporären div-Element
|
||||||
|
const tempDiv = document.createElement('div');
|
||||||
|
tempDiv.innerHTML = textStr;
|
||||||
|
|
||||||
|
// Funktion zum Hervorheben von Text
|
||||||
|
function highlightNode(node) {
|
||||||
|
if (node.nodeType === 3) { // Text node
|
||||||
|
const text = node.textContent;
|
||||||
|
let newText = text;
|
||||||
|
|
||||||
|
escapedTerms.forEach(term => {
|
||||||
|
const regex = new RegExp(`(${term})`, 'gi');
|
||||||
|
newText = newText.replace(regex, '<mark>$1</mark>');
|
||||||
|
});
|
||||||
|
|
||||||
|
if (newText !== text) {
|
||||||
|
const span = document.createElement('span');
|
||||||
|
span.innerHTML = newText;
|
||||||
|
node.parentNode.replaceChild(span, node);
|
||||||
|
}
|
||||||
|
} else if (node.nodeType === 1) { // Element node
|
||||||
|
// Überspringe mark-Tags und Links
|
||||||
|
if (node.tagName !== 'MARK' && node.tagName !== 'A') {
|
||||||
|
Array.from(node.childNodes).forEach(highlightNode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
highlightNode(tempDiv);
|
||||||
|
return tempDiv.innerHTML;
|
||||||
|
}
|
||||||
|
|
||||||
function createAddressLink(street, plz, city) {
|
function createAddressLink(street, plz, city) {
|
||||||
if (!street || !plz || !city) return 'N/A';
|
if (!street || !plz || !city) return 'N/A';
|
||||||
const address = `${street}, ${plz} ${city}`;
|
const address = `${street}, ${plz} ${city}`;
|
||||||
const searchQuery = encodeURIComponent(address);
|
const searchQuery = encodeURIComponent(address);
|
||||||
return `${address}
|
const routeQuery = encodeURIComponent(address);
|
||||||
|
const clientIP = '{{ request.headers.get("X-Forwarded-For", request.remote_addr) }}';
|
||||||
|
console.log('Client IP in createAddressLink:', clientIP);
|
||||||
|
return `<span class="address-text">${address}</span>
|
||||||
<a href="https://www.google.com/maps/search/?api=1&query=${searchQuery}"
|
<a href="https://www.google.com/maps/search/?api=1&query=${searchQuery}"
|
||||||
class="address-link" target="_blank" rel="noopener noreferrer">
|
class="address-link" target="_blank" rel="noopener noreferrer">
|
||||||
<i class="fa-solid fa-location-pin location-pin"></i>
|
<i class="fa-solid fa-location-pin location-pin"></i>
|
||||||
|
</a>
|
||||||
|
<a href="https://www.google.com/maps/dir/?api=1&destination=${routeQuery}"
|
||||||
|
class="route-link" target="_blank" rel="noopener noreferrer">
|
||||||
|
<i class="fa-solid fa-car route-pin"></i>
|
||||||
</a>`;
|
</a>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function createCustomerLink(customerNumber) {
|
function adjustCustomerNumber(number) {
|
||||||
if (!customerNumber) return 'N/A';
|
return number - 12000;
|
||||||
return `<a href="medisw:openkkbefe/P${customerNumber}?NetGrp=4" class="customer-link">${customerNumber}</a>`;
|
}
|
||||||
|
|
||||||
|
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(',');
|
||||||
|
|
||||||
|
// Debug-Ausgabe für die IP-Bereiche
|
||||||
|
console.log('Client IP in createCustomerLink:', clientIP);
|
||||||
|
console.log('Allowed IP Ranges:', allowedIPRanges);
|
||||||
|
|
||||||
|
// Überprüfe, ob die Client-IP in einem der erlaubten Bereiche liegt
|
||||||
|
const isAllowed = allowedIPRanges.some(range => {
|
||||||
|
const trimmedRange = range.trim();
|
||||||
|
console.log('Checking range:', trimmedRange);
|
||||||
|
return isIPInSubnet(clientIP, trimmedRange);
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log('isAllowed in createCustomerLink:', isAllowed);
|
||||||
|
|
||||||
|
const adjustedNumber = adjustCustomerNumber(nummer);
|
||||||
|
if (isAllowed) {
|
||||||
|
return `<a href="medisw:openkkbefe/P${adjustedNumber}?NetGrp=4" class="customer-link">${nummer}</a>`;
|
||||||
|
} else {
|
||||||
|
return nummer;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function showCopyFeedback() {
|
function showCopyFeedback() {
|
||||||
@@ -268,85 +242,128 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function searchCustomers() {
|
function searchCustomers() {
|
||||||
const name = document.getElementById('nameInput').value;
|
const query = document.getElementById('searchInput').value.trim();
|
||||||
const ort = document.getElementById('ortInput').value;
|
const fachrichtung = document.getElementById('fachrichtungInput').value.trim();
|
||||||
const kundennummer = document.getElementById('kundennummerInput').value;
|
const ort = document.getElementById('ortInput').value.trim();
|
||||||
const fachrichtung = document.getElementById('fachrichtungInput').value;
|
const name = document.getElementById('nameInput').value.trim();
|
||||||
const telefon = document.getElementById('telefonInput').value;
|
const telefon = document.getElementById('telefonInput').value.trim();
|
||||||
const query = document.getElementById('searchInput').value;
|
const kundennummer = document.getElementById('kundennummerInput')?.value.trim() || '';
|
||||||
|
|
||||||
// Prüfe, ob mindestens ein Suchfeld ausgefüllt ist
|
// Sammle alle nicht-leeren Suchbegriffe
|
||||||
if (!name && !ort && !kundennummer && !fachrichtung && !telefon && !query) {
|
const searchTerms = [query, fachrichtung, ort, name, telefon, kundennummer]
|
||||||
document.getElementById('results').innerHTML = '';
|
.filter(term => term && term.length > 0);
|
||||||
lastResults = [];
|
|
||||||
updateResultCounts();
|
// Prüfe, ob alle Suchfelder leer sind
|
||||||
|
if (searchTerms.length === 0) {
|
||||||
|
const resultsDiv = document.getElementById('results');
|
||||||
|
const generalCount = document.getElementById('generalCount');
|
||||||
|
resultsDiv.innerHTML = '';
|
||||||
|
generalCount.textContent = '';
|
||||||
|
generalCount.classList.remove('visible');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lade-Animation anzeigen
|
const resultsDiv = document.getElementById('results');
|
||||||
document.getElementById('loading').style.display = 'block';
|
const loadingDiv = document.getElementById('loading');
|
||||||
document.getElementById('results').innerHTML = '';
|
loadingDiv.style.display = 'block';
|
||||||
|
resultsDiv.innerHTML = '';
|
||||||
// URL-Parameter erstellen
|
|
||||||
const params = new URLSearchParams();
|
const searchParams = new URLSearchParams();
|
||||||
if (name) params.append('name', name);
|
if (query) searchParams.append('q', query);
|
||||||
if (ort) params.append('ort', ort);
|
if (fachrichtung) searchParams.append('fachrichtung', fachrichtung);
|
||||||
if (kundennummer) params.append('kundennummer', kundennummer);
|
if (ort) searchParams.append('ort', ort);
|
||||||
if (fachrichtung) params.append('fachrichtung', fachrichtung);
|
if (name) searchParams.append('name', name);
|
||||||
if (telefon) params.append('telefon', telefon);
|
if (telefon) searchParams.append('telefon', telefon);
|
||||||
if (query) params.append('q', query);
|
if (kundennummer) searchParams.append('kundennummer', kundennummer);
|
||||||
|
|
||||||
fetch(`/search?${params.toString()}`)
|
fetch(`/search?${searchParams.toString()}`)
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(data => {
|
.then(data => {
|
||||||
if (data.error) {
|
resultsDiv.innerHTML = '';
|
||||||
showError(data.error);
|
|
||||||
|
// Prüfe, ob data ein Objekt mit results-Array ist
|
||||||
|
if (!data || !data.results || !Array.isArray(data.results)) {
|
||||||
|
console.error('Unerwartetes Datenformat:', data);
|
||||||
|
resultsDiv.innerHTML = '<div class="error">Unerwartetes Datenformat vom Server</div>';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const resultsContainer = document.getElementById('results');
|
const results = data.results;
|
||||||
resultsContainer.innerHTML = '';
|
if (results.length === 0) {
|
||||||
|
resultsDiv.innerHTML = '<div class="no-results">Keine Ergebnisse gefunden</div>';
|
||||||
if (data.results && data.results.length > 0) {
|
|
||||||
data.results.forEach(customer => {
|
|
||||||
const card = document.createElement('div');
|
|
||||||
card.className = 'card mb-3';
|
|
||||||
const customerLink = createCustomerLink(customer.Nummer);
|
|
||||||
console.log('Customer:', customer); // Debug-Ausgabe
|
|
||||||
console.log('Customer link:', customerLink); // Debug-Ausgabe
|
|
||||||
card.innerHTML = `
|
|
||||||
<div class="card-body">
|
|
||||||
<h5 class="card-title">${customer.Vorname} ${customer.Nachname}</h5>
|
|
||||||
<p class="card-text">
|
|
||||||
<strong>Kundennummer:</strong> ${customerLink}<br>
|
|
||||||
<strong>Fachrichtung:</strong> ${customer.Fachrichtung || 'N/A'}<br>
|
|
||||||
<strong>Adresse:</strong> ${createAddressLink(customer.Strasse, customer.PLZ, customer.Ort)}<br>
|
|
||||||
<strong>Telefon:</strong> ${createPhoneLink(customer.Tel)}<br>
|
|
||||||
<strong>E-Mail:</strong> ${createEmailLink(customer.mail)}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
`;
|
|
||||||
resultsContainer.appendChild(card);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Zeige die Anzahl der Treffer an
|
|
||||||
const totalResults = document.getElementById('total-results');
|
|
||||||
if (totalResults) {
|
|
||||||
totalResults.textContent = `${data.total} Treffer gefunden`;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
resultsContainer.innerHTML = '<div class="alert alert-info">Keine Ergebnisse gefunden.</div>';
|
results.forEach(customer => {
|
||||||
|
const card = document.createElement('div');
|
||||||
|
card.className = 'customer-card';
|
||||||
|
|
||||||
|
// Debug-Ausgabe für die Kundendaten
|
||||||
|
console.log('Kundendaten:', customer);
|
||||||
|
console.log('Alle verfügbaren Felder:', Object.keys(customer));
|
||||||
|
console.log('Telefon-bezogene Felder:', {
|
||||||
|
Telefon: customer.Telefon,
|
||||||
|
Telefonnummer: customer.Telefonnummer,
|
||||||
|
telefon: customer.telefon,
|
||||||
|
telefonnummer: customer.telefonnummer,
|
||||||
|
phone: customer.phone,
|
||||||
|
'phone.number': customer.phone?.number
|
||||||
|
});
|
||||||
|
|
||||||
|
// Erstelle die Adresse mit Hervorhebung
|
||||||
|
const address = `${customer.Strasse || ''}, ${customer.PLZ || ''} ${customer.Ort || ''}`;
|
||||||
|
const addressLink = createAddressLink(customer.Strasse, customer.PLZ, customer.Ort);
|
||||||
|
const highlightedAddress = highlightText(addressLink, searchTerms);
|
||||||
|
|
||||||
|
// Erstelle die Kundennummer mit Hervorhebung
|
||||||
|
const highlightedNumber = highlightText(customer.Nummer, searchTerms);
|
||||||
|
const customerLink = createCustomerLink(customer.Nummer);
|
||||||
|
|
||||||
|
// Erstelle die Telefonnummern mit Hervorhebung
|
||||||
|
let phoneNumber = '';
|
||||||
|
let companyPhone = '';
|
||||||
|
let mobilePhone = '';
|
||||||
|
|
||||||
|
if (typeof customer === 'object') {
|
||||||
|
phoneNumber = customer.Tel || '';
|
||||||
|
companyPhone = customer['Tele Firma'] || '';
|
||||||
|
mobilePhone = customer.Handy || '';
|
||||||
|
}
|
||||||
|
|
||||||
|
const phoneLink = createPhoneLink(phoneNumber);
|
||||||
|
const companyPhoneLink = createPhoneLink(companyPhone);
|
||||||
|
const mobilePhoneLink = createPhoneLink(mobilePhone);
|
||||||
|
|
||||||
|
const highlightedPhone = highlightText(phoneLink, searchTerms);
|
||||||
|
const highlightedCompanyPhone = highlightText(companyPhoneLink, searchTerms);
|
||||||
|
const highlightedMobilePhone = highlightText(mobilePhoneLink, searchTerms);
|
||||||
|
|
||||||
|
card.innerHTML = `
|
||||||
|
<div class="customer-info">
|
||||||
|
<strong>Kundennummer:</strong> ${customerLink}<br>
|
||||||
|
<strong>Name:</strong> ${highlightText(`${customer.Vorname || ''} ${customer.Nachname || ''}`, searchTerms)}<br>
|
||||||
|
<strong>Fachrichtung:</strong> ${highlightText(customer.Fachrichtung || '', searchTerms)}<br>
|
||||||
|
<strong>Adresse:</strong> ${highlightedAddress}<br>
|
||||||
|
<strong>Telefon:</strong> ${highlightedPhone}<br>
|
||||||
|
<strong>Firma:</strong> ${highlightedCompanyPhone}<br>
|
||||||
|
<strong>Mobil:</strong> ${highlightedMobilePhone}
|
||||||
|
</div>
|
||||||
|
<button class="share-button" onclick="copyCustomerLink('${adjustCustomerNumber(customer.Nummer)}')">
|
||||||
|
<i class="fas fa-share-alt"></i> Teilen
|
||||||
|
</button>
|
||||||
|
`;
|
||||||
|
resultsDiv.appendChild(card);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
// Aktualisiere die Anzahl der Treffer
|
||||||
|
const generalCount = document.getElementById('generalCount');
|
||||||
|
generalCount.textContent = results.length > 0 ? `${results.length} Treffer gefunden` : '';
|
||||||
|
generalCount.classList.toggle('visible', results.length > 0);
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.error('Fehler:', error);
|
console.error('Fehler bei der Suche:', error);
|
||||||
document.getElementById('results').innerHTML =
|
resultsDiv.innerHTML = '<div class="error">Ein Fehler ist aufgetreten</div>';
|
||||||
`<div class="alert alert-danger">${error.message}</div>`;
|
|
||||||
lastResults = [];
|
|
||||||
updateResultCounts();
|
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
document.getElementById('loading').style.display = 'none';
|
loadingDiv.style.display = 'none';
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
60
templates/login.html
Normal file
60
templates/login.html
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="de">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>medisoftware Kundensuche</title>
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
min-height: 100vh;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
.main-content {
|
||||||
|
flex: 1 0 auto;
|
||||||
|
padding: 2rem 0;
|
||||||
|
margin-bottom: 4rem; /* Platz für die fixierte Fußzeile */
|
||||||
|
}
|
||||||
|
.footer {
|
||||||
|
flex-shrink: 0;
|
||||||
|
text-align: center;
|
||||||
|
padding: 1rem;
|
||||||
|
background-color: #f8f9fa;
|
||||||
|
border-top: 1px solid #dee2e6;
|
||||||
|
width: 100%;
|
||||||
|
position: fixed;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
z-index: 100;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="container mt-5">
|
||||||
|
<div class="text-center mb-4">
|
||||||
|
<img src="{{ url_for('static', filename='medisoftware_logo_rb_200.png') }}" alt="medisoftware Logo" class="img-fluid" style="max-width: 200px;">
|
||||||
|
</div>
|
||||||
|
<div class="row justify-content-center">
|
||||||
|
<div class="col-md-4">
|
||||||
|
<h2 class="text-center">Login</h2>
|
||||||
|
<form method="POST" action="/login">
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="password" class="form-label">Passwort</label>
|
||||||
|
<input type="password" class="form-control" id="password" name="password" required>
|
||||||
|
</div>
|
||||||
|
<button type="submit" class="btn btn-primary w-100">Einloggen</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<footer class="footer">
|
||||||
|
<div class="footer-content">
|
||||||
|
Made with ❤️ and 🍺 by <a href="https://www.medisoftware.de" target="_blank" class="footer-link">medisoftware</a>
|
||||||
|
<div style="font-size: 0.8em;">Version: v1.2.0</div>
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
|
</body>
|
||||||
|
</html>
|
Reference in New Issue
Block a user