diff --git a/components/copyCreatedDocumentModal.vue b/components/copyCreatedDocumentModal.vue new file mode 100644 index 0000000..a06010a --- /dev/null +++ b/components/copyCreatedDocumentModal.vue @@ -0,0 +1,106 @@ + + + + + \ No newline at end of file diff --git a/pages/createDocument/edit/[[id]].vue b/pages/createDocument/edit/[[id]].vue index 5c8c292..f73a0a7 100644 --- a/pages/createDocument/edit/[[id]].vue +++ b/pages/createDocument/edit/[[id]].vue @@ -198,19 +198,60 @@ const setupPage = async () => { if(route.query.linkedDocument) { itemInfo.value.linkedDocument = route.query.linkedDocument - let linkedDocument = await useSupabaseSelectSingle("createddocuments",itemInfo.value.linkedDocument) - itemInfo.value.rows = linkedDocument.rows - itemInfo.value.customer = linkedDocument.customer - itemInfo.value.project = linkedDocument.project - itemInfo.value.contact = linkedDocument.contact - itemInfo.value.description = linkedDocument.description - itemInfo.value.deliveryDate = linkedDocument.deliveryDate - itemInfo.value.deliveryDateType = linkedDocument.deliveryDateType + + if(route.query.optionsToImport) { + //Import only true + let optionsToImport = JSON.parse(route.query.optionsToImport) + + console.log(optionsToImport) + console.log(linkedDocument) + + if(optionsToImport.taxType) itemInfo.value.taxType = linkedDocument.taxType + if(optionsToImport.customer) itemInfo.value.customer = linkedDocument.customer + if(optionsToImport.letterhead) itemInfo.value.letterhead = linkedDocument.letterhead + if(optionsToImport.contact) itemInfo.value.contact = linkedDocument.contact + if(optionsToImport.deliveryDateType) itemInfo.value.deliveryDateType = linkedDocument.deliveryDateType + if(optionsToImport.deliveryDate) itemInfo.value.deliveryDate = linkedDocument.deliveryDate + if(optionsToImport.deliveryDateEnd) itemInfo.value.deliveryDateEnd = linkedDocument.deliveryDateEnd + if(optionsToImport.documentDate) itemInfo.value.documentDate = linkedDocument.documentDate + if(optionsToImport.paymentDays) itemInfo.value.paymentDays = linkedDocument.paymentDays + if(optionsToImport.customSurchargePercentage) itemInfo.value.customSurchargePercentage = linkedDocument.customSurchargePercentage + if(optionsToImport.contactPerson) itemInfo.value.contactPerson = linkedDocument.contactPerson + if(optionsToImport.plant) itemInfo.value.plant = linkedDocument.plant + if(optionsToImport.project) itemInfo.value.project = linkedDocument.project + if(optionsToImport.title) itemInfo.value.title = linkedDocument.title + if(optionsToImport.description) itemInfo.value.description = linkedDocument.description + if(optionsToImport.startText) itemInfo.value.startText = linkedDocument.startText + if(optionsToImport.rows) itemInfo.value.rows = linkedDocument.rows + if(optionsToImport.endText) itemInfo.value.endText = linkedDocument.endText + + } else { + // Import all + + itemInfo.value.taxType = linkedDocument.taxType + itemInfo.value.customer = linkedDocument.customer + itemInfo.value.letterhead = linkedDocument.letterhead + itemInfo.value.contact = linkedDocument.contact + itemInfo.value.deliveryDateType = linkedDocument.deliveryDateType + itemInfo.value.deliveryDate = linkedDocument.deliveryDate + itemInfo.value.deliveryDateEnd = linkedDocument.deliveryDateEnd + itemInfo.value.documentDate = linkedDocument.documentDate + itemInfo.value.paymentDays = linkedDocument.paymentDays + itemInfo.value.customSurchargePercentage = linkedDocument.customSurchargePercentage + itemInfo.value.contactPerson = linkedDocument.contactPerson + itemInfo.value.plant = linkedDocument.plant + itemInfo.value.project = linkedDocument.project + itemInfo.value.title = linkedDocument.title + itemInfo.value.description = linkedDocument.description + itemInfo.value.startText = linkedDocument.startText + itemInfo.value.rows = linkedDocument.rows + itemInfo.value.endText = linkedDocument.endText + } - setCustomerData() + setCustomerData(null,true) if(route.query.loadMode === "storno") { itemInfo.value.rows.forEach(row => { @@ -323,7 +364,7 @@ const setTaxType = () => { } } -const setCustomerData = async (customerId) => { +const setCustomerData = async (customerId, loadOnlyAdress = false) => { if(customerId){ itemInfo.value.customer = customerId @@ -341,11 +382,11 @@ const setCustomerData = async (customerId) => { itemInfo.value.address.city = customer.infoData.city itemInfo.value.address.special = customer.infoData.special - if(customer.customPaymentDays) itemInfo.value.paymentDays = customer.customPaymentDays + if(!loadOnlyAdress && customer.customPaymentDays) itemInfo.value.paymentDays = customer.customPaymentDays - if(customer.customSurchargePercentage) itemInfo.value.customSurchargePercentage = customer.customSurchargePercentage + if(!loadOnlyAdress && customer.customSurchargePercentage) itemInfo.value.customSurchargePercentage = customer.customSurchargePercentage - if(contacts.value.filter(i => i.customer === itemInfo.value.customer).length === 1) { + if(!loadOnlyAdress && contacts.value.filter(i => i.customer === itemInfo.value.customer).length === 1) { itemInfo.value.contact = contacts.value.filter(i => i.customer === itemInfo.value.customer)[0].id } diff --git a/pages/createDocument/show/[id].vue b/pages/createDocument/show/[id].vue index c6064c9..200030a 100644 --- a/pages/createDocument/show/[id].vue +++ b/pages/createDocument/show/[id].vue @@ -1,4 +1,6 @@