(function (A, D, I) { function exportScores(fd, x) { var type = fd.type; x.push(''); for (var [nr, data] of Object.entries(fd.scores)) { var fNrs = (fd.photos[nr] || []).map(function (_, i) { return fd.orderNr + '_loc' + nr + '_foto' + (i + 1); }).join('; '); if (D.usesDwlBal(type)) { x.push('' + nr + '' + I.esc(data.dwl || '') + '' + I.esc(data.bal || '') + '' + I.esc(fNrs) + '' + I.esc(data.opm || '') + ''); } else if (type === D.TYPE_OVERWEG) { x.push('' + I.esc(data.locatie || '') + '' + I.esc(data.score || '') + ''); } else if (type === D.TYPE_SPOOR) { x.push('' + nr + '' + I.esc(data.kmVan || '') + '' + I.esc(data.kmTot || '') + '' + I.esc(data.lengte || '') + '' + I.esc(data.techJaar || '') + '' + I.esc(data.inspJaar || '') + '' + I.esc(data.score || '') + '' + I.esc(fNrs) + ''); } } x.push(''); } A.exportFormData = async function () { await A.saveCurrentForm(); var fd = A.state.formData; var x = ['', '
']; x.push('' + I.esc(fd.orderNr) + ''); x.push('' + I.esc(document.getElementById('inp_inspecteur').value) + ''); x.push('' + I.esc(document.getElementById('inp_inspectiedatum').value) + ''); x.push('' + I.esc(document.getElementById('inp_techjaar').value) + ''); x.push('' + I.esc(document.getElementById('inp_inspjaar').value) + ''); x.push('' + I.esc(document.getElementById('inp_opmerkingen').value) + ''); var hasOvPhotos = Object.values(fd.overviewPhotos).some(function (p) { return p.length > 0; }); if (hasOvPhotos) { x.push(''); for (var [pos, photos] of Object.entries(fd.overviewPhotos)) { photos.forEach(function (_, i) { x.push('' + I.esc(pos) + '' + I.esc(fd.orderNr.replace('/', '-')) + '_' + pos + '_foto' + (i + 1) + ''); }); } x.push(''); } exportScores(fd, x); x.push('
'); I.downloadBlob(new Blob([x.join('\n')], { type: 'application/xml' }), fd.orderNr.replace('/', '-') + '_inspectie_' + new Date().toISOString().slice(0, 10) + '.xml'); var pc = 0; for (var [nr, phs] of Object.entries(fd.photos)) { phs.forEach(function (p, i) { pc++; I.downloadBlob(p.blob, fd.orderNr.replace('/', '-') + '_loc' + nr + '_foto' + (i + 1) + '.jpg'); }); } for (var [pos2, phs2] of Object.entries(fd.overviewPhotos)) { phs2.forEach(function (p, i) { pc++; I.downloadBlob(p.blob, fd.orderNr.replace('/', '-') + '_' + pos2 + '_foto' + (i + 1) + '.jpg'); }); } alert('Opgeslagen!\n- 1 XML-bestand\n- ' + pc + ' foto(\'s)'); }; })(window.App.Application, window.App.Domain, window.App.Infrastructure);