dev #1731
|
@ -121,15 +121,18 @@ module.exports = Self => {
|
|||
`, [started, ended]);
|
||||
stmts.push(stmt);
|
||||
|
||||
stmt = new ParameterizedSQL(`INSERT INTO mail (receiver, subject, body)
|
||||
SELECT CONCAT(u.name, '@verdnatura.es'),
|
||||
CONCAT('Error registro de horas semana ', ?, ' año ', ?) ,
|
||||
CONCAT('No se ha podido enviar el registro de horas al empleado/s: ', GROUP_CONCAT(DISTINCT CONCAT('<br>', w.id, ' ', w.firstName, ' ', w.lastName)))
|
||||
FROM tmp.timeControlError tce
|
||||
JOIN vn.workerTimeControl wtc ON wtc.id = tce.id
|
||||
JOIN worker w ON w.id = wtc.userFK
|
||||
JOIN account.user u ON u.id = w.bossFk
|
||||
GROUP BY w.bossFk`, [args.week, args.year]);
|
||||
stmt = new ParameterizedSQL(`
|
||||
INSERT INTO mail (receiver, subject, body)
|
||||
SELECT CONCAT(u.name, '@verdnatura.es'),
|
||||
CONCAT('Error registro de horas semana ', ?, ' año ', ?) ,
|
||||
CONCAT('No se ha podido enviar el registro de horas al empleado/s: ',
|
||||
GROUP_CONCAT(DISTINCT CONCAT('<br>', w.id, ' ', w.firstName, ' ', w.lastName)))
|
||||
FROM tmp.timeControlError tce
|
||||
JOIN vn.workerTimeControl wtc ON wtc.id = tce.id
|
||||
JOIN worker w ON w.id = wtc.userFK
|
||||
JOIN account.user u ON u.id = w.bossFk
|
||||
GROUP BY w.bossFk
|
||||
`, [args.week, args.year]);
|
||||
stmts.push(stmt);
|
||||
|
||||
stmt = new ParameterizedSQL(`
|
||||
|
@ -176,6 +179,7 @@ module.exports = Self => {
|
|||
|
||||
const workerTimeControlConfig = await models.WorkerTimeControlConfig.findOne(null, myOptions);
|
||||
|
||||
console.log(days[index]);
|
||||
for (let day of days[index]) {
|
||||
if (!myOptions.transaction) {
|
||||
tx = await Self.beginTransaction({});
|
||||
|
@ -371,7 +375,30 @@ module.exports = Self => {
|
|||
}
|
||||
} catch (e) {
|
||||
if (tx) await tx.rollback();
|
||||
throw e;
|
||||
delete myOptions.transaction;
|
||||
|
||||
const stmts = [];
|
||||
let stmt;
|
||||
stmt = new ParameterizedSQL(`
|
||||
INSERT INTO mail (receiver, subject, body)
|
||||
SELECT CONCAT(u.name, '@verdnatura.es'),
|
||||
CONCAT('Error registro de horas semana ', ?, ' año ', ?) ,
|
||||
CONCAT('No se ha podido enviar el registro de horas al empleado/s: ',
|
||||
GROUP_CONCAT(DISTINCT CONCAT('<br>', w.id, ' ', w.firstName, ' ', w.lastName)))
|
||||
FROM worker w
|
||||
JOIN account.user u ON u.id = w.bossFk
|
||||
WHERE w.id = ?
|
||||
GROUP BY w.bossFk
|
||||
`, [args.week, args.year, day.workerFk]);
|
||||
stmts.push(stmt);
|
||||
|
||||
const sql = ParameterizedSQL.join(stmts, ';');
|
||||
await conn.executeStmt(sql);
|
||||
|
||||
previousWorkerFk = day.workerFk;
|
||||
previousReceiver = day.receiver;
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue