| 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
|
| 3986 |
chandransh |
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
|
|
|
58 |
//vendors.put(2L, "Tulip Tech Products");
|
|
|
59 |
vendors.put(3L, "Sarvottam Telecare");
|
|
|
60 |
vendors.put(4L, "Indira Switch");
|
|
|
61 |
|
|
|
62 |
for(Entry<Long, String> vendor: vendors.entrySet()){
|
|
|
63 |
vendorBox.addItem(vendor.getValue(), vendor.getKey()+"");
|
|
|
64 |
}
|
|
|
65 |
vpanel.add(getHorizontalPanel(vendorLabel, vendorBox));
|
|
|
66 |
|
|
|
67 |
|
| 2781 |
chandransh |
68 |
vpanel.add(getHorizontalPanel(billedBy, new Label(user)));
|
| 1146 |
chandransh |
69 |
vpanel.add(submitbutton);
|
|
|
70 |
|
|
|
71 |
setWidget(vpanel);
|
|
|
72 |
setAutoHideEnabled(true);
|
|
|
73 |
setGlassEnabled(true);
|
| 2843 |
chandransh |
74 |
if(billingType == BillingType.OURS)
|
|
|
75 |
setText("Enter all the details below:");
|
|
|
76 |
else
|
|
|
77 |
setText("Enter Jacket Number below:");
|
| 1146 |
chandransh |
78 |
setModal(true);
|
|
|
79 |
|
|
|
80 |
submitbutton.addClickHandler(new ClickHandler() {
|
|
|
81 |
|
|
|
82 |
@Override
|
|
|
83 |
public void onClick(ClickEvent event) {
|
| 2352 |
chandransh |
84 |
long jacketNumber = -1;
|
| 2843 |
chandransh |
85 |
long imeiNumber = -1;
|
|
|
86 |
String itemNumber = "NO_NUMBER";
|
| 2352 |
chandransh |
87 |
try {
|
|
|
88 |
jacketNumber = Long.parseLong(jacketNumberBox.getText());
|
|
|
89 |
} catch(NumberFormatException nfe){
|
|
|
90 |
nfe.printStackTrace();
|
| 1146 |
chandransh |
91 |
}
|
| 2352 |
chandransh |
92 |
|
|
|
93 |
if(jacketNumber <= 0){
|
|
|
94 |
errorLabel.setText("Invalid Jacket number.");
|
|
|
95 |
return;
|
|
|
96 |
}
|
|
|
97 |
|
| 2843 |
chandransh |
98 |
if(billingType == BillingType.OURS){
|
|
|
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 |
|
| 3986 |
chandransh |
105 |
if("Handsets".equalsIgnoreCase(order.getProductGroup())){
|
| 2843 |
chandransh |
106 |
try {
|
|
|
107 |
imeiNumber = Long.parseLong(imeiNumberBox.getText());
|
|
|
108 |
} catch(NumberFormatException nfe){
|
|
|
109 |
nfe.printStackTrace();
|
|
|
110 |
}
|
|
|
111 |
|
|
|
112 |
if(imeiNumber <= 0){
|
|
|
113 |
errorLabel.setText("Invalid IMEI number");
|
|
|
114 |
return;
|
|
|
115 |
}
|
|
|
116 |
}
|
| 2781 |
chandransh |
117 |
}
|
| 4286 |
rajveer |
118 |
long vendorId = -1;
|
|
|
119 |
try {
|
|
|
120 |
vendorId = Long.parseLong(vendorBox.getValue(vendorBox.getSelectedIndex()));
|
|
|
121 |
} catch(NumberFormatException nfe){
|
|
|
122 |
nfe.printStackTrace();
|
|
|
123 |
}
|
|
|
124 |
|
|
|
125 |
if(vendorId <= 0){
|
|
|
126 |
errorLabel.setText("Invalid Vendor");
|
|
|
127 |
return;
|
|
|
128 |
}
|
|
|
129 |
|
|
|
130 |
eventBus.fireEvent(new AddJacketNumberEvent(order, jacketNumber, imeiNumber, itemNumber.trim(), user, billingType, vendorId));
|
| 2352 |
chandransh |
131 |
hide();
|
|
|
132 |
clean();
|
| 1146 |
chandransh |
133 |
}
|
|
|
134 |
});
|
|
|
135 |
}
|
|
|
136 |
|
|
|
137 |
public void clean(){
|
|
|
138 |
jacketNumberBox.setText("");
|
| 2352 |
chandransh |
139 |
imeiNumberBox.setText("");
|
| 1146 |
chandransh |
140 |
errorLabel.setText("");
|
|
|
141 |
}
|
| 2352 |
chandransh |
142 |
|
| 2781 |
chandransh |
143 |
private HorizontalPanel getHorizontalPanel(Label label, Widget textBox){
|
| 2352 |
chandransh |
144 |
HorizontalPanel hpanel = new HorizontalPanel();
|
|
|
145 |
hpanel.setSpacing(5);
|
|
|
146 |
hpanel.add(label);
|
|
|
147 |
hpanel.add(textBox);
|
|
|
148 |
hpanel.setCellWidth(label, "120px");
|
|
|
149 |
return hpanel;
|
|
|
150 |
}
|
| 1146 |
chandransh |
151 |
}
|