salix/modules/client/front/consumption/index.js

70 lines
1.6 KiB
JavaScript
Raw Normal View History

2020-06-10 11:35:41 +00:00
import ngModule from '../module';
import Section from 'salix/components/section';
class Controller extends Section {
2020-06-15 07:07:13 +00:00
constructor($element, $, vnReport, vnEmail) {
2020-06-10 11:35:41 +00:00
super($element, $);
2020-06-15 07:07:13 +00:00
this.vnReport = vnReport;
this.vnEmail = vnEmail;
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() {
2020-06-15 07:07:13 +00:00
this.vnReport.show('campaign-metrics', this.reportParams);
2020-06-12 07:18:19 +00:00
}
sendEmail() {
2020-06-15 07:07:13 +00:00
this.vnEmail.send('campaign-metrics', this.reportParams);
2020-06-12 07:18:19 +00:00
}
changeGrouped(value) {
const model = this.$.model;
model.addFilter({}, {grouped: value});
}
2020-06-10 11:35:41 +00:00
}
2020-06-15 07:07:13 +00:00
Controller.$inject = ['$element', '$scope', 'vnReport', 'vnEmail'];
2020-06-10 11:35:41 +00:00
ngModule.vnComponent('vnClientConsumption', {
2020-06-10 11:35:41 +00:00
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
}
});