feat: send email
gitea/salix/pipeline/head There was a failure building this commit
Details
gitea/salix/pipeline/head There was a failure building this commit
Details
This commit is contained in:
parent
1f2ea2c4d8
commit
3243d35bd7
|
@ -153,6 +153,7 @@
|
|||
"Email already exists": "Email already exists",
|
||||
"User already exists": "User already exists",
|
||||
"Absence change notification on the labour calendar": "Notificacion de cambio de ausencia en el calendario laboral",
|
||||
"Record of hours week": "Registro de horas semana {{week}} año {{year}} ",
|
||||
"Created absence": "El empleado <strong>{{author}}</strong> ha añadido una ausencia de tipo '{{absenceType}}' a <a href='{{{workerUrl}}}'><strong>{{employee}}</strong></a> para el día {{dated}}.",
|
||||
"Deleted absence": "El empleado <strong>{{author}}</strong> ha eliminado una ausencia de tipo '{{absenceType}}' a <a href='{{{workerUrl}}}'><strong>{{employee}}</strong></a> del día {{dated}}.",
|
||||
"I have deleted the ticket id": "He eliminado el ticket id [{{id}}]({{{url}}})",
|
||||
|
|
|
@ -30,6 +30,7 @@ module.exports = Self => {
|
|||
|
||||
Self.sendMail = async(ctx, options) => {
|
||||
const models = Self.app.models;
|
||||
const $t = ctx.req.__; // $translate
|
||||
const args = ctx.args;
|
||||
const myOptions = {};
|
||||
const conn = Self.dataSource.connector;
|
||||
|
@ -137,7 +138,7 @@ module.exports = Self => {
|
|||
SELECT * FROM tmp.timeBusinessCalculate`);
|
||||
|
||||
stmt = new ParameterizedSQL(`
|
||||
SELECT CONCAT(u.name, '@verdnatura.es'),
|
||||
SELECT CONCAT(u.name, '@verdnatura.es') receiver,
|
||||
u.id workerFk,
|
||||
tb.dated,
|
||||
tb.timeWorkDecimal,
|
||||
|
@ -177,6 +178,9 @@ module.exports = Self => {
|
|||
const sql = ParameterizedSQL.join(stmts, ';');
|
||||
const days = await conn.executeStmt(sql, myOptions);
|
||||
|
||||
let previousWorkerFk = days[index][0].workerFk;
|
||||
let previousReceiver = days[index][0].receiver;
|
||||
|
||||
for (let day of days[index]) {
|
||||
if (day.timeWorkDecimal > 0 && day.timeWorkedDecimal == null
|
||||
&& (day.permissionRate ? day.permissionRate : true)) {
|
||||
|
@ -332,7 +336,23 @@ module.exports = Self => {
|
|||
if (lastWorkerTimeControl) lastWorkerTimeControl.updateAttribute('direction', 'out', myOptions);
|
||||
}
|
||||
}
|
||||
|
||||
const origin = ctx.req.headers.origin;
|
||||
const lastDay = days[index][days[index].length - 1];
|
||||
if (day.workerFk != previousWorkerFk || day == lastDay) {
|
||||
await models.Mail.create({
|
||||
receiver: previousReceiver,
|
||||
subject: $t('Record of hours week', {
|
||||
week: args.week,
|
||||
year: args.year
|
||||
}),
|
||||
body: `${origin}/#!/worker/${previousWorkerFk}/time-control?timestamp=`
|
||||
});
|
||||
previousWorkerFk = day.workerFk;
|
||||
previousReceiver = day.receiver;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue