diff --git a/modules/worker/back/methods/worker-time-control/sendMail.js b/modules/worker/back/methods/worker-time-control/sendMail.js index e43f4a8ab..2e1e00d83 100644 --- a/modules/worker/back/methods/worker-time-control/sendMail.js +++ b/modules/worker/back/methods/worker-time-control/sendMail.js @@ -165,8 +165,8 @@ module.exports = Self => { const sql = ParameterizedSQL.join(stmts, ';'); const days = await conn.executeStmt(sql, myOptions); - let previousWorkerFk = days[index][0].workerFk; - let previousReceiver = days[index][0].receiver; + let previousWorkerFk = days[index][0]?.workerFk; + let previousReceiver = days[index][0]?.receiver; const workerTimeControlConfig = await models.WorkerTimeControlConfig.findOne(null, myOptions); diff --git a/modules/worker/back/methods/worker-time-control/weeklyHourRecordEmail.js b/modules/worker/back/methods/worker-time-control/weeklyHourRecordEmail.js index f19ab17e1..e352eb3cb 100644 --- a/modules/worker/back/methods/worker-time-control/weeklyHourRecordEmail.js +++ b/modules/worker/back/methods/worker-time-control/weeklyHourRecordEmail.js @@ -61,7 +61,7 @@ module.exports = Self => { const url = `${salix.url}worker/${args.workerId}/time-control?timestamp=${timestamp}`; ctx.args.url = url; - await models.WorkerTimeControl.updateMailState(ctx, ctx.workerId, myOptions); + await models.WorkerTimeControl.updateMailState(ctx, ctx.args.workerId, myOptions); return Self.sendTemplate(ctx, 'weekly-hour-record'); }; diff --git a/modules/worker/front/time-control/index.js b/modules/worker/front/time-control/index.js index 7f7bad137..2993e3986 100644 --- a/modules/worker/front/time-control/index.js +++ b/modules/worker/front/time-control/index.js @@ -380,7 +380,6 @@ class Controller extends Section { updateWorkerTimeControlMail(state, reason) { const params = { - workerId: this.worker.id, year: this.date.getFullYear(), week: this.weekNumber, state @@ -389,7 +388,7 @@ class Controller extends Section { if (reason) params.reason = reason; - const query = `WorkerTimeControls/updateWorkerTimeControlMail`; + const query = `WorkerTimeControls/${this.worker.id}/updateMailState`; this.$http.post(query, params).then(() => { this.getMailStates(this.date); this.getWeekData(); diff --git a/modules/worker/front/time-control/index.spec.js b/modules/worker/front/time-control/index.spec.js index 42df4ba9b..3868ded75 100644 --- a/modules/worker/front/time-control/index.spec.js +++ b/modules/worker/front/time-control/index.spec.js @@ -201,7 +201,7 @@ describe('Component vnWorkerTimeControl', () => { controller.date = today; controller.weekNumber = 1; - $httpBackend.expect('POST', 'WorkerTimeControls/updateWorkerTimeControlMail').respond(); + $httpBackend.expect('POST', 'WorkerTimeControls/1/updateMailState').respond(); controller.isSatisfied(); $httpBackend.flush(); @@ -236,7 +236,7 @@ describe('Component vnWorkerTimeControl', () => { controller.weekNumber = 1; controller.reason = 'reason'; - $httpBackend.expect('POST', 'WorkerTimeControls/updateWorkerTimeControlMail').respond(); + $httpBackend.expect('POST', 'WorkerTimeControls/1/updateMailState').respond(); controller.isSatisfied(); $httpBackend.flush();