Work on general clean up. Better export and email of sponsor data

This commit is contained in:
Scott Idem
2024-05-03 17:07:08 -04:00
parent a3a32e188d
commit f72d7be5b2
11 changed files with 984 additions and 5 deletions

View File

@@ -182,6 +182,15 @@ async function handle_load_ae_obj_li__sponsorship({account_id, try_cache=true})
if ($ae_loc.administrator_access) {
enabled = 'all';
hidden = 'all';
limit = 150;
} else if ($ae_loc.trusted_access) {
enabled = 'enabled';
hidden = 'not_hidden';
limit = 100;
} else {
enabled = 'enabled';
hidden = 'not_hidden';
limit = 25;
}
// let enabled = $ae_loc.mod.sponsorships.enabled;
@@ -364,6 +373,57 @@ async function handle_load_ae_obj_id__sponsorship({sponsorship_id, try_cache=fal
return ae_sponsorship_obj_get_promise;
}
function send_guest_list_email() {
let guest_li_html_table: string;
if ($slct.sponsorship_obj_li && $slct.sponsorship_obj_li.length > 0) {
guest_li_html_table = '<table style="border: thin solid black; border-collapse: collapse; width: 100%;">';
guest_li_html_table += '<tr style="border: thin solid black"><th>Sponsor</th><th>Name</th><th>Title</th><th>Affiliations</th><th>ADA</th><th>Dietary</th><th>Comments</th></tr>';
for (let i = 0; i < $slct.sponsorship_obj_li.length; i++) {
if ($slct.sponsorship_obj_li[i].guest_li_json && $slct.sponsorship_obj_li[i].guest_li_json.length > 0) {
for (let j = 0; j < $slct.sponsorship_obj_li[i].guest_li_json.length; j++) {
guest_li_html_table += '<tr style="border: thin solid black">';
guest_li_html_table += `<td>${$slct.sponsorship_obj_li[i].name} (lvl ${$slct.sponsorship_obj_li[i].level_num})</td>`;
guest_li_html_table += `<td>${$slct.sponsorship_obj_li[i].guest_li_json[j].full_name}</td>`;
guest_li_html_table += `<td>${$slct.sponsorship_obj_li[i].guest_li_json[j].title ?? ''}</td>`;
guest_li_html_table += `<td>${$slct.sponsorship_obj_li[i].guest_li_json[j].affiliations ?? ''}</td>`;
guest_li_html_table += `<td>${$slct.sponsorship_obj_li[i].guest_li_json[j].ada ? `ADA: ${$slct.sponsorship_obj_li[i].guest_li_json[j].ada}` : ''}</td>`;
guest_li_html_table += `<td>${$slct.sponsorship_obj_li[i].guest_li_json[j].dietary ? `Dietary: ${$slct.sponsorship_obj_li[i].guest_li_json[j].dietary}` : ''}</td>`;
guest_li_html_table += `<td>${$slct.sponsorship_obj_li[i].guest_li_json[j].comments ? `Comments: ${$slct.sponsorship_obj_li[i].guest_li_json[j].comments}` : ''}</td>`;
guest_li_html_table += '</tr>';
}
}
// let guest_html_table_row = '<tr>';
// guest_html_table_row += `<td>${$slct.sponsorship_obj_li[i].full_name}</td>`;
// guest_html_table_row += `<td>${$slct.sponsorship_obj_li[i].title ?? ''}</td>`;
// guest_html_table_row += `<td>${$slct.sponsorship_obj_li[i].affiliations ?? ''}</td>`;
// guest_html_table_row += `<td>${$slct.sponsorship_obj_li[i].ada ? `ADA: ${$slct.sponsorship_obj_li[i].ada}` : ''}</td>`;
// guest_html_table_row += `<td>${$slct.sponsorship_obj_li[i].dietary ? `Dietary: ${$slct.sponsorship_obj_li[i].dietary}` : ''}</td>`;
// guest_html_table_row += `<td>${$slct.sponsorship_obj_li[i].comments ? `Comments: ${$slct.sponsorship_obj_li[i].comments}` : ''}</td>`;
}
guest_li_html_table += '</table>';
}
console.log('Guest List HTML Table:', guest_li_html_table);
let subject = `CHOW 2024 Sponsor Hub Sponsors List`;
let body_html = `
<p>The complete guest list is below in a table format.</p>
${guest_li_html_table ? `<div><strong>Guests:</strong></br>${guest_li_html_table}</div>` : '<div>Guests: -- No Guests Added --</div>'}
`;
api.send_email({
api_cfg: $ae_api,
from_email: 'noreply+chow@oneskyit.com',
from_name: 'CHOW 2024 Sponsor Hub',
to_email: $ae_loc.user_email,
subject: subject,
body_html: body_html,
});
}
</script>
@@ -426,6 +486,25 @@ async function handle_load_ae_obj_id__sponsorship({sponsorship_id, try_cache=fal
{/await}
<span class="fas fa-download mx-1"></span> Export Data
</button>
<button
class="btn btn-sm variant-ghost-primary w-48 mb-1 email_data_btn"
on:click={() => {
if (!confirm(`Are you sure you want to send this email? To: ${$ae_loc.user_email}?`)) {return false;}
// Question pop up to change the email address
$ae_loc.user_email = prompt('Enter the email address to send the guest list to:', $ae_loc.user_email);
if (!$ae_loc.user_email) {
return false;
}
send_guest_list_email();
}}
>
<span class="fas fa-paper-plane mx-1"></span>
Email With Guest List
</button>
{/if}
</section>

View File

@@ -280,7 +280,13 @@ $: if ($slct.sponsorship_obj) {
<!-- Contact: -->
</span>
{$slct.sponsorship_obj.guest_li_json[index].full_name}
{#if $slct.sponsorship_obj.guest_li_json[index].email}
&mdash;
{$slct.sponsorship_obj.guest_li_json[index].title ?? ''}
{$slct.sponsorship_obj.guest_li_json[index].affiliations ?? ''}
{$slct.sponsorship_obj.guest_li_json[index].ada ? `ADA: ${$slct.sponsorship_obj.guest_li_json[index].ada}` : ''}
{$slct.sponsorship_obj.guest_li_json[index].dietary ? `Dietary: ${$slct.sponsorship_obj.guest_li_json[index].dietary}` : ''}
{$slct.sponsorship_obj.guest_li_json[index].comments ? `Comments: ${$slct.sponsorship_obj.guest_li_json[index].comments}` : ''}
<!-- {#if $slct.sponsorship_obj.guest_li_json[index].email}
| <a href="mailto:{$slct.sponsorship_obj.guest_li_json[index].email}?Subject={$slct.sponsorship_obj.full_name}">{$slct.sponsorship_obj.guest_li_json[index].email}</a>
{/if}
{#if $slct.sponsorship_obj.guest_li_json[index].phone_mobile}
@@ -295,7 +301,7 @@ $: if ($slct.sponsorship_obj) {
<span class="ae_label">| Office:</span>
<a href="tel:{$slct.sponsorship_obj.guest_li_json[index].phone_office}">{$slct.sponsorship_obj.guest_li_json[index].phone_office}</a>
{/if}
{#if $slct.sponsorship_obj.guest_li_json[index].other_text}| {$slct.sponsorship_obj.guest_li_json[index].other_text}{/if}
{#if $slct.sponsorship_obj.guest_li_json[index].other_text}| {$slct.sponsorship_obj.guest_li_json[index].other_text}{/if} -->
</li>
{/each}
</ul>