Compare commits

..

8 Commits

13 changed files with 610 additions and 277 deletions

View File

@ -47,7 +47,10 @@ public class POStatusController {
}
@GetMapping(value = "/generate-po-pdf", produces = MediaType.APPLICATION_PDF_VALUE)
public ResponseEntity<InputStreamResource> sendPoAndReturnPdf(@ModelAttribute POsDetails pOsDetails, Model model) throws Exception{
return purchaseOrderService.generatePOPdf(pOsDetails, model);
public ResponseEntity<InputStreamResource> sendPoAndReturnPdf(@ModelAttribute POsDetails pOsDetails,
@RequestParam(required = false, defaultValue = "true") boolean includeJobCard,
@RequestParam(required = false, defaultValue = "true") boolean includeStoreDetails,
Model model) throws Exception{
return purchaseOrderService.generatePOPdf(pOsDetails, model, includeJobCard, includeStoreDetails);
}
}

View File

@ -5,6 +5,7 @@ import com.utopiaindustries.model.ctp.JobCard;
import com.utopiaindustries.model.ctp.PurchaseOrderCTP;
import com.utopiaindustries.service.PurchaseOrderCTPService;
import com.utopiaindustries.util.StringUtils;
import org.springframework.security.core.parameters.P;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
@ -85,6 +86,11 @@ public class PurchaseOrderCTPController {
return "redirect:/purchase-order";
}
@GetMapping( "/store-items/{id}" )
public String getPOStoreItems( @PathVariable("id") long poId,
Model model ){
model.addAttribute("storeItems", purchaseOrderCTPService.getStoreItemsByPoId( poId ));
return "/reporting/po-store-items-table";
}
}

View File

