Feature: VCF-Export der Suchergebnisse
This commit is contained in:
@@ -119,14 +119,21 @@ async function copyCustomerLink(customerNumber) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function updateResultCounts() {
|
function updateResultCounts() {
|
||||||
// Nur Gesamtzahl anzeigen
|
const resultCount = document.getElementById('result-count');
|
||||||
const generalCount = lastResults.length;
|
const exportButton = document.getElementById('exportButton');
|
||||||
document.getElementById('resultCount').textContent =
|
const vcfExportButton = document.getElementById('vcfExportButton');
|
||||||
generalCount > 0 ? `${generalCount} Treffer gefunden` : '';
|
|
||||||
document.getElementById('resultCount').classList.toggle('visible', generalCount > 0);
|
|
||||||
|
|
||||||
// Export-Button anzeigen/verstecken
|
if (lastResults && lastResults.length > 0) {
|
||||||
document.getElementById('exportButton').style.display = generalCount > 0 ? 'inline-block' : 'none';
|
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() {
|
function exportToCSV() {
|
||||||
@@ -198,6 +205,39 @@ function exportToCSV() {
|
|||||||
document.body.removeChild(link);
|
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) {
|
function displayResults(results) {
|
||||||
const resultsDiv = document.getElementById('results');
|
const resultsDiv = document.getElementById('results');
|
||||||
const resultCount = document.getElementById('resultCount');
|
const resultCount = document.getElementById('resultCount');
|
||||||
|
@@ -80,10 +80,13 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="result-counts">
|
<div id="result-counts" class="mt-2">
|
||||||
<span id="resultCount" class="result-count"></span>
|
<span id="result-count"></span>
|
||||||
<button id="exportButton" class="btn btn-sm btn-outline-success ms-2" onclick="exportToCSV()" style="display: none;">
|
<button id="exportButton" class="btn btn-sm btn-outline-primary ms-2" onclick="exportToCSV()" style="display: none;">
|
||||||
<i class="fas fa-file-csv"></i> CSV Export
|
<i class="bi bi-file-earmark-excel"></i> CSV exportieren
|
||||||
|
</button>
|
||||||
|
<button id="vcfExportButton" class="btn btn-sm btn-outline-primary ms-2" onclick="exportToVCF()" style="display: none;">
|
||||||
|
<i class="bi bi-person-vcard"></i> VCF exportieren
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user