getout
unknown
plain_text
2 years ago
2.7 kB
4
Indexable
function getDownloadOutstandBalance() {
let as_on_date1 = $("#as_on_date").val();
let client_code1 = $("#client_code").val();
let client_code
if (client_code1.indexOf("-") != -1) {
client_code = client_code1.substring(0, client_code1.indexOf("-"));
} else {
client_code = client_code1;
}
let report_name = $("#report_name").val();
let toastBtn = document.getElementById('checkToastValid')
let toastBtn_err = document.getElementById('checkToastValid-err')
let filter = document.querySelectorAll('input[name="filter[]"]:checked')
let filteredData = []
filter.forEach((item)=>{
filteredData.push(item.value)
})
console.log(filteredData);
if (!as_on_date1) {
$("#as_on_date_err").html("Please select From Date");
return false;
} else {
$("#as_on_date_err").html("");
}
let newas_on_date
if (as_on_date1) {
let as_on_daten = formatDate(as_on_date1);
let datearray1 = as_on_daten.split("/");
newas_on_date =
datearray1[1] + "/" + datearray1[0] + "/" + datearray1[2];
} else {
as_on_date1 = "";
}
let as_on_date = new Date(newas_on_date);
let formData = {
reportId: "64942290bc889dc5cb25e733",
client_code: client_code,
sent_format_type: "xlsx",
send_request_type: "download",
from_date: "",
to_date: "",
as_on_date: yyyymmdd(as_on_date),
client_type: "",
exchange_segment: "",
// filter:filteredData,
group_name: client_code,
};
console.log(formData)
$.ajax({
url: rep_download_local_url + 'api/MyGainn/PrintAddReports',
method: 'POST',
data: JSON.stringify(formData),
processData: false,
headers: {
Authorization: `Bearer ${sessionStorage.getItem("Gainn_Download")}`
},
contentType: 'application/json',
xhrFields: {
responseType: 'blob'
},
success: function (response, status, xhr) {
if (xhr.status === 200) {
let blob = new Blob([response]);
let downloadUrl = URL.createObjectURL(blob);
console.log(downloadUrl)
let a = document.createElement('a');
a.href = downloadUrl;
a.download = `${client_code}_${report_name}_${getTodayDate()}.xlsx`;
a.click();
URL.revokeObjectURL(downloadUrl);
toastBtn.click()
}
else {
console.log('Error downloading Excel file:', xhr.status);
toastBtn_err.click()
}
},
complete: function () {
$("#submitBtn").html("Submit");
$("#submitBtn").prop("disabled", false);
},
error: function (xhr, status, error) {
console.log('Error downloading Excel file:', error);
}
});
}Editor is loading...