diff --git a/modules/order/back/methods/order/filter.js b/modules/order/back/methods/order/filter.js index ef6ea8a44..bd987dd5b 100644 --- a/modules/order/back/methods/order/filter.js +++ b/modules/order/back/methods/order/filter.js @@ -119,7 +119,7 @@ module.exports = Self => { case 'sourceApp': return {'o.source_app': value}; case 'ticketFk': - return {'ort.ticketFk': value}; + return {'ot.ticketFk': value}; case 'isConfirmed': return {'o.confirmed': value ? 1 : 0}; case 'myTeam': @@ -137,7 +137,10 @@ module.exports = Self => { let stmt; stmt = new ParameterizedSQL( - `SELECT + `CREATE TEMPORARY TABLE tmp.filter + (INDEX (id)) + ENGINE = MEMORY + SELECT o.id, o.total, o.date_send landed, @@ -168,20 +171,20 @@ module.exports = Self => { LEFT JOIN ticket t ON t.id = ot.ticketFk LEFT JOIN zoneEstimatedDelivery zed ON zed.zoneFk = t.zoneFk`); - if (args && args.ticketFk) { - stmt.merge({ - sql: `LEFT JOIN orderTicket ort ON ort.orderFk = o.id` - }); - } - stmt.merge(conn.makeWhere(filter.where)); - stmt.merge(`GROUP BY o.id`); stmt.merge(conn.makePagination(filter)); stmts.push(stmt); + stmt = new ParameterizedSQL(`SELECT * FROM tmp.filter`); + stmt.merge(`GROUP BY id`); + stmt.merge(conn.makeOrderBy(filter.order)); + const ordersIndex = stmts.push(stmt) - 1; + + stmts.push(`DROP TEMPORARY TABLE tmp.filter`); + const sql = ParameterizedSQL.join(stmts, ';'); const result = await conn.executeStmt(sql); - return result; + return result[ordersIndex]; }; }; diff --git a/modules/order/front/index/index.html b/modules/order/front/index/index.html index 288e81226..a2a4a5226 100644 --- a/modules/order/front/index/index.html +++ b/modules/order/front/index/index.html @@ -17,7 +17,7 @@ Landed Hour Agency - Total + Total