| 1146 |
chandransh |
1 |
package in.shop2020.hotspot.dashbaord.client.inbox;
|
|
|
2 |
|
| 4286 |
rajveer |
3 |
import java.util.HashMap;
|
|
|
4 |
import java.util.Map;
|
|
|
5 |
import java.util.Map.Entry;
|
|
|
6 |
|
| 1146 |
chandransh |
7 |
import in.shop2020.hotspot.dashbaord.client.event.AddJacketNumberEvent;
|
| 2843 |
chandransh |
8 |
import in.shop2020.hotspot.dashbaord.shared.actions.BillingType;
|
| 1146 |
chandransh |
9 |
import in.shop2020.hotspot.dashbaord.shared.actions.Order;
|
|
|
10 |
|
|
|
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;
|
| 4286 |
rajveer |
19 |
import com.google.gwt.user.client.ui.ListBox;
|
| 1146 |
chandransh |
20 |
import com.google.gwt.user.client.ui.TextBox;
|
|
|
21 |
import com.google.gwt.user.client.ui.VerticalPanel;
|
| 2781 |
chandransh |
22 |
import com.google.gwt.user.client.ui.Widget;
|
| 1146 |
chandransh |
23 |
|
|
|
24 |
public class JacketInfoBox extends DialogBox {
|
|
|
25 |
private Label errorLabel = new Label("");
|
| 2781 |
chandransh |
26 |
|
| 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 |
|
| 2352 |
chandransh |
33 |
private Label imeiNumberLabel = new Label("IMEI No.");
|
|
|
34 |
private TextBox imeiNumberBox = new TextBox();
|
| 2781 |
chandransh |
35 |
|
|
|
36 |
private Label billedBy = new Label("Billed by");
|
|
|
37 |
|
| 4286 |
rajveer |
38 |
private Label vendorLabel = new Label("Vendor");
|
|
|
39 |
private ListBox vendorBox = new ListBox();
|
|
|
40 |
|
|
|
41 |
|
| 1146 |
chandransh |
42 |
private Button submitbutton = new Button("Submit");
|
|
|
43 |
private VerticalPanel vpanel = new VerticalPanel();
|
|
|
44 |
|
| 4286 |
rajveer |
45 |
private Map<Long, String> vendors = new HashMap<Long, String>();
|
|
|
46 |
|
| 2843 |
chandransh |
47 |
public JacketInfoBox(final EventBus eventBus, final Order order, final String user, final BillingType billingType){
|
| 1146 |
chandransh |
48 |
vpanel.add(errorLabel);
|
| 2352 |
chandransh |
49 |
vpanel.add(getHorizontalPanel(jacketNumberLabel, jacketNumberBox)); //Ask for the jacket number
|
| 2843 |
chandransh |
50 |
if(billingType == BillingType.OURS){
|
|
|
51 |
vpanel.add(getHorizontalPanel(itemNumberLabel, itemNumberBox)); //Ask for the item number
|
| 4345 |
mandeep.dh |
52 |
if("Handsets".equalsIgnoreCase(order.getProductGroup())) {
|
| 2843 |
chandransh |
53 |
vpanel.add(getHorizontalPanel(imeiNumberLabel, imeiNumberBox)); //Ask for IMEI only in case of Handsets
|
|
|
54 |
}
|
| 2352 |
chandransh |
55 |
}
|
| 4286 |
rajveer |
56 |
|
|
|
57 |
//FIXME Hardcoded for vendor
|
| 4345 |
mandeep.dh |
58 |
// vendors.put(2L, "Tulip Tech Products");
|
| 4286 |
rajveer |
59 |
vendors.put(3L, "Sarvottam Telecare");
|
|
|
60 |
vendors.put(4L, "Indira Switch");
|
| 4345 |
mandeep.dh |
61 |
vendors.put(5L, "S Mobility");
|
|
|
62 |
|
| 4286 |
rajveer |
63 |
for(Entry<Long, String> vendor: vendors.entrySet()){
|
|
|
64 |
vendorBox.addItem(vendor.getValue(), vendor.getKey()+"");
|
|
|
65 |
}
|
|
|
66 |
vpanel.add(getHorizontalPanel(vendorLabel, vendorBox));
|
|
|
67 |
|
|
|
68 |
|
| 2781 |
chandransh |
69 |
vpanel.add(getHorizontalPanel(billedBy, new Label(user)));
|
| 1146 |
chandransh |
70 |
vpanel.add(submitbutton);
|
|
|
71 |
|
|
|
72 |
setWidget(vpanel);
|
|
|
73 |
setAutoHideEnabled(true);
|
|
|
74 |
setGlassEnabled(true);
|
| 2843 |
chandransh |
75 |
if(billingType == BillingType.OURS)
|
|
|
76 |
setText("Enter all the details below:");
|
|
|
77 |
else
|
|
|
78 |
setText("Enter Jacket Number below:");
|
| 1146 |
chandransh |
79 |
setModal(true);
|
|
|
80 |
|
|
|
81 |
submitbutton.addClickHandler(new ClickHandler() {
|
|
|
82 |
|
|
|
83 |
@Override
|
|
|
84 |
public void onClick(ClickEvent event) {
|
| 2352 |
chandransh |
85 |
long jacketNumber = -1;
|
| 2843 |
chandransh |
86 |
long imeiNumber = -1;
|
|
|
87 |
String itemNumber = "NO_NUMBER";
|
| 2352 |
chandransh |
88 |
try {
|
|
|
89 |
jacketNumber = Long.parseLong(jacketNumberBox.getText());
|
|
|
90 |
} catch(NumberFormatException nfe){
|
|
|
91 |
nfe.printStackTrace();
|
| 1146 |
chandransh |
92 |
}
|
| 2352 |
chandransh |
93 |
|
|
|
94 |
if(jacketNumber <= 0){
|
|
|
95 |
errorLabel.setText("Invalid Jacket number.");
|
|
|
96 |
return;
|
|
|
97 |
}
|
|
|
98 |
|
| 2843 |
chandransh |
99 |
if(billingType == BillingType.OURS){
|
|
|
100 |
itemNumber = itemNumberBox.getText();
|
|
|
101 |
if(itemNumber==null || itemNumber.trim().isEmpty()){
|
|
|
102 |
errorLabel.setText("Item Number can't be left empty");
|
|
|
103 |
return;
|
|
|
104 |
}
|
|
|
105 |
|
| 3986 |
chandransh |
106 |
if("Handsets".equalsIgnoreCase(order.getProductGroup())){
|
| 2843 |
chandransh |
107 |
try {
|
|
|
108 |
imeiNumber = Long.parseLong(imeiNumberBox.getText());
|
|
|
109 |
} catch(NumberFormatException nfe){
|
|
|
110 |
nfe.printStackTrace();
|
|
|
111 |
}
|
|
|
112 |
|
|
|
113 |
if(imeiNumber <= 0){
|
|
|
114 |
errorLabel.setText("Invalid IMEI number");
|
|
|
115 |
return;
|
|
|
116 |
}
|
|
|
117 |
}
|
| 2781 |
chandransh |
118 |
}
|
| 4286 |
rajveer |
119 |
long vendorId = -1;
|
|
|
120 |
try {
|
|
|
121 |
vendorId = Long.parseLong(vendorBox.getValue(vendorBox.getSelectedIndex()));
|
|
|
122 |
} catch(NumberFormatException nfe){
|
|
|
123 |
nfe.printStackTrace();
|
|
|
124 |
}
|
|
|
125 |
|
|
|
126 |
if(vendorId <= 0){
|
|
|
127 |
errorLabel.setText("Invalid Vendor");
|
|
|
128 |
return;
|
|
|
129 |
}
|
|
|
130 |
|
|
|
131 |
eventBus.fireEvent(new AddJacketNumberEvent(order, jacketNumber, imeiNumber, itemNumber.trim(), user, billingType, vendorId));
|
| 2352 |
chandransh |
132 |
hide();
|
|
|
133 |
clean();
|
| 1146 |
chandransh |
134 |
}
|
|
|
135 |
});
|
|
|
136 |
}
|
|
|
137 |
|
|
|
138 |
public void clean(){
|
|
|
139 |
jacketNumberBox.setText("");
|
| 2352 |
chandransh |
140 |
imeiNumberBox.setText("");
|
| 1146 |
chandransh |
141 |
errorLabel.setText("");
|
|
|
142 |
}
|
| 2352 |
chandransh |
143 |
|
| 2781 |
chandransh |
144 |
private HorizontalPanel getHorizontalPanel(Label label, Widget textBox){
|
| 2352 |
chandransh |
145 |
HorizontalPanel hpanel = new HorizontalPanel();
|
|
|
146 |
hpanel.setSpacing(5);
|
|
|
147 |
hpanel.add(label);
|
|
|
148 |
hpanel.add(textBox);
|
|
|
149 |
hpanel.setCellWidth(label, "120px");
|
|
|
150 |
return hpanel;
|
|
|
151 |
}
|
| 1146 |
chandransh |
152 |
}
|