Feature: Suchfeld für Fachrichtung hinzugefügt
This commit is contained in:
21
app.py
21
app.py
@@ -50,7 +50,8 @@ def init_db():
|
|||||||
telefon TEXT,
|
telefon TEXT,
|
||||||
mobil TEXT,
|
mobil TEXT,
|
||||||
email TEXT,
|
email TEXT,
|
||||||
bemerkung TEXT
|
bemerkung TEXT,
|
||||||
|
fachrichtung TEXT
|
||||||
)
|
)
|
||||||
''')
|
''')
|
||||||
|
|
||||||
@@ -63,6 +64,7 @@ def init_db():
|
|||||||
c.execute('CREATE INDEX IF NOT EXISTS idx_customers_telefon ON customers(telefon)')
|
c.execute('CREATE INDEX IF NOT EXISTS idx_customers_telefon ON customers(telefon)')
|
||||||
c.execute('CREATE INDEX IF NOT EXISTS idx_customers_mobil ON customers(mobil)')
|
c.execute('CREATE INDEX IF NOT EXISTS idx_customers_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)')
|
||||||
|
|
||||||
# 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)')
|
||||||
@@ -97,8 +99,8 @@ def import_csv():
|
|||||||
# Importiere die Daten
|
# 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)
|
INSERT INTO customers (nummer, name, strasse, plz, ort, telefon, mobil, email, bemerkung, fachrichtung)
|
||||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||||
''', (
|
''', (
|
||||||
row['Nummer'],
|
row['Nummer'],
|
||||||
row['name'],
|
row['name'],
|
||||||
@@ -108,7 +110,8 @@ def import_csv():
|
|||||||
row['Tel'],
|
row['Tel'],
|
||||||
row['Handy'],
|
row['Handy'],
|
||||||
row['mail'],
|
row['mail'],
|
||||||
f"Fachrichtung: {row['Fachrichtung']}"
|
f"Fachrichtung: {row['Fachrichtung']}",
|
||||||
|
row['Fachrichtung']
|
||||||
))
|
))
|
||||||
|
|
||||||
conn.commit()
|
conn.commit()
|
||||||
@@ -132,8 +135,8 @@ def search_customers(search_params):
|
|||||||
# Allgemeine Suche über alle Felder
|
# Allgemeine Suche über alle Felder
|
||||||
if search_params.get('q'):
|
if search_params.get('q'):
|
||||||
search_term = f"%{search_params['q']}%"
|
search_term = f"%{search_params['q']}%"
|
||||||
query += " AND (name LIKE ? OR ort LIKE ? OR nummer LIKE ? OR telefon LIKE ? OR mobil LIKE ? OR email LIKE ? OR bemerkung LIKE ?)"
|
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] * 7)
|
params.extend([search_term] * 8)
|
||||||
|
|
||||||
# Spezifische Suche für einzelne Felder
|
# Spezifische Suche für einzelne Felder
|
||||||
if search_params.get('name'):
|
if search_params.get('name'):
|
||||||
@@ -169,7 +172,8 @@ def search_customers(search_params):
|
|||||||
'telefon': row[6],
|
'telefon': row[6],
|
||||||
'mobil': row[7],
|
'mobil': row[7],
|
||||||
'email': row[8],
|
'email': row[8],
|
||||||
'bemerkung': row[9]
|
'bemerkung': row[9],
|
||||||
|
'fachrichtung': row[10]
|
||||||
}
|
}
|
||||||
customers.append(customer)
|
customers.append(customer)
|
||||||
|
|
||||||
@@ -270,7 +274,8 @@ def search():
|
|||||||
'plz': request.args.get('plz', ''),
|
'plz': request.args.get('plz', ''),
|
||||||
'telefon': request.args.get('telefon', ''),
|
'telefon': request.args.get('telefon', ''),
|
||||||
'email': request.args.get('email', ''),
|
'email': request.args.get('email', ''),
|
||||||
'q': request.args.get('q', '')
|
'q': request.args.get('q', ''),
|
||||||
|
'fachrichtung': request.args.get('fachrichtung', '')
|
||||||
}
|
}
|
||||||
|
|
||||||
# Führe die Suche in der Datenbank durch
|
# Führe die Suche in der Datenbank durch
|
||||||
|
@@ -58,6 +58,11 @@
|
|||||||
<i class="fas fa-search search-icon"></i>
|
<i class="fas fa-search search-icon"></i>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="fachrichtungInput">Fachrichtung</label>
|
||||||
|
<input type="text" class="form-control" id="fachrichtungInput" placeholder="Fachrichtung eingeben">
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="result-counts">
|
<div class="result-counts">
|
||||||
@@ -256,6 +261,7 @@
|
|||||||
const ort = document.getElementById('ortInput').value;
|
const ort = document.getElementById('ortInput').value;
|
||||||
const nummer = document.getElementById('nummerInput').value;
|
const nummer = document.getElementById('nummerInput').value;
|
||||||
const plz = document.getElementById('plzInput').value;
|
const plz = document.getElementById('plzInput').value;
|
||||||
|
const fachrichtung = document.getElementById('fachrichtungInput').value;
|
||||||
|
|
||||||
// Zeige das Lade-Icon
|
// Zeige das Lade-Icon
|
||||||
document.getElementById('loading').style.display = 'block';
|
document.getElementById('loading').style.display = 'block';
|
||||||
@@ -267,6 +273,7 @@
|
|||||||
if (ort) params.append('ort', ort);
|
if (ort) params.append('ort', ort);
|
||||||
if (nummer) params.append('nummer', nummer);
|
if (nummer) params.append('nummer', nummer);
|
||||||
if (plz) params.append('plz', plz);
|
if (plz) params.append('plz', plz);
|
||||||
|
if (fachrichtung) params.append('fachrichtung', fachrichtung);
|
||||||
|
|
||||||
// Führe die Suche durch
|
// Führe die Suche durch
|
||||||
fetch('/search?' + params.toString())
|
fetch('/search?' + params.toString())
|
||||||
@@ -323,7 +330,8 @@
|
|||||||
document.getElementById('nameInput'),
|
document.getElementById('nameInput'),
|
||||||
document.getElementById('ortInput'),
|
document.getElementById('ortInput'),
|
||||||
document.getElementById('nummerInput'),
|
document.getElementById('nummerInput'),
|
||||||
document.getElementById('plzInput')
|
document.getElementById('plzInput'),
|
||||||
|
document.getElementById('fachrichtungInput')
|
||||||
];
|
];
|
||||||
|
|
||||||
const resetIcons = [
|
const resetIcons = [
|
||||||
@@ -331,7 +339,8 @@
|
|||||||
document.querySelector('.reset-icon[onclick="clearInput(\'nameInput\')"]'),
|
document.querySelector('.reset-icon[onclick="clearInput(\'nameInput\')"]'),
|
||||||
document.querySelector('.reset-icon[onclick="clearInput(\'ortInput\')"]'),
|
document.querySelector('.reset-icon[onclick="clearInput(\'ortInput\')"]'),
|
||||||
document.querySelector('.reset-icon[onclick="clearInput(\'nummerInput\')"]'),
|
document.querySelector('.reset-icon[onclick="clearInput(\'nummerInput\')"]'),
|
||||||
document.querySelector('.reset-icon[onclick="clearInput(\'plzInput\')"]')
|
document.querySelector('.reset-icon[onclick="clearInput(\'plzInput\')"]'),
|
||||||
|
document.querySelector('.reset-icon[onclick="clearInput(\'fachrichtungInput\')"]')
|
||||||
];
|
];
|
||||||
|
|
||||||
searchInputs.forEach((input, index) => {
|
searchInputs.forEach((input, index) => {
|
||||||
|
Reference in New Issue
Block a user