Feature: CSV-Export der Suchergebnisse
This commit is contained in:
@@ -5,6 +5,12 @@ 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
|
## [1.2.16] - 2024-03-21
|
||||||
### Geändert
|
### Geändert
|
||||||
- Verbesserte Darstellung der Suchergebnisse mit rechtsbündigen Aktionen
|
- Verbesserte Darstellung der Suchergebnisse mit rechtsbündigen Aktionen
|
||||||
|
@@ -124,6 +124,78 @@ function updateResultCounts() {
|
|||||||
document.getElementById('resultCount').textContent =
|
document.getElementById('resultCount').textContent =
|
||||||
generalCount > 0 ? `${generalCount} Treffer gefunden` : '';
|
generalCount > 0 ? `${generalCount} Treffer gefunden` : '';
|
||||||
document.getElementById('resultCount').classList.toggle('visible', generalCount > 0);
|
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) {
|
function displayResults(results) {
|
||||||
|
@@ -82,6 +82,9 @@
|
|||||||
|
|
||||||
<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">
|
||||||
|
Reference in New Issue
Block a user