|
function uploadStatus() { |
|
$("#invoiceModal").modal("hide"); |
|
var doc = new jsPDF(); |
|
|
|
//From Javascript |
|
var finalY = doc.lastAutoTable.finalY || 10; |
|
doc.text("Millestone Payment Invoice", 14, finalY + 15); |
|
doc.autoTable({ |
|
startY: finalY + 20, |
|
head: [["Millestone", "Amount", "Date uploaded", "Uploaded by", "Status"]], |
|
body: [ |
|
[`${tskName}`, `${tskCost}`, `${dateNow}`, `${user}`, `${tskStatus}`], |
|
], |
|
}); |
|
let blob = doc.output("blob"); |
|
|
|
var arrayBuffer; |
|
var fileReader = new FileReader(); |
|
|
|
//tskName = tskName.replace(/%/g, ""); |
|
fileReader.onload = function () { |
|
arrayBuffer = this.result; |
|
$.ajax({ |
|
url: |
|
_spPageContextInfo.webAbsoluteUrl + |
|
`/_api/web/getfolderbyserverrelativeurl('Invoices')/Files/add(overwrite=true, url='${tskName}.pdf')`, |
|
type: "POST", |
|
data: arrayBuffer, |
|
processData: false, |
|
headers: { |
|
Accept: "application/json; odata=verbose", |
|
"content-type": "application/json; odata=verbose", |
|
"X-RequestDigest": $("#__REQUESTDIGEST").val(), |
|
"content-length": arrayBuffer.byteLength, |
|
}, |
|
success: function (data, textStatus, jqXHR) { |
|
console.log( |
|
"successHandler " + "textstatus:" + textStatus + "data: " + data |
|
); |
|
}, |
|
error: function (xhr, ajaxOptions, thrownError) { |
|
console.log( |
|
"Request failed: " + |
|
xhr.status + |
|
"\n" + |
|
thrownError + |
|
"\n" + |
|
xhr.responseText |
|
); |
|
}, |
|
}); |
|
}; |
|
fileReader.readAsArrayBuffer(blob); |
|
} |