parent
ac586fec5a
commit
01d2a7e6aa
@ -92,11 +92,12 @@
|
||||
text: $_("generating-pdf"),
|
||||
duration: -1,
|
||||
}).showToast();
|
||||
let count_orgs =0;
|
||||
for (const o of generate_orgs) {
|
||||
const runners = await RunnerOrganizationService.runnerOrganizationControllerGetRunners(
|
||||
o.id
|
||||
);
|
||||
fetch(
|
||||
count_orgs++;
|
||||
let count = 0;
|
||||
let runners = await RunnerOrganizationService.runnerOrganizationControllerGetRunners(o.id, true)
|
||||
await fetch(
|
||||
`${config.baseurl_documentserver}/contracts?locale=${locale}&download=true&key=${config.documentserver_key}`,
|
||||
{
|
||||
method: "POST",
|
||||
@ -106,39 +107,87 @@
|
||||
body: JSON.stringify(runners),
|
||||
}
|
||||
)
|
||||
.then((response) => {
|
||||
if (response.status != "200") {
|
||||
toast.hideToast();
|
||||
Toastify({
|
||||
text: $_("pdf-generation-failed"),
|
||||
duration: 3500,
|
||||
backgroundColor:
|
||||
"linear-gradient(90deg, hsla(281, 37%, 45%, 1) 0%, hsla(1, 62%, 48%, 1) 100%)",
|
||||
}).showToast();
|
||||
} else {
|
||||
return response.blob();
|
||||
}
|
||||
})
|
||||
.then((blob) => {
|
||||
count++;
|
||||
const url = window.URL.createObjectURL(blob);
|
||||
let a = document.createElement("a");
|
||||
a.href = url;
|
||||
a.download = `${$_('sponsorings')}_${o.name}-${locale}.pdf`;
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
a.remove();
|
||||
if (count === generate_orgs.length) {
|
||||
toast.hideToast();
|
||||
Toastify({
|
||||
text: $_("pdfs-successfully-generated"),
|
||||
duration: 3500,
|
||||
backgroundColor:
|
||||
"linear-gradient(to right, #00b09b, #96c93d)",
|
||||
}).showToast();
|
||||
}
|
||||
})
|
||||
.catch((err) => {});
|
||||
.then((response) => {
|
||||
if (response.status != "200") {
|
||||
toast.hideToast();
|
||||
Toastify({
|
||||
text: $_("pdf-generation-failed"),
|
||||
duration: 3500,
|
||||
backgroundColor:
|
||||
"linear-gradient(90deg, hsla(281, 37%, 45%, 1) 0%, hsla(1, 62%, 48%, 1) 100%)",
|
||||
}).showToast();
|
||||
} else {
|
||||
return response.blob();
|
||||
}
|
||||
})
|
||||
.then((blob) => {
|
||||
const url = window.URL.createObjectURL(blob);
|
||||
let a = document.createElement("a");
|
||||
a.href = url;
|
||||
a.download = `${$_('sponsorings')}_${o.name}_direct-${locale}.pdf`;
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
a.remove();
|
||||
if (count === o.teams.length && count_orgs === generate_orgs.length) {
|
||||
toast.hideToast();
|
||||
console.log("here")
|
||||
Toastify({
|
||||
text: $_("pdfs-successfully-generated"),
|
||||
duration: 3500,
|
||||
backgroundColor:
|
||||
"linear-gradient(to right, #00b09b, #96c93d)",
|
||||
}).showToast();
|
||||
}
|
||||
})
|
||||
.catch((err) => {});
|
||||
for await (const t of o.teams) {
|
||||
count++;
|
||||
const runners = await RunnerTeamService.runnerTeamControllerGetRunners(
|
||||
t.id
|
||||
);
|
||||
await fetch(
|
||||
`${config.baseurl_documentserver}/contracts?locale=${locale}&download=true&key=${config.documentserver_key}`,
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(runners),
|
||||
}
|
||||
)
|
||||
.then((response) => {
|
||||
if (response.status != "200") {
|
||||
toast.hideToast();
|
||||
Toastify({
|
||||
text: $_("pdf-generation-failed"),
|
||||
duration: 3500,
|
||||
backgroundColor:
|
||||
"linear-gradient(90deg, hsla(281, 37%, 45%, 1) 0%, hsla(1, 62%, 48%, 1) 100%)",
|
||||
}).showToast();
|
||||
} else {
|
||||
return response.blob();
|
||||
}
|
||||
})
|
||||
.then((blob) => {
|
||||
const url = window.URL.createObjectURL(blob);
|
||||
let a = document.createElement("a");
|
||||
a.href = url;
|
||||
a.download = `${$_('sponsorings')}_${o.name}_${t.name}-${locale}.pdf`;
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
a.remove();
|
||||
if (count === o.teams.length && count_orgs === generate_orgs.length) {
|
||||
toast.hideToast();
|
||||
Toastify({
|
||||
text: $_("pdfs-successfully-generated"),
|
||||
duration: 3500,
|
||||
backgroundColor:
|
||||
"linear-gradient(to right, #00b09b, #96c93d)",
|
||||
}).showToast();
|
||||
}
|
||||
})
|
||||
.catch((err) => {});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user