| 167 |
ashish |
1 |
package in.shop2020.hotspot.dashbaord.client.inbox;
|
|
|
2 |
|
|
|
3 |
import in.shop2020.hotspot.dashbaord.client.event.AcceptOrderEvent;
|
| 4421 |
mandeep.dh |
4 |
import in.shop2020.hotspot.dashbaord.client.event.FlagOrderEvent;
|
| 487 |
rajveer |
5 |
import in.shop2020.hotspot.dashbaord.client.event.NostockOrderEvent;
|
| 4421 |
mandeep.dh |
6 |
import in.shop2020.hotspot.dashbaord.client.event.ProvisionalCaptureEvent;
|
| 2513 |
chandransh |
7 |
import in.shop2020.hotspot.dashbaord.client.event.RequestPickupEvent;
|
| 2628 |
chandransh |
8 |
import in.shop2020.hotspot.dashbaord.client.event.ReshipOrderEvent;
|
| 2843 |
chandransh |
9 |
import in.shop2020.hotspot.dashbaord.shared.actions.BillingType;
|
| 306 |
ashish |
10 |
import in.shop2020.hotspot.dashbaord.shared.actions.DetailsMask;
|
| 167 |
ashish |
11 |
import in.shop2020.hotspot.dashbaord.shared.actions.Order;
|
| 2835 |
chandransh |
12 |
import in.shop2020.hotspot.dashbaord.shared.actions.UserType;
|
| 167 |
ashish |
13 |
|
| 4421 |
mandeep.dh |
14 |
import java.util.Map;
|
|
|
15 |
|
| 167 |
ashish |
16 |
import org.enunes.gwt.mvp.client.EventBus;
|
|
|
17 |
|
|
|
18 |
import com.google.gwt.core.client.GWT;
|
|
|
19 |
import com.google.gwt.event.dom.client.ClickEvent;
|
|
|
20 |
import com.google.gwt.event.dom.client.ClickHandler;
|
|
|
21 |
import com.google.gwt.resources.client.CssResource;
|
|
|
22 |
import com.google.gwt.uibinder.client.UiBinder;
|
|
|
23 |
import com.google.gwt.uibinder.client.UiField;
|
| 487 |
rajveer |
24 |
import com.google.gwt.user.client.Window;
|
| 306 |
ashish |
25 |
import com.google.gwt.user.client.ui.Button;
|
| 167 |
ashish |
26 |
import com.google.gwt.user.client.ui.FlexTable;
|
| 306 |
ashish |
27 |
import com.google.gwt.user.client.ui.HorizontalPanel;
|
|
|
28 |
import com.google.gwt.user.client.ui.Label;
|
| 167 |
ashish |
29 |
import com.google.gwt.user.client.ui.ResizeComposite;
|
| 306 |
ashish |
30 |
import com.google.gwt.user.client.ui.VerticalPanel;
|
| 167 |
ashish |
31 |
import com.google.gwt.user.client.ui.Widget;
|
|
|
32 |
|
|
|
33 |
public class OrderDetails extends ResizeComposite{
|
|
|
34 |
|
|
|
35 |
public interface Listener{
|
|
|
36 |
void onClick();
|
|
|
37 |
}
|
|
|
38 |
|
| 585 |
chandransh |
39 |
interface OrderDetailsUiBinder extends UiBinder<Widget, OrderDetails>{ }
|
| 167 |
ashish |
40 |
|
|
|
41 |
interface SelectionStyle extends CssResource{
|
| 306 |
ashish |
42 |
String blueLabel();
|
|
|
43 |
String greenLabel();
|
| 167 |
ashish |
44 |
}
|
|
|
45 |
|
| 585 |
chandransh |
46 |
private static final OrderDetailsUiBinder binder = GWT.create(OrderDetailsUiBinder.class);
|
| 167 |
ashish |
47 |
|
|
|
48 |
@UiField FlexTable header;
|
|
|
49 |
@UiField FlexTable table;
|
| 306 |
ashish |
50 |
@UiField HorizontalPanel orderDetails;
|
|
|
51 |
@UiField VerticalPanel orderDetails1;
|
|
|
52 |
@UiField VerticalPanel orderDetails2;
|
|
|
53 |
@UiField VerticalPanel orderDetails3;
|
|
|
54 |
@UiField VerticalPanel orderDetails4;
|
|
|
55 |
@UiField VerticalPanel orderDetails5;
|
|
|
56 |
@UiField SelectionStyle selectionStyle;
|
| 167 |
ashish |
57 |
|
|
|
58 |
|
|
|
59 |
private final EventBus eventbus;
|
|
|
60 |
private Order order;
|
|
|
61 |
private Order transaction;
|
| 2509 |
chandransh |
62 |
|
| 3065 |
chandransh |
63 |
//Buttons for the Warehouse Executive
|
| 4367 |
rajveer |
64 |
//private Button verifyOrder = new Button();
|
| 306 |
ashish |
65 |
private Button acceptOrder = new Button();
|
|
|
66 |
private Button rejectOrder = new Button();
|
| 4361 |
rajveer |
67 |
private Button printAllInvoices = new Button();
|
| 306 |
ashish |
68 |
private Button notAvailable= new Button();
|
|
|
69 |
private Button addBillingInfo= new Button();
|
| 2449 |
chandransh |
70 |
private Button printInvoice = new Button();
|
| 2610 |
chandransh |
71 |
private Button receiveReturn = new Button();
|
| 2509 |
chandransh |
72 |
private Button validateDOA = new Button();
|
| 4495 |
rajveer |
73 |
private Button validateReturnProduct = new Button();
|
| 677 |
chandransh |
74 |
|
| 3463 |
chandransh |
75 |
//Buttons for the Admin to track order
|
| 2509 |
chandransh |
76 |
private Button flagOrder = new Button();
|
|
|
77 |
private Button requestPickup = new Button();
|
|
|
78 |
private Button authorizePickup = new Button();
|
|
|
79 |
private Button refundOrder = new Button();
|
| 4421 |
mandeep.dh |
80 |
private Button reshipOrder = new Button();
|
|
|
81 |
private Button provisionallyCapturePaymentForOrder = new Button();
|
| 2509 |
chandransh |
82 |
|
| 3463 |
chandransh |
83 |
//Buttons for the Admin to edit order details
|
|
|
84 |
private Button addWeight = new Button();
|
|
|
85 |
private Button changeColor = new Button();
|
| 3553 |
chandransh |
86 |
private Button addDelayReason = new Button();
|
| 3463 |
chandransh |
87 |
private Button shiftWarehouse = new Button();
|
|
|
88 |
|
| 306 |
ashish |
89 |
private String user;
|
|
|
90 |
private DetailsMask mask;
|
| 677 |
chandransh |
91 |
private long warehouseID;
|
| 2835 |
chandransh |
92 |
private UserType userType;
|
| 2843 |
chandransh |
93 |
private BillingType billingType;
|
| 4363 |
rajveer |
94 |
private Map<Long, String> vendors;
|
| 167 |
ashish |
95 |
|
| 4363 |
rajveer |
96 |
public OrderDetails(EventBus eventbus, Order order, Order order2, DetailsMask mask, String user, long warehouseID, UserType userType, BillingType billingType, Map<Long, String> vendors){
|
| 167 |
ashish |
97 |
this.eventbus = eventbus;
|
|
|
98 |
this.order = order;
|
|
|
99 |
this.transaction = order2;
|
| 306 |
ashish |
100 |
this.mask = mask;
|
|
|
101 |
this.user = user;
|
| 677 |
chandransh |
102 |
this.warehouseID = warehouseID;
|
| 2835 |
chandransh |
103 |
this.userType = userType;
|
| 2843 |
chandransh |
104 |
this.billingType = billingType;
|
| 4363 |
rajveer |
105 |
this.vendors = vendors;
|
| 2449 |
chandransh |
106 |
|
| 167 |
ashish |
107 |
initWidget(binder.createAndBindUi(this));
|
| 4359 |
rajveer |
108 |
initTableForWE();
|
| 2835 |
chandransh |
109 |
if(this.userType == UserType.ADMIN){
|
| 2509 |
chandransh |
110 |
initTableForAdmin();
|
|
|
111 |
}
|
| 306 |
ashish |
112 |
loadOrderDetails();
|
| 167 |
ashish |
113 |
}
|
|
|
114 |
|
| 2509 |
chandransh |
115 |
private void initTableForWE() {
|
| 4367 |
rajveer |
116 |
header.getColumnFormatter().setWidth(0, "100px");
|
|
|
117 |
header.getColumnFormatter().setWidth(1, "100px");
|
|
|
118 |
header.getColumnFormatter().setWidth(2, "100px");
|
|
|
119 |
header.getColumnFormatter().setWidth(3, "100px");
|
|
|
120 |
header.getColumnFormatter().setWidth(4, "100px");
|
|
|
121 |
header.getColumnFormatter().setWidth(5, "100px");
|
|
|
122 |
header.getColumnFormatter().setWidth(6, "100px");
|
|
|
123 |
header.getColumnFormatter().setWidth(7, "100px");
|
| 306 |
ashish |
124 |
|
| 4367 |
rajveer |
125 |
//verifyOrder.setText("Verify");
|
| 306 |
ashish |
126 |
acceptOrder.setText("Accept");
|
|
|
127 |
notAvailable.setText("Out Of Stock");
|
|
|
128 |
addBillingInfo.setText("Bill");
|
| 2843 |
chandransh |
129 |
if(billingType == BillingType.OURS)
|
|
|
130 |
addBillingInfo.setVisible(false);
|
| 2449 |
chandransh |
131 |
printInvoice.setText("Print Invoice");
|
| 2610 |
chandransh |
132 |
receiveReturn.setText("Receive Return");
|
| 2509 |
chandransh |
133 |
validateDOA.setText("Validate DOA");
|
| 4495 |
rajveer |
134 |
validateReturnProduct.setText("Product Usable ?");
|
| 4248 |
rajveer |
135 |
rejectOrder.setText("Cancel Order");
|
| 4361 |
rajveer |
136 |
printAllInvoices.setText("Print All Invoices");
|
| 486 |
rajveer |
137 |
|
| 4367 |
rajveer |
138 |
//header.setWidget(0, 0, verifyOrder);
|
|
|
139 |
header.setWidget(0, 0, acceptOrder);
|
|
|
140 |
header.setWidget(0, 1, notAvailable);
|
|
|
141 |
header.setWidget(0, 2, addBillingInfo);
|
|
|
142 |
header.setWidget(0, 3, printInvoice);
|
|
|
143 |
header.setWidget(0, 4, receiveReturn);
|
|
|
144 |
header.setWidget(0, 5, validateDOA);
|
|
|
145 |
header.setWidget(0, 6, rejectOrder);
|
|
|
146 |
header.setWidget(0, 7, printAllInvoices);
|
| 4495 |
rajveer |
147 |
header.setWidget(0, 8, validateReturnProduct);
|
| 2509 |
chandransh |
148 |
|
|
|
149 |
registerButtonHandlersForWE();
|
| 4367 |
rajveer |
150 |
if(this.userType == UserType.WAREHOUSE_EXECUTIVE || this.userType == UserType.ADMIN){
|
|
|
151 |
implementMaskForWE();
|
|
|
152 |
}
|
|
|
153 |
if(this.userType == UserType.WAREHOUSE_MONITOR){
|
|
|
154 |
implementMaskForWM();
|
|
|
155 |
}
|
|
|
156 |
|
| 167 |
ashish |
157 |
}
|
|
|
158 |
|
| 2509 |
chandransh |
159 |
private void registerButtonHandlersForWE(){
|
| 4367 |
rajveer |
160 |
/*
|
| 3065 |
chandransh |
161 |
verifyOrder.addClickHandler(new ClickHandler() {
|
|
|
162 |
|
|
|
163 |
@Override
|
|
|
164 |
public void onClick(ClickEvent event) {
|
|
|
165 |
if(verifyOrder.isEnabled()){
|
|
|
166 |
GWT.log("Verify order event fired");
|
|
|
167 |
eventbus.fireEvent(new VerifyOrderEvent(order));
|
|
|
168 |
}
|
|
|
169 |
}
|
|
|
170 |
});
|
| 4367 |
rajveer |
171 |
*/
|
| 3065 |
chandransh |
172 |
|
| 306 |
ashish |
173 |
acceptOrder.addClickHandler(new ClickHandler() {
|
|
|
174 |
|
|
|
175 |
@Override
|
|
|
176 |
public void onClick(ClickEvent event) {
|
| 2558 |
chandransh |
177 |
if(acceptOrder.isEnabled())
|
| 306 |
ashish |
178 |
eventbus.fireEvent(new AcceptOrderEvent(order));
|
|
|
179 |
}
|
|
|
180 |
});
|
| 486 |
rajveer |
181 |
|
| 487 |
rajveer |
182 |
notAvailable.addClickHandler(new ClickHandler() {
|
|
|
183 |
|
|
|
184 |
@Override
|
|
|
185 |
public void onClick(ClickEvent event) {
|
| 2558 |
chandransh |
186 |
if(notAvailable.isEnabled())
|
|
|
187 |
eventbus.fireEvent(new NostockOrderEvent(order));
|
| 487 |
rajveer |
188 |
}
|
|
|
189 |
});
|
|
|
190 |
|
| 4248 |
rajveer |
191 |
rejectOrder.addClickHandler(new ClickHandler() {
|
|
|
192 |
|
|
|
193 |
@Override
|
|
|
194 |
public void onClick(ClickEvent event) {
|
|
|
195 |
if(rejectOrder.isEnabled()){
|
|
|
196 |
RejectReasonBox box = new RejectReasonBox(eventbus, order, user);
|
|
|
197 |
box.center();
|
|
|
198 |
}
|
|
|
199 |
}
|
|
|
200 |
});
|
|
|
201 |
|
| 306 |
ashish |
202 |
addBillingInfo.addClickHandler(new ClickHandler() {
|
|
|
203 |
|
|
|
204 |
@Override
|
|
|
205 |
public void onClick(ClickEvent event) {
|
| 1146 |
chandransh |
206 |
if(!addBillingInfo.isEnabled())
|
|
|
207 |
return;
|
| 306 |
ashish |
208 |
BillingInfoBox box = new BillingInfoBox(eventbus, order, user);
|
|
|
209 |
box.center();
|
|
|
210 |
}
|
|
|
211 |
});
|
| 487 |
rajveer |
212 |
|
| 2449 |
chandransh |
213 |
printInvoice.addClickHandler(new ClickHandler() {
|
| 306 |
ashish |
214 |
|
|
|
215 |
@Override
|
|
|
216 |
public void onClick(ClickEvent event) {
|
| 2449 |
chandransh |
217 |
if(!printInvoice.isEnabled())
|
| 1146 |
chandransh |
218 |
return;
|
| 4265 |
rajveer |
219 |
if(order.getJacketNumber()==0 && billingType == BillingType.OURS){
|
| 4363 |
rajveer |
220 |
JacketInfoBox box = new JacketInfoBox(eventbus, order, user, billingType, vendors);
|
| 1146 |
chandransh |
221 |
//box.clean();
|
|
|
222 |
box.center();
|
|
|
223 |
}else{
|
| 4361 |
rajveer |
224 |
String invoiceGenerationUrl = GWT.getHostPageBaseURL() + "invoice/?id=" + order.getOrderId() + "&warehouse=" + warehouseID;
|
| 2843 |
chandransh |
225 |
if(billingType == BillingType.OURS)
|
|
|
226 |
invoiceGenerationUrl += "&withBill=true";
|
|
|
227 |
else
|
|
|
228 |
invoiceGenerationUrl += "&withBill=false";
|
| 1146 |
chandransh |
229 |
Window.open(invoiceGenerationUrl, "newWindowName", "window features.");
|
|
|
230 |
}
|
| 306 |
ashish |
231 |
}
|
|
|
232 |
});
|
| 2588 |
chandransh |
233 |
|
| 4361 |
rajveer |
234 |
printAllInvoices.addClickHandler(new ClickHandler() {
|
|
|
235 |
|
|
|
236 |
@Override
|
|
|
237 |
public void onClick(ClickEvent event) {
|
|
|
238 |
if(!printAllInvoices.isEnabled()){
|
|
|
239 |
return;
|
|
|
240 |
}else{
|
|
|
241 |
String invoiceGenerationUrl = GWT.getHostPageBaseURL() + "invoice/?id=" + order.getOrderId() + "&printAll=true&warehouse=" + warehouseID;
|
|
|
242 |
if(billingType == BillingType.OURS)
|
|
|
243 |
invoiceGenerationUrl += "&withBill=true";
|
|
|
244 |
else
|
|
|
245 |
invoiceGenerationUrl += "&withBill=false";
|
|
|
246 |
Window.open(invoiceGenerationUrl, "newWindowName", "window features.");
|
|
|
247 |
}
|
|
|
248 |
}
|
|
|
249 |
});
|
|
|
250 |
|
| 2610 |
chandransh |
251 |
receiveReturn.addClickHandler(new ClickHandler() {
|
| 2588 |
chandransh |
252 |
|
|
|
253 |
@Override
|
|
|
254 |
public void onClick(ClickEvent event) {
|
| 4478 |
rajveer |
255 |
if(!receiveReturn.isEnabled())
|
|
|
256 |
return;
|
|
|
257 |
ReceiveReturnBox box = new ReceiveReturnBox(eventbus, order);
|
|
|
258 |
box.center();
|
| 2588 |
chandransh |
259 |
}
|
|
|
260 |
});
|
|
|
261 |
|
|
|
262 |
validateDOA.addClickHandler(new ClickHandler() {
|
|
|
263 |
|
|
|
264 |
@Override
|
|
|
265 |
public void onClick(ClickEvent event) {
|
|
|
266 |
if(!validateDOA.isEnabled())
|
|
|
267 |
return;
|
|
|
268 |
DoaValidationBox box = new DoaValidationBox(eventbus, order);
|
|
|
269 |
box.center();
|
|
|
270 |
}
|
|
|
271 |
});
|
| 4495 |
rajveer |
272 |
|
|
|
273 |
validateReturnProduct.addClickHandler(new ClickHandler() {
|
|
|
274 |
|
|
|
275 |
@Override
|
|
|
276 |
public void onClick(ClickEvent event) {
|
|
|
277 |
if(!validateReturnProduct.isEnabled())
|
|
|
278 |
return;
|
|
|
279 |
ProductValidationBox box = new ProductValidationBox(eventbus, order);
|
|
|
280 |
box.center();
|
|
|
281 |
}
|
|
|
282 |
});
|
| 2449 |
chandransh |
283 |
}
|
| 487 |
rajveer |
284 |
|
| 4367 |
rajveer |
285 |
private void implementMaskForWM(){
|
| 4495 |
rajveer |
286 |
maskButtonsForWE(false, false, false, false, false, false, false, false, false); //Unknown state, let's disallow any untoward actions.
|
| 4367 |
rajveer |
287 |
}
|
|
|
288 |
|
| 2509 |
chandransh |
289 |
private void implementMaskForWE(){
|
| 306 |
ashish |
290 |
switch(mask){
|
| 3065 |
chandransh |
291 |
case VERIFICATION_PENDING:
|
| 4495 |
rajveer |
292 |
maskButtonsForWE(false, false, false, false, false, false, false, false, false); //Do not allow the WE to verify the order.
|
| 3065 |
chandransh |
293 |
break;
|
| 4421 |
mandeep.dh |
294 |
case CAPTURE_IN_PROCESS:
|
| 306 |
ashish |
295 |
case NEW:
|
| 4495 |
rajveer |
296 |
maskButtonsForWE(true, false, true, false, false, false, false, false, false); //Allow the WE to either accept the order or mark it as out of stock.
|
| 306 |
ashish |
297 |
break;
|
|
|
298 |
case ACCEPT:
|
| 2843 |
chandransh |
299 |
//TODO: Mask buttons based on the billingType
|
|
|
300 |
if(billingType == BillingType.OURS)
|
| 4495 |
rajveer |
301 |
maskButtonsForWE(false, false, false, true, true, false, false, true, false); // For our billing, allow the WE to directly print the invoive.
|
| 2843 |
chandransh |
302 |
else
|
| 4495 |
rajveer |
303 |
maskButtonsForWE(false, false, false, true, true, false, false, true, false); //For external billing, allow the WE to feed the invoice info.
|
| 306 |
ashish |
304 |
break;
|
| 486 |
rajveer |
305 |
case REJECT:
|
| 4495 |
rajveer |
306 |
maskButtonsForWE(false, false, false, false, false, false, false, false, false); //Can't do anything once the order has been rejected.
|
| 486 |
rajveer |
307 |
break;
|
| 306 |
ashish |
308 |
case BILL:
|
| 4495 |
rajveer |
309 |
maskButtonsForWE(false, false, false, true, false, false, false, false, false); //Allow WE to print the invoice for a billed order.
|
| 306 |
ashish |
310 |
break;
|
|
|
311 |
case SHIP:
|
| 4495 |
rajveer |
312 |
maskButtonsForWE(false, false, false, false, false, false, false, false, false);
|
| 306 |
ashish |
313 |
break;
|
| 487 |
rajveer |
314 |
case NO_STOCK:
|
| 4495 |
rajveer |
315 |
maskButtonsForWE(true, false, false, false, false, false, false, false, false); //Allow WE to accept a low inventory item.
|
| 487 |
rajveer |
316 |
break;
|
| 4248 |
rajveer |
317 |
case CANCEL_CONFIRMED:
|
| 4495 |
rajveer |
318 |
maskButtonsForWE(false, true, false, false, false, false, false, false, false); //Allow WE to Cancel a order which is in cancellation pending state.
|
| 4248 |
rajveer |
319 |
break;
|
| 2509 |
chandransh |
320 |
case DOA_AWAITED:
|
| 2610 |
chandransh |
321 |
case SALES_RETURN_AWAITED:
|
| 4495 |
rajveer |
322 |
maskButtonsForWE(false, false, false, false, false, true, false, false, false); //Allow WE to accept the packet.
|
| 2509 |
chandransh |
323 |
break;
|
| 2610 |
chandransh |
324 |
case DOA_RECEIVED:
|
| 4495 |
rajveer |
325 |
maskButtonsForWE(false, false, false, false, false, false, true, false, false); //Allow WE to validate the DOA certificate.
|
| 2509 |
chandransh |
326 |
break;
|
| 4495 |
rajveer |
327 |
case RET_RECEIVED:
|
|
|
328 |
maskButtonsForWE(false, false, false, false, false, false, false, false, true); //Allow WE to validate the DOA certificate.
|
|
|
329 |
break;
|
|
|
330 |
|
| 2558 |
chandransh |
331 |
default:
|
| 4495 |
rajveer |
332 |
maskButtonsForWE(false, false, false, false, false, false, false, false, false); //Unknown state, let's disallow any untoward actions.
|
| 2558 |
chandransh |
333 |
break;
|
| 306 |
ashish |
334 |
}
|
|
|
335 |
}
|
|
|
336 |
|
| 4495 |
rajveer |
337 |
private void maskButtonsForWE(boolean accept, boolean reject, boolean notavailable, boolean printInv, boolean billing, boolean acceptdoa, boolean validatedoa, boolean printAllInvoice, boolean validatereturnproduct){
|
| 4367 |
rajveer |
338 |
//verifyOrder.setEnabled(verify);
|
| 3065 |
chandransh |
339 |
acceptOrder.setEnabled(accept);
|
| 306 |
ashish |
340 |
notAvailable.setEnabled(notavailable);
|
| 2449 |
chandransh |
341 |
printInvoice.setEnabled(printInv);
|
| 306 |
ashish |
342 |
addBillingInfo.setEnabled(billing);
|
| 2610 |
chandransh |
343 |
receiveReturn.setEnabled(acceptdoa);
|
| 2509 |
chandransh |
344 |
validateDOA.setEnabled(validatedoa);
|
|
|
345 |
rejectOrder.setEnabled(reject);
|
| 4363 |
rajveer |
346 |
printAllInvoices.setEnabled(printAllInvoice);
|
| 4495 |
rajveer |
347 |
validateReturnProduct.setEnabled(validatereturnproduct);
|
| 306 |
ashish |
348 |
}
|
| 2509 |
chandransh |
349 |
|
|
|
350 |
private void initTableForAdmin() {
|
|
|
351 |
if(transaction.isDoaFlag()){
|
|
|
352 |
flagOrder.setText("Unflag");
|
|
|
353 |
} else {
|
|
|
354 |
flagOrder.setText("Flag");
|
|
|
355 |
}
|
|
|
356 |
|
|
|
357 |
requestPickup.setText("Request Pick-up No");
|
| 4455 |
rajveer |
358 |
authorizePickup.setText("Confirm Pick-up");
|
| 2509 |
chandransh |
359 |
reshipOrder.setText("Reship");
|
|
|
360 |
refundOrder.setText("Refund");
|
| 4421 |
mandeep.dh |
361 |
provisionallyCapturePaymentForOrder.setText("Capture payment provisionally");
|
| 2509 |
chandransh |
362 |
|
| 2558 |
chandransh |
363 |
header.setWidget(1, 0, flagOrder);
|
|
|
364 |
header.setWidget(1, 1, requestPickup);
|
|
|
365 |
header.setWidget(1, 2, authorizePickup);
|
|
|
366 |
header.setWidget(1, 3, reshipOrder);
|
| 4421 |
mandeep.dh |
367 |
header.setWidget(1, 5, provisionallyCapturePaymentForOrder);
|
| 2558 |
chandransh |
368 |
header.setWidget(1, 6, refundOrder);
|
| 2509 |
chandransh |
369 |
|
| 3463 |
chandransh |
370 |
addWeight.setText("Add weight");
|
|
|
371 |
changeColor.setText("Change Color");
|
| 3553 |
chandransh |
372 |
addDelayReason.setText("Add Delay Reason");
|
| 3463 |
chandransh |
373 |
shiftWarehouse.setText("Shift Warehouse");
|
|
|
374 |
|
|
|
375 |
header.setWidget(2, 0, addWeight);
|
|
|
376 |
header.setWidget(2, 1, changeColor);
|
| 3553 |
chandransh |
377 |
header.setWidget(2, 2, addDelayReason);
|
| 3463 |
chandransh |
378 |
header.setWidget(2, 6, shiftWarehouse);
|
|
|
379 |
|
|
|
380 |
if(order.getTotalWeight() != 0)
|
|
|
381 |
addWeight.setEnabled(false);
|
|
|
382 |
|
| 2509 |
chandransh |
383 |
registerButtonHandlersForAdmin();
|
| 3729 |
chandransh |
384 |
implementMaskForAdmin();
|
| 2509 |
chandransh |
385 |
}
|
| 306 |
ashish |
386 |
|
| 2509 |
chandransh |
387 |
private void registerButtonHandlersForAdmin(){
|
|
|
388 |
flagOrder.addClickHandler(new ClickHandler() {
|
|
|
389 |
|
|
|
390 |
@Override
|
|
|
391 |
public void onClick(ClickEvent event) {
|
|
|
392 |
if(flagOrder.isEnabled()){
|
|
|
393 |
eventbus.fireEvent(new FlagOrderEvent(order));
|
|
|
394 |
}
|
|
|
395 |
}
|
|
|
396 |
});
|
|
|
397 |
|
|
|
398 |
requestPickup.addClickHandler(new ClickHandler() {
|
|
|
399 |
|
|
|
400 |
@Override
|
|
|
401 |
public void onClick(ClickEvent event) {
|
| 2513 |
chandransh |
402 |
if(requestPickup.isEnabled()){
|
|
|
403 |
GWT.log("Raising a pickup request for: " + order.getOrderId());
|
|
|
404 |
eventbus.fireEvent(new RequestPickupEvent(order));
|
|
|
405 |
}
|
| 2509 |
chandransh |
406 |
}
|
|
|
407 |
});
|
|
|
408 |
|
|
|
409 |
authorizePickup.addClickHandler(new ClickHandler() {
|
|
|
410 |
|
|
|
411 |
@Override
|
|
|
412 |
public void onClick(ClickEvent event) {
|
| 2526 |
chandransh |
413 |
if(!authorizePickup.isEnabled())
|
|
|
414 |
return;
|
|
|
415 |
PickupAuthorizationInfoBox box = new PickupAuthorizationInfoBox(eventbus, order);
|
|
|
416 |
box.center();
|
| 2509 |
chandransh |
417 |
}
|
|
|
418 |
});
|
|
|
419 |
|
| 2628 |
chandransh |
420 |
reshipOrder.addClickHandler(new ClickHandler() {
|
|
|
421 |
|
|
|
422 |
@Override
|
|
|
423 |
public void onClick(ClickEvent event) {
|
|
|
424 |
if(reshipOrder.isEnabled()){
|
|
|
425 |
GWT.log("Reshipping the order: " + order.getOrderId());
|
|
|
426 |
eventbus.fireEvent(new ReshipOrderEvent(order));
|
|
|
427 |
}
|
|
|
428 |
}
|
|
|
429 |
});
|
| 4421 |
mandeep.dh |
430 |
|
|
|
431 |
provisionallyCapturePaymentForOrder.addClickHandler(new ClickHandler() {
|
|
|
432 |
|
|
|
433 |
@Override
|
|
|
434 |
public void onClick(ClickEvent event) {
|
|
|
435 |
if(provisionallyCapturePaymentForOrder.isEnabled()) {
|
|
|
436 |
GWT.log("Provisionally capturing payment for order: " + order.getOrderId());
|
|
|
437 |
eventbus.fireEvent(new ProvisionalCaptureEvent(order));
|
|
|
438 |
}
|
|
|
439 |
}
|
|
|
440 |
});
|
|
|
441 |
|
| 2509 |
chandransh |
442 |
refundOrder.addClickHandler(new ClickHandler() {
|
|
|
443 |
|
|
|
444 |
@Override
|
|
|
445 |
public void onClick(ClickEvent event) {
|
| 2747 |
chandransh |
446 |
if(refundOrder.isEnabled()){
|
|
|
447 |
RejectReasonBox box = new RejectReasonBox(eventbus, order, user);
|
| 2558 |
chandransh |
448 |
//box.clear();
|
| 4092 |
chandransh |
449 |
box.center();
|
| 2558 |
chandransh |
450 |
}
|
| 2509 |
chandransh |
451 |
}
|
|
|
452 |
});
|
| 3463 |
chandransh |
453 |
|
|
|
454 |
addWeight.addClickHandler(new ClickHandler() {
|
|
|
455 |
|
|
|
456 |
@Override
|
|
|
457 |
public void onClick(ClickEvent event) {
|
|
|
458 |
if(addWeight.isEnabled()){
|
|
|
459 |
AddWeightBox box = new AddWeightBox(eventbus, order);
|
|
|
460 |
box.center();
|
|
|
461 |
}
|
|
|
462 |
}
|
|
|
463 |
});
|
|
|
464 |
|
|
|
465 |
changeColor.addClickHandler(new ClickHandler() {
|
|
|
466 |
|
|
|
467 |
@Override
|
|
|
468 |
public void onClick(ClickEvent event) {
|
| 3473 |
chandransh |
469 |
if(changeColor.isEnabled()){
|
|
|
470 |
ChooseColorBox box = new ChooseColorBox(eventbus, order);
|
|
|
471 |
box.center();
|
|
|
472 |
}
|
| 3463 |
chandransh |
473 |
}
|
|
|
474 |
});
|
|
|
475 |
|
| 3553 |
chandransh |
476 |
addDelayReason.addClickHandler(new ClickHandler() {
|
|
|
477 |
|
|
|
478 |
@Override
|
|
|
479 |
public void onClick(ClickEvent event) {
|
|
|
480 |
AddDelayReasonBox box = new AddDelayReasonBox(eventbus, order);
|
|
|
481 |
box.center();
|
|
|
482 |
}
|
|
|
483 |
});
|
|
|
484 |
|
| 3463 |
chandransh |
485 |
shiftWarehouse.addClickHandler(new ClickHandler() {
|
|
|
486 |
|
|
|
487 |
@Override
|
|
|
488 |
public void onClick(ClickEvent event) {
|
| 3473 |
chandransh |
489 |
if(shiftWarehouse.isEnabled()){
|
|
|
490 |
ChooseWarehouseBox box = new ChooseWarehouseBox(eventbus, order);
|
|
|
491 |
box.center();
|
|
|
492 |
}
|
| 3463 |
chandransh |
493 |
}
|
|
|
494 |
});
|
| 2509 |
chandransh |
495 |
}
|
|
|
496 |
|
|
|
497 |
private void implementMaskForAdmin(){
|
|
|
498 |
switch(mask){
|
| 4421 |
mandeep.dh |
499 |
case CAPTURE_IN_PROCESS:
|
|
|
500 |
maskButtonsForAdmin(false, false, false, false, true, true, true); //Allow the OM to refund a COD order or an order with low inventory or when a customer calls or writes to cancel an order.
|
|
|
501 |
break;
|
|
|
502 |
case VERIFICATION_PENDING:
|
| 3729 |
chandransh |
503 |
case NEW:
|
|
|
504 |
case NO_STOCK:
|
|
|
505 |
case ACCEPT:
|
|
|
506 |
case BILL:
|
| 4421 |
mandeep.dh |
507 |
maskButtonsForAdmin(false, false, false, false, true, true, false); //Allow the OM to refund a COD order or an order with low inventory or when a customer calls or writes to cancel an order.
|
| 2558 |
chandransh |
508 |
break;
|
| 2509 |
chandransh |
509 |
case DELIVERED:
|
| 4455 |
rajveer |
510 |
maskButtonsForAdmin(false, false, false, false, false, true, false); //Allow the OM to flag and request pickup.
|
|
|
511 |
break;
|
|
|
512 |
case DOA_REQUEST_AUTHORIZED:
|
| 4421 |
mandeep.dh |
513 |
maskButtonsForAdmin(true, true, false, false, false, true, false); //Allow the OM to flag and request pickup.
|
| 2509 |
chandransh |
514 |
break;
|
|
|
515 |
case DOA_PICKUP_REQUESTED:
|
| 4421 |
mandeep.dh |
516 |
maskButtonsForAdmin(true, true, true, false, false, true, false); //Allow the OM to either re-request a pickup no. or authorize pickup by entering one
|
| 2509 |
chandransh |
517 |
break;
|
| 2610 |
chandransh |
518 |
case DOA_RETURNED:
|
| 2509 |
chandransh |
519 |
case SALES_RETURNED:
|
| 4421 |
mandeep.dh |
520 |
maskButtonsForAdmin(false, false, false, true, true, true, false); //Allow the OM to either reship the order or refund it
|
| 2509 |
chandransh |
521 |
break;
|
| 2558 |
chandransh |
522 |
default:
|
| 4421 |
mandeep.dh |
523 |
maskButtonsForAdmin(false, false, false, false, false, true, false); //Unknown state. Let's not allow any untoward actions.
|
| 2558 |
chandransh |
524 |
break;
|
| 2509 |
chandransh |
525 |
}
|
|
|
526 |
}
|
|
|
527 |
|
| 4421 |
mandeep.dh |
528 |
private void maskButtonsForAdmin(boolean flag, boolean reqPickup, boolean authPickup, boolean reship,
|
|
|
529 |
boolean refund, boolean printInv, boolean provisionallyCapturePayment)
|
|
|
530 |
{
|
| 2509 |
chandransh |
531 |
flagOrder.setEnabled(flag);
|
|
|
532 |
requestPickup.setEnabled(reqPickup);
|
|
|
533 |
authorizePickup.setEnabled(authPickup);
|
|
|
534 |
reshipOrder.setEnabled(reship);
|
| 4421 |
mandeep.dh |
535 |
provisionallyCapturePaymentForOrder.setEnabled(provisionallyCapturePayment);
|
| 2509 |
chandransh |
536 |
refundOrder.setEnabled(refund);
|
| 4309 |
rajveer |
537 |
printInvoice.setEnabled(printInv);
|
| 2509 |
chandransh |
538 |
}
|
|
|
539 |
|
| 306 |
ashish |
540 |
private void loadOrderDetails(){
|
| 4175 |
rajveer |
541 |
orderDetails1.add(getHorizontalPanel("FREE ITEM: ", transaction.getDealText()));
|
| 966 |
chandransh |
542 |
orderDetails1.add(getHorizontalPanel("PRODUCT GROUP: ", transaction.getProductGroup()));
|
|
|
543 |
orderDetails1.add(getHorizontalPanel("BRAND: ", transaction.getBrand()));
|
|
|
544 |
orderDetails1.add(getHorizontalPanel("MODEL: ", getModelDisplayName(transaction)));
|
|
|
545 |
orderDetails1.add(getHorizontalPanel("Item ID: ", transaction.getItemId()+""));
|
| 4175 |
rajveer |
546 |
|
| 3553 |
chandransh |
547 |
orderDetails1.add(getHorizontalPanel("DELAY REASON: ", transaction.getDelayReason()));
|
| 4004 |
chandransh |
548 |
orderDetails1.add(getHorizontalPanel("ALERT: ", transaction.getAlert().toString()));
|
| 306 |
ashish |
549 |
|
| 966 |
chandransh |
550 |
orderDetails2.add(getHorizontalPanel("NAME: ", transaction.getCustomerName()));
|
|
|
551 |
orderDetails2.add(getHorizontalPanel("ADDRESS: ", getDisplayAddress(transaction)));
|
|
|
552 |
orderDetails2.add(getHorizontalPanel("MOBILE NUMBER: ", transaction.getCustomerMobileNumber()));
|
| 306 |
ashish |
553 |
|
| 966 |
chandransh |
554 |
orderDetails3.add(getHorizontalPanel("TOTAL WEIGHT: ", transaction.getTotalWeight()+""));
|
|
|
555 |
orderDetails3.add(getHorizontalPanel("TOTAL AMOUNT(Rs): ", transaction.getTotalAmount()+""));
|
| 306 |
ashish |
556 |
|
| 966 |
chandransh |
557 |
orderDetails4.add(getHorizontalPanel("AIRWAY BILL NO: ", transaction.getAirwayBillNo()));
|
|
|
558 |
orderDetails4.add(getHorizontalPanel("INVOICE NUMBER: ", transaction.getInvoiceNumber()));
|
|
|
559 |
orderDetails4.add(getHorizontalPanel("JACKET NUMBER: ", transaction.getJacketNumber() + ""));
|
| 2781 |
chandransh |
560 |
orderDetails4.add(getHorizontalPanel("ITEM NO: ", getDisplayNameForNullableString(transaction.getItemNumber())));
|
|
|
561 |
orderDetails4.add(getHorizontalPanel("IMEI NO: ", transaction.getImeiNumber() + ""));
|
|
|
562 |
|
| 966 |
chandransh |
563 |
orderDetails4.add(getHorizontalPanel("BILLED BY: ", transaction.getBilledBy()));
|
|
|
564 |
}
|
| 639 |
chandransh |
565 |
|
| 966 |
chandransh |
566 |
private HorizontalPanel getHorizontalPanel(String labelText, String valueText) {
|
|
|
567 |
HorizontalPanel hpanel = new HorizontalPanel();
|
| 639 |
chandransh |
568 |
hpanel.setSpacing(5);
|
| 966 |
chandransh |
569 |
hpanel.add(new Label(labelText));
|
|
|
570 |
hpanel.add(new Label(valueText));
|
| 639 |
chandransh |
571 |
hpanel.setCellWidth(hpanel.getWidget(0), "128px");
|
|
|
572 |
hpanel.setCellWidth(hpanel.getWidget(1), "128px");
|
|
|
573 |
hpanel.getWidget(0).setStyleName(selectionStyle.blueLabel());
|
|
|
574 |
hpanel.getWidget(1).setStyleName(selectionStyle.greenLabel());
|
| 966 |
chandransh |
575 |
return hpanel;
|
|
|
576 |
}
|
| 306 |
ashish |
577 |
|
| 966 |
chandransh |
578 |
private String getModelDisplayName(Order order){
|
|
|
579 |
String modelName = "";
|
|
|
580 |
if(order.getModelName()!=null)
|
|
|
581 |
modelName = order.getModelName() + " ";
|
|
|
582 |
if(order.getModelNumber()!=null)
|
|
|
583 |
modelName = modelName + order.getModelNumber();
|
|
|
584 |
if(order.getColor()!=null)
|
|
|
585 |
modelName = modelName + " (" + order.getColor() + ")";
|
|
|
586 |
return modelName;
|
| 306 |
ashish |
587 |
}
|
| 966 |
chandransh |
588 |
|
|
|
589 |
private String getDisplayAddress(Order order){
|
|
|
590 |
StringBuilder displayAddress = new StringBuilder();
|
|
|
591 |
displayAddress.append(order.getCustomerAddress1() + "\n");
|
|
|
592 |
displayAddress.append(order.getCustomerAddress2() + "\n");
|
|
|
593 |
displayAddress.append(order.getCustomerCity() + "\n");
|
|
|
594 |
displayAddress.append(order.getCustomerState() + " PIN - " + order.getCustomerPincode());
|
|
|
595 |
return displayAddress.toString();
|
|
|
596 |
}
|
| 2781 |
chandransh |
597 |
|
|
|
598 |
private String getDisplayNameForNullableString(String s) {
|
|
|
599 |
if (s == null)
|
|
|
600 |
return "";
|
|
|
601 |
return s;
|
|
|
602 |
}
|
| 167 |
ashish |
603 |
}
|