diff --git a/src/components/orgs/OrgDetail.svelte b/src/components/orgs/OrgDetail.svelte index 3934110b..ea459cf0 100644 --- a/src/components/orgs/OrgDetail.svelte +++ b/src/components/orgs/OrgDetail.svelte @@ -24,7 +24,8 @@ $: isAddress1Valid = editable.address?.address1?.trim().length !== 0; $: iszipcodevalid = editable.address?.postalcode?.trim().length !== 0; $: iscityvalid = editable.address?.city?.trim().length !== 0; - + $: sponsoring_contracts_download_open = false; + const promise = RunnerOrganizationService.runnerOrganizationControllerGetOne( params.orgid ).then((value) => { @@ -54,6 +55,14 @@ }); let modal_open = false; let delete_org = {}; + document.addEventListener("click", function (e) { + if ( + e.target.parentNode.parentNode.id != "sponsoring:dropdown" && + e.target.parentNode.parentNode.id != "sponsoring:dropdown:menu" + ) { + sponsoring_contracts_download_open = false; + } + }); function deleteOrganization() { RunnerOrganizationService.runnerOrganizationControllerRemove( original_object.id, @@ -100,6 +109,55 @@ } } export let import_modal_open = false; + async function generateSponsoringContract(locale) { + sponsoring_contracts_download_open = false; + const runners = await RunnerOrganizationService.runnerOrganizationControllerGetRunners( + original_object.id + ); + const toast = Toastify({ + text: $_("generating-pdf"), + duration: -1, + }).showToast(); + fetch( + `https://dev.lauf-fuer-kaya.de/documents/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_" + original_object.name + ".pdf"; + document.body.appendChild(a); + a.click(); + a.remove(); + toast.hideToast(); + Toastify({ + text: $_("pdf-successfully-generated"), + duration: 3500, + backgroundColor: "linear-gradient(to right, #00b09b, #96c93d)", + }).showToast(); + }) + .catch((err) => {}); + } {original_object.name} - +
+
+ +
+ {#if sponsoring_contracts_download_open} +
+ +
+ {/if} +
{#if store.state.jwtinfo.userdetails.permissions.includes('RUNNER:IMPORT')} +
+
+ +
+ {#if sponsoring_contracts_download_open} +
+ +
+ {/if} +
{/if}
{ orgs = val; @@ -68,6 +77,59 @@ }) .catch((err) => {}); } + function generateSponsoringContract(locale) { + sponsoring_contracts_download_open = false; + const toast = Toastify({ + text: $_("generating-pdf"), + duration: -1, + }).showToast(); + fetch( + `https://dev.lauf-fuer-kaya.de/documents/contracts?locale=${locale}&download=true&key=${config.documentserver_key}`, + { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify([original_data_pdf]), + } + ) + .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 = + "Sponsoring_" + + original_data.firstname + + (original_data.middlename || "") + + original_data.lastname + + ".pdf"; + document.body.appendChild(a); + a.click(); + a.remove(); + toast.hideToast(); + Toastify({ + text: $_("pdf-successfully-generated"), + duration: 3500, + backgroundColor: "linear-gradient(to right, #00b09b, #96c93d)", + }).showToast(); + }) + .catch((err) => { + console.error(err); + }); + } {#await runner_promise} @@ -132,58 +194,54 @@ }} class="w-full justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-blue-400 text-base font-medium text-white sm:w-auto sm:text-sm">{$_('cancel')} {/if} - +
+
+ +
+ {#if sponsoring_contracts_download_open} +
+ +
+ {/if} +
{#if !delete_triggered}
{#if current_runners.some((r) => r.is_selected === true)} - +
+
+ +
+ {#if sponsoring_contracts_download_open} +
+ +
+ {/if} +
{/if}
{ contacts = val; }); + document.addEventListener("click", function (e) { + if ( + e.target.parentNode.parentNode.id != "sponsoring:dropdown" && + e.target.parentNode.parentNode.id != "sponsoring:dropdown:menu" + ) { + sponsoring_contracts_download_open = false; + } + }); function deleteTeam() { RunnerTeamService.runnerTeamControllerRemove(original.id, false) .then((resp) => { @@ -82,6 +91,55 @@ .catch((err) => {}); } } + async function generateSponsoringContract(locale) { + sponsoring_contracts_download_open = false; + const runners = await RunnerTeamService.runnerTeamControllerGetRunners( + teamdata.id + ); + const toast = Toastify({ + text: $_("generating-pdf"), + duration: -1, + }).showToast(); + fetch( + `https://dev.lauf-fuer-kaya.de/documents/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_" + teamdata.name + ".pdf"; + document.body.appendChild(a); + a.click(); + a.remove(); + toast.hideToast(); + Toastify({ + text: $_("pdf-successfully-generated"), + duration: 3500, + backgroundColor: "linear-gradient(to right, #00b09b, #96c93d)", + }).showToast(); + }) + .catch((err) => {}); + } {original.name} - +
+
+ +
+ {#if sponsoring_contracts_download_open} +
+ +
+ {/if} +
{#if store.state.jwtinfo.userdetails.permissions.includes('RUNNER:IMPORT')}
- +