@ -23,7 +23,7 @@ public class PurchaseOrderCTPDao {
private final String TABLE_NAME = "cut_to_pack.purchase_order";
private final String SELECT_QUERY = String.format( "SELECT * FROM %s WHERE id = :id", TABLE_NAME );
private final String SELECT_ALL_QUERY = String.format( "SELECT * FROM %s ORDER BY id DESC", TABLE_NAME );
private final String SELECT_ALL_QUERY = String.format( "SELECT * FROM %s ", TABLE_NAME );
private final String SELECT_BY_PO_CODE = String.format( "SELECT * FROM %s WHERE purchase_order_code = :purchase_order_code", TABLE_NAME );
private final String DELETE_QUERY = String.format( "DELETE FROM %s WHERE id = :id", TABLE_NAME );
private final String INSERT_QUERY = String.format(

View File

@ -1,6 +1,5 @@
package com.utopiaindustries.dao.ctp;
import com.utopiaindustries.model.ctp.PackagingItems;
import com.utopiaindustries.model.ctp.StoreItem;
import com.utopiaindustries.util.KeyHolderFunctions;
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
@ -10,7 +9,9 @@ import org.springframework.jdbc.support.KeyHolder;
import org.springframework.stereotype.Repository;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Repository
public class StoreItemDao {
@ -38,6 +39,7 @@ public class StoreItemDao {
"finish_item_id = VALUES(finish_item_id), account_id = VALUES(account_id), bundle_id = VALUES(bundle_id), reject_reason = VALUES(reject_reason)",
TABLE_NAME
);
String SELECT_BY_JOB_CARD_GROUP_REJECT_REASON = String.format("SELECT reject_reason, COUNT(*) AS total FROM %s WHERE job_card_id IN (:job_card_id) GROUP BY reject_reason", TABLE_NAME);
private static final String SELECT_BY_DATE_AND_IDs = String.format("SELECT COUNT(*) FROM %s WHERE (:start_date IS NULL OR created_at >= :start_date) AND created_at <= :end_date AND id IN (:ids)", TABLE_NAME);
@ -110,4 +112,20 @@ public class StoreItemDao {
Long count = namedParameterJdbcTemplate.queryForObject(SELECT_BY_DATE_AND_IDs, params, Long.class);
return count != null ? count : 0;
}
public Map<String, Integer> totalCountByJobCardIdsAndGroupByRejectReason(List<Long> jobCardIds) {
MapSqlParameterSource params = new MapSqlParameterSource();
params.addValue("job_card_id", jobCardIds);
List<Map<String, Object>> rows = namedParameterJdbcTemplate.queryForList(SELECT_BY_JOB_CARD_GROUP_REJECT_REASON, params);
Map<String, Integer> result = new HashMap<>();
for (Map<String, Object> row : rows) {
String reason = (String) row.get("reject_reason");
Integer total = ((Number) row.get("total")).intValue();
result.put(reason, total);
}
return result;
}
}

View File

@ -9,17 +9,24 @@ public class POsDetails {
private long poRequiredQuantity;
// items detail
private long totalCutting;
private long remainingCutting;
private long totalStitching;
private long remainingStitching;
private long totalEndLineQC;
private long remainingEndLineQC;
private long totalFinishing;
private long remainingFinishing;
private long totalAGradeItem;
private long totalBGradeItem;
private long totalCGradeItem;
private long actualCutting;
private long balanceToCutting;
private long cuttingReceived;
private long cuttingOki;
private long cuttingReject;
private long stitchingIn;
private long stitchingWips;
private long stitchingOut;
private long finishIn;
private long finishRej;
private long finishQaApproved;
private long storeReceived;
private long storeWaiting;
private long packagingIn;
private long packagingOut;
private long packagingStock;
private long shippedScan;
private long shippedNet;
private boolean poStatus;
public long getPoQuantity() {
@ -46,94 +53,6 @@ public class POsDetails {
this.articleTitle = articleTitle;
}
public long getTotalCutting() {
return totalCutting;
}
public void setTotalCutting(long totalCutting) {
this.totalCutting = totalCutting;
}
public long getRemainingCutting() {
return remainingCutting;
}
public void setRemainingCutting(long remainingCutting) {
this.remainingCutting = remainingCutting;
}
public long getTotalStitching() {
return totalStitching;
}
public void setTotalStitching(long totalStitching) {
this.totalStitching = totalStitching;
}
public long getRemainingStitching() {
return remainingStitching;
}
public void setRemainingStitching(long remainingStitching) {
this.remainingStitching = remainingStitching;
}
public long getTotalEndLineQC() {
return totalEndLineQC;
}
public void setTotalEndLineQC(long totalEndLineQC) {
this.totalEndLineQC = totalEndLineQC;
}
public long getRemainingEndLineQC() {
return remainingEndLineQC;
}
public void setRemainingEndLineQC(long remainingEndLineQC) {
this.remainingEndLineQC = remainingEndLineQC;
}
public long getTotalFinishing() {
return totalFinishing;
}
public void setTotalFinishing(long totalFinishing) {
this.totalFinishing = totalFinishing;
}
public long getRemainingFinishing() {
return remainingFinishing;
}
public void setRemainingFinishing(long remainingFinishing) {
this.remainingFinishing = remainingFinishing;
}
public long getTotalAGradeItem() {
return totalAGradeItem;
}
public void setTotalAGradeItem(long totalAGradeItem) {
this.totalAGradeItem = totalAGradeItem;
}
public long getTotalBGradeItem() {
return totalBGradeItem;
}
public void setTotalBGradeItem(long totalBGradeItem) {
this.totalBGradeItem = totalBGradeItem;
}
public long getTotalCGradeItem() {
return totalCGradeItem;
}
public void setTotalCGradeItem(long totalCGradeItem) {
this.totalCGradeItem = totalCGradeItem;
}
public long getPoId() {
return poId;
}
@ -150,6 +69,150 @@ public class POsDetails {
this.poRequiredQuantity = poRequiredQuantity;
}
public long getActualCutting() {
return actualCutting;
}
public void setActualCutting(long actualCutting) {
this.actualCutting = actualCutting;
}
public long getBalanceToCutting() {
return balanceToCutting;
}
public void setBalanceToCutting(long balanceToCutting) {
this.balanceToCutting = balanceToCutting;
}
public long getCuttingReceived() {
return cuttingReceived;
}
public void setCuttingReceived(long cuttingReceived) {
this.cuttingReceived = cuttingReceived;
}
public long getCuttingOki() {
return cuttingOki;
}
public void setCuttingOki(long cuttingOki) {
this.cuttingOki = cuttingOki;
}
public long getCuttingReject() {
return cuttingReject;
}
public void setCuttingReject(long cuttingReject) {
this.cuttingReject = cuttingReject;
}
public long getStitchingIn() {
return stitchingIn;
}
public void setStitchingIn(long stitchingIn) {
this.stitchingIn = stitchingIn;
}
public long getStitchingWips() {
return stitchingWips;
}
public void setStitchingWips(long stitchingWips) {
this.stitchingWips = stitchingWips;
}
public long getStitchingOut() {
return stitchingOut;
}
public void setStitchingOut(long stitchingOut) {
this.stitchingOut = stitchingOut;
}
public long getFinishIn() {
return finishIn;
}
public void setFinishIn(long finishIn) {
this.finishIn = finishIn;
}
public long getFinishRej() {
return finishRej;
}
public void setFinishRej(long finishRej) {
this.finishRej = finishRej;
}
public long getFinishQaApproved() {
return finishQaApproved;
}
public void setFinishQaApproved(long finishQaApproved) {
this.finishQaApproved = finishQaApproved;
}
public long getStoreReceived() {
return storeReceived;
}
public void setStoreReceived(long storeReceived) {
this.storeReceived = storeReceived;
}
public long getStoreWaiting() {
return storeWaiting;
}
public void setStoreWaiting(long storeWaiting) {
this.storeWaiting = storeWaiting;
}
public long getPackagingIn() {
return packagingIn;
}
public void setPackagingIn(long packagingIn) {
this.packagingIn = packagingIn;
}
public long getPackagingOut() {
return packagingOut;
}
public void setPackagingOut(long packagingOut) {
this.packagingOut = packagingOut;
}
public long getPackagingStock() {
return packagingStock;
}
public void setPackagingStock(long packagingStock) {
this.packagingStock = packagingStock;
}
public long getShippedScan() {
return shippedScan;
}
public void setShippedScan(long shippedScan) {
this.shippedScan = shippedScan;
}
public long getShippedNet() {
return shippedNet;
}
public void setShippedNet(long shippedNet) {
this.shippedNet = shippedNet;
}
public boolean isPoStatus() {
return poStatus;
}
@ -161,17 +224,29 @@ public class POsDetails {
@Override
public String toString() {
return "POsDetails{" +
"totalCutting=" + totalCutting +
", remainingCutting=" + remainingCutting +
", totalStitching=" + totalStitching +
", remainingStitching=" + remainingStitching +
", totalEndLineQC=" + totalEndLineQC +
", remainingEndLineQC=" + remainingEndLineQC +
", totalFinishing=" + totalFinishing +
", remainingFinishing=" + remainingFinishing +
", totalAGradeItem=" + totalAGradeItem +
", totalBGradeItem=" + totalBGradeItem +
", totalCGradeItem=" + totalCGradeItem +
"poId=" + poId +
", poNumber='" + poNumber + '\'' +
", articleTitle='" + articleTitle + '\'' +
", poQuantity=" + poQuantity +
", poRequiredQuantity=" + poRequiredQuantity +
", actualCutting=" + actualCutting +
", balanceToCutting=" + balanceToCutting +
", cuttingReceived=" + cuttingReceived +
", cuttingOki=" + cuttingOki +
", cuttingReject=" + cuttingReject +
", stitchingIn=" + stitchingIn +
", stitchingWips=" + stitchingWips +
", stitchingOut=" + stitchingOut +
", finishIn=" + finishIn +
", finishRej=" + finishRej +
", finishQaApproved=" + finishQaApproved +
", storeReceived=" + storeReceived +
", storeWaiting=" + storeWaiting +
", packagingIn=" + packagingIn +
", packagingOut=" + packagingOut +
", packagingStock=" + packagingStock +
", shippedScan=" + shippedScan +
", shippedNet=" + shippedNet +
'}';
}
}

View File

@ -17,6 +17,6 @@ public class PackagingService {
public void createPackagingItem(FinishedItemWrapper wrapper){
inventoryService.createPackagingItemAndTransaction(wrapper, wrapper.getAccountId());
}
}

View File

@ -1,6 +1,8 @@
package com.utopiaindustries.service;
import com.utopiaindustries.dao.ctp.JobCardDAO;
import com.utopiaindustries.dao.ctp.PurchaseOrderCTPDao;
import com.utopiaindustries.dao.ctp.StoreItemDao;
import com.utopiaindustries.model.ctp.*;
import com.utopiaindustries.model.uind.PurchaseOrder;
import com.utopiaindustries.querybuilder.ctp.JobCardQueryBuilder;
@ -14,15 +16,22 @@ import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service
public class PurchaseOrderCTPService {
private final PurchaseOrderCTPDao purchaseOrderCTPDao;
private final JobCardDAO jobCardDAO;
private final StoreItemDao storeItemDao;
public PurchaseOrderCTPService(PurchaseOrderCTPDao purchaseOrderCTPDao) {
public PurchaseOrderCTPService(PurchaseOrderCTPDao purchaseOrderCTPDao, JobCardDAO jobCardDAO, StoreItemDao storeItemDao) {
this.purchaseOrderCTPDao = purchaseOrderCTPDao;
this.jobCardDAO = jobCardDAO;
this.storeItemDao = storeItemDao;
}
/*
@ -77,4 +86,17 @@ public class PurchaseOrderCTPService {
return purchaseOrderCTPDao.findByTerm( term );
}
public Map<String,Integer> getStoreItemsByPoId(Long poId){
Map<String,Integer> totalItems = new HashMap<>();
List<JobCard> jobCards = jobCardDAO.findByPoId(poId);
List<Long> jobCardIds = jobCards.stream()
.map(JobCard::getId)
.collect(Collectors.toList());
if(!jobCardIds.isEmpty()){
return storeItemDao.totalCountByJobCardIdsAndGroupByRejectReason(jobCardIds);
}else {
return totalItems;
}
}
}

View File

@ -1,5 +1,6 @@
package com.utopiaindustries.service;
import com.utopiaindustries.dao.ctp.StoreItemDao;
import com.utopiaindustries.dao.uind.PurchaseOrderDAO;
import com.utopiaindustries.model.ctp.JobCardItem;
import com.utopiaindustries.model.ctp.POsDetails;
@ -13,19 +14,20 @@ import org.springframework.stereotype.Service;
import org.springframework.ui.Model;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service
public class PurchaseOrderService {
private final PurchaseOrderDAO purchaseOrderDAO;
private final ReportingService reportingService;
private final PurchaseOrderCTPService purchaseOrderCTPService;
private final HTMLBuilder htmlBuilder;
private PDFResponseEntityInputStreamResource pdfGenerator;
public PurchaseOrderService(PurchaseOrderDAO purchaseOrderDAO, ReportingService reportingService, HTMLBuilder htmlBuilder, PDFResponseEntityInputStreamResource pdfGenerator) {
public PurchaseOrderService(PurchaseOrderDAO purchaseOrderDAO, PurchaseOrderCTPService purchaseOrderCTPService, HTMLBuilder htmlBuilder, PDFResponseEntityInputStreamResource pdfGenerator) {
this.purchaseOrderDAO = purchaseOrderDAO;
this.reportingService = reportingService;
this.purchaseOrderCTPService = purchaseOrderCTPService;
this.htmlBuilder = htmlBuilder;
this.pdfGenerator = pdfGenerator;
}
@ -37,9 +39,17 @@ public class PurchaseOrderService {
/**
* Print Job card *
* **/
public ResponseEntity<InputStreamResource> generatePOPdf(POsDetails pOsDetails, Model model ) throws Exception {
public ResponseEntity<InputStreamResource> generatePOPdf(POsDetails pOsDetails, Model model, boolean jobCardDetail, boolean storeDetail ) throws Exception {
Map<String,Integer> storeItems = purchaseOrderCTPService.getStoreItemsByPoId(pOsDetails.getPoId());
model.addAttribute("poDetail", pOsDetails);
model.addAttribute( "baseUrl", URLUtils.getCurrentBaseUrl() );
if (storeDetail && !storeItems.isEmpty()){
model.addAttribute("showStore", true);
model.addAttribute("store", storeItems);
}else {
model.addAttribute("showStore", false);
}
String htmlStr = htmlBuilder.buildHTML( "po-status-pdf", model );
// return pdf
return pdfGenerator.generatePdf( htmlStr, "Po-status", "inline" );

View File

@ -30,8 +30,9 @@ public class ReportingService {
private final InventoryAccountDAO inventoryAccountDAO;
private final PurchaseOrderCTPDao purchaseOrderCTPDao;
private final StoreItemDao storeItemDao;
private final PackagingItemsDAO packagingItemsDAO;
public ReportingService(JobCardItemDAO jobCardItemDAO, BundleDAO bundleDAO, InventoryTransactionLegDAO inventoryTransactionLegDAO, JobCardDAO jobCardDAO, FinishedItemDAO finishedItemDAO, StitchingOfflineItemDAO stitchingOfflineItemDAO, InventoryAccountDAO inventoryAccountDAO, PurchaseOrderCTPDao purchaseOrderCTPDao, StoreItemDao storeItemDao) {
public ReportingService(JobCardItemDAO jobCardItemDAO, BundleDAO bundleDAO, InventoryTransactionLegDAO inventoryTransactionLegDAO, JobCardDAO jobCardDAO, FinishedItemDAO finishedItemDAO, StitchingOfflineItemDAO stitchingOfflineItemDAO, InventoryAccountDAO inventoryAccountDAO, PurchaseOrderCTPDao purchaseOrderCTPDao, StoreItemDao storeItemDao, PackagingItemsDAO packagingItemsDAO) {
this.jobCardItemDAO = jobCardItemDAO;
this.bundleDAO = bundleDAO;
this.inventoryTransactionLegDAO = inventoryTransactionLegDAO;
@ -41,6 +42,7 @@ public class ReportingService {
this.inventoryAccountDAO = inventoryAccountDAO;
this.purchaseOrderCTPDao = purchaseOrderCTPDao;
this.storeItemDao = storeItemDao;
this.packagingItemsDAO = packagingItemsDAO;
}
public Map<String, Integer> getJobCardProgress(String jobCardID) {
@ -446,18 +448,25 @@ public class ReportingService {
purchaseOrderCTPList = purchaseOrderCTPDao.findAll();
}
Map<String,Integer> jobCardCompleteItems = new HashMap<>();
for (PurchaseOrderCTP pos : purchaseOrderCTPList) {
List<JobCard> jobCards = jobCardDAO.findByPoId(pos.getId());
BigDecimal totalProduction = BigDecimal.ZERO;
BigDecimal expectedProduction = BigDecimal.ZERO;
BigDecimal actualProduction = BigDecimal.ZERO;
Long qaProgressItems = 0L;
Long totalFinishItem = 0L;
Long totalRejectPieces = 0L;
long stitchingIn = 0L;
long stitchingOut = 0L;
long finishApprovedItem = 0L;
long finishRejectItem = 0L;
long storeItems = 0L;
long packagingItems = 0L;
POsDetails pOsDetails = new POsDetails();
for (JobCard jobCard : jobCards) {
List<JobCardItem> jobCardItems = jobCardItemDAO.findByCardId(jobCard.getId());
expectedProduction = expectedProduction.add(jobCardItems.stream()
.map(item -> Optional.ofNullable(item.getExpectedProduction()).orElse(BigDecimal.ZERO))
.reduce(BigDecimal.ZERO, BigDecimal::add));
totalProduction = totalProduction.add(jobCardItems.stream()
.map(item -> Optional.ofNullable(item.getTotalProduction()).orElse(BigDecimal.ZERO))
.reduce(BigDecimal.ZERO, BigDecimal::add));
@ -465,34 +474,49 @@ public class ReportingService {
actualProduction = actualProduction.add(jobCardItems.stream()
.map(item -> Optional.ofNullable(item.getActualProduction()).orElse(BigDecimal.ZERO))
.reduce(BigDecimal.ZERO, BigDecimal::add));
qaProgressItems += Optional.ofNullable(stitchingOfflineItemDAO.CalculateTotalQA(jobCard.getId())).orElse(0L);
totalFinishItem += Optional.ofNullable(finishedItemDAO.calculateTotalFinishItem(jobCard.getId())).orElse(0L);
totalRejectPieces += Optional.ofNullable(storeItemDao.calculateTotalRejectItemByJobCardId(jobCard.getId())).orElse(0L);
jobCardCompleteItems = getSegregateItems(String.valueOf(jobCard.getId()));
if (jobCardCompleteItems == null) {
jobCardCompleteItems = new HashMap<>();
}
//stitching detail
stitchingIn += Optional.of(stitchingOfflineItemDAO.findByJobCardId(jobCard.getId()).size()).orElse(0);
stitchingOut += Optional.ofNullable(stitchingOfflineItemDAO.CalculateTotalQA(jobCard.getId())).orElse(0L);
//finishItems detail
List<FinishedItem> finishedItems = finishedItemDAO.findByJobCardId(jobCard.getId());
finishApprovedItem += finishedItems.stream().filter(e -> e.getQaStatus().equals("APPROVED")).count();
finishRejectItem += finishedItems.stream().filter(e -> e.getQaStatus().equals("REJECT")).count();
//reject store details
storeItems += Optional.ofNullable(storeItemDao.calculateTotalRejectItemByJobCardId(jobCard.getId())).orElse(0L);
//reject packaging details
packagingItems += Optional.of(packagingItemsDAO.findByJobCardId(jobCard.getId()).size()).orElse(0);
}
pOsDetails.setPoId(pos.getId());
pOsDetails.setPoNumber(pos.getPurchaseOrderCode());
pOsDetails.setArticleTitle(pos.getArticleName());
pOsDetails.setPoQuantity(pos.getPurchaseOrderQuantity());
pOsDetails.setPoRequiredQuantity(pos.getPurchaseOrderQuantityRequired());
pOsDetails.setTotalCutting(actualProduction.intValue());
pOsDetails.setTotalStitching(qaProgressItems);
pOsDetails.setTotalEndLineQC(qaProgressItems.intValue());
pOsDetails.setTotalFinishing(totalFinishItem);
pOsDetails.setActualCutting(expectedProduction.longValue());
pOsDetails.setBalanceToCutting(pos.getPurchaseOrderQuantityRequired() - actualProduction.longValue());
pOsDetails.setCuttingReceived(expectedProduction.longValue());
pOsDetails.setCuttingOki(actualProduction.intValue());
pOsDetails.setCuttingReject(expectedProduction.subtract(actualProduction).intValue());
pOsDetails.setStitchingIn(stitchingIn);
pOsDetails.setStitchingOut(stitchingOut);
pOsDetails.setStitchingWips(stitchingIn - stitchingOut);
pOsDetails.setFinishIn(stitchingOut);
pOsDetails.setFinishRej(finishRejectItem);
pOsDetails.setFinishQaApproved(finishApprovedItem);
pOsDetails.setStoreReceived(storeItems);
pOsDetails.setStoreWaiting(finishRejectItem - storeItems);
pOsDetails.setFinishQaApproved(finishApprovedItem);
pOsDetails.setPackagingIn(packagingItems);
pOsDetails.setPackagingOut(packagingItems);
pOsDetails.setPackagingStock(0);
pOsDetails.setShippedScan(packagingItems);
pOsDetails.setShippedNet(packagingItems);
pOsDetails.setPackagingStock(0);
pOsDetails.setPoStatus(false);
pOsDetails.setRemainingCutting(pos.getPurchaseOrderQuantityRequired() - actualProduction.intValue());
pOsDetails.setRemainingStitching(pos.getPurchaseOrderQuantityRequired() - qaProgressItems);
pOsDetails.setRemainingEndLineQC(pos.getPurchaseOrderQuantityRequired() - qaProgressItems);
pOsDetails.setRemainingFinishing(pos.getPurchaseOrderQuantityRequired() - totalFinishItem);
pOsDetails.setTotalAGradeItem(jobCardCompleteItems.getOrDefault("A GRADE", 0));
pOsDetails.setTotalBGradeItem(totalRejectPieces.intValue());
pOsDetailsList.add(pOsDetails);
}
return pOsDetailsList;

View File

@ -78,9 +78,9 @@
<a th:href="@{/store/}" class="nav-link"
th:classappend="${#strings.startsWith(#httpServletRequest.getRequestURI(), '/ctp/store') ? 'active' : ''}">Store</a>
</li>
<li class="nav-item"
th:classappend="${#strings.startsWith(#httpServletRequest.getRequestURI(), '/ctp/po-status') ? 'active' : ''}">
<a th:href="@{/po-status/}" class="nav-link">Online PO Status</a>
<li class="nav-item" sec:authorize="hasAnyRole('ROLE_PURCHASE_ORDER', 'ROLE_ADMIN')">
<a th:href="@{/po-status/}" class="nav-link"
th:classappend="${#strings.startsWith(#httpServletRequest.getRequestURI(), '/ctp/po-status') ? 'active' : ''}">Online PO Status</a>
</li>
<li class="nav-item" sec:authorize="hasAnyRole('ROLE_REPORTING', 'ROLE_ADMIN')">
<a th:href="@{/reporting/}" class="nav-link"

View File

@ -10,43 +10,60 @@
<title>Job Card</title>
<link href="https://fonts.googleapis.com/css?family=Open+Sans+Condensed:700|Open+Sans:400,400i&display=swap" rel="stylesheet">
<link rel="stylesheet" type="text/css" th:href="@{|${baseUrl}/css/print.css|}">
<style type="text/css">
@page {
size: landscape;
margin: 10mm;
}
@media print {
body {
transform: rotate(0deg); /* Not needed for @page landscape */
width: 100%;
}
}
.td-value{
text-align: center;
border: 1px solid black;
}
</style>
</head>
<body>
<div class="container-fluid">
<table>
<tr>
<td width="400">
<td width="50%">
<img width="200" th:src="@{|${baseUrl}/img/utopia-industries.png|}" alt="Utopia Industries">
</td>
<td width="400">
<td width="50%">
<table class="bordered">
<tr class="tr-header">
<td colspan="2" th:text="'PO Online Status'"></td>
<td colspan="2" style="text-align: center" th:text="'PO Online Status'"></td>
</tr>
<tbody>
<tr>
<td style="width: 40%; border: 1px solid black;"><i>PO Code</i></td>
<td style="width: 60%; border: 1px solid black;">
<td style="width: 40%;"><i>PO Code</i></td>
<td style="width: 60%;">
<a class="text-reset" target="_blank" th:text="${poDetail.getPoNumber()}"></a>
</td>
</tr>
<tr>
<td style="width: 40%; border: 1px solid black;"><i>Article Name</i></td>
<td style="width: 60%; border: 1px solid black;">
<td style="width: 40%;"><i>Article Name</i></td>
<td style="width: 60%;">
<a class="text-reset" target="_blank" th:text="${poDetail.getArticleTitle()}"></a>
</td>
</tr>
<tr>
<td class="align-middle" style="border: 1px solid black;"><i>PO Quantity</i></td>
<td style="border: 1px solid black;"><span th:text="${poDetail.getPoQuantity()}"></span></td>
<td class="align-middle"><i>PO Quantity</i></td>
<td><span th:text="${poDetail.getPoQuantity()}"></span></td>
</tr>
<tr>
<td class="align-middle" style="border: 1px solid black;"><i>PO Required Excess+</i></td>
<td style="border: 1px solid black;"><span th:text="${poDetail.getPoRequiredQuantity()}"></span></td>
<td class="align-middle"><i>PO Required Excess+</i></td>
<td><span th:text="${poDetail.getPoRequiredQuantity()}"></span></td>
</tr>
<tr>
<td class="align-middle" style="border: 1px solid black;"><i>PO Status</i></td>
<td style="border: 1px solid black;">
<td class="align-middle"><i>PO Status</i></td>
<td>
<span th:if="*{poDetail.isPoStatus}" th:text="'CLOSE'"></span>
<span th:if="*{!poDetail.isPoStatus}" th:text="'OPEN'"></span>
</td>
@ -57,34 +74,79 @@
</tr>
</table>
<table class="bordered" style="width: 100%; margin-top: 20px; border-collapse: collapse; ">
<h5 class="no-margin-top no-margin-bottom" style="margin-top: 20px;">PO Details</h5>
<thead >
<table style="margin-top: 10px;">
<h5 class="no-margin-top no-margin-bottom" style="margin-top: 10px;">PO Details</h5>
<thead>
<tr class="tr-header">
<td>Cutting</td>
<td>Cutting Balance</td>
<td>Stitching</td>
<td>Stitching Balance</td>
<td>End Line QC</td>
<td>End Line QC Balance</td>
<td>Finishing Items</td>
<td>Finishing Items Balance</td>
<td>A Grade Items</td>
<td>Reject Items In Store</td>
<td style="width: 70px; text-align: center"></td>
<td style="width: 60px; text-align: center">Cutting Insp.</td>
<td style="width: 150px; text-align: center">Stitching</td>
<td style="width: 60px; text-align: center">Finished</td>
<td style="width: 90px; text-align: center; padding-left: 40px">Rej. Store</td>
<td style="width: 100px; text-align: center">Packaging</td>
<td style="width: 80px; text-align: center">Shipped</td>
</tr>
</thead>
</table>
<table >
<thead>
<tr class="tr-header">
<td style="width: 50px; text-align: center" >Actual Cut</td>
<td style="width: 50px; text-align: center; border-right: 1px solid white;">Bal.To Cut</td>
<td style="width: 50px; text-align: center;">Rcvd.</td>
<td style="width: 50px; text-align: center">Ok</td>
<td style="width: 50px; text-align: center; border-right: 1px solid white;">Rej.</td>
<td style="width: 50px; text-align: center">In</td>
<td style="width: 50px; text-align: center">WIP</td>
<td style="width: 50px; text-align: center; border-right: 1px solid white;">Out</td>
<td style="width: 50px; text-align: center">In</td>
<td style="width: 50px; text-align: center">Rej</td>
<td style="width: 50px; text-align: center; border-right: 1px solid white;">QA Approv.</td>
<td style="width: 50px; text-align: center">Rcvd.</td>
<td style="width: 50px; text-align: center; border-right: 1px solid white;">waiting</td>
<td style="width: 50px; text-align: center">In</td>
<td style="width: 50px; text-align: center">Out</td>
<td style="width: 50px; text-align: center; border-right: 1px solid white;">Stock</td>
<td style="width: 50px; text-align: center">Scan</td>
<td style="width: 50px; text-align: center; border-right: 1px solid white;">Net</td>
</tr>
</thead>
<tbody>
<tr >
<td style="border: 1px solid black;" th:text="${poDetail.getTotalCutting()}"></td>
<td style="border: 1px solid black;" th:text="${poDetail.getRemainingCutting()}"></td>
<td style="border: 1px solid black;" th:text="${poDetail.getTotalStitching()}"></td>
<td style="border: 1px solid black;" th:text="${poDetail.getRemainingStitching()}"></td>
<td style="border: 1px solid black;" th:text="${poDetail.getTotalEndLineQC()}"></td>
<td style="border: 1px solid black;" th:text="${poDetail.getRemainingEndLineQC()}"></td>
<td style="border: 1px solid black;" th:text="${poDetail.getTotalFinishing()}"></td>
<td style="border: 1px solid black;" th:text="${poDetail.getRemainingFinishing()}"></td>
<td style="border: 1px solid black;" th:text="${poDetail.getTotalAGradeItem()}"></td>
<td style="border: 1px solid black;" th:text="${poDetail.getTotalBGradeItem()}"></td>
<td th:text="${poDetail.getActualCutting()}" class="td-value"></td>
<td th:text="${poDetail.getBalanceToCutting()}" class="td-value"></td>
<td th:text="${poDetail.getCuttingReceived()}" class="td-value"></td>
<td th:text="${poDetail.getCuttingOki()}" class="td-value"></td>
<td th:text="${poDetail.getCuttingReject()}" class="td-value"></td>
<td th:text="${poDetail.getStitchingIn()}" class="td-value"></td>
<td th:text="${poDetail.getStitchingWips()}" class="td-value"></td>
<td th:text="${poDetail.getStitchingOut()}" class="td-value"></td>
<td th:text="${poDetail.getFinishIn()}" class="td-value"></td>
<td th:text="${poDetail.getFinishRej()}" class="td-value"></td>
<td th:text="${poDetail.getFinishQaApproved()}" class="td-value"></td>
<td th:text="${poDetail.getStoreReceived()}" class="td-value"></td>
<td th:text="${poDetail.getStoreWaiting()}" class="td-value"></td>
<td th:text="${poDetail.getPackagingIn()}" class="td-value"></td>
<td th:text="${poDetail.getPackagingOut()}" class="td-value"></td>
<td th:text="${poDetail.getPackagingStock()}" class="td-value"></td>
<td th:text="${poDetail.getShippedScan()}" class="td-value"></td>
<td th:text="${poDetail.getShippedNet()}" class="td-value"></td>
</tr>
</tbody>
</table>
<table class="bordered" style="width: 50%; margin-top: 20px;" th:if="${showStore}">
<tr class="tr-header">
<td colspan="2" style="text-align: center" th:text="'Reject Items In Store'"></td>
</tr>
<tbody>
<tr th:each="heading : ${store.keySet()}"
th:if="${store != null and not store.isEmpty()}">
<td style="width: 40%;"><i th:text="${heading}"></i></td>
<td style="width: 60%;">
<a class="text-reset" target="_blank" th:text="${store.get(heading)}"></a>
</td>
</tr>
</tbody>
</table>

View File

@ -7,26 +7,36 @@
<header class="row page-header" th:replace="_fragments :: page-header"></header>
<main class="row page-main">
<aside class="col-sm-2" th:replace="/reporting/po-report-sidebar :: sidebar"></aside>
<div class="col-lg-10 col-sm-10">
<h3>All PO's </h3>
<table th:if="${ #lists != null && #lists.size(allPOs) != 0 }" class="table table-striped font-sm"
data-order="[[ 0, &quot;asc&quot; ]]">
<div class="col-lg-10 col-sm-10" style="overflow-x: auto;">
<h3>All PO's</h3>
<div class="table-responsive"> <!-- Bootstrap responsive table wrapper -->
<table th:if="${ #lists != null && #lists.size(allPOs) != 0 }"
class="table table-striped font-sm" style="min-width: 1500px;">
<thead>
<tr>
<th>PO Number</th>
<th>PO Article</th>
<th>PO Quantity</th>
<th>Req+ Excess</th>
<th>Cutting</th>
<th>Cutting Balance</th>
<th>Stitching</th>
<th>Stitching Balance</th>
<th>End Line QC</th>
<th>End Line QC Balance</th>
<th>Finishing Items</th>
<th>Finishing Items Balance</th>
<th>A Grade Items</th>
<th>Reject Items In Store</th>
<th>Cut.</th>
<th>Cut Bal.</th>
<th>Cut Recv.</th>
<th>Cut oki</th>
<th>Cut Rej.</th>
<th>Stit. In</th>
<th>Stit. Out</th>
<th>Stit. Wips</th>
<th>finish In</th>
<th>finish Rej.</th>
<th>finish QA APP.</th>
<th>Rej. Store Rcvd</th>
<th>Rej. Store Waiting</th>
<th>Packed In</th>
<th>Packed Out</th>
<th>Packed Stock</th>
<th>Shipped Scan</th>
<th>Shipped Net</th>
<th></th>
<th>PO Status</th>
<th>Generate PDF</th>
</tr>
@ -39,16 +49,30 @@
<td th:text="${poDetail.articleTitle}"></td>
<td th:text="${poDetail.poQuantity}"></td>
<td th:text="${poDetail.poRequiredQuantity}"></td>
<td th:text="${poDetail.totalCutting}"></td>
<td th:text="${poDetail.remainingCutting}"></td>
<td th:text="${poDetail.totalStitching}"></td>
<td th:text="${poDetail.remainingStitching}"></td>
<td th:text="${poDetail.totalEndLineQC}"></td>
<td th:text="${poDetail.remainingEndLineQC}"></td>
<td th:text="${poDetail.totalFinishing}"></td>
<td th:text="${poDetail.remainingFinishing}"></td>
<td th:text="${poDetail.totalAGradeItem}"></td>
<td th:text="${poDetail.totalBGradeItem}"></td>
<td th:text="${poDetail.actualCutting}"></td>
<td th:text="${poDetail.balanceToCutting}"></td>
<td th:text="${poDetail.cuttingReceived}"></td>
<td th:text="${poDetail.cuttingOki}"></td>
<td th:text="${poDetail.cuttingReject}"></td>
<td th:text="${poDetail.stitchingIn}"></td>
<td th:text="${poDetail.stitchingOut}"></td>
<td th:text="${poDetail.stitchingWips}"></td>
<td th:text="${poDetail.finishIn}"></td>
<td th:text="${poDetail.finishRej}"></td>
<td th:text="${poDetail.finishQaApproved}"></td>
<td th:text="${poDetail.storeReceived}"></td>
<td th:text="${poDetail.storeWaiting}"></td>
<td th:text="${poDetail.packagingIn}"></td>
<td th:text="${poDetail.packagingOut}"></td>
<td th:text="${poDetail.packagingStock}"></td>
<td th:text="${poDetail.shippedScan}"></td>
<td th:text="${poDetail.shippedNet}"></td>
<td data-show-dropdown-transactions
th:data-po-id="${poDetail.poId}"
title="Store-Items">
<span data-dropdown-icon-transactions class="bi bi-caret-right-fill"></span>
</td>
<td>
<span class="badge font-sm badge-danger" th:if="*{poDetail.poStatus}" th:text="'CLOSE'"></span>
<span class="badge font-sm badge-ACTIVE" th:if="*{!poDetail.poStatus}" th:text="'OPEN'"></span>
@ -62,24 +86,29 @@
<input type="hidden" name="articleTitle" th:value="${poDetail.articleTitle}"/>
<input type="hidden" name="poQuantity" th:value="${poDetail.poQuantity}"/>
<input type="hidden" name="poRequiredQuantity" th:value="${poDetail.poRequiredQuantity}"/>
<input type="hidden" name="totalCutting" th:value="${poDetail.totalCutting}"/>
<input type="hidden" name="remainingCutting" th:value="${poDetail.remainingCutting}"/>
<input type="hidden" name="totalStitching" th:value="${poDetail.totalStitching}"/>
<input type="hidden" name="remainingStitching" th:value="${poDetail.remainingStitching}"/>
<input type="hidden" name="totalEndLineQC" th:value="${poDetail.totalEndLineQC}"/>
<input type="hidden" name="remainingEndLineQC" th:value="${poDetail.remainingEndLineQC}"/>
<input type="hidden" name="totalFinishing" th:value="${poDetail.totalFinishing}"/>
<input type="hidden" name="remainingFinishing" th:value="${poDetail.remainingFinishing}"/>
<input type="hidden" name="totalAGradeItem" th:value="${poDetail.totalAGradeItem}"/>
<input type="hidden" name="totalBGradeItem" th:value="${poDetail.totalBGradeItem}"/>
<input type="hidden" name="actualCutting" th:value="${poDetail.actualCutting}"/>
<input type="hidden" name="balanceToCutting" th:value="${poDetail.balanceToCutting}"/>
<input type="hidden" name="cuttingReceived" th:value="${poDetail.cuttingReceived}"/>
<input type="hidden" name="cuttingOki" th:value="${poDetail.cuttingOki}"/>
<input type="hidden" name="cuttingReject" th:value="${poDetail.cuttingReject}"/>
<input type="hidden" name="stitchingIn" th:value="${poDetail.stitchingIn}"/>
<input type="hidden" name="stitchingOut" th:value="${poDetail.stitchingOut}"/>
<input type="hidden" name="stitchingWips" th:value="${poDetail.stitchingWips}"/>
<input type="hidden" name="finishIn" th:value="${poDetail.finishIn}"/>
<input type="hidden" name="finishRej" th:value="${poDetail.finishRej}"/>
<input type="hidden" name="finishQaApproved" th:value="${poDetail.finishQaApproved}"/>
<input type="hidden" name="storeReceived" th:value="${poDetail.storeReceived}"/>
<input type="hidden" name="storeWaiting" th:value="${poDetail.storeWaiting}"/>
<input type="hidden" name="packagingIn" th:value="${poDetail.packagingIn}"/>
<input type="hidden" name="packagingOut" th:value="${poDetail.packagingOut}"/>
<input type="hidden" name="packagingStock" th:value="${poDetail.packagingStock}"/>
<input type="hidden" name="shippedScan" th:value="${poDetail.shippedScan}"/>
<input type="hidden" name="shippedNet" th:value="${poDetail.shippedNet}"/>
<input type="hidden" name="poStatus" th:value="${poDetail.poStatus}"/>
<!-- Link styled as a button -->
<a href="javascript:void(0);"
th:onclick="'document.getElementById(\'form-' + ${poDetail.poId} + '\').submit()'"
th:onclick="'showPdfOptions(' + ${poDetail.poId} + ')'"
class="btn btn-sm btn-secondary"
title="Generate PDF"
target="_blank">
title="Generate PDF">
<i class="bi bi-filetype-pdf"></i>
</a>
</form>
@ -89,8 +118,133 @@
</table>
<h4 th:if="${#lists.size(allPOs) == 0 }">No PO found.</h4>
</div>
</div>
<div class="modal fade" id="pdfOptionsModal" tabindex="-1" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Select PDF Options</h5>
</div>
<div class="modal-body">
<!-- <div class="form-check">-->
<!-- <input class="form-check-input" type="checkbox" id="includeJobCard" name="includeJobCard" value="true" checked>-->
<!-- <label class="form-check-label" for="includeJobCard">-->
<!-- Include Job Card Details-->
<!-- </label>-->
<!-- </div>-->
<div class="form-check">
<input class="form-check-input" type="checkbox" id="includeStoreDetails" name="includeStoreDetails" value="true" checked>
<label class="form-check-label" for="includeStoreDetails">
Include Store Details
</label>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" onclick="submitPdfForm()">Generate PDF</button>
</div>
</div>
</div>
</div>
</main>
</div>
<div th:replace="_fragments :: page-footer-scripts"></div>
<script>
// PDF Generation Functions
let currentPoIdForPdf = null;
function showPdfOptions(poId) {
currentPoIdForPdf = poId;
$('#pdfOptionsModal').modal('show');
}
function submitPdfForm() {
if (!currentPoIdForPdf) return;
const form = document.getElementById('form-' + currentPoIdForPdf);
// Remove existing options if they exist
const existingJobCard = form.querySelector('input[name="includeJobCard"]');
const existingStoreDetails = form.querySelector('input[name="includeStoreDetails"]');
if (existingJobCard) form.removeChild(existingJobCard);
if (existingStoreDetails) form.removeChild(existingStoreDetails);
// Add params to show store details in pdf
const includeStoreDetails = document.createElement('input');
includeStoreDetails.type = 'hidden';
includeStoreDetails.name = 'includeStoreDetails';
includeStoreDetails.value = document.getElementById('includeStoreDetails').checked;
form.appendChild(includeStoreDetails);
form.submit();
$('#pdfOptionsModal').modal('hide');
}
// DataTable and Dropdown Initialization
$(document).ready(function() {
const $body = $('body');
// Initialize DataTables for each individual table
$('table[data-account-table]').each(function () {
$(this).DataTable({
paging: false,
pageLength: 100,
searching: false,
lengthChange: false,
processing: false,
dom: `
<'row'<'col-sm-3'B><'col-sm-4'f>>
<'row'<'col-sm-6't>>
<'row'<'col-sm-3'i><'col-sm-4'p>>`,
buttons: [{
extend: 'excel',
text: '',
className: 'bi bi-file-earmark-spreadsheet btn-sm d-none'
}]
});
});
// Dropdown transactions toggle
$body.on('click', '[data-show-dropdown-transactions]', function (e) {
e.preventDefault();
const $this = $(this);
const $tr = $this.closest('tr');
const $table = $this.closest('table');
const dataTable = $table.DataTable();
const $row = dataTable.row($tr);
const $spanDropdown = $this.find('[data-dropdown-icon-transactions]');
const poId = $this.data('po-id');
$spanDropdown.toggleClass('bi-caret-right-fill bi-caret-down-fill');
if ($row.child.isShown()) {
$row.child.hide();
} else {
$row.child(`<span class="spinner-border text-center spinner-border-md" role="status"></span>`).show();
$.ajax({
url: `/ctp/purchase-order/store-items/${poId}`,
success: function(data) {
if (data.includes('page-login') ||
data.includes('login__form') ||
data.includes('Sign in')) {
// Redirect to login page
window.location.href = '/ctp/login?logout';
} else {
$row.child(data).show();
}
},
error: function(xhr) {
if (xhr.status === 401) {
window.location.href = '/ctp/login?logout';
} else {
$row.child('<span class="text-danger">Error loading data</span>').show();
}
}
});
}
});
});
</script>
</body>
</html>

View File

@ -3,43 +3,24 @@
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
/* Custom CSS for full height and center alignment of span */
.vertical-divider {
display: flex;
justify-content: center; /* Center horizontally */
align-items: center; /* Center vertically */
}
.vertical-divider span {
display: inline-block;
width: 1px;
background-color: #dee2e6;
height: 100%; /* Take full height of the parent div */
}
</style>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-sm-12">
<table th:if="${#lists.size(transactions) != 0 && #lists != null }" class="table table-bordered font-sm mb-4" data-account-tables>
<div class="col-sm-8">
<table th:if="${#lists != null && #lists.size(storeItems.keySet()) != 0 }" class="table table-bordered font-sm mb-4" data-account-tables >
<thead>
<tr>
<th>Cut To Pack</th>
<th>Knitting</th>
<th>Dying</th>
<th th:each="heading : ${storeItems.keySet()}" th:text="${heading}"></th>
</tr>
</thead>
<tbody>
<tr th:each="transaction : ${transactions}" th:object="${transaction}">
<td th:text="*{id}"></td>
<td th:text="*{itemId}"></td>
<td th:text="*{sku}"></td>
<tr>
<td th:each="heading : ${storeItems.keySet()}" th:text="${storeItems.get(heading)}"></td>
</tr>
</tbody>
</table>
<h5 th:if="${#lists.size(transactions) == 0}" class="mt-2">No Inventory Transactions found.</h5>
<h5 th:if="${#lists.size(storeItems.keySet()) == 0}" class="mt-2">No Items found.</h5>
</div>
</div>
</div>
@ -53,43 +34,21 @@
// Prevent reinitializing if already done
if (!$.fn.DataTable.isDataTable($table)) {
$table.DataTable({
pageLength: 5,
searching: true,
paging: false,
searching: false,
lengthChange: false,
processing: false,
dom: `
<'row'<'col-sm-5'B><'col-sm-7'f>>
<'row'<'col-sm-12't>>
<'row'<'col-sm-5'i><'col-sm-7'p>>`,
info: false,
dom: 't',
buttons: [{
extend: 'excel',
text: '',
className: 'bi bi-file-earmark-spreadsheet btn-sm d-none' // Keep it hidden
className: 'bi bi-file-earmark-spreadsheet btn-sm d-none'
}]
});
}
});
(async function () {
const $selectAllCheckBox = $('[data-checkbox-all]');
$selectAllCheckBox.change(function () {
if ($selectAllCheckBox.prop('checked')) {
// When parent checkbox is checked, check all child checkboxes
$('[name="parent-doc-type-ids"]').each(function () {
let $this = $(this);
$this.prop('checked', true);
});
} else {
// When parent checkbox is unchecked, uncheck all child checkboxes
$('[name="parent-doc-type-ids"]').each(function () {
let $this = $(this);
$this.prop('checked', false);
});
}
});
})(jQuery)
</script>
</body>