#6924 Notify absences only to department boss #3175
|
@ -87,7 +87,8 @@ module.exports = Self => {
|
|||
`SELECT COUNT(*) halfHolidayCounter
|
||||
FROM vn.calendar c
|
||||
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 c.dated BETWEEN util.firstDayOfYear(?)
|
||||
AND LAST_DAY(DATE_ADD(?, INTERVAL 12 - MONTH(?) MONTH))`, [id, date, now, now]);
|
||||
|
@ -120,10 +121,12 @@ module.exports = Self => {
|
|||
}, myOptions);
|
||||
|
||||
const department = labour.department();
|
||||
if (department && department.notificationEmail) {
|
||||
if (department) {
|
||||
|
||||
const absenceType = await models.AbsenceType.findById(args.absenceTypeId, null, myOptions);
|
||||
const account = await models.VnUser.findById(userId, 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 body = $t('Created absence', {
|
||||
author: account.nickname,
|
||||
|
@ -135,7 +138,7 @@ module.exports = Self => {
|
|||
await models.Mail.create({
|
||||
subject: $t('Absence change notification on the labour calendar'),
|
||||
body: body,
|
||||
receiver: department.notificationEmail
|
||||
receiver: boss.email
|
||||
}, myOptions);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Diria que ja no cal mirar ni el department