1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.module.purap.document.web.struts;
17
18 import org.apache.log4j.Logger;
19 import org.kuali.ole.module.purap.PurapAuthorizationConstants;
20 import org.kuali.ole.module.purap.PurapKeyConstants;
21 import org.kuali.ole.module.purap.document.BulkReceivingDocument;
22 import org.kuali.ole.sys.OLEConstants;
23 import org.kuali.ole.sys.document.web.struts.FinancialSystemTransactionalDocumentFormBase;
24 import org.kuali.rice.kns.web.ui.ExtraButton;
25 import org.kuali.rice.krad.util.KRADConstants;
26 import org.kuali.rice.krad.util.ObjectUtils;
27
28 import javax.servlet.http.HttpServletRequest;
29 import java.util.List;
30
31 public class BulkReceivingForm extends FinancialSystemTransactionalDocumentFormBase {
32
33 protected static final Logger LOG = Logger.getLogger(BulkReceivingForm.class);
34 protected Integer purchaseOrderId;
35
36 public BulkReceivingForm() {
37 super();
38 }
39
40 @Override
41 protected String getDefaultDocumentTypeName() {
42 return "RCVB";
43 }
44
45 public BulkReceivingDocument getBulkReceivingDocument() {
46 return (BulkReceivingDocument) getDocument();
47 }
48
49 public void setBulkReceivingDocument(BulkReceivingDocument bulkReceivingDocument) {
50 setDocument(bulkReceivingDocument);
51 }
52
53 public Integer getPurchaseOrderId() {
54 return purchaseOrderId;
55 }
56
57 public void setPurchaseOrderId(Integer purchaseOrderId) {
58 this.purchaseOrderId = purchaseOrderId;
59 }
60
61
62
63
64
65
66
67
68
69
70
71 @Override
72 public List<ExtraButton> getExtraButtons() {
73 extraButtons.clear();
74
75 String displayInitTab = (String) getEditingMode().get(PurapAuthorizationConstants.BulkReceivingEditMode.DISPLAY_INIT_TAB);
76 if (ObjectUtils.isNotNull(displayInitTab) && displayInitTab.equalsIgnoreCase("true")) {
77 extraButtons.add(createBulkReceivingContinueButton());
78 extraButtons.add(createClearInitFieldsButton());
79 } else if (getBulkReceivingDocument().getDocumentHeader().getWorkflowDocument().isEnroute() ||
80 getBulkReceivingDocument().getDocumentHeader().getWorkflowDocument().isProcessed() ||
81 getBulkReceivingDocument().getDocumentHeader().getWorkflowDocument().isFinal()) {
82 extraButtons.add(createPrintReceivingTicketButton());
83 }
84
85 return extraButtons;
86 }
87
88
89
90
91
92
93 protected ExtraButton createBulkReceivingContinueButton() {
94 ExtraButton continueButton = new ExtraButton();
95 continueButton.setExtraButtonProperty("methodToCall.continueBulkReceiving");
96 continueButton.setExtraButtonSource("${" + OLEConstants.RICE_EXTERNALIZABLE_IMAGES_URL_KEY + "}buttonsmall_continue.gif");
97 continueButton.setExtraButtonAltText("Continue");
98 return continueButton;
99 }
100
101
102
103
104
105
106 protected ExtraButton createClearInitFieldsButton() {
107 ExtraButton clearButton = new ExtraButton();
108 clearButton.setExtraButtonProperty("methodToCall.clearInitFields");
109 clearButton.setExtraButtonSource("${" + OLEConstants.RICE_EXTERNALIZABLE_IMAGES_URL_KEY + "}buttonsmall_clear.gif");
110 clearButton.setExtraButtonAltText("Clear");
111 return clearButton;
112 }
113
114
115
116
117
118
119 protected ExtraButton createPrintReceivingTicketButton() {
120 ExtraButton printButton = new ExtraButton();
121 printButton.setExtraButtonProperty("methodToCall.printReceivingTicketPDF");
122 printButton.setExtraButtonSource("${" + OLEConstants.EXTERNALIZABLE_IMAGES_URL_KEY + "}buttonsmall_print.gif");
123 printButton.setExtraButtonAltText("Print");
124 return printButton;
125 }
126
127 public String getGoodsDeliveredByLabel() {
128 return PurapKeyConstants.MESSAGE_BULK_RECEIVING_GOODSDELIVEREDBY_LABEL;
129 }
130
131
132 @Override
133 public boolean shouldMethodToCallParameterBeUsed(String methodToCallParameterName, String methodToCallParameterValue, HttpServletRequest request) {
134 if (KRADConstants.DISPATCH_REQUEST_PARAMETER.equals(methodToCallParameterName) && "printReceivingTicket".equals(methodToCallParameterValue)) {
135 return true;
136 }
137 return super.shouldMethodToCallParameterBeUsed(methodToCallParameterName, methodToCallParameterValue, request);
138 }
139 }