Lista Doni Navi

This commit is contained in:
Paolo Arena
2020-03-21 10:33:10 +01:00
parent 3f6ffc973a
commit ad99211571
674 changed files with 1374 additions and 214 deletions

320
src/components/CMyNave/CMyNave.ts Normal file → Executable file
View File

@@ -9,9 +9,11 @@ import { CTitleBanner } from '../CTitleBanner'
import { UserStore } from '../../store/Modules'
import { lists } from '../../store/Modules/lists'
import translate from '../../globalroutines/util'
import { CMyChipList } from '../CMyChipList'
import { CVideo } from '../CVideo'
@Component({
components: { CTitleBanner },
components: { CTitleBanner, CMyChipList, CVideo },
})
export default class CMyNave extends MixinNave {
@@ -21,6 +23,7 @@ export default class CMyNave extends MixinNave {
public $t
public link_chat: string = ''
public cosa: string = 'tragitto'
public cosa2: string = 'donatore'
public nave: any = null
public numpercorso = 7
public riga: number = 1
@@ -28,6 +31,33 @@ export default class CMyNave extends MixinNave {
public rigadoni: number = 1
public coldoni: number = 1
public mediatore: any = {}
public donatore: any = {}
public iodonatore: any = {}
public iosognatore: any = {}
public donoinviato: boolean = false
public arrdonatori: any[] = []
public recsel = null
public MyPagination: {
sortBy: string,
descending: boolean,
page: number,
rowsNumber: number, // specifying this determines pagination is server-side
rowsPerPage: number
} = { sortBy: 'index', descending: false, page: 1, rowsNumber: 10, rowsPerPage: 10 }
public coldonatori: any[] = [
/*{
name: 'index',
required: true,
label: 'Num',
align: 'left',
field: 'index',
sortable: true
},*/
{ name: 'name', align: 'center', label: 'Nome', field: 'name', sortable: true },
{ name: 'surname', align: 'center', label: 'Cognome', field: 'surname', sortable: true },
{ name: 'date_made_gift', align: 'center', label: 'Inviato', field: 'date_made_gift', sortable: true },
{ name: 'made_gift', align: 'center', label: 'Confermato', field: 'made_gift', sortable: true },
]
public tragitto = [
{
@@ -84,15 +114,53 @@ export default class CMyNave extends MixinNave {
this.coldoni = tools.getValDb('coldoni', false, 1)
this.mediatore = this.getmediatore()
this.donatore = this.getdonatore()
this.iodonatore = this.getIoDonatore()
this.iosognatore = this.getIoSognatore()
this.donoinviato = this.getDonoInviato
// console.log('this.mediatore', this.mediatore)
// console.log('this.donatore', this.donatore)
if (!!this.mediatore) {
this.link_chat = this.mediatore.link_chat
}
this.arrdonatori = this.creaarrDonatori()
}
public getListaDonatoriDaConfermare() {
let mystr = ''
if (!!this.nave.listadonatoridelsognatore) {
if (this.nave.listadonatoridelsognatore.length > 0) {
for (const rec of this.nave.listadonatoridelsognatore) {
mystr += rec.name + ' ' + rec.surname + ' [' + rec.riga + '.' + rec.col + ']<br>'
}
}
}
return mystr
}
public creaarrDonatori() {
const arr = []
if (!!this.nave.listadonatoridelsognatore) {
if (this.nave.listadonatoridelsognatore.length > 0) {
let index = 0
for (const rec of this.nave.listadonatoridelsognatore) {
index++
arr.push({ index, ...rec})
}
}
}
return arr
}
public getNavePartByInd(ind) {
if (!!this.navi_partenza[ind])
return this.navi_partenza[ind].date_start
return tools.getstrshortDate(this.navi_partenza[ind].date_start)
else
return ' --/--/-- '
}
@@ -105,7 +173,7 @@ export default class CMyNave extends MixinNave {
}
public getColnave(col) {
let ris = Math.floor(col / (2 * 4))
let ris = Math.ceil(col / (2 * 4))
if (ris <= 1)
ris = 1
return ris
@@ -113,10 +181,10 @@ export default class CMyNave extends MixinNave {
public sonoMediatore() {
if (!!this.nave) {
if (!!this.nave.rec.donatore.recmediatore)
if (!!this.nave.rec.donatore)
return this.nave.rec.donatore.recmediatore.ind_order === this.nave.ind_order
else {
if (!!this.nave.rec.mediatore.recmediatore)
if (!!this.nave.rec.mediatore)
return this.nave.rec.mediatore.recmediatore.ind_order === this.nave.ind_order
}
}
@@ -124,40 +192,194 @@ export default class CMyNave extends MixinNave {
return false
}
public sonoDonatore() {
public partenza_primo_donatore() {
if (!!this.nave) {
for (const rec of this.nave.rec.donatore.arrdonatori) {
if (!!rec) {
if (rec.ind_order === this.nave.ind_order)
return true
if (!!this.nave.rec.mediatore) {
for (const rec of this.nave.rec.mediatore.arrdonatori) {
if (!!rec)
return rec.date_start
}
}
}
return ''
}
public getGiornoDelDono() {
if (!!this.nave) {
return tools.getstrDate(this.nave.date_start)
}
}
get GiornoDelDonoArrivato() {
if (!!this.nave) {
return tools.isDateArrived(this.nave.date_start)
}
return false
}
get FattoDono() {
if (!!this.iodonatore) {
return this.iodonatore.made_gift
}
return false
}
public getIoDonatore() {
if (!!this.nave) {
if (!!this.nave.rec.donatore) {
for (const rec of this.nave.rec.donatore.arrdonatori) {
if (!!rec) {
if (rec.ind_order === this.nave.ind_order)
return rec
}
}
}
}
return null
}
public getIoSognatore() {
const sognatore = this.sognatoredelDono()
if (!!sognatore) {
return sognatore.ind_order === this.nave.ind_order
}
return null
}
public sognatoredelDono() {
if (!!this.nave) {
if (!!this.nave.rec.donatore.recsognatori)
return this.nave.rec.donatore.recsognatori[0]
}
return null
}
public HoRicevutoIlDono(rec) {
this.recsel = rec
const msgtitle = this.$t('dashboard.dono_ricevuto_2')
const msginvia = this.$t('dashboard.confermi_dono_ricevuto', {
donatore: rec.name + ' ' + rec.surname
})
const mymsg = this.$t('dashboard.confermi_dono_ricevuto_msg', {
sognatore: this.sognatoredelDono().name + ' ' + this.sognatoredelDono().surname,
donatore: rec.name + ' ' + rec.surname
})
tools.askConfirm(this.$q, msgtitle, msginvia + ' ' + '?', translate('dialog.yes'), translate('dialog.no'), this, '', lists.MenuAction.DONO_RICEVUTO, 0, {
param1: {
_id: rec._id,
made_gift: true
},
param2: rec.username,
param3: mymsg
})
}
public HoEffettuatoIlDono() {
const msgtitle = translate('dashboard.confermi_dono')
const msginvia = msgtitle
const mymsg = this.$t('dashboard.msg_bot_conferma', {
donatore: this.iodonatore.name + ' ' + this.iodonatore.surname,
sognatore: this.sognatoredelDono().name + ' ' + this.sognatoredelDono().surname
})
tools.askConfirm(this.$q, msgtitle, msginvia + ' ' + '?', translate('dialog.yes'), translate('dialog.no'), this, '', lists.MenuAction.DONO_INVIATO, 0, {
param1: {
_id: this.iodonatore._id,
date_made_gift: tools.getDateNow()
},
param2: this.sognatoredelDono().username,
param3: mymsg
})
}
public ActionAfterYes(action, item, data) {
console.log('ActionAfterYes...')
if (action === lists.MenuAction.DONO_INVIATO) {
if (!!this.iodonatore) {
this.iodonatore.date_made_gift = tools.getDateNow()
this.donoinviato = true
console.log('date_made_gift', this.iodonatore.date_made_gift)
}
// this.refresh()
} else if (action === lists.MenuAction.DONO_RICEVUTO) {
if (!!this.recsel) {
this.recsel.made_gift = true
}
}
}
public getMetodoPagamentoSognatore() {
const rec = this.sognatoredelDono()
if (!!rec) {
try {
return rec.profile.paymenttypes
} catch (e) {
return ''
}
}
}
public getemailPagamentoSognatore() {
const rec = this.sognatoredelDono()
if (!!rec) {
if (!!rec.profile)
return rec.profile.email_paypal
}
return ''
}
get getDonoInviato() {
if (!!this.iodonatore) {
return !!this.iodonatore.date_made_gift
}
return false
}
public sonoDonatore() {
return !!this.iodonatore
}
public sonoSognatore() {
return !!this.iosognatore
}
public getmediatore() {
return this.nave.rec.donatore.recmediatore
if (!!this.nave.rec.mediatore)
return this.nave.rec.mediatore.recmediatore
return null
}
public getdonatore() {
if (!!this.nave.rec.donatore)
return this.nave.rec.donatore.recmediatore
return null
}
public change_link_chat() {
const recmed = this.getmediatore()
if (recmed.link_chat !== this.link_chat) {
recmed.link_chat = this.link_chat
if (!!recmed) {
if (recmed.link_chat !== this.link_chat) {
recmed.link_chat = this.link_chat
const mydata = {
link_chat: recmed.link_chat
const mydata = {
link_chat: recmed.link_chat
}
tools.saveFieldToServer(this, 'navi', recmed._id, mydata)
}
tools.saveFieldToServer(this, 'navi', recmed._id, mydata)
}
}
get linkchatopen() {
return this.link_chat
}
public sonoSognatore() {
return this.nave.rec.donatore.recsognatore.ind_order === this.nave.ind_order
return this.donatore.link_chat
}
public getclassSelect(rec) {
@@ -204,7 +426,8 @@ export default class CMyNave extends MixinNave {
}
public geticon(rec) {
if (!rec.ind)
return ''
if (this.rigadoni >= this.getrigaNaveByInd(rec.ind)) {
return 'fas fa-gift'
}
@@ -213,18 +436,20 @@ export default class CMyNave extends MixinNave {
public async InviaMsgANave(msgobj, navemediatore) {
let msgtitle = translate('dashboard.controlla_donatori')
let msginvia = msgtitle
if (msgobj.inviareale) {
msgtitle = translate('dashboard.invia_link_chat')
msginvia = translate('dashboard.inviare_msg_donatori')
}
await tools.askConfirm(this.$q, msgtitle, translate('dashboard.inviare_msg_donatori') + ' ' + '?', translate('dialog.yes'), translate('dialog.no'), this, '', lists.MenuAction.INVIA_MSG_A_DONATORI, 0, {
tools.askConfirm(this.$q, msgtitle, msginvia + ' ' + '?', translate('dialog.yes'), translate('dialog.no'), this, '', lists.MenuAction.INVIA_MSG_A_DONATORI, 0, {
param1: msgobj,
param2: navemediatore
})
}
public async InviaMsgADonatori(msgobj) {
public InviaMsgADonatori(msgobj) {
const navemediatore = {
id: this.mediatore._id,
@@ -236,8 +461,8 @@ export default class CMyNave extends MixinNave {
}
get linkchatesiste() {
if (!!this.linkchatopen)
return this.linkchatopen.length > 10
if (!!this.link_chat)
return this.link_chat.length > 10
return false
}
@@ -245,11 +470,52 @@ export default class CMyNave extends MixinNave {
const msgobj = {
tipomsg: tools.TipoMsg.SEND_LINK_CHAT_DONATORI,
msgpar1: this.linkchatopen,
msgpar1: this.link_chat,
inviareale,
}
this.InviaMsgADonatori(msgobj)
}
public getdatastr(mydata) {
return tools.getstrshortDate(mydata)
}
public gettitlemediatore() {
return this.getdatastr(this.partenza_primo_donatore()) + ' ' + 'NAVE' + ' ' + this.mediatore.riga + '.' + this.mediatore.col + ' ' + '🎁' + 'AYNI'
}
public gettitledonatore() {
return this.getdatastr(this.donatore.date_start) + ' ' + 'NAVE' + ' ' + this.donatore.riga + '.' + this.donatore.col + ' ' + '🎁' + 'AYNI'
}
public gettesto() {
return this.$t('dashboard.sonomediatore', { nomenave: this.gettitlemediatore() })
}
public getisProvvisoriaStr() {
if (!!this.iodonatore) {
if (this.iodonatore.provvisoria) {
return ' Temporanea '
}
}
return ''
}
public getposizione() {
return this.$t('dashboard.posizione') + ' ' + this.getisProvvisoriaStr() + this.nave.riga + '.' + this.nave.col
}
public getDoniAttesaDiConferma() {
return this.arrdonatori.filter((rec) => (!!rec.date_made_gift && !rec.made_gift)).reduce((sum, item) => sum + 1, 0)
}
public getDoniConfermati() {
return this.arrdonatori.filter((rec) => rec.made_gift).reduce((sum, item) => sum + 1, 0)
}
public getDoniMancanti() {
return this.arrdonatori.filter((rec) => (!rec.made_gift && !rec.date_made_gift)).reduce((sum, item) => sum + 1, 0)
}
}