4856-worker.time-control #1375

Merged
joan merged 32 commits from 4856-worker.time-control into dev 2023-03-16 06:39:02 +00:00
3 changed files with 135 additions and 36 deletions
Showing only changes of commit 3051768781 - Show all commits

View File

@ -0,0 +1,3 @@
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
VALUES
('Time', '*', '*', 'ALLOW', 'ROLE', 'employee');
vicent marked this conversation as resolved Outdated
Outdated
Review

Esta taula crec que deuría ser de soles lectura. No crec que deguen pode modificar eixa taula.
Este ACL de sols lectura també pot anar directament al model com en altres similars, per al rol $everyone

Esta taula crec que deuría ser de soles lectura. No crec que deguen pode modificar eixa taula. Este ACL de sols lectura també pot anar directament al model com en altres similars, per al rol $everyone

View File

@ -14,6 +14,9 @@
"year": {
"type": "number"
},
"month": {
"type": "number"
},
"week": {
"type": "number"
}

View File

@ -24,6 +24,97 @@ class Controller extends Section {
}
this.date = initialDate;
const filterTime = {
fields: ['week'],
where: {
month: this.date.getMonth() + 1,
year: this.date.getFullYear()
}
};
this.$http.get('Times', {filter: filterTime})
.then(res => {
const weeks = res.data.map(time => time.week);
const weekNumbersSet = new Set(weeks);
const weekNumbers = Array.from(weekNumbersSet);
const filter = {
where: {
workerFk: this.$params.id,
year: this.date.getFullYear(),
week: {inq: weekNumbers}
}
};
this.$http.get('WorkerTimeControlMails', {filter})
.then(res => {
const workerTimeControlMails = res.data;
console.log(workerTimeControlMails);
for (const workerTimeControlMail of workerTimeControlMails) {
// const [data] = res.data;
// if (!data) {
// if (this.weekNumber == weekNumberValue) this.state = null;
// return;
// }
const state = workerTimeControlMail.state;
console.log(workerTimeControlMail.week, this.weekNumberValue);
if (workerTimeControlMail.week == this.weekNumberValue) {
this.state = state;
this.reason = workerTimeControlMail.reason;
}
if (state == 'CONFIRMED') {
this.weekNumberHTML.classList.add('confirmed');
this.weekNumberHTML.setAttribute('title', 'Conforme');
}
if (state == 'REVISE') {
this.weekNumberHTML.classList.add('revise');
this.weekNumberHTML.setAttribute('title', 'No conforme');
}
if (state == 'SENDED') {
this.weekNumberHTML.classList.add('sended');
this.weekNumberHTML.setAttribute('title', 'Pendiente');
}
}
});
});
// console.log(this.weekNumbers);
// const filter = {
// where: {
// workerFk: this.$params.id,
// year: this.date.getFullYear(),
// week: {inq: this.weekNumbers}
// }
// };
// this.$http.get('WorkerTimeControlMails', {filter})
// .then(res => {
// console.log(res.data);
// // const [data] = res.data;
// // if (!data) {
// // if (this.weekNumber == weekNumberValue) this.state = null;
// // return;
// // }
// // const state = data.state;
// // if (this.weekNumber == weekNumberValue) {
// // this.state = state;
// // this.reason = data.reason;
// // }
// // if (state == 'CONFIRMED') {
// // weekNumber.classList.add('confirmed');
// // weekNumber.setAttribute('title', 'Conforme');
// // }
// // if (state == 'REVISE') {
// // weekNumber.classList.add('revise');
// // weekNumber.setAttribute('title', 'No conforme');
// // }
// // if (state == 'SENDED') {
// // weekNumber.classList.add('sended');
// // weekNumber.setAttribute('title', 'Pendiente');
// // }
// });
}
get isHr() {
@ -314,7 +405,7 @@ class Controller extends Section {
const firstDayOfYear = new Date(tempDate.getFullYear(), 0, 1);
const differenceInMilliseconds = firstDayOfWeek.getTime() - firstDayOfYear.getTime();
const weekNumber = Math.floor(differenceInMilliseconds / (1000 * 60 * 60 * 24 * 7)) + 1;
return weekNumber - 1;
return weekNumber;
}
isSatisfied() {
@ -363,43 +454,45 @@ class Controller extends Section {
}
formatWeek($element) {
let weekNumber = $element.firstElementChild;
let weekNumberValue = $element.firstElementChild.innerHTML - 1;
const filter = {
where: {
workerFk: this.$params.id,
year: this.date.getFullYear(),
week: weekNumberValue
}
};
this.weekNumberHTML = $element.firstElementChild;
console.log(this.weekNumberHTML);
this.weekNumberValue = $element.firstElementChild.innerHTML;
this.$http.get('WorkerTimeControlMails', {filter})
.then(res => {
const [data] = res.data;
if (!data) {
if (this.weekNumber == weekNumberValue) this.state = null;
return;
}
// const filter = {
// where: {
// workerFk: this.$params.id,
// year: this.date.getFullYear(),
// week: weekNumberValue
// }
// };
const state = data.state;
if (this.weekNumber == weekNumberValue) {
this.state = state;
this.reason = data.reason;
}
// this.$http.get('WorkerTimeControlMails', {filter})
// .then(res => {
// const [data] = res.data;
// if (!data) {
// if (this.weekNumber == weekNumberValue) this.state = null;
// return;
// }
if (state == 'CONFIRMED') {
weekNumber.classList.add('confirmed');
weekNumber.setAttribute('title', 'Conforme');
}
if (state == 'REVISE') {
weekNumber.classList.add('revise');
weekNumber.setAttribute('title', 'No conforme');
}
if (state == 'SENDED') {
weekNumber.classList.add('sended');
weekNumber.setAttribute('title', 'Pendiente');
}
});
// const state = data.state;
// if (this.weekNumber == weekNumberValue) {
// this.state = state;
// this.reason = data.reason;
// }
// if (state == 'CONFIRMED') {
// weekNumber.classList.add('confirmed');
// weekNumber.setAttribute('title', 'Conforme');
// }
// if (state == 'REVISE') {
// weekNumber.classList.add('revise');
// weekNumber.setAttribute('title', 'No conforme');
// }
// if (state == 'SENDED') {
// weekNumber.classList.add('sended');
// weekNumber.setAttribute('title', 'Pendiente');
// }
// });
}
resendEmail() {
@ -407,7 +500,7 @@ class Controller extends Section {
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,
week: this.weekNumber,
year: this.date.getFullYear(),
url: url,
};