import ngModule from '../module'; import Section from 'salix/components/section'; class Controller extends Section { constructor($element, $) { super($element, $); 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); } showTicketDescriptor(event, sale) { if (!sale.isTicket) return; this.$.ticketDescriptor.show(event.target, sale.origin); } 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}); } } Controller.$inject = ['$element', '$scope']; ngModule.component('vnClientConsumption', { template: require('./index.html'), controller: Controller, bindings: { client: '<' }, require: { card: '^vnClientCard' } });