From aeaf74c021e08988c84d435c887100bd69eb50a8 Mon Sep 17 00:00:00 2001 From: "usama.jameel" Date: Tue, 7 Jan 2025 12:45:34 +0500 Subject: [PATCH] fixed inventory account sidebar And add functionality in backend --- .../InventoryAccountController.java | 14 +++- .../ctp/InventoryAccountQueryBuilder.java | 26 ++++-- .../service/InventoryAccountService.java | 30 +++++++ .../templates/_inventory-account-sidebar.html | 79 +++++++------------ .../templates/cutting/inventory-accounts.html | 2 +- .../resources/templates/job-card-list.html | 4 +- .../resources/templates/job-card-view.html | 10 +-- 7 files changed, 96 insertions(+), 69 deletions(-) diff --git a/src/main/java/com/utopiaindustries/controller/InventoryAccountController.java b/src/main/java/com/utopiaindustries/controller/InventoryAccountController.java index 4a450c2..30f0400 100644 --- a/src/main/java/com/utopiaindustries/controller/InventoryAccountController.java +++ b/src/main/java/com/utopiaindustries/controller/InventoryAccountController.java @@ -3,6 +3,7 @@ package com.utopiaindustries.controller; import com.utopiaindustries.auth.AdminRole; import com.utopiaindustries.model.ctp.InventoryAccount; import com.utopiaindustries.service.InventoryAccountService; +import com.utopiaindustries.util.StringUtils; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.*; @@ -20,8 +21,17 @@ public class InventoryAccountController { } @GetMapping - public String showInventoryAccounts( Model model ){ - model.addAttribute( "accounts", inventoryAccountService.findInventoryAccounts() ); + public String showInventoryAccounts( @RequestParam( value = "id", required = false ) String id, + @RequestParam( value = "title", required = false) String title, + @RequestParam( value = "active", required = false ) String active, + @RequestParam( value = "created-by", required = false ) String createdBy, + @RequestParam( value = "start-date", required = false ) String startDate, + @RequestParam( value = "end-date", required = false ) String endDate, + @RequestParam( value = "site-id", required = false ) String siteId, + @RequestParam( value = "count", required = false ) Long count, + Model model ){ + + model.addAttribute( "accounts", inventoryAccountService.findInventoryAccountsByFilter(id, title, active, createdBy, startDate, endDate, siteId, count) ); return "inventory-account-list"; } diff --git a/src/main/java/com/utopiaindustries/querybuilder/ctp/InventoryAccountQueryBuilder.java b/src/main/java/com/utopiaindustries/querybuilder/ctp/InventoryAccountQueryBuilder.java index 11e5df9..d8618eb 100644 --- a/src/main/java/com/utopiaindustries/querybuilder/ctp/InventoryAccountQueryBuilder.java +++ b/src/main/java/com/utopiaindustries/querybuilder/ctp/InventoryAccountQueryBuilder.java @@ -54,15 +54,25 @@ public class InventoryAccountQueryBuilder { .and() .columnEqualToOrLessThan("created_at", endDate1) .and() - .columnEquals("location_site_id", siteId) - .and() - .columnEquals("parent_entity_type", parentEntityType ) - .and() - .columnEquals("parent_entity_id", parentEntityId ) - .and() - .columnEquals("is_packaging", isPackaging ); + .columnEquals("location_site_id", siteId); - if (!accountIds.isEmpty()) { + + if (isPackaging != null){ + qb.and() + .columnEquals("is_packaging", isPackaging ); + } + + if (parentEntityId != null && !parentEntityId.equals("")){ + qb.and() + .columnEquals("parent_entity_id", parentEntityId ); + } + + if (parentEntityType != null && !parentEntityType.equals("")){ + qb.and() + .columnEquals("parent_entity_type", parentEntityType ); + } + + if ( accountIds != null && !accountIds.isEmpty()) { qb.and() .columnIn("id", accountIds.toArray( new Long[0] )); } diff --git a/src/main/java/com/utopiaindustries/service/InventoryAccountService.java b/src/main/java/com/utopiaindustries/service/InventoryAccountService.java index d83b4a7..70d2af4 100644 --- a/src/main/java/com/utopiaindustries/service/InventoryAccountService.java +++ b/src/main/java/com/utopiaindustries/service/InventoryAccountService.java @@ -78,6 +78,36 @@ public class InventoryAccountService { return accounts; } + public List findInventoryAccountsByFilter(String id, String title, String active, String createdBy, String startDate, String endDate, + String siteId, Long count){ + List accounts; + if( StringUtils.isAnyNotNullOrEmpty( id,title, active, createdBy, startDate, endDate, siteId ) ){ + String query = InventoryAccountQueryBuilder.buildQuery( + id, + title, + active, + createdBy, + startDate, + endDate, + siteId, + count, + null, + "", + "", + null + + ); + System.out.println( query ); + accounts = inventoryAccountDAO.findByQuery( query ); + } else { + accounts = inventoryAccountDAO.findAll(); + } + for( InventoryAccount account : accounts ){ + account.setLocationTitle( locationSiteDAO.find( account.getLocationSiteId() ).getTitle() ); + } + return accounts; + } + public InventoryAccount createNewAccount(){ // get login user Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); diff --git a/src/main/resources/templates/_inventory-account-sidebar.html b/src/main/resources/templates/_inventory-account-sidebar.html index 5e10cbf..484e305 100644 --- a/src/main/resources/templates/_inventory-account-sidebar.html +++ b/src/main/resources/templates/_inventory-account-sidebar.html @@ -7,72 +7,49 @@
Refine Your Search
+
+ + +
- +
- - -
-
- - + + +
-
- - -
-
-
- - -
-
- - -
-
-
- - + +
- - + +
- - + + +
+
+
-
- - + +
+ - Reset + Reset
diff --git a/src/main/resources/templates/cutting/inventory-accounts.html b/src/main/resources/templates/cutting/inventory-accounts.html index 044c3dc..6151dcd 100644 --- a/src/main/resources/templates/cutting/inventory-accounts.html +++ b/src/main/resources/templates/cutting/inventory-accounts.html @@ -45,7 +45,7 @@ - ACTIVE + ACTIVE INACTIVE diff --git a/src/main/resources/templates/job-card-list.html b/src/main/resources/templates/job-card-list.html index 37ba409..c0cba3f 100644 --- a/src/main/resources/templates/job-card-list.html +++ b/src/main/resources/templates/job-card-list.html @@ -37,11 +37,11 @@ - + - - + - diff --git a/src/main/resources/templates/job-card-view.html b/src/main/resources/templates/job-card-view.html index 8d785da..5fda209 100644 --- a/src/main/resources/templates/job-card-view.html +++ b/src/main/resources/templates/job-card-view.html @@ -119,8 +119,8 @@ - - + + @@ -153,9 +153,9 @@ - - - + + +