function genCvr(selected, errordel) {console.log('cover gen') var output = []; if (document.getElementById('schAttach').checked) { output.push({ source: 'output/reports/', file: '_schedule.pdf', type: 'sch' }); } var str = selected.split('|'); output.push({ source: 'output/reports/', file: 'report_cover.pdf', type: 'rc' }); if (document.getElementById('wsAttach').checked || outputMode == "pdf") { console.log('ws started'); var x = document.getElementById('itemList').textContent; console.log(x); var xhr = new XMLHttpRequest(); xhr.open("POST", 'includes/master/report_functions.php', true); xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xhr.onreadystatechange = function () { if (xhr.readyState === 4 && xhr.status === 200) { var files = xhr.responseText.split('|'); files.forEach(function (value) { if (value !== '') { const found = output.some(el => el.file === value + '.pdf'); if (!found) { output.push({ source: 'output/wsfiles/', file: value + '.pdf', type: 'ws' }); console.log(value + ' added'); } } }); document.getElementById('delivery').style.display = 'block'; var outputString = JSON.stringify(output); var loadMailer = new XMLHttpRequest(); loadMailer.open("GET", ROOT_URL + '/includes/master/deliveryMailer.php?attachments=' + encodeURIComponent(outputString) + '&clientnumber=&tenant=' + encodeURIComponent(TENANT_URL), true); loadMailer.onload = function () { if (loadMailer.status === 200) { document.getElementById('mailerContainer').innerHTML = loadMailer.responseText; } }; loadMailer.send(); document.getElementById('loading').style.display = 'none'; } }; xhr.send('FUNCTION=detectPWS&items=' + encodeURIComponent(x) + '&client='); } else { document.getElementById('delivery').style.display = 'block'; var outputString = JSON.stringify(output); var loadMailer = new XMLHttpRequest(); loadMailer.open("GET", ROOT_URL + '/includes/master/deliveryMailer.php?attachments=' + encodeURIComponent(outputString) + '&clientnumber=&tenant=' + encodeURIComponent(TENANT_URL), true); loadMailer.onload = function () { if (loadMailer.status === 200) { document.getElementById('mailerContainer').innerHTML = loadMailer.responseText; } }; loadMailer.send(); document.getElementById('loading').style.display = 'none'; } }