diff --git a/examples/inventory_corporate.html b/examples/inventory_corporate.html
index 1c43870..2f7cf0c 100644
--- a/examples/inventory_corporate.html
+++ b/examples/inventory_corporate.html
@@ -1016,18 +1016,52 @@ input.invalid, select.invalid, textarea.invalid {
body += 'Versie: ' + CONFIG.version + '\n';
body += 'Datum: ' + formatDateTime(new Date()) + '\n\n';
+ // Collect photos separately
+ const photos = [];
+
Object.entries(data).forEach(([key, value]) => {
- if (value && value !== '' && !key.includes('foto') && !key.includes('photo')) {
- const label = document.querySelector(`label[for="${key}"]`);
- const labelText = label ? label.textContent.replace('*', '').trim() : key;
- const displayValue = Array.isArray(value) ? value.join(', ') : value;
- body += labelText + ': ' + displayValue + '\n';
+ if (value && value !== '') {
+ // Check if this is a photo (base64 image)
+ if (typeof value === 'string' && value.startsWith('data:image/')) {
+ const label = document.querySelector(`label[for="${key}"]`);
+ const labelText = label ? label.textContent.replace('*', '').trim() : key;
+ // Extract extension from data URL (e.g., data:image/jpeg;base64,...)
+ const mimeMatch = value.match(/data:image\/([a-z]+);/);
+ const ext = mimeMatch ? mimeMatch[1] : 'jpg';
+ photos.push({
+ name: labelText,
+ extension: ext,
+ data: value
+ });
+ } else {
+ const label = document.querySelector(`label[for="${key}"]`);
+ const labelText = label ? label.textContent.replace('*', '').trim() : key;
+ const displayValue = Array.isArray(value) ? value.join(', ') : value;
+ body += labelText + ': ' + displayValue + '\n';
+ }
}
});
body += '\n========================\n';
- body += 'Let op: Foto\'s kunnen niet via mailto worden verzonden.\n';
- body += 'Gebruik CSV export voor complete data inclusief foto\'s.';
+
+ // Add photos section if there are any
+ if (photos.length > 0) {
+ body += '\nFOTO BIJLAGEN (BASE64)\n';
+ body += '========================\n';
+ body += 'Onderstaande foto\'s zijn gecodeerd in base64 formaat.\n';
+ body += 'Kopieer de tekst tussen START en EINDE naar een base64 decoder\n';
+ body += 'of gebruik een online tool zoals base64-image.de\n\n';
+
+ photos.forEach((photo, index) => {
+ const filename = photo.name.replace(/[^a-zA-Z0-9]/g, '_') + '.' + photo.extension;
+ body += '--- FOTO ' + (index + 1) + ': ' + filename + ' ---\n';
+ body += '>>> START BASE64 >>>\n';
+ body += photo.data + '\n';
+ body += '<<< EINDE BASE64 <<<\n\n';
+ });
+ } else {
+ body += 'Geen foto\'s toegevoegd aan dit formulier.\n';
+ }
const mailto = 'mailto:' + encodeURIComponent(CONFIG.export.mailto.to) +
'?subject=' + encodeURIComponent(subject) +
@@ -1039,6 +1073,12 @@ input.invalid, select.invalid, textarea.invalid {
button.disabled = false;
}
+ // Check if mailto URL is too long (most clients support ~2000 chars)
+ if (mailto.length > 100000) {
+ showToast('Email te groot door foto. Gebruik CSV export.', 'error');
+ return;
+ }
+
window.location.href = mailto;
}, 50);
};
diff --git a/examples/inventory_minimal.html b/examples/inventory_minimal.html
index cdd62e2..647c42e 100644
--- a/examples/inventory_minimal.html
+++ b/examples/inventory_minimal.html
@@ -1047,18 +1047,52 @@ select {
body += 'Versie: ' + CONFIG.version + '\n';
body += 'Datum: ' + formatDateTime(new Date()) + '\n\n';
+ // Collect photos separately
+ const photos = [];
+
Object.entries(data).forEach(([key, value]) => {
- if (value && value !== '' && !key.includes('foto') && !key.includes('photo')) {
- const label = document.querySelector(`label[for="${key}"]`);
- const labelText = label ? label.textContent.replace('*', '').trim() : key;
- const displayValue = Array.isArray(value) ? value.join(', ') : value;
- body += labelText + ': ' + displayValue + '\n';
+ if (value && value !== '') {
+ // Check if this is a photo (base64 image)
+ if (typeof value === 'string' && value.startsWith('data:image/')) {
+ const label = document.querySelector(`label[for="${key}"]`);
+ const labelText = label ? label.textContent.replace('*', '').trim() : key;
+ // Extract extension from data URL (e.g., data:image/jpeg;base64,...)
+ const mimeMatch = value.match(/data:image\/([a-z]+);/);
+ const ext = mimeMatch ? mimeMatch[1] : 'jpg';
+ photos.push({
+ name: labelText,
+ extension: ext,
+ data: value
+ });
+ } else {
+ const label = document.querySelector(`label[for="${key}"]`);
+ const labelText = label ? label.textContent.replace('*', '').trim() : key;
+ const displayValue = Array.isArray(value) ? value.join(', ') : value;
+ body += labelText + ': ' + displayValue + '\n';
+ }
}
});
body += '\n========================\n';
- body += 'Let op: Foto\'s kunnen niet via mailto worden verzonden.\n';
- body += 'Gebruik CSV export voor complete data inclusief foto\'s.';
+
+ // Add photos section if there are any
+ if (photos.length > 0) {
+ body += '\nFOTO BIJLAGEN (BASE64)\n';
+ body += '========================\n';
+ body += 'Onderstaande foto\'s zijn gecodeerd in base64 formaat.\n';
+ body += 'Kopieer de tekst tussen START en EINDE naar een base64 decoder\n';
+ body += 'of gebruik een online tool zoals base64-image.de\n\n';
+
+ photos.forEach((photo, index) => {
+ const filename = photo.name.replace(/[^a-zA-Z0-9]/g, '_') + '.' + photo.extension;
+ body += '--- FOTO ' + (index + 1) + ': ' + filename + ' ---\n';
+ body += '>>> START BASE64 >>>\n';
+ body += photo.data + '\n';
+ body += '<<< EINDE BASE64 <<<\n\n';
+ });
+ } else {
+ body += 'Geen foto\'s toegevoegd aan dit formulier.\n';
+ }
const mailto = 'mailto:' + encodeURIComponent(CONFIG.export.mailto.to) +
'?subject=' + encodeURIComponent(subject) +
@@ -1070,6 +1104,12 @@ select {
button.disabled = false;
}
+ // Check if mailto URL is too long (most clients support ~2000 chars)
+ if (mailto.length > 100000) {
+ showToast('Email te groot door foto. Gebruik CSV export.', 'error');
+ return;
+ }
+
window.location.href = mailto;
}, 50);
};
diff --git a/examples/inventory_modern.html b/examples/inventory_modern.html
index ac1c776..5648de8 100644
--- a/examples/inventory_modern.html
+++ b/examples/inventory_modern.html
@@ -1078,18 +1078,52 @@ input.invalid, select.invalid, textarea.invalid {
body += 'Versie: ' + CONFIG.version + '\n';
body += 'Datum: ' + formatDateTime(new Date()) + '\n\n';
+ // Collect photos separately
+ const photos = [];
+
Object.entries(data).forEach(([key, value]) => {
- if (value && value !== '' && !key.includes('foto') && !key.includes('photo')) {
- const label = document.querySelector(`label[for="${key}"]`);
- const labelText = label ? label.textContent.replace('*', '').trim() : key;
- const displayValue = Array.isArray(value) ? value.join(', ') : value;
- body += labelText + ': ' + displayValue + '\n';
+ if (value && value !== '') {
+ // Check if this is a photo (base64 image)
+ if (typeof value === 'string' && value.startsWith('data:image/')) {
+ const label = document.querySelector(`label[for="${key}"]`);
+ const labelText = label ? label.textContent.replace('*', '').trim() : key;
+ // Extract extension from data URL (e.g., data:image/jpeg;base64,...)
+ const mimeMatch = value.match(/data:image\/([a-z]+);/);
+ const ext = mimeMatch ? mimeMatch[1] : 'jpg';
+ photos.push({
+ name: labelText,
+ extension: ext,
+ data: value
+ });
+ } else {
+ const label = document.querySelector(`label[for="${key}"]`);
+ const labelText = label ? label.textContent.replace('*', '').trim() : key;
+ const displayValue = Array.isArray(value) ? value.join(', ') : value;
+ body += labelText + ': ' + displayValue + '\n';
+ }
}
});
body += '\n========================\n';
- body += 'Let op: Foto\'s kunnen niet via mailto worden verzonden.\n';
- body += 'Gebruik CSV export voor complete data inclusief foto\'s.';
+
+ // Add photos section if there are any
+ if (photos.length > 0) {
+ body += '\nFOTO BIJLAGEN (BASE64)\n';
+ body += '========================\n';
+ body += 'Onderstaande foto\'s zijn gecodeerd in base64 formaat.\n';
+ body += 'Kopieer de tekst tussen START en EINDE naar een base64 decoder\n';
+ body += 'of gebruik een online tool zoals base64-image.de\n\n';
+
+ photos.forEach((photo, index) => {
+ const filename = photo.name.replace(/[^a-zA-Z0-9]/g, '_') + '.' + photo.extension;
+ body += '--- FOTO ' + (index + 1) + ': ' + filename + ' ---\n';
+ body += '>>> START BASE64 >>>\n';
+ body += photo.data + '\n';
+ body += '<<< EINDE BASE64 <<<\n\n';
+ });
+ } else {
+ body += 'Geen foto\'s toegevoegd aan dit formulier.\n';
+ }
const mailto = 'mailto:' + encodeURIComponent(CONFIG.export.mailto.to) +
'?subject=' + encodeURIComponent(subject) +
@@ -1101,6 +1135,12 @@ input.invalid, select.invalid, textarea.invalid {
button.disabled = false;
}
+ // Check if mailto URL is too long (most clients support ~2000 chars)
+ if (mailto.length > 100000) {
+ showToast('Email te groot door foto. Gebruik CSV export.', 'error');
+ return;
+ }
+
window.location.href = mailto;
}, 50);
};
diff --git a/src/templates.py b/src/templates.py
index 13f2e67..2ff1bde 100644
--- a/src/templates.py
+++ b/src/templates.py
@@ -1327,18 +1327,52 @@ JAVASCRIPT = """
body += 'Versie: ' + CONFIG.version + '\\n';
body += 'Datum: ' + formatDateTime(new Date()) + '\\n\\n';
+ // Collect photos separately
+ const photos = [];
+
Object.entries(data).forEach(([key, value]) => {
- if (value && value !== '' && !key.includes('foto') && !key.includes('photo')) {
- const label = document.querySelector(`label[for="${key}"]`);
- const labelText = label ? label.textContent.replace('*', '').trim() : key;
- const displayValue = Array.isArray(value) ? value.join(', ') : value;
- body += labelText + ': ' + displayValue + '\\n';
+ if (value && value !== '') {
+ // Check if this is a photo (base64 image)
+ if (typeof value === 'string' && value.startsWith('data:image/')) {
+ const label = document.querySelector(`label[for="${key}"]`);
+ const labelText = label ? label.textContent.replace('*', '').trim() : key;
+ // Extract extension from data URL (e.g., data:image/jpeg;base64,...)
+ const mimeMatch = value.match(/data:image\\/([a-z]+);/);
+ const ext = mimeMatch ? mimeMatch[1] : 'jpg';
+ photos.push({
+ name: labelText,
+ extension: ext,
+ data: value
+ });
+ } else {
+ const label = document.querySelector(`label[for="${key}"]`);
+ const labelText = label ? label.textContent.replace('*', '').trim() : key;
+ const displayValue = Array.isArray(value) ? value.join(', ') : value;
+ body += labelText + ': ' + displayValue + '\\n';
+ }
}
});
body += '\\n========================\\n';
- body += 'Let op: Foto\\'s kunnen niet via mailto worden verzonden.\\n';
- body += 'Gebruik CSV export voor complete data inclusief foto\\'s.';
+
+ // Add photos section if there are any
+ if (photos.length > 0) {
+ body += '\\nFOTO BIJLAGEN (BASE64)\\n';
+ body += '========================\\n';
+ body += 'Onderstaande foto\\'s zijn gecodeerd in base64 formaat.\\n';
+ body += 'Kopieer de tekst tussen START en EINDE naar een base64 decoder\\n';
+ body += 'of gebruik een online tool zoals base64-image.de\\n\\n';
+
+ photos.forEach((photo, index) => {
+ const filename = photo.name.replace(/[^a-zA-Z0-9]/g, '_') + '.' + photo.extension;
+ body += '--- FOTO ' + (index + 1) + ': ' + filename + ' ---\\n';
+ body += '>>> START BASE64 >>>\\n';
+ body += photo.data + '\\n';
+ body += '<<< EINDE BASE64 <<<\\n\\n';
+ });
+ } else {
+ body += 'Geen foto\\'s toegevoegd aan dit formulier.\\n';
+ }
const mailto = 'mailto:' + encodeURIComponent(CONFIG.export.mailto.to) +
'?subject=' + encodeURIComponent(subject) +
@@ -1350,6 +1384,12 @@ JAVASCRIPT = """
button.disabled = false;
}
+ // Check if mailto URL is too long (most clients support ~2000 chars)
+ if (mailto.length > 100000) {
+ showToast('Email te groot door foto. Gebruik CSV export.', 'error');
+ return;
+ }
+
window.location.href = mailto;
}, 50);
};