| 1146 |
chandransh |
1 |
package in.shop2020.hotspot.dashbaord.client.inbox;
|
|
|
2 |
|
|
|
3 |
import in.shop2020.hotspot.dashbaord.client.event.AddJacketNumberEvent;
|
| 2843 |
chandransh |
4 |
import in.shop2020.hotspot.dashbaord.shared.actions.BillingType;
|
| 1146 |
chandransh |
5 |
import in.shop2020.hotspot.dashbaord.shared.actions.Order;
|
|
|
6 |
|
| 5110 |
mandeep.dh |
7 |
import java.util.Map;
|
|
|
8 |
import java.util.Map.Entry;
|
|
|
9 |
|
| 1146 |
chandransh |
10 |
import org.enunes.gwt.mvp.client.EventBus;
|
|
|
11 |
|
|
|
12 |
import com.google.gwt.event.dom.client.ClickEvent;
|
|
|
13 |
import com.google.gwt.event.dom.client.ClickHandler;
|
|
|
14 |
import com.google.gwt.user.client.ui.Button;
|
|
|
15 |
import com.google.gwt.user.client.ui.DialogBox;
|
|
|
16 |
import com.google.gwt.user.client.ui.HorizontalPanel;
|
|
|
17 |
import com.google.gwt.user.client.ui.Label;
|
| 4286 |
rajveer |
18 |
import com.google.gwt.user.client.ui.ListBox;
|
| 1146 |
chandransh |
19 |
import com.google.gwt.user.client.ui.TextBox;
|
|
|
20 |
import com.google.gwt.user.client.ui.VerticalPanel;
|
| 2781 |
chandransh |
21 |
import com.google.gwt.user.client.ui.Widget;
|
| 1146 |
chandransh |
22 |
|
|
|
23 |
public class JacketInfoBox extends DialogBox {
|
|
|
24 |
private Label errorLabel = new Label("");
|
| 2781 |
chandransh |
25 |
|
| 5110 |
mandeep.dh |
26 |
private Label warehousePickSuggestion = new Label("");
|
| 1146 |
chandransh |
27 |
private Label jacketNumberLabel = new Label("Jacket Number");
|
|
|
28 |
private TextBox jacketNumberBox = new TextBox();
|
| 2781 |
chandransh |
29 |
|
|
|
30 |
private Label itemNumberLabel = new Label("Item Number");
|
|
|
31 |
private TextBox itemNumberBox = new TextBox();
|
|
|
32 |
|
| 4658 |
mandeep.dh |
33 |
private Label serialNumberLabel = new Label("Serial No.");
|
|
|
34 |
private TextBox serialNumberBox = new TextBox();
|
| 2781 |
chandransh |
35 |
|
|
|
36 |
private Label billedBy = new Label("Billed by");
|
|
|
37 |
|
| 5110 |
mandeep.dh |
38 |
private Label warehouseLabel = new Label("Warehouse");
|
|
|
39 |
private ListBox warehouseBox = new ListBox();
|
| 4286 |
rajveer |
40 |
|
|
|
41 |
|
| 1146 |
chandransh |
42 |
private Button submitbutton = new Button("Submit");
|
|
|
43 |
private VerticalPanel vpanel = new VerticalPanel();
|
|
|
44 |
|
| 4286 |
rajveer |
45 |
|
| 5110 |
mandeep.dh |
46 |
public JacketInfoBox(final EventBus eventBus, final Order order, final String user,
|
|
|
47 |
final BillingType billingType, Map<Long, String> warehouses){
|
| 1146 |
chandransh |
48 |
vpanel.add(errorLabel);
|
| 5110 |
mandeep.dh |
49 |
if (order.getPickFromWarehouse() != null) {
|
|
|
50 |
warehousePickSuggestion.setText("Pick from WH: " + order.getPickFromWarehouse());
|
|
|
51 |
}
|
|
|
52 |
|
| 2352 |
chandransh |
53 |
vpanel.add(getHorizontalPanel(jacketNumberLabel, jacketNumberBox)); //Ask for the jacket number
|
| 2843 |
chandransh |
54 |
if(billingType == BillingType.OURS){
|
| 5110 |
mandeep.dh |
55 |
// Check if we need to suggest Hotspot warehouses ?
|
|
|
56 |
vpanel.add(warehousePickSuggestion);
|
| 2843 |
chandransh |
57 |
vpanel.add(getHorizontalPanel(itemNumberLabel, itemNumberBox)); //Ask for the item number
|
| 5110 |
mandeep.dh |
58 |
if(order.isSerialized()) {
|
| 4658 |
mandeep.dh |
59 |
vpanel.add(getHorizontalPanel(serialNumberLabel, serialNumberBox)); //Ask for Serial number only in case of Handsets
|
| 2843 |
chandransh |
60 |
}
|
| 5110 |
mandeep.dh |
61 |
else {
|
|
|
62 |
for(Entry<Long, String> warehouse: warehouses.entrySet()){
|
|
|
63 |
warehouseBox.addItem(warehouse.getValue(), warehouse.getKey()+"");
|
|
|
64 |
}
|
|
|
65 |
|
|
|
66 |
vpanel.add(getHorizontalPanel(warehouseLabel, warehouseBox));
|
|
|
67 |
}
|
| 2352 |
chandransh |
68 |
}
|
| 4286 |
rajveer |
69 |
|
| 2781 |
chandransh |
70 |
vpanel.add(getHorizontalPanel(billedBy, new Label(user)));
|
| 1146 |
chandransh |
71 |
vpanel.add(submitbutton);
|
|
|
72 |
|
|
|
73 |
setWidget(vpanel);
|
|
|
74 |
setAutoHideEnabled(true);
|
|
|
75 |
setGlassEnabled(true);
|
| 2843 |
chandransh |
76 |
if(billingType == BillingType.OURS)
|
|
|
77 |
setText("Enter all the details below:");
|
|
|
78 |
else
|
|
|
79 |
setText("Enter Jacket Number below:");
|
| 1146 |
chandransh |
80 |
setModal(true);
|
|
|
81 |
|
|
|
82 |
submitbutton.addClickHandler(new ClickHandler() {
|
|
|
83 |
|
|
|
84 |
@Override
|
|
|
85 |
public void onClick(ClickEvent event) {
|
| 2352 |
chandransh |
86 |
long jacketNumber = -1;
|
| 4658 |
mandeep.dh |
87 |
String serialNumber = null;
|
| 2843 |
chandransh |
88 |
String itemNumber = "NO_NUMBER";
|
| 2352 |
chandransh |
89 |
try {
|
|
|
90 |
jacketNumber = Long.parseLong(jacketNumberBox.getText());
|
|
|
91 |
} catch(NumberFormatException nfe){
|
|
|
92 |
nfe.printStackTrace();
|
| 1146 |
chandransh |
93 |
}
|
| 2352 |
chandransh |
94 |
|
|
|
95 |
if(jacketNumber <= 0){
|
|
|
96 |
errorLabel.setText("Invalid Jacket number.");
|
|
|
97 |
return;
|
|
|
98 |
}
|
| 5110 |
mandeep.dh |
99 |
|
|
|
100 |
long fulfilmentWarehouseId = -1;
|
| 2843 |
chandransh |
101 |
if(billingType == BillingType.OURS){
|
|
|
102 |
itemNumber = itemNumberBox.getText();
|
|
|
103 |
if(itemNumber==null || itemNumber.trim().isEmpty()){
|
|
|
104 |
errorLabel.setText("Item Number can't be left empty");
|
|
|
105 |
return;
|
|
|
106 |
}
|
|
|
107 |
|
| 5110 |
mandeep.dh |
108 |
if(order.isSerialized()) {
|
| 2843 |
chandransh |
109 |
try {
|
| 4658 |
mandeep.dh |
110 |
serialNumber = serialNumberBox.getText();
|
| 2843 |
chandransh |
111 |
} catch(NumberFormatException nfe){
|
|
|
112 |
nfe.printStackTrace();
|
|
|
113 |
}
|
| 5110 |
mandeep.dh |
114 |
|
| 4658 |
mandeep.dh |
115 |
if(serialNumber == null){
|
|
|
116 |
errorLabel.setText("Invalid Serial number");
|
| 2843 |
chandransh |
117 |
return;
|
|
|
118 |
}
|
|
|
119 |
}
|
| 5110 |
mandeep.dh |
120 |
else {
|
|
|
121 |
try {
|
|
|
122 |
fulfilmentWarehouseId = Long.parseLong(warehouseBox.getValue(warehouseBox.getSelectedIndex()));
|
|
|
123 |
} catch(NumberFormatException nfe) {
|
|
|
124 |
nfe.printStackTrace();
|
|
|
125 |
}
|
|
|
126 |
|
|
|
127 |
if(fulfilmentWarehouseId <= 0){
|
|
|
128 |
errorLabel.setText("Invalid Warehouse");
|
|
|
129 |
return;
|
|
|
130 |
}
|
|
|
131 |
}
|
| 2781 |
chandransh |
132 |
}
|
| 5110 |
mandeep.dh |
133 |
|
|
|
134 |
eventBus.fireEvent(new AddJacketNumberEvent(order, jacketNumber, serialNumber, itemNumber.trim(), user, billingType, fulfilmentWarehouseId));
|
| 2352 |
chandransh |
135 |
hide();
|
|
|
136 |
clean();
|
| 1146 |
chandransh |
137 |
}
|
|
|
138 |
});
|
|
|
139 |
}
|
|
|
140 |
|
| 5110 |
mandeep.dh |
141 |
public void clean() {
|
| 1146 |
chandransh |
142 |
jacketNumberBox.setText("");
|
| 4658 |
mandeep.dh |
143 |
serialNumberBox.setText("");
|
| 1146 |
chandransh |
144 |
errorLabel.setText("");
|
| 5110 |
mandeep.dh |
145 |
warehousePickSuggestion.setText("");
|
| 1146 |
chandransh |
146 |
}
|
| 2352 |
chandransh |
147 |
|
| 4658 |
mandeep.dh |
148 |
private HorizontalPanel getHorizontalPanel(Label label, Widget textBox) {
|
| 2352 |
chandransh |
149 |
HorizontalPanel hpanel = new HorizontalPanel();
|
|
|
150 |
hpanel.setSpacing(5);
|
|
|
151 |
hpanel.add(label);
|
|
|
152 |
hpanel.add(textBox);
|
|
|
153 |
hpanel.setCellWidth(label, "120px");
|
|
|
154 |
return hpanel;
|
|
|
155 |
}
|
| 1146 |
chandransh |
156 |
}
|