Compare commits
2 commits
ab4ea4ba4b
...
e5a3d948a5
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e5a3d948a5 | ||
|
|
0d78ce4db3 |
1 changed files with 53 additions and 0 deletions
|
|
@ -170,6 +170,10 @@ export class CustomerController extends Controller {
|
|||
@Query() activeBranchOnly?: boolean,
|
||||
@Query() startDate?: Date,
|
||||
@Query() endDate?: Date,
|
||||
@Query() businessType?: string,
|
||||
@Query() province?: string,
|
||||
@Query() district?: string,
|
||||
@Query() subDistrict?: string,
|
||||
) {
|
||||
const where = {
|
||||
OR: queryOrNot<Prisma.CustomerWhereInput[]>(query, [
|
||||
|
|
@ -192,6 +196,47 @@ export class CustomerController extends Controller {
|
|||
: permissionCond(req.user, { activeOnly: activeBranchOnly }),
|
||||
},
|
||||
},
|
||||
branch: {
|
||||
some: {
|
||||
AND: [
|
||||
businessType
|
||||
? {
|
||||
OR: [
|
||||
{ businessType: { name: { contains: businessType, mode: "insensitive" } } },
|
||||
{ businessType: { nameEN: { contains: businessType, mode: "insensitive" } } },
|
||||
],
|
||||
}
|
||||
: {},
|
||||
|
||||
province
|
||||
? {
|
||||
OR: [
|
||||
{ province: { name: { contains: province, mode: "insensitive" } } },
|
||||
{ province: { nameEN: { contains: province, mode: "insensitive" } } },
|
||||
],
|
||||
}
|
||||
: {},
|
||||
|
||||
district
|
||||
? {
|
||||
OR: [
|
||||
{ district: { name: { contains: district, mode: "insensitive" } } },
|
||||
{ district: { nameEN: { contains: district, mode: "insensitive" } } },
|
||||
],
|
||||
}
|
||||
: {},
|
||||
|
||||
subDistrict
|
||||
? {
|
||||
OR: [
|
||||
{ subDistrict: { name: { contains: subDistrict, mode: "insensitive" } } },
|
||||
{ subDistrict: { nameEN: { contains: subDistrict, mode: "insensitive" } } },
|
||||
],
|
||||
}
|
||||
: {},
|
||||
],
|
||||
},
|
||||
},
|
||||
...whereDateQuery(startDate, endDate),
|
||||
} satisfies Prisma.CustomerWhereInput;
|
||||
|
||||
|
|
@ -597,6 +642,10 @@ export class CustomerExportController extends CustomerController {
|
|||
@Query() activeBranchOnly?: boolean,
|
||||
@Query() startDate?: Date,
|
||||
@Query() endDate?: Date,
|
||||
@Query() businessType?: string,
|
||||
@Query() province?: string,
|
||||
@Query() district?: string,
|
||||
@Query() subDistrict?: string,
|
||||
) {
|
||||
const ret = await this.list(
|
||||
req,
|
||||
|
|
@ -610,6 +659,10 @@ export class CustomerExportController extends CustomerController {
|
|||
activeBranchOnly,
|
||||
startDate,
|
||||
endDate,
|
||||
businessType,
|
||||
province,
|
||||
district,
|
||||
subDistrict,
|
||||
);
|
||||
|
||||
this.setHeader("Content-Type", "text/csv");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue