diff --git a/modules/worker/front/time-control/index.html b/modules/worker/front/time-control/index.html index 937e9a5817..0b6c01ea52 100644 --- a/modules/worker/front/time-control/index.html +++ b/modules/worker/front/time-control/index.html @@ -97,7 +97,8 @@ + class="right" + ng-show="::$ctrl.isHr"> diff --git a/modules/worker/front/time-control/index.js b/modules/worker/front/time-control/index.js index 33a300ac79..1fadb93f54 100644 --- a/modules/worker/front/time-control/index.js +++ b/modules/worker/front/time-control/index.js @@ -26,10 +26,22 @@ class Controller extends Section { this.date = initialDate; } + get isHr() { + return this.aclService.hasAny(['hr']); + } + get worker() { return this._worker; } + get weekNumber() { + return this.getWeekNumber(this.date); + } + + set weekNumber(value) { + this._weekNumber = value; + } + set worker(value) { this._worker = value; } @@ -306,11 +318,10 @@ class Controller extends Section { } isSatisfied() { - const weekNumber = this.getWeekNumber(this.date); const params = { workerId: this.worker.id, year: this.date.getFullYear(), - week: weekNumber, + week: this.weekNumber, state: 'CONFIRMED' }; const query = `WorkerTimeControls/updateWorkerTimeControlMail`; @@ -321,11 +332,10 @@ class Controller extends Section { } isUnsatisfied() { - const weekNumber = this.getWeekNumber(this.date); const params = { workerId: this.worker.id, year: this.date.getFullYear(), - week: weekNumber, + week: this.weekNumber, state: 'REVISE', reason: this.reason }; @@ -374,11 +384,9 @@ class Controller extends Section { this.$http.get('WorkerTimeControlMails/findOne', {filter}) .then(res => { const state = res.data.state; - const currentWeekNumber = this.getWeekNumber(this.date); - if (currentWeekNumber == weekNumberValue) { + if (this.weekNumber == weekNumberValue) { this.state = state; this.reason = res.data.reason; - console.log(currentWeekNumber, weekNumberValue, this.state, this.reason); } if (state == 'CONFIRMED') { weekNumber.classList.add('confirmed'); @@ -390,25 +398,17 @@ class Controller extends Section { } resendEmail() { - const filter = { - where: {userFk: this.$params.id}, + const timestamp = this.date.getTime() / 1000; + const url = `${window.location.origin}/#!/worker/${this.worker.id}/time-control?timestamp=${timestamp}`; + const params = { + recipient: this.worker.user.emailUser.email, + week: this.weekNumber + 1, + year: this.date.getFullYear(), + url: url, }; - this.$http.get('EmailUsers/findOne', {filter}) + this.$http.post(`WorkerTimeControls/weekly-hour-hecord-email`, params) .then(res => { - const timestamp = this.date.getTime() / 1000; - const url = `${window.location.origin}/#!/worker/${this.$params.id}/time-control?timestamp=${timestamp}`; - const weekNumber = this.getWeekNumber(this.date); - - const params = { - recipient: res.data.email, - week: weekNumber + 1, - year: this.date.getFullYear(), - url: url, - }; - this.$http.post(`WorkerTimeControls/weekly-hour-hecord-email`, params) - .then(res => { - this.vnApp.showSuccess(this.$t('Email sended')); - }); + this.vnApp.showSuccess(this.$t('Email sended')); }); }