| 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 |
|
| 5411 |
rajveer |
7 |
import java.util.ArrayList;
|
|
|
8 |
import java.util.List;
|
| 5110 |
mandeep.dh |
9 |
import java.util.Map;
|
|
|
10 |
|
| 1146 |
chandransh |
11 |
import org.enunes.gwt.mvp.client.EventBus;
|
|
|
12 |
|
|
|
13 |
import com.google.gwt.event.dom.client.ClickEvent;
|
|
|
14 |
import com.google.gwt.event.dom.client.ClickHandler;
|
|
|
15 |
import com.google.gwt.user.client.ui.Button;
|
|
|
16 |
import com.google.gwt.user.client.ui.DialogBox;
|
|
|
17 |
import com.google.gwt.user.client.ui.HorizontalPanel;
|
|
|
18 |
import com.google.gwt.user.client.ui.Label;
|
|
|
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 |
|
| 5411 |
rajveer |
38 |
private Button submitbutton = new Button("Submit");
|
| 1146 |
chandransh |
39 |
private VerticalPanel vpanel = new VerticalPanel();
|
|
|
40 |
|
| 5411 |
rajveer |
41 |
private long quantity;
|
|
|
42 |
private List<String> serialNumbers;
|
|
|
43 |
private List<String> itemNumbers;
|
| 5110 |
mandeep.dh |
44 |
public JacketInfoBox(final EventBus eventBus, final Order order, final String user,
|
|
|
45 |
final BillingType billingType, Map<Long, String> warehouses){
|
| 5411 |
rajveer |
46 |
this.quantity = (long)order.getQuantity();
|
|
|
47 |
serialNumbers = new ArrayList<String>((int)this.quantity);
|
|
|
48 |
itemNumbers = new ArrayList<String>((int)this.quantity);
|
| 1146 |
chandransh |
49 |
vpanel.add(errorLabel);
|
| 5110 |
mandeep.dh |
50 |
if (order.getPickFromWarehouse() != null) {
|
|
|
51 |
warehousePickSuggestion.setText("Pick from WH: " + order.getPickFromWarehouse());
|
|
|
52 |
}
|
|
|
53 |
|
| 2352 |
chandransh |
54 |
vpanel.add(getHorizontalPanel(jacketNumberLabel, jacketNumberBox)); //Ask for the jacket number
|
| 5361 |
mandeep.dh |
55 |
if(billingType == BillingType.OURS) {
|
| 5110 |
mandeep.dh |
56 |
// Check if we need to suggest Hotspot warehouses ?
|
| 5530 |
mandeep.dh |
57 |
vpanel.add(warehousePickSuggestion);
|
|
|
58 |
if (order.isHasItemNumber()) {
|
|
|
59 |
vpanel.add(getHorizontalPanel(itemNumberLabel, itemNumberBox)); //Ask for the item number
|
|
|
60 |
}
|
|
|
61 |
|
| 5110 |
mandeep.dh |
62 |
if(order.isSerialized()) {
|
| 4658 |
mandeep.dh |
63 |
vpanel.add(getHorizontalPanel(serialNumberLabel, serialNumberBox)); //Ask for Serial number only in case of Handsets
|
| 2843 |
chandransh |
64 |
}
|
| 5361 |
mandeep.dh |
65 |
}
|
| 5110 |
mandeep.dh |
66 |
|
| 2781 |
chandransh |
67 |
vpanel.add(getHorizontalPanel(billedBy, new Label(user)));
|
| 1146 |
chandransh |
68 |
vpanel.add(submitbutton);
|
|
|
69 |
|
|
|
70 |
setWidget(vpanel);
|
|
|
71 |
setAutoHideEnabled(true);
|
|
|
72 |
setGlassEnabled(true);
|
| 2843 |
chandransh |
73 |
if(billingType == BillingType.OURS)
|
|
|
74 |
setText("Enter all the details below:");
|
|
|
75 |
else
|
|
|
76 |
setText("Enter Jacket Number below:");
|
| 1146 |
chandransh |
77 |
setModal(true);
|
|
|
78 |
|
|
|
79 |
submitbutton.addClickHandler(new ClickHandler() {
|
|
|
80 |
|
|
|
81 |
@Override
|
|
|
82 |
public void onClick(ClickEvent event) {
|
| 2352 |
chandransh |
83 |
long jacketNumber = -1;
|
| 5442 |
rajveer |
84 |
String serialNumber = "";
|
|
|
85 |
String itemNumber = "";
|
| 2352 |
chandransh |
86 |
try {
|
|
|
87 |
jacketNumber = Long.parseLong(jacketNumberBox.getText());
|
|
|
88 |
} catch(NumberFormatException nfe){
|
|
|
89 |
nfe.printStackTrace();
|
| 1146 |
chandransh |
90 |
}
|
| 2352 |
chandransh |
91 |
|
|
|
92 |
if(jacketNumber <= 0){
|
|
|
93 |
errorLabel.setText("Invalid Jacket number.");
|
|
|
94 |
return;
|
|
|
95 |
}
|
| 5110 |
mandeep.dh |
96 |
|
| 2843 |
chandransh |
97 |
if(billingType == BillingType.OURS){
|
| 5530 |
mandeep.dh |
98 |
if (order.isHasItemNumber()) {
|
|
|
99 |
itemNumber = itemNumberBox.getText();
|
|
|
100 |
if(itemNumber==null || itemNumber.trim().isEmpty()){
|
|
|
101 |
errorLabel.setText("Item Number can't be left empty");
|
|
|
102 |
return;
|
|
|
103 |
}
|
|
|
104 |
itemNumber = itemNumber.trim();
|
|
|
105 |
}
|
|
|
106 |
|
| 5110 |
mandeep.dh |
107 |
if(order.isSerialized()) {
|
| 2843 |
chandransh |
108 |
try {
|
| 4658 |
mandeep.dh |
109 |
serialNumber = serialNumberBox.getText();
|
| 2843 |
chandransh |
110 |
} catch(NumberFormatException nfe){
|
|
|
111 |
nfe.printStackTrace();
|
|
|
112 |
}
|
| 5110 |
mandeep.dh |
113 |
|
| 5442 |
rajveer |
114 |
if(serialNumber == null || serialNumber.isEmpty()){
|
| 4658 |
mandeep.dh |
115 |
errorLabel.setText("Invalid Serial number");
|
| 2843 |
chandransh |
116 |
return;
|
|
|
117 |
}
|
| 5411 |
rajveer |
118 |
serialNumber = serialNumber.trim();
|
| 2843 |
chandransh |
119 |
}
|
| 2781 |
chandransh |
120 |
}
|
| 5411 |
rajveer |
121 |
|
|
|
122 |
serialNumbers.add(serialNumber);
|
|
|
123 |
itemNumbers.add(itemNumber);
|
|
|
124 |
if(billingType == BillingType.OURS && order.isSerialized() && quantity > 1) {
|
|
|
125 |
quantity = quantity - 1;
|
|
|
126 |
itemNumberBox.setText("");
|
|
|
127 |
serialNumberBox.setText("");
|
|
|
128 |
errorLabel.setText( quantity + " more items need to be scanned. Scan next item.");
|
|
|
129 |
return;
|
|
|
130 |
}
|
|
|
131 |
|
|
|
132 |
if(billingType == BillingType.OURS && !order.isSerialized()){
|
|
|
133 |
for(int i=1; i<(int)quantity; i++){
|
|
|
134 |
serialNumbers.add(serialNumber);
|
|
|
135 |
itemNumbers.add(itemNumber);
|
|
|
136 |
}
|
|
|
137 |
}
|
|
|
138 |
|
|
|
139 |
eventBus.fireEvent(new AddJacketNumberEvent(order, jacketNumber, serialNumbers, itemNumbers, user, billingType));
|
| 2352 |
chandransh |
140 |
hide();
|
|
|
141 |
clean();
|
| 1146 |
chandransh |
142 |
}
|
|
|
143 |
});
|
|
|
144 |
}
|
|
|
145 |
|
| 5110 |
mandeep.dh |
146 |
public void clean() {
|
| 1146 |
chandransh |
147 |
jacketNumberBox.setText("");
|
| 4658 |
mandeep.dh |
148 |
serialNumberBox.setText("");
|
| 1146 |
chandransh |
149 |
errorLabel.setText("");
|
| 5110 |
mandeep.dh |
150 |
warehousePickSuggestion.setText("");
|
| 1146 |
chandransh |
151 |
}
|
| 2352 |
chandransh |
152 |
|
| 4658 |
mandeep.dh |
153 |
private HorizontalPanel getHorizontalPanel(Label label, Widget textBox) {
|
| 2352 |
chandransh |
154 |
HorizontalPanel hpanel = new HorizontalPanel();
|
|
|
155 |
hpanel.setSpacing(5);
|
|
|
156 |
hpanel.add(label);
|
|
|
157 |
hpanel.add(textBox);
|
|
|
158 |
hpanel.setCellWidth(label, "120px");
|
|
|
159 |
return hpanel;
|
|
|
160 |
}
|
| 1146 |
chandransh |
161 |
}
|