Better org pdf generation feature/130-org_doc_splitting #131
@ -216,15 +216,16 @@
|
|||||||
|
|
||||||
async function generateOrgCards(locale) {
|
async function generateOrgCards(locale) {
|
||||||
const toast = Toastify({
|
const toast = Toastify({
|
||||||
text: $_("generating-pdf"),
|
text: $_("generating-pdfs"),
|
||||||
duration: -1,
|
duration: -1,
|
||||||
}).showToast();
|
}).showToast();
|
||||||
let count = 0;
|
|
||||||
const current_cards = await RunnerCardService.runnerCardControllerGetAll();
|
const current_cards = await RunnerCardService.runnerCardControllerGetAll();
|
||||||
|
let count = 0;
|
||||||
|
let count_orgs =0;
|
||||||
for (const o of generate_orgs) {
|
for (const o of generate_orgs) {
|
||||||
const runners = await RunnerOrganizationService.runnerOrganizationControllerGetRunners(
|
count_orgs++;
|
||||||
o.id
|
let count = 0;
|
||||||
);
|
let runners = await RunnerOrganizationService.runnerOrganizationControllerGetRunners(o.id, true)
|
||||||
let cards = [];
|
let cards = [];
|
||||||
for (let runner of runners) {
|
for (let runner of runners) {
|
||||||
let card = current_cards.find((c) => c.runner?.id == runner.id);
|
let card = current_cards.find((c) => c.runner?.id == runner.id);
|
||||||
@ -235,7 +236,7 @@
|
|||||||
}
|
}
|
||||||
cards.push(card);
|
cards.push(card);
|
||||||
}
|
}
|
||||||
fetch(
|
await fetch(
|
||||||
`${config.baseurl_documentserver}/cards?locale=${locale}&download=true&key=${config.documentserver_key}`,
|
`${config.baseurl_documentserver}/cards?locale=${locale}&download=true&key=${config.documentserver_key}`,
|
||||||
{
|
{
|
||||||
method: "POST",
|
method: "POST",
|
||||||
@ -245,39 +246,97 @@
|
|||||||
body: JSON.stringify(cards),
|
body: JSON.stringify(cards),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
if (response.status != "200") {
|
if (response.status != "200") {
|
||||||
toast.hideToast();
|
toast.hideToast();
|
||||||
Toastify({
|
Toastify({
|
||||||
text: $_("pdf-generation-failed"),
|
text: $_("pdf-generation-failed"),
|
||||||
duration: 3500,
|
duration: 3500,
|
||||||
backgroundColor:
|
backgroundColor:
|
||||||
"linear-gradient(90deg, hsla(281, 37%, 45%, 1) 0%, hsla(1, 62%, 48%, 1) 100%)",
|
"linear-gradient(90deg, hsla(281, 37%, 45%, 1) 0%, hsla(1, 62%, 48%, 1) 100%)",
|
||||||
}).showToast();
|
}).showToast();
|
||||||
} else {
|
} else {
|
||||||
return response.blob();
|
return response.blob();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.then((blob) => {
|
.then((blob) => {
|
||||||
count++;
|
const url = window.URL.createObjectURL(blob);
|
||||||
const url = window.URL.createObjectURL(blob);
|
let a = document.createElement("a");
|
||||||
let a = document.createElement("a");
|
a.href = url;
|
||||||
a.href = url;
|
a.download = `${$_('runnercards')}_${o.name}_direct-${locale}.pdf`;
|
||||||
a.download = `${$_('runnercards')}_${o.name}-${locale}.pdf`;
|
document.body.appendChild(a);
|
||||||
document.body.appendChild(a);
|
a.click();
|
||||||
a.click();
|
a.remove();
|
||||||
a.remove();
|
if (count === o.teams.length && count_orgs === generate_orgs.length) {
|
||||||
if (count === generate_orgs.length) {
|
toast.hideToast();
|
||||||
toast.hideToast();
|
console.log("here")
|
||||||
Toastify({
|
Toastify({
|
||||||
text: $_("pdfs-successfully-generated"),
|
text: $_("pdfs-successfully-generated"),
|
||||||
duration: 3500,
|
duration: 3500,
|
||||||
backgroundColor:
|
backgroundColor:
|
||||||
"linear-gradient(to right, #00b09b, #96c93d)",
|
"linear-gradient(to right, #00b09b, #96c93d)",
|
||||||
}).showToast();
|
}).showToast();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((err) => {});
|
.catch((err) => {});
|
||||||
|
for await (const t of o.teams) {
|
||||||
|
count++;
|
||||||
|
let runners = await RunnerTeamService.runnerTeamControllerGetRunners(
|
||||||
|
t.id
|
||||||
|
);
|
||||||
|
let cards = [];
|
||||||
|
for (let runner of runners) {
|
||||||
|
let card = current_cards.find((c) => c.runner?.id == runner.id);
|
||||||
|
if (!card) {
|
||||||
|
card = await RunnerCardService.runnerCardControllerPost({
|
||||||
|
runner: runner.id,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
cards.push(card);
|
||||||
|
}
|
||||||
|
await fetch(
|
||||||
|
`${config.baseurl_documentserver}/cards?locale=${locale}&download=true&key=${config.documentserver_key}`,
|
||||||
|
{
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
body: JSON.stringify(cards),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.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 = `${$_('runnercards')}_${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) => {});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
text: $_("generating-pdf"),
|
text: $_("generating-pdf"),
|
||||||
duration: -1,
|
duration: -1,
|
||||||
}).showToast();
|
}).showToast();
|
||||||
const current_donations = await DonationService.donationControllerGetAll();
|
const current_donations = (await DonationService.donationControllerGetAll()) || [];
|
||||||
let certificateRunners = [];
|
let certificateRunners = [];
|
||||||
for (let runner of generate_runners) {
|
for (let runner of generate_runners) {
|
||||||
runner.distanceDonations = current_donations.find((d) => d.runner?.id == runner.id) || [];
|
runner.distanceDonations = current_donations.find((d) => d.runner?.id == runner.id) || [];
|
||||||
@ -96,7 +96,7 @@
|
|||||||
duration: -1,
|
duration: -1,
|
||||||
}).showToast();
|
}).showToast();
|
||||||
let count = 0;
|
let count = 0;
|
||||||
const current_donations = await DonationService.donationControllerGetAll();
|
const current_donations = (await DonationService.donationControllerGetAll()) || [];
|
||||||
for (const t of generate_teams) {
|
for (const t of generate_teams) {
|
||||||
const runners = await RunnerTeamService.runnerTeamControllerGetRunners(
|
const runners = await RunnerTeamService.runnerTeamControllerGetRunners(
|
||||||
t.id
|
t.id
|
||||||
@ -154,21 +154,22 @@
|
|||||||
|
|
||||||
async function generateOrgCertificates(locale) {
|
async function generateOrgCertificates(locale) {
|
||||||
const toast = Toastify({
|
const toast = Toastify({
|
||||||
text: $_("generating-pdf"),
|
text: $_("generating-pdfs"),
|
||||||
duration: -1,
|
duration: -1,
|
||||||
}).showToast();
|
}).showToast();
|
||||||
|
const current_donations = (await DonationService.donationControllerGetAll()) || [];
|
||||||
let count = 0;
|
let count = 0;
|
||||||
const current_donations = await DonationService.donationControllerGetAll();
|
let count_orgs =0;
|
||||||
for (const o of generate_orgs) {
|
for (const o of generate_orgs) {
|
||||||
const runners = await RunnerOrganizationService.runnerOrganizationControllerGetRunners(
|
count_orgs++;
|
||||||
o.id
|
let count = 0;
|
||||||
);
|
let runners = await RunnerOrganizationService.runnerOrganizationControllerGetRunners(o.id, true)
|
||||||
let certificateRunners = [];
|
let certificateRunners = [];
|
||||||
for (let runner of runners) {
|
for (let runner of runners) {
|
||||||
runner.distanceDonations = current_donations.find((d) => d.runner?.id == runner.id) || [];
|
runner.distanceDonations = current_donations.find((d) => d.runner?.id == runner.id) || [];
|
||||||
certificateRunners.push(runner);
|
certificateRunners.push(runner);
|
||||||
}
|
}
|
||||||
fetch(
|
await fetch(
|
||||||
`${config.baseurl_documentserver}/certificates?locale=${locale}&download=true&key=${config.documentserver_key}`,
|
`${config.baseurl_documentserver}/certificates?locale=${locale}&download=true&key=${config.documentserver_key}`,
|
||||||
{
|
{
|
||||||
method: "POST",
|
method: "POST",
|
||||||
@ -178,39 +179,92 @@
|
|||||||
body: JSON.stringify(certificateRunners),
|
body: JSON.stringify(certificateRunners),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
if (response.status != "200") {
|
if (response.status != "200") {
|
||||||
toast.hideToast();
|
toast.hideToast();
|
||||||
Toastify({
|
Toastify({
|
||||||
text: $_("pdf-generation-failed"),
|
text: $_("pdf-generation-failed"),
|
||||||
duration: 3500,
|
duration: 3500,
|
||||||
backgroundColor:
|
backgroundColor:
|
||||||
"linear-gradient(90deg, hsla(281, 37%, 45%, 1) 0%, hsla(1, 62%, 48%, 1) 100%)",
|
"linear-gradient(90deg, hsla(281, 37%, 45%, 1) 0%, hsla(1, 62%, 48%, 1) 100%)",
|
||||||
}).showToast();
|
}).showToast();
|
||||||
} else {
|
} else {
|
||||||
return response.blob();
|
return response.blob();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.then((blob) => {
|
.then((blob) => {
|
||||||
count++;
|
const url = window.URL.createObjectURL(blob);
|
||||||
const url = window.URL.createObjectURL(blob);
|
let a = document.createElement("a");
|
||||||
let a = document.createElement("a");
|
a.href = url;
|
||||||
a.href = url;
|
a.download = `${$_('certificates')}_${o.name}_direct-${locale}.pdf`;
|
||||||
a.download = `${$_('certificates')}_${o.name}-${locale}.pdf`;
|
document.body.appendChild(a);
|
||||||
document.body.appendChild(a);
|
a.click();
|
||||||
a.click();
|
a.remove();
|
||||||
a.remove();
|
if (count === o.teams.length && count_orgs === generate_orgs.length) {
|
||||||
if (count === generate_orgs.length) {
|
toast.hideToast();
|
||||||
toast.hideToast();
|
console.log("here")
|
||||||
Toastify({
|
Toastify({
|
||||||
text: $_("pdfs-successfully-generated"),
|
text: $_("pdfs-successfully-generated"),
|
||||||
duration: 3500,
|
duration: 3500,
|
||||||
backgroundColor:
|
backgroundColor:
|
||||||
"linear-gradient(to right, #00b09b, #96c93d)",
|
"linear-gradient(to right, #00b09b, #96c93d)",
|
||||||
}).showToast();
|
}).showToast();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((err) => {});
|
.catch((err) => {});
|
||||||
|
for await (const t of o.teams) {
|
||||||
|
count++;
|
||||||
|
let runners = await RunnerTeamService.runnerTeamControllerGetRunners(
|
||||||
|
t.id
|
||||||
|
);
|
||||||
|
let certificateRunners = [];
|
||||||
|
for (let runner of runners) {
|
||||||
|
runner.distanceDonations = current_donations.find((d) => d.runner?.id == runner.id) || [];
|
||||||
|
certificateRunners.push(runner);
|
||||||
|
}
|
||||||
|
await fetch(
|
||||||
|
`${config.baseurl_documentserver}/certificates?locale=${locale}&download=true&key=${config.documentserver_key}`,
|
||||||
|
{
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
body: JSON.stringify(certificateRunners),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.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 = `${$_('certificates')}_${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) => {});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -92,11 +92,12 @@
|
|||||||
text: $_("generating-pdf"),
|
text: $_("generating-pdf"),
|
||||||
duration: -1,
|
duration: -1,
|
||||||
}).showToast();
|
}).showToast();
|
||||||
|
let count_orgs =0;
|
||||||
for (const o of generate_orgs) {
|
for (const o of generate_orgs) {
|
||||||
const runners = await RunnerOrganizationService.runnerOrganizationControllerGetRunners(
|
count_orgs++;
|
||||||
o.id
|
let count = 0;
|
||||||
);
|
let runners = await RunnerOrganizationService.runnerOrganizationControllerGetRunners(o.id, true)
|
||||||
fetch(
|
await fetch(
|
||||||
`${config.baseurl_documentserver}/contracts?locale=${locale}&download=true&key=${config.documentserver_key}`,
|
`${config.baseurl_documentserver}/contracts?locale=${locale}&download=true&key=${config.documentserver_key}`,
|
||||||
{
|
{
|
||||||
method: "POST",
|
method: "POST",
|
||||||
@ -106,39 +107,87 @@
|
|||||||
body: JSON.stringify(runners),
|
body: JSON.stringify(runners),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
if (response.status != "200") {
|
if (response.status != "200") {
|
||||||
toast.hideToast();
|
toast.hideToast();
|
||||||
Toastify({
|
Toastify({
|
||||||
text: $_("pdf-generation-failed"),
|
text: $_("pdf-generation-failed"),
|
||||||
duration: 3500,
|
duration: 3500,
|
||||||
backgroundColor:
|
backgroundColor:
|
||||||
"linear-gradient(90deg, hsla(281, 37%, 45%, 1) 0%, hsla(1, 62%, 48%, 1) 100%)",
|
"linear-gradient(90deg, hsla(281, 37%, 45%, 1) 0%, hsla(1, 62%, 48%, 1) 100%)",
|
||||||
}).showToast();
|
}).showToast();
|
||||||
} else {
|
} else {
|
||||||
return response.blob();
|
return response.blob();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.then((blob) => {
|
.then((blob) => {
|
||||||
count++;
|
const url = window.URL.createObjectURL(blob);
|
||||||
const url = window.URL.createObjectURL(blob);
|
let a = document.createElement("a");
|
||||||
let a = document.createElement("a");
|
a.href = url;
|
||||||
a.href = url;
|
a.download = `${$_('sponsorings')}_${o.name}_direct-${locale}.pdf`;
|
||||||
a.download = `${$_('sponsorings')}_${o.name}-${locale}.pdf`;
|
document.body.appendChild(a);
|
||||||
document.body.appendChild(a);
|
a.click();
|
||||||
a.click();
|
a.remove();
|
||||||
a.remove();
|
if (count === o.teams.length && count_orgs === generate_orgs.length) {
|
||||||
if (count === generate_orgs.length) {
|
toast.hideToast();
|
||||||
toast.hideToast();
|
console.log("here")
|
||||||
Toastify({
|
Toastify({
|
||||||
text: $_("pdfs-successfully-generated"),
|
text: $_("pdfs-successfully-generated"),
|
||||||
duration: 3500,
|
duration: 3500,
|
||||||
backgroundColor:
|
backgroundColor:
|
||||||
"linear-gradient(to right, #00b09b, #96c93d)",
|
"linear-gradient(to right, #00b09b, #96c93d)",
|
||||||
}).showToast();
|
}).showToast();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((err) => {});
|
.catch((err) => {});
|
||||||
|
for await (const t of o.teams) {
|
||||||
|
count++;
|
||||||
|
let 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