diff --git a/modules/ticket/front/basic-data/step-one/index.html b/modules/ticket/front/basic-data/step-one/index.html index eb2fe95605..59435635ed 100644 --- a/modules/ticket/front/basic-data/step-one/index.html +++ b/modules/ticket/front/basic-data/step-one/index.html @@ -70,7 +70,7 @@ { + Self.remoteMethod('includingExpired', { + description: 'Returns a list of agencies from a warehouse', + accepts: [{ + arg: 'filter', + type: 'Object', + description: `Filter defining where, order, offset, and limit - must be a JSON-encoded string` + }], + returns: { + type: ['object'], + root: true + }, + http: { + path: `/includingExpired`, + verb: 'GET' + } + }); + + Self.includingExpired = async filter => { + const conn = Self.dataSource.connector; + const where = filter.where; + // filter = mergeFilters(filter, {where}); + const stmts = []; + let stmt; + + console.log(where); + + if (where.agencyModeFk) { + stmt = new ParameterizedSQL(`CALL vn.zone_getLanded(?, ?, ?, ?, ?)`, [ + where.shipped, + where.addressFk, + where.agencyModeFk, + where.warehouseFk, + true]); + stmts.push(stmt); + } + + stmt = new ParameterizedSQL( + `SELECT id, name, agencyModeFk + FROM vn.zone z`); + + if (where.agencyModeFk) + stmt.merge(`JOIN tmp.zoneGetLanded zgl ON zgl.zoneFk = z.id`); + + stmt.merge(conn.makePagination(filter)); + + let index; + if (stmts.length) + index = stmts.push(stmt) - 1; + else stmts.push(stmt); + + const sql = ParameterizedSQL.join(stmts, ';'); + const result = await conn.executeStmt(sql); + + return index ? result[index] : result; + }; +}; diff --git a/modules/zone/back/models/zone.js b/modules/zone/back/models/zone.js index b0f21c998d..0b1b9d106e 100644 --- a/modules/zone/back/models/zone.js +++ b/modules/zone/back/models/zone.js @@ -5,6 +5,7 @@ module.exports = Self => { require('../methods/zone/toggleIsIncluded')(Self); require('../methods/zone/getUpcomingDeliveries')(Self); require('../methods/zone/deleteZone')(Self); + require('../methods/zone/includingExpired')(Self); Self.validatesPresenceOf('agencyModeFk', { message: `Agency cannot be blank`