refs #6220 add filter address
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Carlos Satorres 2023-12-12 13:14:41 +01:00
parent 7e6f311a43
commit 6cefc982e4
1 changed files with 39 additions and 42 deletions

View File

@ -107,17 +107,29 @@ module.exports = Self => {
return {or: [
{'c.phone': {like: `%${value}%`}},
{'c.mobile': {like: `%${value}%`}},
{'a.phone': {like: `%${value}%`}},
]};
case 'zoneFk':
param = 'a.postalCode';
return {[param]: {inq: postalCode}};
return {'a.postalCode': {inq: postalCode}};
case 'city':
return {or: [
{'c.city': {like: `%${value}`}},
{'a.city': {like: `%${value}`}}
]};
case 'postcode':
return {or: [
{'c.postcode': {like: `%${value}`}},
{'a.postalCode': {like: `%${value}`}}
]};
case 'provinceFk':
return {or: [
{'p.name': {like: `%${value}`}},
{'a.provinceFk': {like: `%${value}`}}
]};
case 'name':
case 'salesPersonFk':
case 'fi':
case 'socialName':
case 'city':
case 'postcode':
case 'provinceFk':
case 'email':
param = `c.${param}`;
return {[param]: {like: `%${value}%`}};
@ -129,47 +141,32 @@ module.exports = Self => {
const stmts = [];
const stmt = new ParameterizedSQL(
`SELECT
DISTINCT c.id,
c.name,
c.fi,
c.socialName,
c.phone,
c.mobile,
c.city,
c.postcode,
c.email,
c.isActive,
c.isFreezed,
p.id,
p.name,
u.id,
u.name,
a.street,
a.city,
a.provinceFk,
a.postalCode,
a.phone,
a.mobile,
a.nickname,
a.isDefaultAddress,
a.agencyModeFk,
a.isActive,
a.longitude,
a.latitude,
a.isEqualizated,
a.customsAgentFk,
a.incotermsFk,
a.isLogifloraAllowed,
a.editorFk
FROM client c
LEFT JOIN account.user u ON u.id = c.salesPersonFk
LEFT JOIN province p ON p.id = c.provinceFk
JOIN vn.address a ON a.clientFk = c.id;
DISTINCT c.id,
c.name,
c.fi,
c.socialName,
CONCAT(c.phone, ',',GROUP_CONCAT(DISTINCT a.phone)) phone,
c.mobile,
CONCAT(c.city, ',',GROUP_CONCAT(DISTINCT a.city)) city,
c.postcode,
a.postalCode,
c.email,
c.isActive,
c.isFreezed,
p.id AS provinceFk2,
a.provinceFk,
p.name AS province,
u.id AS salesPersonFk,
u.name AS salesPerson
FROM client c
LEFT JOIN account.user u ON u.id = c.salesPersonFk
LEFT JOIN province p ON p.id = c.provinceFk
JOIN address a ON a.clientFk = c.id
`
);
stmt.merge(conn.makeWhere(filter.where));
stmt.merge('GROUP BY c.id');
stmt.merge(conn.makePagination(filter));
const clientsIndex = stmts.push(stmt) - 1;