Index: src/main/groovy/com/lemans/pricecalc/Mapper.groovy =================================================================== diff -u -r410adb5b46bcbf0daa24fd480fd9bd31bf785cac -raffa884e54fede454bba680b92e1617e7157607f --- src/main/groovy/com/lemans/pricecalc/Mapper.groovy (.../Mapper.groovy) (revision 410adb5b46bcbf0daa24fd480fd9bd31bf785cac) +++ src/main/groovy/com/lemans/pricecalc/Mapper.groovy (.../Mapper.groovy) (revision affa884e54fede454bba680b92e1617e7157607f) @@ -4,7 +4,7 @@ class Mapper { static final List PART_MULTI_FILTERS = ['subComCodeId', 'categoryId', 'derivedPartStatusId'] - static final List PART_FILTERS = ['vendorId', 'brandId', 'catalogId', 'isActive', 'isDigiActive', 'productId', 'columnName', 'statusCodeId', 'buyer', 'activeVendorId'] + static final List PART_FILTERS = ['vendorId', 'brandId', 'catalogId', 'isActive', 'isDigiActive', 'productId', 'columnName', 'statusCodeId', 'buyer', 'activeVendorId', '_is_pc_admin_'] static final List PART_LIKE_FILTERS = ['partDescr'] static final List PART_LIKE_NO_SPECIAL_FILTERS = ['vendorPartNumber', 'partNumber', 'lastUpdatedBy'] @@ -37,10 +37,10 @@ } } - static Map selectAndJoin(String filterName) { + static Map selectAndJoin(Map criteria) { List joins = [] String select - switch (filterName) { + switch (criteria.filterName) { case 'brandId': joins << 'INNER JOIN [PartsSource_DS].dbo.Brand b WITH(NOLOCK) ON b.brandId = vp.brandId AND b.dateDeleted IS NULL' select = "[filter] = 'brand', id = b.brandId, code = b.brandCode, descr = b.brandName" @@ -89,7 +89,12 @@ select = "[filter] = 'catalog', id = c.catalogId, code = c.catalogId, descr = c.catalogName" break case 'buyer': - joins << 'INNER JOIN dbo.vwVendor v WITH(NOLOCK) ON v.vendorId = vp.vendorId' + if (criteria._is_pc_admin_ == 'true') { + joins << 'INNER JOIN dbo.vwVendor v WITH(NOLOCK) ON v.vendorId = vp.vendorId' + } else { + joins << """INNER JOIN dbo.vwVendor v WITH(NOLOCK) ON v.vendorId = vp.vendorId + AND (v.buyerGlobalId = "${criteria.username}" OR v.buyerManagerGlobalId = "${criteria.username}")""" + } select = "[filter] = 'buyer', id = v.buyerGlobalId, code = v.buyerGlobalId, descr = v.buyerGlobalId" break case 'activeVendorId': Index: src/main/groovy/com/lemans/pricecalc/controllers/search/SearchController.groovy =================================================================== diff -u -r89abc50695e7c767441e814fdec7b7aeac9f6a2f -raffa884e54fede454bba680b92e1617e7157607f --- src/main/groovy/com/lemans/pricecalc/controllers/search/SearchController.groovy (.../SearchController.groovy) (revision 89abc50695e7c767441e814fdec7b7aeac9f6a2f) +++ src/main/groovy/com/lemans/pricecalc/controllers/search/SearchController.groovy (.../SearchController.groovy) (revision affa884e54fede454bba680b92e1617e7157607f) @@ -21,7 +21,7 @@ @GetMapping(value = "/part/filter/{filterName}/options") def partsFilterOptions(@PathVariable String filterName) { List errors = [] - Map criteria = partFilters() + [filterName: filterName] + filters(['filterType']) + Map criteria = partFilters() + [filterName: filterName] + filters(['filterType']) + [username: auditUserNameOnly] validateFilterNameAndType(filterName, criteria.filterType, errors) errors ? renderList(errors) : renderPaginated(searchService.filterOptions(criteria)) } Index: src/main/groovy/com/lemans/pricecalc/services/search/SearchService.groovy =================================================================== diff -u -rf941c5e84b7ab32df1329056a261914e9bfd3ef9 -raffa884e54fede454bba680b92e1617e7157607f --- src/main/groovy/com/lemans/pricecalc/services/search/SearchService.groovy (.../SearchService.groovy) (revision f941c5e84b7ab32df1329056a261914e9bfd3ef9) +++ src/main/groovy/com/lemans/pricecalc/services/search/SearchService.groovy (.../SearchService.groovy) (revision affa884e54fede454bba680b92e1617e7157607f) @@ -15,7 +15,7 @@ CatalogRepository catalogRepository Map filterOptions(Map criteria) { - Map selectAndJoin = Mapper.selectAndJoin(criteria.filterName) + Map selectAndJoin = Mapper.selectAndJoin(criteria) dqx(criteria).executeWithOutCount( "${selectAndJoin.select} \n ${DynamicQueryExecutor.truncateSelect(SqlQueries.PARTS_NOT_IN_CATALOG_SQL)}", partsWithoutCatalogClauses(criteria), @@ -26,7 +26,7 @@ } Map auditLogFilterOptions(Map criteria) { - Map selectAndJoin = Mapper.selectAndJoin(criteria.filterName) + Map selectAndJoin = Mapper.selectAndJoin(criteria) if (criteria.columnName == 'catalogPartStatus') { criteria.columnName = 'statusCodeId' } dqx(criteria).executeWithOutCount( "${selectAndJoin.select} \n ${DynamicQueryExecutor.truncateSelect(SqlQueries.CATALOG_PARTS_AUDIT_LOG_SQL)}",