2020-06-10 11:35:41 +00:00
|
|
|
import ngModule from '../module';
|
|
|
|
import Section from 'salix/components/section';
|
|
|
|
|
|
|
|
class Controller extends Section {
|
|
|
|
constructor($element, $) {
|
|
|
|
super($element, $);
|
2020-06-12 07:18:19 +00:00
|
|
|
this.filter = {
|
|
|
|
where: {
|
|
|
|
isPackaging: false
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
const minDate = new Date();
|
|
|
|
minDate.setHours(0, 0, 0, 0);
|
|
|
|
minDate.setMonth(minDate.getMonth() - 2);
|
|
|
|
|
|
|
|
const maxDate = new Date();
|
|
|
|
maxDate.setHours(23, 59, 59, 59);
|
|
|
|
|
|
|
|
this.filterParams = {
|
|
|
|
from: minDate,
|
|
|
|
to: maxDate
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
get reportParams() {
|
|
|
|
const userParams = this.$.model.userParams;
|
|
|
|
return Object.assign({
|
|
|
|
authorization: this.vnToken.token,
|
|
|
|
recipientId: this.client.id
|
|
|
|
}, userParams);
|
2020-06-10 11:35:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
showTicketDescriptor(event, sale) {
|
|
|
|
if (!sale.isTicket) return;
|
|
|
|
|
|
|
|
this.$.ticketDescriptor.show(event.target, sale.origin);
|
|
|
|
}
|
2020-06-12 07:18:19 +00:00
|
|
|
|
|
|
|
showReport() {
|
|
|
|
const params = this.reportParams;
|
|
|
|
const serializedParams = this.$httpParamSerializer(params);
|
|
|
|
window.open(`api/report/campaign-metrics?${serializedParams}`);
|
|
|
|
}
|
|
|
|
|
|
|
|
sendEmail() {
|
|
|
|
const params = this.reportParams;
|
|
|
|
this.$http.get(`email/campaign-metrics`, {params})
|
|
|
|
.then(() => this.vnApp.showMessage(this.$t('Notification sent!')));
|
|
|
|
}
|
|
|
|
|
|
|
|
changeGrouped(value) {
|
|
|
|
const model = this.$.model;
|
|
|
|
|
|
|
|
model.addFilter({}, {grouped: value});
|
|
|
|
}
|
2020-06-10 11:35:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Controller.$inject = ['$element', '$scope'];
|
|
|
|
|
|
|
|
ngModule.component('vnClientConsumption', {
|
|
|
|
template: require('./index.html'),
|
|
|
|
controller: Controller,
|
|
|
|
bindings: {
|
|
|
|
client: '<'
|
2020-06-12 07:18:19 +00:00
|
|
|
},
|
|
|
|
require: {
|
|
|
|
card: '^vnClientCard'
|
2020-06-10 11:35:41 +00:00
|
|
|
}
|
|
|
|
});
|