Erste Version mit spezifischen Suchfeldern und Teilen-Funktion
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>medisoftware Kundensuche</title>
|
||||
<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">
|
||||
<style>
|
||||
body {
|
||||
@@ -60,6 +61,42 @@
|
||||
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;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
@@ -67,9 +104,28 @@
|
||||
<div class="container search-container">
|
||||
<h1 class="text-center mb-4">medisoftware Kundensuche</h1>
|
||||
|
||||
<div class="search-fields">
|
||||
<div class="search-field">
|
||||
<input type="text" id="nameInput" class="form-control"
|
||||
placeholder="Name...">
|
||||
</div>
|
||||
<div class="search-field">
|
||||
<input type="text" id="ortInput" class="form-control"
|
||||
placeholder="Ort...">
|
||||
</div>
|
||||
<div class="search-field">
|
||||
<input type="text" id="kundennummerInput" class="form-control"
|
||||
placeholder="Kundennummer...">
|
||||
</div>
|
||||
<div class="search-field">
|
||||
<input type="text" id="fachrichtungInput" class="form-control"
|
||||
placeholder="Fachrichtung...">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="input-group mb-4 position-relative">
|
||||
<input type="text" id="searchInput" class="form-control form-control-lg"
|
||||
placeholder="Suchen Sie nach Name, Fachrichtung, Ort oder Kundennummer...">
|
||||
placeholder="Allgemeine Suche...">
|
||||
<span class="search-icon">🔍</span>
|
||||
</div>
|
||||
|
||||
@@ -85,6 +141,10 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="shareFeedback" class="share-feedback">
|
||||
Link kopiert!
|
||||
</div>
|
||||
|
||||
<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>
|
||||
</footer>
|
||||
@@ -94,11 +154,8 @@
|
||||
|
||||
function createPhoneLink(phone) {
|
||||
if (!phone) return 'N/A';
|
||||
// Entferne alle nicht-numerischen Zeichen für den tel: Link
|
||||
const cleaned = phone.replace(/\D/g, '');
|
||||
// Füge immer eine führende 0 hinzu
|
||||
const telLink = '0' + cleaned;
|
||||
// Zeige die ursprüngliche Nummer an
|
||||
return `<a href="tel:${telLink}" class="phone-link">${phone}</a>`;
|
||||
}
|
||||
|
||||
@@ -126,9 +183,37 @@
|
||||
</a>`;
|
||||
}
|
||||
|
||||
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) {
|
||||
console.error('Fehler beim Kopieren:', err);
|
||||
}
|
||||
}
|
||||
|
||||
function searchCustomers() {
|
||||
const name = document.getElementById('nameInput').value;
|
||||
const ort = document.getElementById('ortInput').value;
|
||||
const kundennummer = document.getElementById('kundennummerInput').value;
|
||||
const fachrichtung = document.getElementById('fachrichtungInput').value;
|
||||
const query = document.getElementById('searchInput').value;
|
||||
if (query.length < 2) {
|
||||
|
||||
// Prüfe, ob mindestens ein Suchfeld ausgefüllt ist
|
||||
if (!name && !ort && !kundennummer && !fachrichtung && !query) {
|
||||
document.getElementById('results').innerHTML = '';
|
||||
return;
|
||||
}
|
||||
@@ -137,7 +222,15 @@
|
||||
document.getElementById('loading').style.display = 'block';
|
||||
document.getElementById('results').innerHTML = '';
|
||||
|
||||
fetch(`/search?q=${encodeURIComponent(query)}`)
|
||||
// URL-Parameter erstellen
|
||||
const params = new URLSearchParams();
|
||||
if (name) params.append('name', name);
|
||||
if (ort) params.append('ort', ort);
|
||||
if (kundennummer) params.append('kundennummer', kundennummer);
|
||||
if (fachrichtung) params.append('fachrichtung', fachrichtung);
|
||||
if (query) params.append('q', query);
|
||||
|
||||
fetch(`/search?${params.toString()}`)
|
||||
.then(response => {
|
||||
if (!response.ok) {
|
||||
return response.json().then(data => {
|
||||
@@ -170,6 +263,11 @@
|
||||
<strong>Telefon:</strong> ${createPhoneLink(customer.Tel)}<br>
|
||||
<strong>E-Mail:</strong> ${createEmailLink(customer.mail)}
|
||||
</p>
|
||||
<div class="card-actions">
|
||||
<button class="btn btn-outline-primary share-button" onclick="copyCustomerLink('${customer.Nummer}')">
|
||||
🔗 Teilen
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
resultsDiv.appendChild(card);
|
||||
@@ -181,26 +279,42 @@
|
||||
`<div class="alert alert-danger">${error.message}</div>`;
|
||||
})
|
||||
.finally(() => {
|
||||
// Lade-Animation ausblenden
|
||||
document.getElementById('loading').style.display = 'none';
|
||||
});
|
||||
}
|
||||
|
||||
// Event-Listener für die Live-Suche
|
||||
document.getElementById('searchInput').addEventListener('input', function(e) {
|
||||
// Clear previous timeout
|
||||
clearTimeout(searchTimeout);
|
||||
|
||||
// Set new timeout
|
||||
searchTimeout = setTimeout(() => {
|
||||
searchCustomers();
|
||||
}, 300); // 300ms Verzögerung
|
||||
const searchInputs = [
|
||||
document.getElementById('nameInput'),
|
||||
document.getElementById('ortInput'),
|
||||
document.getElementById('kundennummerInput'),
|
||||
document.getElementById('fachrichtungInput'),
|
||||
document.getElementById('searchInput')
|
||||
];
|
||||
|
||||
searchInputs.forEach(input => {
|
||||
input.addEventListener('input', function() {
|
||||
clearTimeout(searchTimeout);
|
||||
searchTimeout = setTimeout(searchCustomers, 300);
|
||||
});
|
||||
});
|
||||
|
||||
// Suche bei Enter-Taste
|
||||
document.getElementById('searchInput').addEventListener('keypress', function(e) {
|
||||
if (e.key === 'Enter') {
|
||||
clearTimeout(searchTimeout);
|
||||
// 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 fachrichtung = urlParams.get('fachrichtung');
|
||||
const query = urlParams.get('q');
|
||||
|
||||
if (name) document.getElementById('nameInput').value = name;
|
||||
if (ort) document.getElementById('ortInput').value = ort;
|
||||
if (kundennummer) document.getElementById('kundennummerInput').value = kundennummer;
|
||||
if (fachrichtung) document.getElementById('fachrichtungInput').value = fachrichtung;
|
||||
if (query) document.getElementById('searchInput').value = query;
|
||||
|
||||
if (name || ort || kundennummer || fachrichtung || query) {
|
||||
searchCustomers();
|
||||
}
|
||||
});
|
||||
|
Reference in New Issue
Block a user