diff --git a/modules/ticket/back/methods/ticket/saveSign.js b/modules/ticket/back/methods/ticket/saveSign.js index fd5a95e68..d619e2037 100644 --- a/modules/ticket/back/methods/ticket/saveSign.js +++ b/modules/ticket/back/methods/ticket/saveSign.js @@ -166,16 +166,16 @@ module.exports = Self => { const ticketIncorrect = await Self.rawSql(` SELECT tls.ticketFk - FROM ticketLastState tls - JOIN ticketTracking tt ON tt.id = tls.ticketTrackingFk - JOIN ticket t ON t.id = tt.ticketFk - JOIN state s ON s.id = tt.stateFk - WHERE t.routeFk = ? - AND s.\`order\` < ? - AND priority <(SELECT t.priority - FROM ticket t - WHERE t.id = ?)` - , [ticket.routeFk, orderState.order, ticket.id], myOptions); + FROM ticketLastState tls + JOIN ticketTracking tt ON tt.id = tls.ticketTrackingFk + JOIN ticket t ON t.id = tt.ticketFk + JOIN state s ON s.id = tt.stateFk + WHERE t.routeFk = ? + AND s.\`order\` < ? + AND priority < (SELECT priority + FROM ticket + WHERE id = ?) + `, [ticket.routeFk, orderState.order, ticket.id], myOptions); if (ticketIncorrect?.length > 0) await sendMail(ticket.routeFk, ticket.id, ticket.zone().name);