Feature: VCF-Export der Suchergebnisse
This commit is contained in:
@@ -119,14 +119,21 @@ async function copyCustomerLink(customerNumber) {
|
||||
}
|
||||
|
||||
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);
|
||||
const resultCount = document.getElementById('result-count');
|
||||
const exportButton = document.getElementById('exportButton');
|
||||
const vcfExportButton = document.getElementById('vcfExportButton');
|
||||
|
||||
// Export-Button anzeigen/verstecken
|
||||
document.getElementById('exportButton').style.display = generalCount > 0 ? 'inline-block' : 'none';
|
||||
if (lastResults && lastResults.length > 0) {
|
||||
resultCount.textContent = `${lastResults.length} Ergebnisse gefunden`;
|
||||
resultCount.style.display = 'inline';
|
||||
exportButton.style.display = 'inline-block';
|
||||
vcfExportButton.style.display = 'inline-block';
|
||||
} else {
|
||||
resultCount.textContent = '';
|
||||
resultCount.style.display = 'none';
|
||||
exportButton.style.display = 'none';
|
||||
vcfExportButton.style.display = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
function exportToCSV() {
|
||||
@@ -198,6 +205,39 @@ function exportToCSV() {
|
||||
document.body.removeChild(link);
|
||||
}
|
||||
|
||||
function exportToVCF() {
|
||||
if (!lastResults || lastResults.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const vcfData = lastResults.map(customer => {
|
||||
const lines = [
|
||||
'BEGIN:VCARD',
|
||||
'VERSION:3.0',
|
||||
`FN:${customer.vorname} ${customer.nachname}`,
|
||||
`N:${customer.nachname};${customer.vorname};;`,
|
||||
`TEL;TYPE=CELL:${customer.telefon || ''}`,
|
||||
`TEL;TYPE=HOME:${customer.telefon_2 || ''}`,
|
||||
`EMAIL:${customer.email || ''}`,
|
||||
`ADR;TYPE=HOME:;;${customer.strasse || ''};${customer.plz || ''};${customer.ort || ''};${customer.land || ''}`,
|
||||
`ORG:${customer.firma || ''}`,
|
||||
`NOTE:${customer.notizen || ''}`,
|
||||
'END:VCARD'
|
||||
];
|
||||
return lines.join('\n');
|
||||
}).join('\n\n');
|
||||
|
||||
const blob = new Blob([vcfData], { type: 'text/vcard;charset=utf-8' });
|
||||
const url = window.URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = `kontakte_${new Date().toISOString().split('T')[0]}.vcf`;
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
window.URL.revokeObjectURL(url);
|
||||
document.body.removeChild(a);
|
||||
}
|
||||
|
||||
function displayResults(results) {
|
||||
const resultsDiv = document.getElementById('results');
|
||||
const resultCount = document.getElementById('resultCount');
|
||||
|
Reference in New Issue
Block a user