| 167 |
ashish |
1 |
package in.shop2020.hotspot.dashbaord.client.inbox;
|
|
|
2 |
|
|
|
3 |
import in.shop2020.hotspot.dashbaord.client.event.AcceptOrderEvent;
|
| 487 |
rajveer |
4 |
import in.shop2020.hotspot.dashbaord.client.event.NostockOrderEvent;
|
| 2509 |
chandransh |
5 |
import in.shop2020.hotspot.dashbaord.client.event.FlagOrderEvent;
|
| 2513 |
chandransh |
6 |
import in.shop2020.hotspot.dashbaord.client.event.RequestPickupEvent;
|
| 306 |
ashish |
7 |
import in.shop2020.hotspot.dashbaord.shared.actions.DetailsMask;
|
| 167 |
ashish |
8 |
import in.shop2020.hotspot.dashbaord.shared.actions.Order;
|
|
|
9 |
|
|
|
10 |
import org.enunes.gwt.mvp.client.EventBus;
|
|
|
11 |
|
|
|
12 |
import com.google.gwt.core.client.GWT;
|
|
|
13 |
import com.google.gwt.event.dom.client.ClickEvent;
|
|
|
14 |
import com.google.gwt.event.dom.client.ClickHandler;
|
|
|
15 |
import com.google.gwt.resources.client.CssResource;
|
|
|
16 |
import com.google.gwt.uibinder.client.UiBinder;
|
|
|
17 |
import com.google.gwt.uibinder.client.UiField;
|
| 487 |
rajveer |
18 |
import com.google.gwt.user.client.Window;
|
| 306 |
ashish |
19 |
import com.google.gwt.user.client.ui.Button;
|
| 167 |
ashish |
20 |
import com.google.gwt.user.client.ui.FlexTable;
|
| 306 |
ashish |
21 |
import com.google.gwt.user.client.ui.HorizontalPanel;
|
|
|
22 |
import com.google.gwt.user.client.ui.Label;
|
| 167 |
ashish |
23 |
import com.google.gwt.user.client.ui.ResizeComposite;
|
| 306 |
ashish |
24 |
import com.google.gwt.user.client.ui.VerticalPanel;
|
| 167 |
ashish |
25 |
import com.google.gwt.user.client.ui.Widget;
|
|
|
26 |
|
|
|
27 |
public class OrderDetails extends ResizeComposite{
|
|
|
28 |
|
|
|
29 |
public interface Listener{
|
|
|
30 |
void onClick();
|
|
|
31 |
}
|
|
|
32 |
|
| 585 |
chandransh |
33 |
interface OrderDetailsUiBinder extends UiBinder<Widget, OrderDetails>{ }
|
| 167 |
ashish |
34 |
|
|
|
35 |
interface SelectionStyle extends CssResource{
|
| 306 |
ashish |
36 |
String blueLabel();
|
|
|
37 |
String greenLabel();
|
| 167 |
ashish |
38 |
}
|
|
|
39 |
|
| 585 |
chandransh |
40 |
private static final OrderDetailsUiBinder binder = GWT.create(OrderDetailsUiBinder.class);
|
| 167 |
ashish |
41 |
|
|
|
42 |
@UiField FlexTable header;
|
|
|
43 |
@UiField FlexTable table;
|
| 306 |
ashish |
44 |
@UiField HorizontalPanel orderDetails;
|
|
|
45 |
@UiField VerticalPanel orderDetails1;
|
|
|
46 |
@UiField VerticalPanel orderDetails2;
|
|
|
47 |
@UiField VerticalPanel orderDetails3;
|
|
|
48 |
@UiField VerticalPanel orderDetails4;
|
|
|
49 |
@UiField VerticalPanel orderDetails5;
|
|
|
50 |
@UiField SelectionStyle selectionStyle;
|
| 167 |
ashish |
51 |
|
|
|
52 |
|
|
|
53 |
private final EventBus eventbus;
|
|
|
54 |
private Order order;
|
|
|
55 |
private Order transaction;
|
| 2509 |
chandransh |
56 |
|
|
|
57 |
//Buttons for the Warehouse Executive
|
| 306 |
ashish |
58 |
private Button acceptOrder = new Button();
|
|
|
59 |
private Button rejectOrder = new Button();
|
|
|
60 |
private Button notAvailable= new Button();
|
|
|
61 |
private Button addBillingInfo= new Button();
|
| 2449 |
chandransh |
62 |
private Button printInvoice = new Button();
|
| 2509 |
chandransh |
63 |
private Button acceptDOA = new Button();
|
|
|
64 |
private Button validateDOA = new Button();
|
| 677 |
chandransh |
65 |
|
| 2509 |
chandransh |
66 |
//Buttons for the Admin
|
|
|
67 |
private Button flagOrder = new Button();
|
|
|
68 |
private Button requestPickup = new Button();
|
|
|
69 |
private Button authorizePickup = new Button();
|
|
|
70 |
private Button refundOrder = new Button();
|
|
|
71 |
private Button reshipOrder = new Button();
|
|
|
72 |
|
| 306 |
ashish |
73 |
private String user;
|
|
|
74 |
private DetailsMask mask;
|
| 677 |
chandransh |
75 |
private long warehouseID;
|
| 2449 |
chandransh |
76 |
private boolean isAdmin;
|
| 167 |
ashish |
77 |
|
| 2449 |
chandransh |
78 |
public OrderDetails(EventBus eventbus, Order order, Order order2, DetailsMask mask, String user, long warehouseID, boolean isAdmin){
|
| 167 |
ashish |
79 |
this.eventbus = eventbus;
|
|
|
80 |
this.order = order;
|
|
|
81 |
this.transaction = order2;
|
| 306 |
ashish |
82 |
this.mask = mask;
|
|
|
83 |
this.user = user;
|
| 677 |
chandransh |
84 |
this.warehouseID = warehouseID;
|
| 2449 |
chandransh |
85 |
this.isAdmin = isAdmin;
|
|
|
86 |
|
| 167 |
ashish |
87 |
initWidget(binder.createAndBindUi(this));
|
| 2509 |
chandransh |
88 |
if(this.isAdmin){
|
|
|
89 |
initTableForAdmin();
|
|
|
90 |
}else{
|
|
|
91 |
initTableForWE();
|
|
|
92 |
}
|
| 306 |
ashish |
93 |
loadOrderDetails();
|
| 167 |
ashish |
94 |
}
|
|
|
95 |
|
| 2509 |
chandransh |
96 |
private void initTableForWE() {
|
| 167 |
ashish |
97 |
header.getColumnFormatter().setWidth(0, "128px");
|
| 306 |
ashish |
98 |
header.getColumnFormatter().setWidth(1, "128px");
|
|
|
99 |
header.getColumnFormatter().setWidth(2, "128px");
|
|
|
100 |
header.getColumnFormatter().setWidth(3, "128px");
|
|
|
101 |
header.getColumnFormatter().setWidth(4, "128px");
|
| 677 |
chandransh |
102 |
header.getColumnFormatter().setWidth(5, "128px");
|
|
|
103 |
header.getColumnFormatter().setWidth(6, "256px");
|
| 306 |
ashish |
104 |
|
|
|
105 |
acceptOrder.setText("Accept");
|
|
|
106 |
notAvailable.setText("Out Of Stock");
|
|
|
107 |
addBillingInfo.setText("Bill");
|
| 2449 |
chandransh |
108 |
printInvoice.setText("Print Invoice");
|
| 2509 |
chandransh |
109 |
acceptDOA.setText("Accept DOA");
|
|
|
110 |
validateDOA.setText("Validate DOA");
|
|
|
111 |
rejectOrder.setText("Reject");
|
| 486 |
rajveer |
112 |
|
| 306 |
ashish |
113 |
header.setWidget(0, 0, acceptOrder);
|
| 487 |
rajveer |
114 |
header.setWidget(0, 1, notAvailable);
|
| 2509 |
chandransh |
115 |
header.setWidget(0, 2, addBillingInfo);
|
|
|
116 |
header.setWidget(0, 3, printInvoice);
|
|
|
117 |
header.setWidget(0, 4, acceptDOA);
|
|
|
118 |
header.setWidget(0, 5, validateDOA);
|
| 849 |
chandransh |
119 |
header.setWidget(0, 6, rejectOrder);
|
| 2509 |
chandransh |
120 |
|
|
|
121 |
registerButtonHandlersForWE();
|
|
|
122 |
implementMaskForWE();
|
| 167 |
ashish |
123 |
}
|
|
|
124 |
|
| 2509 |
chandransh |
125 |
private void registerButtonHandlersForWE(){
|
| 306 |
ashish |
126 |
acceptOrder.addClickHandler(new ClickHandler() {
|
|
|
127 |
|
|
|
128 |
@Override
|
|
|
129 |
public void onClick(ClickEvent event) {
|
|
|
130 |
if(acceptOrder.isEnabled()){
|
|
|
131 |
eventbus.fireEvent(new AcceptOrderEvent(order));
|
|
|
132 |
}
|
|
|
133 |
}
|
|
|
134 |
});
|
|
|
135 |
|
| 486 |
rajveer |
136 |
rejectOrder.addClickHandler(new ClickHandler() {
|
|
|
137 |
|
|
|
138 |
@Override
|
|
|
139 |
public void onClick(ClickEvent event) {
|
|
|
140 |
if(!notAvailable.isEnabled()) return;
|
|
|
141 |
RejectReasonBox box = new RejectReasonBox(eventbus, order);
|
|
|
142 |
//box.clear();
|
|
|
143 |
box.center();
|
|
|
144 |
}
|
|
|
145 |
});
|
|
|
146 |
|
| 487 |
rajveer |
147 |
notAvailable.addClickHandler(new ClickHandler() {
|
|
|
148 |
|
|
|
149 |
@Override
|
|
|
150 |
public void onClick(ClickEvent event) {
|
|
|
151 |
eventbus.fireEvent(new NostockOrderEvent(order));
|
|
|
152 |
}
|
|
|
153 |
});
|
|
|
154 |
|
| 306 |
ashish |
155 |
addBillingInfo.addClickHandler(new ClickHandler() {
|
|
|
156 |
|
|
|
157 |
@Override
|
|
|
158 |
public void onClick(ClickEvent event) {
|
| 1146 |
chandransh |
159 |
if(!addBillingInfo.isEnabled())
|
|
|
160 |
return;
|
| 306 |
ashish |
161 |
BillingInfoBox box = new BillingInfoBox(eventbus, order, user);
|
|
|
162 |
box.center();
|
|
|
163 |
}
|
|
|
164 |
});
|
| 487 |
rajveer |
165 |
|
| 2449 |
chandransh |
166 |
printInvoice.addClickHandler(new ClickHandler() {
|
| 306 |
ashish |
167 |
|
|
|
168 |
@Override
|
|
|
169 |
public void onClick(ClickEvent event) {
|
| 2449 |
chandransh |
170 |
if(!printInvoice.isEnabled())
|
| 1146 |
chandransh |
171 |
return;
|
|
|
172 |
if(order.getJacketNumber()==0){
|
|
|
173 |
JacketInfoBox box = new JacketInfoBox(eventbus, order);
|
|
|
174 |
//box.clean();
|
|
|
175 |
box.center();
|
|
|
176 |
}else{
|
|
|
177 |
String invoiceGenerationUrl = "http://" + Window.Location.getHost() + "/Support/invoice/";
|
|
|
178 |
invoiceGenerationUrl = invoiceGenerationUrl + order.getOrderId();
|
|
|
179 |
Window.open(invoiceGenerationUrl, "newWindowName", "window features.");
|
|
|
180 |
}
|
| 306 |
ashish |
181 |
}
|
|
|
182 |
});
|
| 2449 |
chandransh |
183 |
}
|
| 487 |
rajveer |
184 |
|
| 2509 |
chandransh |
185 |
private void implementMaskForWE(){
|
| 306 |
ashish |
186 |
switch(mask){
|
|
|
187 |
case NEW:
|
| 2509 |
chandransh |
188 |
maskButtonsForWE(true, true, true, false, false, false, false);
|
| 306 |
ashish |
189 |
break;
|
|
|
190 |
case ACCEPT:
|
| 2509 |
chandransh |
191 |
maskButtonsForWE(false, false, false, false, true, false, false);
|
| 306 |
ashish |
192 |
break;
|
| 486 |
rajveer |
193 |
case REJECT:
|
| 2509 |
chandransh |
194 |
maskButtonsForWE(false, false, false, false, false, false, false);
|
| 486 |
rajveer |
195 |
break;
|
| 306 |
ashish |
196 |
case BILL:
|
| 2509 |
chandransh |
197 |
maskButtonsForWE(false, false, false, true, false, false, false);
|
| 306 |
ashish |
198 |
break;
|
|
|
199 |
case SHIP:
|
| 2509 |
chandransh |
200 |
maskButtonsForWE(false, false, false, false, false, false, false);
|
| 306 |
ashish |
201 |
break;
|
| 487 |
rajveer |
202 |
case NO_STOCK:
|
| 2509 |
chandransh |
203 |
maskButtonsForWE(true, true, false, false, false, false, false);
|
| 487 |
rajveer |
204 |
break;
|
| 2509 |
chandransh |
205 |
case DOA_AWAITED:
|
|
|
206 |
maskButtonsForWE(false, false, false, false, false, true, false);
|
|
|
207 |
break;
|
|
|
208 |
case DOA_RETURNED:
|
|
|
209 |
maskButtonsForWE(false, false, false, false, false, false, true);
|
|
|
210 |
break;
|
| 306 |
ashish |
211 |
}
|
|
|
212 |
}
|
|
|
213 |
|
| 2509 |
chandransh |
214 |
private void maskButtonsForWE(boolean accept, boolean reject, boolean notavailable, boolean printInv, boolean billing, boolean acceptdoa, boolean validatedoa){
|
| 306 |
ashish |
215 |
acceptOrder.setEnabled(accept);
|
|
|
216 |
notAvailable.setEnabled(notavailable);
|
| 2449 |
chandransh |
217 |
printInvoice.setEnabled(printInv);
|
| 306 |
ashish |
218 |
addBillingInfo.setEnabled(billing);
|
| 2509 |
chandransh |
219 |
acceptDOA.setEnabled(acceptdoa);
|
|
|
220 |
validateDOA.setEnabled(validatedoa);
|
|
|
221 |
rejectOrder.setEnabled(reject);
|
| 306 |
ashish |
222 |
}
|
| 2509 |
chandransh |
223 |
|
|
|
224 |
private void initTableForAdmin() {
|
|
|
225 |
header.getColumnFormatter().setWidth(0, "128px");
|
|
|
226 |
header.getColumnFormatter().setWidth(1, "128px");
|
|
|
227 |
header.getColumnFormatter().setWidth(2, "128px");
|
|
|
228 |
header.getColumnFormatter().setWidth(3, "128px");
|
|
|
229 |
header.getColumnFormatter().setWidth(4, "128px");
|
|
|
230 |
header.getColumnFormatter().setWidth(5, "128px");
|
|
|
231 |
header.getColumnFormatter().setWidth(6, "256px");
|
|
|
232 |
|
|
|
233 |
if(transaction.isDoaFlag()){
|
|
|
234 |
flagOrder.setText("Unflag");
|
|
|
235 |
} else {
|
|
|
236 |
flagOrder.setText("Flag");
|
|
|
237 |
}
|
|
|
238 |
|
|
|
239 |
requestPickup.setText("Request Pick-up No");
|
|
|
240 |
authorizePickup.setText("Authorize Pick-up");
|
|
|
241 |
reshipOrder.setText("Reship");
|
|
|
242 |
refundOrder.setText("Refund");
|
|
|
243 |
|
|
|
244 |
header.setWidget(0, 0, flagOrder);
|
|
|
245 |
header.setWidget(0, 1, requestPickup);
|
|
|
246 |
header.setWidget(0, 2, authorizePickup);
|
|
|
247 |
header.setWidget(0, 3, reshipOrder);
|
|
|
248 |
header.setWidget(0, 6, refundOrder);
|
|
|
249 |
|
|
|
250 |
registerButtonHandlersForAdmin();
|
|
|
251 |
implementMaskForAdmin();
|
|
|
252 |
}
|
| 306 |
ashish |
253 |
|
| 2509 |
chandransh |
254 |
private void registerButtonHandlersForAdmin(){
|
|
|
255 |
flagOrder.addClickHandler(new ClickHandler() {
|
|
|
256 |
|
|
|
257 |
@Override
|
|
|
258 |
public void onClick(ClickEvent event) {
|
|
|
259 |
if(flagOrder.isEnabled()){
|
|
|
260 |
eventbus.fireEvent(new FlagOrderEvent(order));
|
|
|
261 |
}
|
|
|
262 |
}
|
|
|
263 |
});
|
|
|
264 |
|
|
|
265 |
requestPickup.addClickHandler(new ClickHandler() {
|
|
|
266 |
|
|
|
267 |
@Override
|
|
|
268 |
public void onClick(ClickEvent event) {
|
| 2513 |
chandransh |
269 |
if(requestPickup.isEnabled()){
|
|
|
270 |
GWT.log("Raising a pickup request for: " + order.getOrderId());
|
|
|
271 |
eventbus.fireEvent(new RequestPickupEvent(order));
|
|
|
272 |
}
|
| 2509 |
chandransh |
273 |
}
|
|
|
274 |
});
|
|
|
275 |
|
|
|
276 |
authorizePickup.addClickHandler(new ClickHandler() {
|
|
|
277 |
|
|
|
278 |
@Override
|
|
|
279 |
public void onClick(ClickEvent event) {
|
|
|
280 |
// TODO Auto-generated method stub
|
|
|
281 |
|
|
|
282 |
}
|
|
|
283 |
});
|
|
|
284 |
|
|
|
285 |
refundOrder.addClickHandler(new ClickHandler() {
|
|
|
286 |
|
|
|
287 |
@Override
|
|
|
288 |
public void onClick(ClickEvent event) {
|
|
|
289 |
// TODO Auto-generated method stub
|
|
|
290 |
|
|
|
291 |
}
|
|
|
292 |
});
|
|
|
293 |
}
|
|
|
294 |
|
|
|
295 |
private void implementMaskForAdmin(){
|
|
|
296 |
switch(mask){
|
|
|
297 |
case DELIVERED:
|
|
|
298 |
maskButtonsForAdmin(true, true, false, false, false); //Allow the OM to flag and request pickup.
|
|
|
299 |
break;
|
|
|
300 |
case DOA_PICKUP_REQUESTED:
|
|
|
301 |
maskButtonsForAdmin(true, true, true, false, false); //Allow the OM to either re-request a pickup no. or authorize pickup by entering one
|
|
|
302 |
break;
|
|
|
303 |
case SALES_RETURNED:
|
|
|
304 |
maskButtonsForAdmin(false, false, false, true, true); //Allow the OM to either reship the order or refund it
|
|
|
305 |
break;
|
|
|
306 |
}
|
|
|
307 |
}
|
|
|
308 |
|
|
|
309 |
private void maskButtonsForAdmin(boolean flag, boolean reqPickup, boolean authPickup, boolean reship, boolean refund){
|
|
|
310 |
flagOrder.setEnabled(flag);
|
|
|
311 |
requestPickup.setEnabled(reqPickup);
|
|
|
312 |
authorizePickup.setEnabled(authPickup);
|
|
|
313 |
reshipOrder.setEnabled(reship);
|
|
|
314 |
refundOrder.setEnabled(refund);
|
|
|
315 |
}
|
|
|
316 |
|
| 306 |
ashish |
317 |
private void loadOrderDetails(){
|
| 966 |
chandransh |
318 |
orderDetails1.add(getHorizontalPanel("PRODUCT GROUP: ", transaction.getProductGroup()));
|
|
|
319 |
orderDetails1.add(getHorizontalPanel("BRAND: ", transaction.getBrand()));
|
|
|
320 |
orderDetails1.add(getHorizontalPanel("MODEL: ", getModelDisplayName(transaction)));
|
|
|
321 |
orderDetails1.add(getHorizontalPanel("Item ID: ", transaction.getItemId()+""));
|
|
|
322 |
orderDetails1.add(getHorizontalPanel("EXTRA INFO: ", transaction.getExtraInfo()));
|
| 306 |
ashish |
323 |
|
| 966 |
chandransh |
324 |
orderDetails2.add(getHorizontalPanel("NAME: ", transaction.getCustomerName()));
|
|
|
325 |
orderDetails2.add(getHorizontalPanel("ADDRESS: ", getDisplayAddress(transaction)));
|
|
|
326 |
orderDetails2.add(getHorizontalPanel("MOBILE NUMBER: ", transaction.getCustomerMobileNumber()));
|
| 306 |
ashish |
327 |
|
| 966 |
chandransh |
328 |
orderDetails3.add(getHorizontalPanel("TOTAL WEIGHT: ", transaction.getTotalWeight()+""));
|
|
|
329 |
orderDetails3.add(getHorizontalPanel("TOTAL AMOUNT(Rs): ", transaction.getTotalAmount()+""));
|
| 306 |
ashish |
330 |
|
| 966 |
chandransh |
331 |
orderDetails4.add(getHorizontalPanel("AIRWAY BILL NO: ", transaction.getAirwayBillNo()));
|
|
|
332 |
orderDetails4.add(getHorizontalPanel("INVOICE NUMBER: ", transaction.getInvoiceNumber()));
|
|
|
333 |
orderDetails4.add(getHorizontalPanel("JACKET NUMBER: ", transaction.getJacketNumber() + ""));
|
|
|
334 |
orderDetails4.add(getHorizontalPanel("BILLED BY: ", transaction.getBilledBy()));
|
|
|
335 |
}
|
| 639 |
chandransh |
336 |
|
| 966 |
chandransh |
337 |
private HorizontalPanel getHorizontalPanel(String labelText, String valueText) {
|
|
|
338 |
HorizontalPanel hpanel = new HorizontalPanel();
|
| 639 |
chandransh |
339 |
hpanel.setSpacing(5);
|
| 966 |
chandransh |
340 |
hpanel.add(new Label(labelText));
|
|
|
341 |
hpanel.add(new Label(valueText));
|
| 639 |
chandransh |
342 |
hpanel.setCellWidth(hpanel.getWidget(0), "128px");
|
|
|
343 |
hpanel.setCellWidth(hpanel.getWidget(1), "128px");
|
|
|
344 |
hpanel.getWidget(0).setStyleName(selectionStyle.blueLabel());
|
|
|
345 |
hpanel.getWidget(1).setStyleName(selectionStyle.greenLabel());
|
| 966 |
chandransh |
346 |
return hpanel;
|
|
|
347 |
}
|
| 306 |
ashish |
348 |
|
| 966 |
chandransh |
349 |
private String getModelDisplayName(Order order){
|
|
|
350 |
String modelName = "";
|
|
|
351 |
if(order.getModelName()!=null)
|
|
|
352 |
modelName = order.getModelName() + " ";
|
|
|
353 |
if(order.getModelNumber()!=null)
|
|
|
354 |
modelName = modelName + order.getModelNumber();
|
|
|
355 |
if(order.getColor()!=null)
|
|
|
356 |
modelName = modelName + " (" + order.getColor() + ")";
|
|
|
357 |
return modelName;
|
| 306 |
ashish |
358 |
}
|
| 966 |
chandransh |
359 |
|
|
|
360 |
private String getDisplayAddress(Order order){
|
|
|
361 |
StringBuilder displayAddress = new StringBuilder();
|
|
|
362 |
displayAddress.append(order.getCustomerAddress1() + "\n");
|
|
|
363 |
displayAddress.append(order.getCustomerAddress2() + "\n");
|
|
|
364 |
displayAddress.append(order.getCustomerCity() + "\n");
|
|
|
365 |
displayAddress.append(order.getCustomerState() + " PIN - " + order.getCustomerPincode());
|
|
|
366 |
return displayAddress.toString();
|
|
|
367 |
}
|
| 167 |
ashish |
368 |
}
|