function genCvr(selected, errordel) { var output = new Array(); if (parent.$('#schAttach').is(":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 (parent.$('#wsAttach').is(":checked") || outputMode == "pdf") { console.log('ws started') var x = parent.$('#itemList').text() console.log(x) $.post(ROOT_URL + '/includes/master/report_functions.php', { FUNCTION: 'detectPWS', items: x, client: '', tenant: TENANT_URL }, function(ret) { var files = ret.split('|'); $.each(files, function(key, value) { if (value != '') { const { length } = output; const id = length + 1; 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') } else {} } }); $('#delivery').css('display', 'block'); var outputString = JSON.stringify(output); // alert("A" + outputString) //genMasterPDF() $('#mailerContainer').load(ROOT_URL + '/includes/master/deliveryMailer.php?attachments=' + outputString + '&clientnumber=&tenant=