fix report filter

This commit is contained in:
AdisakKanthawilang 2024-12-18 17:23:20 +07:00
parent ce86d800a7
commit 97cd947b7c

View file

@ -45,8 +45,8 @@ export class ReportController extends Controller {
*/
@Get("registry-officer")
async registryOfficer(
@Query() rootId: string,
@Query() year: number,
@Query() rootId?: string,
@Query() year?: number,
@Query() ageMin?: number,
@Query() ageMax?: number,
) {
@ -80,7 +80,7 @@ export class ReportController extends Controller {
.leftJoinAndSelect('current_holder.posLevel', 'posLevel')
.leftJoinAndSelect('current_holder.profileEducations', 'profileEducations')
.where('posMaster.orgRevisionId = :currentRevisionId', { currentRevisionId: currentRevision?.id })
.andWhere('posMaster.orgRootId = :rootId', { rootId })
.andWhere(rootId?'posMaster.orgRootId = :rootId': "1=1", { rootId: rootId })
.andWhere('posMaster.current_holderId Is Not Null')
.andWhere('positions.positionIsSelected = :positionIsSelected', { positionIsSelected: true })
.andWhere( yearInAD && yearInAD != null? 'YEAR(current_holder.dateAppoint) = :year': "1=1", { year: yearInAD })
@ -142,7 +142,7 @@ export class ReportController extends Controller {
template: "registry-officer",
reportName: "xlsx-report",
data: {
year: Extension.ToThaiNumber(year.toString()),
year: year?Extension.ToThaiNumber(year.toString()):Extension.ToThaiNumber(new Date().getFullYear().toString()),
date: Extension.ToThaiNumber(Extension.ToThaiShortDate(new Date())),
list: result
},
@ -156,8 +156,8 @@ export class ReportController extends Controller {
*/
@Get("registry-emp")
async registryEmp(
@Query() rootId: string,
@Query() year: number,
@Query() rootId?: string,
@Query() year?: number,
@Query() ageMin?: number,
@Query() ageMax?: number,
) {
@ -190,7 +190,7 @@ export class ReportController extends Controller {
.leftJoinAndSelect('current_holder.posLevel', 'posLevel')
.leftJoinAndSelect('current_holder.profileEducations', 'profileEducations')
.where('posMaster.orgRevisionId = :currentRevisionId', { currentRevisionId: currentRevision?.id })
.andWhere('posMaster.orgRootId = :rootId', { rootId })
.andWhere(rootId?'posMaster.orgRootId = :rootId': "1=1", { rootId: rootId })
.andWhere('posMaster.current_holderId Is Not Null')
.andWhere('positions.positionIsSelected = :positionIsSelected', { positionIsSelected: true })
.andWhere( yearInAD && yearInAD != null? 'YEAR(current_holder.dateAppoint) = :year': "1=1", { year: yearInAD })
@ -248,7 +248,7 @@ export class ReportController extends Controller {
template: "registry-emp",
reportName: "xlsx-report",
data: {
year: Extension.ToThaiNumber(year.toString()),
year: year?Extension.ToThaiNumber(year.toString()):Extension.ToThaiNumber(new Date().getFullYear().toString()),
date: Extension.ToThaiNumber(Extension.ToThaiShortDate(new Date())),
list: result
},