| 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;
|
| 306 |
ashish |
5 |
import in.shop2020.hotspot.dashbaord.shared.actions.DetailsMask;
|
| 167 |
ashish |
6 |
import in.shop2020.hotspot.dashbaord.shared.actions.Order;
|
|
|
7 |
|
|
|
8 |
import org.enunes.gwt.mvp.client.EventBus;
|
|
|
9 |
|
|
|
10 |
import com.google.gwt.core.client.GWT;
|
|
|
11 |
import com.google.gwt.event.dom.client.ClickEvent;
|
|
|
12 |
import com.google.gwt.event.dom.client.ClickHandler;
|
|
|
13 |
import com.google.gwt.resources.client.CssResource;
|
|
|
14 |
import com.google.gwt.uibinder.client.UiBinder;
|
|
|
15 |
import com.google.gwt.uibinder.client.UiField;
|
| 487 |
rajveer |
16 |
import com.google.gwt.user.client.Window;
|
| 306 |
ashish |
17 |
import com.google.gwt.user.client.ui.Button;
|
| 167 |
ashish |
18 |
import com.google.gwt.user.client.ui.FlexTable;
|
| 306 |
ashish |
19 |
import com.google.gwt.user.client.ui.HorizontalPanel;
|
|
|
20 |
import com.google.gwt.user.client.ui.Label;
|
| 167 |
ashish |
21 |
import com.google.gwt.user.client.ui.ResizeComposite;
|
| 306 |
ashish |
22 |
import com.google.gwt.user.client.ui.VerticalPanel;
|
| 167 |
ashish |
23 |
import com.google.gwt.user.client.ui.Widget;
|
|
|
24 |
|
|
|
25 |
public class OrderDetails extends ResizeComposite{
|
|
|
26 |
|
|
|
27 |
public interface Listener{
|
|
|
28 |
void onClick();
|
|
|
29 |
}
|
|
|
30 |
|
| 585 |
chandransh |
31 |
interface OrderDetailsUiBinder extends UiBinder<Widget, OrderDetails>{ }
|
| 167 |
ashish |
32 |
|
|
|
33 |
interface SelectionStyle extends CssResource{
|
| 306 |
ashish |
34 |
String blueLabel();
|
|
|
35 |
String greenLabel();
|
| 167 |
ashish |
36 |
}
|
|
|
37 |
|
| 585 |
chandransh |
38 |
private static final OrderDetailsUiBinder binder = GWT.create(OrderDetailsUiBinder.class);
|
| 167 |
ashish |
39 |
|
|
|
40 |
@UiField FlexTable header;
|
|
|
41 |
@UiField FlexTable table;
|
| 306 |
ashish |
42 |
@UiField HorizontalPanel orderDetails;
|
|
|
43 |
@UiField VerticalPanel orderDetails1;
|
|
|
44 |
@UiField VerticalPanel orderDetails2;
|
|
|
45 |
@UiField VerticalPanel orderDetails3;
|
|
|
46 |
@UiField VerticalPanel orderDetails4;
|
|
|
47 |
@UiField VerticalPanel orderDetails5;
|
|
|
48 |
@UiField SelectionStyle selectionStyle;
|
| 167 |
ashish |
49 |
|
|
|
50 |
|
|
|
51 |
private final EventBus eventbus;
|
|
|
52 |
private Order order;
|
|
|
53 |
private Order transaction;
|
| 306 |
ashish |
54 |
private Button acceptOrder = new Button();
|
|
|
55 |
private Button rejectOrder = new Button();
|
|
|
56 |
private Button notAvailable= new Button();
|
|
|
57 |
private Button addBillingInfo= new Button();
|
| 2449 |
chandransh |
58 |
private Button printInvoice = new Button();
|
| 677 |
chandransh |
59 |
|
| 306 |
ashish |
60 |
private String user;
|
|
|
61 |
private DetailsMask mask;
|
| 677 |
chandransh |
62 |
private long warehouseID;
|
| 2449 |
chandransh |
63 |
private boolean isAdmin;
|
| 167 |
ashish |
64 |
|
| 2449 |
chandransh |
65 |
public OrderDetails(EventBus eventbus, Order order, Order order2, DetailsMask mask, String user, long warehouseID, boolean isAdmin){
|
| 167 |
ashish |
66 |
this.eventbus = eventbus;
|
|
|
67 |
this.order = order;
|
|
|
68 |
this.transaction = order2;
|
| 306 |
ashish |
69 |
this.mask = mask;
|
|
|
70 |
this.user = user;
|
| 677 |
chandransh |
71 |
this.warehouseID = warehouseID;
|
| 2449 |
chandransh |
72 |
this.isAdmin = isAdmin;
|
|
|
73 |
|
| 167 |
ashish |
74 |
initWidget(binder.createAndBindUi(this));
|
|
|
75 |
initTable();
|
| 306 |
ashish |
76 |
registerButtonHandlers();
|
|
|
77 |
implementMask();
|
|
|
78 |
loadOrderDetails();
|
| 167 |
ashish |
79 |
}
|
|
|
80 |
|
|
|
81 |
private void initTable() {
|
|
|
82 |
header.getColumnFormatter().setWidth(0, "128px");
|
| 306 |
ashish |
83 |
header.getColumnFormatter().setWidth(1, "128px");
|
|
|
84 |
header.getColumnFormatter().setWidth(2, "128px");
|
|
|
85 |
header.getColumnFormatter().setWidth(3, "128px");
|
|
|
86 |
header.getColumnFormatter().setWidth(4, "128px");
|
| 677 |
chandransh |
87 |
header.getColumnFormatter().setWidth(5, "128px");
|
|
|
88 |
header.getColumnFormatter().setWidth(6, "256px");
|
| 306 |
ashish |
89 |
|
|
|
90 |
acceptOrder.setText("Accept");
|
|
|
91 |
rejectOrder.setText("Reject");
|
|
|
92 |
notAvailable.setText("Out Of Stock");
|
|
|
93 |
addBillingInfo.setText("Bill");
|
| 2449 |
chandransh |
94 |
printInvoice.setText("Print Invoice");
|
| 486 |
rajveer |
95 |
|
| 306 |
ashish |
96 |
header.setWidget(0, 0, acceptOrder);
|
| 487 |
rajveer |
97 |
header.setWidget(0, 1, notAvailable);
|
| 2449 |
chandransh |
98 |
header.setWidget(0, 2, printInvoice);
|
| 487 |
rajveer |
99 |
header.setWidget(0, 3, addBillingInfo);
|
| 849 |
chandransh |
100 |
header.setWidget(0, 6, rejectOrder);
|
| 167 |
ashish |
101 |
}
|
|
|
102 |
|
| 306 |
ashish |
103 |
private void registerButtonHandlers(){
|
|
|
104 |
acceptOrder.addClickHandler(new ClickHandler() {
|
|
|
105 |
|
|
|
106 |
@Override
|
|
|
107 |
public void onClick(ClickEvent event) {
|
|
|
108 |
if(acceptOrder.isEnabled()){
|
|
|
109 |
eventbus.fireEvent(new AcceptOrderEvent(order));
|
|
|
110 |
}
|
|
|
111 |
}
|
|
|
112 |
});
|
|
|
113 |
|
| 486 |
rajveer |
114 |
rejectOrder.addClickHandler(new ClickHandler() {
|
|
|
115 |
|
|
|
116 |
@Override
|
|
|
117 |
public void onClick(ClickEvent event) {
|
|
|
118 |
if(!notAvailable.isEnabled()) return;
|
|
|
119 |
RejectReasonBox box = new RejectReasonBox(eventbus, order);
|
|
|
120 |
//box.clear();
|
|
|
121 |
box.center();
|
|
|
122 |
}
|
|
|
123 |
});
|
|
|
124 |
|
| 487 |
rajveer |
125 |
notAvailable.addClickHandler(new ClickHandler() {
|
|
|
126 |
|
|
|
127 |
@Override
|
|
|
128 |
public void onClick(ClickEvent event) {
|
|
|
129 |
eventbus.fireEvent(new NostockOrderEvent(order));
|
|
|
130 |
}
|
|
|
131 |
});
|
|
|
132 |
|
| 306 |
ashish |
133 |
addBillingInfo.addClickHandler(new ClickHandler() {
|
|
|
134 |
|
|
|
135 |
@Override
|
|
|
136 |
public void onClick(ClickEvent event) {
|
| 1146 |
chandransh |
137 |
if(!addBillingInfo.isEnabled())
|
|
|
138 |
return;
|
| 306 |
ashish |
139 |
BillingInfoBox box = new BillingInfoBox(eventbus, order, user);
|
|
|
140 |
box.center();
|
|
|
141 |
}
|
|
|
142 |
});
|
| 487 |
rajveer |
143 |
|
| 2449 |
chandransh |
144 |
printInvoice.addClickHandler(new ClickHandler() {
|
| 306 |
ashish |
145 |
|
|
|
146 |
@Override
|
|
|
147 |
public void onClick(ClickEvent event) {
|
| 2449 |
chandransh |
148 |
if(!printInvoice.isEnabled())
|
| 1146 |
chandransh |
149 |
return;
|
|
|
150 |
if(order.getJacketNumber()==0){
|
|
|
151 |
JacketInfoBox box = new JacketInfoBox(eventbus, order);
|
|
|
152 |
//box.clean();
|
|
|
153 |
box.center();
|
|
|
154 |
}else{
|
|
|
155 |
String invoiceGenerationUrl = "http://" + Window.Location.getHost() + "/Support/invoice/";
|
|
|
156 |
invoiceGenerationUrl = invoiceGenerationUrl + order.getOrderId();
|
|
|
157 |
Window.open(invoiceGenerationUrl, "newWindowName", "window features.");
|
|
|
158 |
}
|
| 306 |
ashish |
159 |
}
|
|
|
160 |
});
|
| 2449 |
chandransh |
161 |
}
|
| 487 |
rajveer |
162 |
|
| 306 |
ashish |
163 |
private void implementMask(){
|
|
|
164 |
switch(mask){
|
|
|
165 |
case NEW:
|
| 2449 |
chandransh |
166 |
maskButtons(true, true, true, false, false);
|
| 306 |
ashish |
167 |
break;
|
|
|
168 |
case ACCEPT:
|
| 2449 |
chandransh |
169 |
maskButtons(false, false, false, false, true);
|
| 306 |
ashish |
170 |
break;
|
| 486 |
rajveer |
171 |
case REJECT:
|
| 2449 |
chandransh |
172 |
maskButtons(false, false, false, false, false);
|
| 486 |
rajveer |
173 |
break;
|
| 306 |
ashish |
174 |
case BILL:
|
| 2449 |
chandransh |
175 |
maskButtons(false, false, false, true, false);
|
| 306 |
ashish |
176 |
break;
|
|
|
177 |
case SHIP:
|
| 2449 |
chandransh |
178 |
maskButtons(false, false, false, false, false);
|
| 306 |
ashish |
179 |
break;
|
| 487 |
rajveer |
180 |
case NO_STOCK:
|
| 2449 |
chandransh |
181 |
maskButtons(true, true, false, false, false);
|
| 487 |
rajveer |
182 |
break;
|
|
|
183 |
|
| 306 |
ashish |
184 |
}
|
|
|
185 |
}
|
|
|
186 |
|
| 2449 |
chandransh |
187 |
private void maskButtons(boolean accept, boolean reject, boolean notavailable, boolean printInv, boolean billing){
|
| 306 |
ashish |
188 |
acceptOrder.setEnabled(accept);
|
|
|
189 |
rejectOrder.setEnabled(reject);
|
|
|
190 |
notAvailable.setEnabled(notavailable);
|
| 2449 |
chandransh |
191 |
printInvoice.setEnabled(printInv);
|
| 306 |
ashish |
192 |
addBillingInfo.setEnabled(billing);
|
|
|
193 |
}
|
|
|
194 |
|
|
|
195 |
private void loadOrderDetails(){
|
| 966 |
chandransh |
196 |
orderDetails1.add(getHorizontalPanel("PRODUCT GROUP: ", transaction.getProductGroup()));
|
|
|
197 |
orderDetails1.add(getHorizontalPanel("BRAND: ", transaction.getBrand()));
|
|
|
198 |
orderDetails1.add(getHorizontalPanel("MODEL: ", getModelDisplayName(transaction)));
|
|
|
199 |
orderDetails1.add(getHorizontalPanel("Item ID: ", transaction.getItemId()+""));
|
|
|
200 |
orderDetails1.add(getHorizontalPanel("EXTRA INFO: ", transaction.getExtraInfo()));
|
| 306 |
ashish |
201 |
|
| 966 |
chandransh |
202 |
orderDetails2.add(getHorizontalPanel("NAME: ", transaction.getCustomerName()));
|
|
|
203 |
orderDetails2.add(getHorizontalPanel("ADDRESS: ", getDisplayAddress(transaction)));
|
|
|
204 |
orderDetails2.add(getHorizontalPanel("MOBILE NUMBER: ", transaction.getCustomerMobileNumber()));
|
| 306 |
ashish |
205 |
|
| 966 |
chandransh |
206 |
orderDetails3.add(getHorizontalPanel("TOTAL WEIGHT: ", transaction.getTotalWeight()+""));
|
|
|
207 |
orderDetails3.add(getHorizontalPanel("TOTAL AMOUNT(Rs): ", transaction.getTotalAmount()+""));
|
| 306 |
ashish |
208 |
|
| 966 |
chandransh |
209 |
orderDetails4.add(getHorizontalPanel("AIRWAY BILL NO: ", transaction.getAirwayBillNo()));
|
|
|
210 |
orderDetails4.add(getHorizontalPanel("INVOICE NUMBER: ", transaction.getInvoiceNumber()));
|
|
|
211 |
orderDetails4.add(getHorizontalPanel("JACKET NUMBER: ", transaction.getJacketNumber() + ""));
|
|
|
212 |
orderDetails4.add(getHorizontalPanel("BILLED BY: ", transaction.getBilledBy()));
|
|
|
213 |
}
|
| 639 |
chandransh |
214 |
|
| 966 |
chandransh |
215 |
private HorizontalPanel getHorizontalPanel(String labelText, String valueText) {
|
|
|
216 |
HorizontalPanel hpanel = new HorizontalPanel();
|
| 639 |
chandransh |
217 |
hpanel.setSpacing(5);
|
| 966 |
chandransh |
218 |
hpanel.add(new Label(labelText));
|
|
|
219 |
hpanel.add(new Label(valueText));
|
| 639 |
chandransh |
220 |
hpanel.setCellWidth(hpanel.getWidget(0), "128px");
|
|
|
221 |
hpanel.setCellWidth(hpanel.getWidget(1), "128px");
|
|
|
222 |
hpanel.getWidget(0).setStyleName(selectionStyle.blueLabel());
|
|
|
223 |
hpanel.getWidget(1).setStyleName(selectionStyle.greenLabel());
|
| 966 |
chandransh |
224 |
return hpanel;
|
|
|
225 |
}
|
| 306 |
ashish |
226 |
|
| 966 |
chandransh |
227 |
private String getModelDisplayName(Order order){
|
|
|
228 |
String modelName = "";
|
|
|
229 |
if(order.getModelName()!=null)
|
|
|
230 |
modelName = order.getModelName() + " ";
|
|
|
231 |
if(order.getModelNumber()!=null)
|
|
|
232 |
modelName = modelName + order.getModelNumber();
|
|
|
233 |
if(order.getColor()!=null)
|
|
|
234 |
modelName = modelName + " (" + order.getColor() + ")";
|
|
|
235 |
return modelName;
|
| 306 |
ashish |
236 |
}
|
| 966 |
chandransh |
237 |
|
|
|
238 |
private String getDisplayAddress(Order order){
|
|
|
239 |
StringBuilder displayAddress = new StringBuilder();
|
|
|
240 |
displayAddress.append(order.getCustomerAddress1() + "\n");
|
|
|
241 |
displayAddress.append(order.getCustomerAddress2() + "\n");
|
|
|
242 |
displayAddress.append(order.getCustomerCity() + "\n");
|
|
|
243 |
displayAddress.append(order.getCustomerState() + " PIN - " + order.getCustomerPincode());
|
|
|
244 |
return displayAddress.toString();
|
|
|
245 |
}
|
| 167 |
ashish |
246 |
}
|