diff --git a/modules/worker/back/methods/calendar/absences.js b/modules/worker/back/methods/calendar/absences.js index 32d311cdb..5861890ed 100644 --- a/modules/worker/back/methods/calendar/absences.js +++ b/modules/worker/back/methods/calendar/absences.js @@ -12,6 +12,11 @@ module.exports = Self => { arg: 'year', type: 'date', required: true, + }, + { + arg: 'all', + type: 'boolean', + required: false, }], returns: [{ arg: 'absences', @@ -27,7 +32,7 @@ module.exports = Self => { } }); - Self.absences = async(ctx, businessFk, year, options) => { + Self.absences = async(ctx, businessFk, year, all, options) => { const models = Self.app.models; const started = new Date(); @@ -45,6 +50,12 @@ module.exports = Self => { if (typeof options == 'object') Object.assign(myOptions, options); + let where = {businessFk}; + if (all) { + let worker = await models.WorkerLabour.findOne({where: where}); + where = {workerFk: worker.workerFk}; + } + const contract = await models.WorkerLabour.findOne({ include: [{ relation: 'holidays', @@ -82,7 +93,7 @@ module.exports = Self => { } } }], - where: {businessFk} + where: where }, myOptions); if (!contract) return; diff --git a/modules/worker/front/time-control/index.js b/modules/worker/front/time-control/index.js index 1f6251391..6af977506 100644 --- a/modules/worker/front/time-control/index.js +++ b/modules/worker/front/time-control/index.js @@ -128,7 +128,8 @@ class Controller extends Section { const fullYear = this.started.getFullYear(); let params = { businessFk: this.businessId, - year: fullYear + year: fullYear, + all: true }; return this.$http.get(`Calendars/absences`, {params})