2018-03-12 13:02:29 +00:00
|
|
|
import ngModule from '../module';
|
2018-11-08 08:20:06 +00:00
|
|
|
import './style.scss';
|
2018-03-12 13:02:29 +00:00
|
|
|
|
|
|
|
export default class Controller {
|
2019-04-03 13:16:32 +00:00
|
|
|
constructor($scope, $state, $stateParams, $translate, $http) {
|
2018-10-30 12:58:02 +00:00
|
|
|
this.$ = $scope;
|
2019-04-03 13:16:32 +00:00
|
|
|
this.$http = $http;
|
2019-03-27 08:58:58 +00:00
|
|
|
this.$translate = $translate;
|
2019-01-24 07:21:00 +00:00
|
|
|
this.$stateParams = $stateParams;
|
2018-11-08 08:20:06 +00:00
|
|
|
this.$state = $state;
|
2018-10-30 12:58:02 +00:00
|
|
|
this.selectedTicket = null;
|
2018-11-08 08:20:06 +00:00
|
|
|
this.moreOptions = [
|
2019-02-06 08:55:17 +00:00
|
|
|
{callback: () => {
|
2019-04-25 05:57:26 +00:00
|
|
|
this.$state.go('ticket.weekly');
|
2019-02-06 08:55:17 +00:00
|
|
|
}, name: 'Turns', always: true},
|
2019-04-25 05:57:26 +00:00
|
|
|
{callback: () => {
|
|
|
|
this.setBalanceCreateDialog();
|
|
|
|
this.$.balanceCreateDialog.show();
|
|
|
|
}, name: 'Payment on account...', always: true}
|
2018-11-08 08:20:06 +00:00
|
|
|
];
|
2018-12-10 13:14:40 +00:00
|
|
|
|
2019-04-03 13:16:32 +00:00
|
|
|
if (!$stateParams.q)
|
|
|
|
this.getScopeDays();
|
|
|
|
}
|
2019-01-23 11:30:32 +00:00
|
|
|
|
2019-04-03 13:16:32 +00:00
|
|
|
getScopeDays() {
|
|
|
|
this.$http.get(`/api/TicketConfigs/findOne`).then(res => {
|
|
|
|
if (res.data) {
|
|
|
|
this.filter = {
|
2019-05-16 10:33:41 +00:00
|
|
|
scopeDays: parseInt(res.data.scopeDays)
|
2019-04-03 13:16:32 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2018-12-10 13:14:40 +00:00
|
|
|
|
2019-04-25 05:57:26 +00:00
|
|
|
setBalanceCreateDialog() {
|
|
|
|
let data = this.$.tickets;
|
|
|
|
let description = [];
|
|
|
|
this.$.balanceCreateDialog.amountPaid = 0;
|
|
|
|
if (data) {
|
|
|
|
for (let i = 0; i < data.length; i++) {
|
|
|
|
if (data[i].checked) {
|
|
|
|
this.$.balanceCreateDialog.amountPaid += data[i].total;
|
|
|
|
this.$.balanceCreateDialog.clientFk = data[i].clientFk;
|
|
|
|
description.push(`${data[i].id}`);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.$.balanceCreateDialog.description = 'Albaran: ';
|
2019-04-29 08:21:36 +00:00
|
|
|
this.$.balanceCreateDialog.description += description.join(', ');
|
2019-04-25 05:57:26 +00:00
|
|
|
}
|
|
|
|
|
2019-04-03 13:16:32 +00:00
|
|
|
buildFilterDates() {
|
|
|
|
let today = new Date();
|
|
|
|
this.today = today.setHours(0, 0, 0, 0);
|
2018-12-12 13:52:20 +00:00
|
|
|
|
2019-04-03 13:16:32 +00:00
|
|
|
let buildDate = new Date(today);
|
|
|
|
buildDate.setDate(today.getDate() + this.scopeDays);
|
|
|
|
buildDate.setHours(23, 59, 59, 999);
|
|
|
|
|
|
|
|
this.daysOnward = buildDate;
|
2019-01-22 15:18:26 +00:00
|
|
|
}
|
|
|
|
|
2018-12-19 07:42:07 +00:00
|
|
|
onSearch(params) {
|
2019-04-03 13:16:32 +00:00
|
|
|
if (params) {
|
|
|
|
if (params.scopeDays) {
|
2019-05-16 10:33:41 +00:00
|
|
|
params.scopeDays = parseInt(params.scopeDays);
|
2019-04-03 13:16:32 +00:00
|
|
|
this.scopeDays = params.scopeDays;
|
|
|
|
this.buildFilterDates();
|
|
|
|
params = Object.assign(params, {from: this.today, to: this.daysOnward});
|
|
|
|
}
|
|
|
|
|
2018-12-19 07:42:07 +00:00
|
|
|
this.$.model.applyFilter(null, params);
|
2019-04-03 13:16:32 +00:00
|
|
|
} else
|
2018-12-19 07:42:07 +00:00
|
|
|
this.$.model.clear();
|
2018-11-08 08:20:06 +00:00
|
|
|
}
|
|
|
|
|
2019-02-07 08:33:54 +00:00
|
|
|
goToLines(event, ticketFk) {
|
2019-03-27 08:58:58 +00:00
|
|
|
this.preventDefault(event);
|
|
|
|
let url = this.$state.href('ticket.card.sale', {id: ticketFk}, {absolute: true});
|
|
|
|
window.open(url, '_blank');
|
2019-02-06 08:55:17 +00:00
|
|
|
}
|
|
|
|
|
2018-11-08 08:20:06 +00:00
|
|
|
onMoreOpen() {
|
|
|
|
let options = this.moreOptions.filter(o => o.always || this.isChecked);
|
|
|
|
this.$.moreButton.data = options;
|
|
|
|
}
|
|
|
|
|
|
|
|
onMoreChange(callback) {
|
|
|
|
callback.call(this);
|
2018-04-10 05:48:04 +00:00
|
|
|
}
|
|
|
|
|
2018-04-19 12:56:05 +00:00
|
|
|
compareDate(date) {
|
|
|
|
let today = new Date();
|
|
|
|
today.setHours(0, 0, 0, 0);
|
|
|
|
let timeTicket = new Date(date);
|
|
|
|
timeTicket.setHours(0, 0, 0, 0);
|
|
|
|
|
|
|
|
let comparation = today - timeTicket;
|
|
|
|
|
|
|
|
if (comparation == 0)
|
|
|
|
return 'warning';
|
|
|
|
if (comparation < 0)
|
|
|
|
return 'success';
|
2018-03-12 13:02:29 +00:00
|
|
|
}
|
2018-08-23 08:08:06 +00:00
|
|
|
|
2018-12-21 06:53:04 +00:00
|
|
|
stateColor(ticket) {
|
|
|
|
if (ticket.alertLevelCode === 'OK')
|
2019-02-10 21:52:35 +00:00
|
|
|
return 'success';
|
2018-12-21 06:53:04 +00:00
|
|
|
else if (ticket.alertLevelCode === 'FREE')
|
2019-02-10 21:52:35 +00:00
|
|
|
return 'notice';
|
2018-12-21 06:53:04 +00:00
|
|
|
else if (ticket.alertLevel === 1)
|
2019-02-10 21:52:35 +00:00
|
|
|
return 'warning';
|
2018-12-21 06:53:04 +00:00
|
|
|
else if (ticket.alertLevel === 0)
|
2019-02-10 21:52:35 +00:00
|
|
|
return 'alert';
|
2018-12-21 06:53:04 +00:00
|
|
|
}
|
|
|
|
|
2019-02-15 11:39:21 +00:00
|
|
|
showClientDescriptor(event, clientFk) {
|
2019-03-27 08:58:58 +00:00
|
|
|
this.preventDefault(event);
|
2019-02-15 11:39:21 +00:00
|
|
|
this.$.clientDescriptor.clientFk = clientFk;
|
|
|
|
this.$.clientDescriptor.parent = event.target;
|
|
|
|
this.$.clientDescriptor.show();
|
|
|
|
}
|
|
|
|
|
2019-04-25 12:24:02 +00:00
|
|
|
showWorkerDescriptor(event, workerFk) {
|
2019-03-27 08:58:58 +00:00
|
|
|
this.preventDefault(event);
|
2019-04-25 12:24:02 +00:00
|
|
|
this.selectedWorker = workerFk;
|
2019-02-15 11:39:21 +00:00
|
|
|
this.$.workerDescriptor.parent = event.target;
|
|
|
|
this.$.workerDescriptor.show();
|
2018-07-26 10:06:53 +00:00
|
|
|
}
|
2018-04-10 05:48:04 +00:00
|
|
|
|
2018-04-19 12:56:05 +00:00
|
|
|
preview(event, ticket) {
|
2019-03-27 08:58:58 +00:00
|
|
|
this.preventDefault(event);
|
2018-10-30 12:58:02 +00:00
|
|
|
this.selectedTicket = ticket;
|
|
|
|
this.$.summary.show();
|
2018-04-19 12:56:05 +00:00
|
|
|
}
|
2019-03-27 08:58:58 +00:00
|
|
|
|
|
|
|
preventDefault(event) {
|
|
|
|
event.preventDefault();
|
|
|
|
event.stopImmediatePropagation();
|
|
|
|
}
|
2018-03-12 13:02:29 +00:00
|
|
|
}
|
2018-04-10 05:48:04 +00:00
|
|
|
|
2019-04-03 13:16:32 +00:00
|
|
|
Controller.$inject = ['$scope', '$state', '$stateParams', '$translate', '$http'];
|
2018-03-12 13:02:29 +00:00
|
|
|
|
2018-05-25 08:03:45 +00:00
|
|
|
ngModule.component('vnTicketIndex', {
|
|
|
|
template: require('./index.html'),
|
2018-03-12 13:02:29 +00:00
|
|
|
controller: Controller
|
|
|
|
});
|