feat: refs #6924 notify absences only to department boss
gitea/salix/pipeline/pr-dev There was a failure building this commit
Details
gitea/salix/pipeline/pr-dev There was a failure building this commit
Details
This commit is contained in:
parent
6c40934f74
commit
25891e0bad
|
@ -87,7 +87,8 @@ module.exports = Self => {
|
||||||
`SELECT COUNT(*) halfHolidayCounter
|
`SELECT COUNT(*) halfHolidayCounter
|
||||||
FROM vn.calendar c
|
FROM vn.calendar c
|
||||||
JOIN vn.business b ON b.id = c.businessFk
|
JOIN vn.business b ON b.id = c.businessFk
|
||||||
WHERE c.dayOffTypeFk = 6
|
JOIN vn.absenceType at ON at.id = c.dayOffTypeFk
|
||||||
|
WHERE at.code = 'halfHoliday'
|
||||||
AND b.workerFk = ?
|
AND b.workerFk = ?
|
||||||
AND c.dated BETWEEN util.firstDayOfYear(?)
|
AND c.dated BETWEEN util.firstDayOfYear(?)
|
||||||
AND LAST_DAY(DATE_ADD(?, INTERVAL 12 - MONTH(?) MONTH))`, [id, date, now, now]);
|
AND LAST_DAY(DATE_ADD(?, INTERVAL 12 - MONTH(?) MONTH))`, [id, date, now, now]);
|
||||||
|
@ -120,10 +121,12 @@ module.exports = Self => {
|
||||||
}, myOptions);
|
}, myOptions);
|
||||||
|
|
||||||
const department = labour.department();
|
const department = labour.department();
|
||||||
if (department && department.notificationEmail) {
|
if (department) {
|
||||||
const absenceType = await models.AbsenceType.findById(args.absenceTypeId, null, myOptions);
|
const absenceType = await models.AbsenceType.findById(args.absenceTypeId, null, myOptions);
|
||||||
const account = await models.VnUser.findById(userId, null, myOptions);
|
const account = await models.VnUser.findById(userId, null, myOptions);
|
||||||
const subordinated = await models.VnUser.findById(id, null, myOptions);
|
const subordinated = await models.VnUser.findById(id, null, myOptions);
|
||||||
|
const worker = await models.Worker.findById(subordinated.id, null, myOptions);
|
||||||
|
const boss = await models.VnUser.findById(worker.bossFk, null, myOptions);
|
||||||
const url = await Self.app.models.Url.getUrl();
|
const url = await Self.app.models.Url.getUrl();
|
||||||
const body = $t('Created absence', {
|
const body = $t('Created absence', {
|
||||||
author: account.nickname,
|
author: account.nickname,
|
||||||
|
@ -135,7 +138,7 @@ module.exports = Self => {
|
||||||
await models.Mail.create({
|
await models.Mail.create({
|
||||||
subject: $t('Absence change notification on the labour calendar'),
|
subject: $t('Absence change notification on the labour calendar'),
|
||||||
body: body,
|
body: body,
|
||||||
receiver: department.notificationEmail
|
receiver: boss.email
|
||||||
}, myOptions);
|
}, myOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue