From cdb313118575fae80541bcfebf54428e418de6ae Mon Sep 17 00:00:00 2001 From: florianfederspiel Date: Fri, 17 Jan 2025 11:53:25 +0100 Subject: [PATCH] Added E-Mail loading from Customer --- components/displayOpenBalances.vue | 2 +- composables/useFiles.js | 2 +- pages/email/new.vue | 10 +++++++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/components/displayOpenBalances.vue b/components/displayOpenBalances.vue index cc7c7d6..55771c6 100644 --- a/components/displayOpenBalances.vue +++ b/components/displayOpenBalances.vue @@ -6,7 +6,7 @@ let draftInvoicesSum = ref(0) let draftInvoicesCount = ref(0) let unallocatedStatements = ref(0) const setupPage = async () => { - let documents = (await useSupabaseSelect("createddocuments","*, statementallocations(*), customer(id,name)")).filter(i => i.type === "invoices" ||i.type === "advanceInvoices") + let documents = (await useSupabaseSelect("createddocuments","*, statementallocations(*), customer(id,name)")).filter(i => i.type === "invoices" ||i.type === "advanceInvoices").filter(i => !i.archived) let draftDocuments = documents.filter(i => i.state === "Entwurf") let finalizedDocuments = documents.filter(i => i.state === "Gebucht") diff --git a/composables/useFiles.js b/composables/useFiles.js index 41a34f1..a57ce5f 100644 --- a/composables/useFiles.js +++ b/composables/useFiles.js @@ -144,7 +144,7 @@ export const useFiles = () => { } else { data = (await supabase .from("files") - .select('*, incominginvoice(*), project(*), vendor(*), customer(*), contract(*), plant(*), createddocument(*), vehicle(*), product(*), profile(*), check(*), inventoryitem(*)') + .select('*, incominginvoice(*), project(*), vendor(*), customer(*), contract(*), plant(*), createddocument(*, customer(*)), vehicle(*), product(*), profile(*), check(*), inventoryitem(*)') .in("id",documentIds) .not("path","is",null) .not("archived","is",true) diff --git a/pages/email/new.vue b/pages/email/new.vue index 76c997a..87fb5f5 100644 --- a/pages/email/new.vue +++ b/pages/email/new.vue @@ -51,9 +51,17 @@ const setupPage = async () => { //console.log(loadedDocuments.value) if(loadedDocuments.value.length > 0) { + console.log(loadedDocuments.value[0]) emailData.value.subject = loadedDocuments.value[0].createddocument.title - emailData.value.to = loadedDocuments.value[0].createddocument.contact ? loadedDocuments.value[0].createddocument.contact.email : "" + if(loadedDocuments.value[0].createddocument.contact && loadedDocuments.value[0].createddocument.contact.email) { + console.log("Contact") + emailData.value.to = loadedDocuments.value[0].createddocument.contact.email + } else if(loadedDocuments.value[0].createddocument.customer && loadedDocuments.value[0].createddocument.customer.infoData.email) { + + + emailData.value.to = loadedDocuments.value[0].createddocument.customer.infoData.email + } } }