#6924 Notify absences only to department boss #3175
|
@ -120,13 +120,10 @@ module.exports = Self => {
|
||||||
dated: args.dated
|
dated: args.dated
|
||||||
}, myOptions);
|
}, myOptions);
|
||||||
|
|
||||||
const department = labour.department();
|
|
||||||
if (department) {
|
|
||||||
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 worker = await models.Worker.findById(subordinated.id, null, myOptions);
|
||||||
const boss = await models.VnUser.findById(worker.bossFk, null, myOptions);
|
const departmentBoss = 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,
|
||||||
|
@ -138,9 +135,8 @@ 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: boss.email
|
receiver: departmentBoss.email
|
||||||
}, myOptions);
|
}, myOptions);
|
||||||
}
|
|
||||||
|
|
||||||
if (tx) await tx.commit();
|
if (tx) await tx.commit();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue