email da inviare ai clienti ...
This commit is contained in:
@@ -10,14 +10,16 @@ import { useQuasar } from 'quasar'
|
||||
import { costanti } from '@costanti'
|
||||
import { shared_consts } from '@src/common/shared_vuejs'
|
||||
// import MixinBase from '@src/mixins/mixin-base'
|
||||
import { serv_constants } from '@store/Modules/serv_constants'
|
||||
import { fieldsTable } from '@store/Modules/fieldsTable'
|
||||
|
||||
import { CSingleCart } from '../../../components/CSingleCart'
|
||||
import { CTitleBanner } from '@components'
|
||||
import { CTitleBanner, CMyFieldDb } from '@components'
|
||||
import { ICart, IOrder, IOrderCart } from '@src/model'
|
||||
|
||||
export default defineComponent({
|
||||
name: 'OrderInfo',
|
||||
components: { CSingleCart, CTitleBanner },
|
||||
components: { CSingleCart, CTitleBanner, CMyFieldDb },
|
||||
props: {},
|
||||
setup() {
|
||||
const userStore = useUserStore()
|
||||
@@ -30,6 +32,7 @@ export default defineComponent({
|
||||
const myorderscart = ref(<IOrderCart[] | undefined>[])
|
||||
const myarrrec = ref(<any>{})
|
||||
const myoldrec = ref(<any>{})
|
||||
const templemail = ref('')
|
||||
|
||||
const cosa = ref(0)
|
||||
|
||||
@@ -48,6 +51,14 @@ export default defineComponent({
|
||||
const statusnow = ref(0)
|
||||
const arrnumstatus = ref(<any[]>[])
|
||||
const columns = ref(<any>[
|
||||
{
|
||||
name: 'apri',
|
||||
align: 'center',
|
||||
required: false,
|
||||
label: 'Apri',
|
||||
field: 'apri',
|
||||
sortable: false
|
||||
},
|
||||
{
|
||||
name: 'numorder',
|
||||
required: true,
|
||||
@@ -89,6 +100,14 @@ export default defineComponent({
|
||||
])
|
||||
|
||||
const columns_Admin = ref(<any>[
|
||||
{
|
||||
name: 'apri',
|
||||
align: 'center',
|
||||
required: false,
|
||||
label: 'Apri',
|
||||
field: 'apri',
|
||||
sortable: false
|
||||
},
|
||||
{
|
||||
name: 'numorder',
|
||||
required: true,
|
||||
@@ -146,7 +165,7 @@ export default defineComponent({
|
||||
])
|
||||
|
||||
watch(() => cosa.value, (newval, oldval) => {
|
||||
|
||||
|
||||
})
|
||||
|
||||
// const { setValDb, getValDb } = MixinBase()
|
||||
@@ -158,7 +177,7 @@ export default defineComponent({
|
||||
function getOrdersCart(): IOrderCart[] | undefined {
|
||||
const hasGasordine: any = (cosa.value === shared_consts.PROD.TUTTI) ? undefined : (cosa.value === shared_consts.PROD.GAS)
|
||||
const ris = productStore.getOrdersCart(taborders.value, hasGasordine)
|
||||
|
||||
|
||||
return ris
|
||||
}
|
||||
|
||||
@@ -170,9 +189,10 @@ export default defineComponent({
|
||||
const totals = {
|
||||
created_at: new Date(),
|
||||
items: null,
|
||||
user:{
|
||||
user: {
|
||||
name: 'TOTALI',
|
||||
surname: '',
|
||||
email: '',
|
||||
},
|
||||
status: 0,
|
||||
// Add other properties as needed
|
||||
@@ -227,6 +247,7 @@ export default defineComponent({
|
||||
|
||||
async function mounted() {
|
||||
|
||||
await userStore.newsletterload(false)
|
||||
await productStore.loadProducts()
|
||||
|
||||
taborders.value = -1
|
||||
@@ -312,6 +333,41 @@ export default defineComponent({
|
||||
})
|
||||
}
|
||||
|
||||
async function sendMailToAll() {
|
||||
const orders = getOrdersCartWithTotals()
|
||||
|
||||
let res = null
|
||||
let inviate = 0
|
||||
|
||||
for (const ord of orders) {
|
||||
res = await productStore.sendMailToTheBuyer(ord._id, templemail.value, false)
|
||||
if (res && res.emailsend)
|
||||
inviate++
|
||||
}
|
||||
|
||||
if (inviate > 0) {
|
||||
tools.showPositiveNotif($q, t('orderscart.email_sent', { inviate }))
|
||||
} else {
|
||||
tools.showNegativeNotif($q, t('orderscart.email_not_send'))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async function sendMailTest() {
|
||||
const orders = getOrdersCartWithTotals()
|
||||
|
||||
if (orders && orders.length > 0) {
|
||||
const res = await productStore.sendMailToTheBuyer(orders[0]._id, templemail.value, true)
|
||||
|
||||
if (res && res.emailsend) {
|
||||
tools.showPositiveNotif($q, t('reset.email_sent'))
|
||||
} else {
|
||||
tools.showNegativeNotif($q, t('orderscart.email_not_send'))
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
onMounted(mounted)
|
||||
|
||||
return {
|
||||
@@ -320,6 +376,7 @@ export default defineComponent({
|
||||
tools,
|
||||
toolsext,
|
||||
shared_consts,
|
||||
globalStore,
|
||||
columns,
|
||||
taborders,
|
||||
arrnumstatus,
|
||||
@@ -334,6 +391,10 @@ export default defineComponent({
|
||||
t,
|
||||
initialPagination,
|
||||
cosa,
|
||||
sendMailToAll,
|
||||
sendMailTest,
|
||||
templemail,
|
||||
fieldsTable,
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user