| 1464 |
varun.gupt |
1 |
$(function(){
|
|
|
2 |
$('#communication_category').change(function(){
|
|
|
3 |
$('#orderComponent, #awbComponent, #productComponent, #subjectComponent, #msgComponent').hide();
|
|
|
4 |
$('#frmContactUs input[name="submit"]').removeAttr('disabled');
|
|
|
5 |
|
|
|
6 |
switch(parseInt($(this).val())) {
|
|
|
7 |
|
|
|
8 |
case 1:
|
|
|
9 |
$('#orderComponent, #productComponent, #subjectComponent, #msgComponent').show();
|
|
|
10 |
$('#lblSubject').html('Reason');
|
|
|
11 |
$('#reason_to_return').attr('name', 'subject').show();
|
|
|
12 |
$('#delivery_problem, #subject').removeAttr('name').hide();
|
|
|
13 |
$('#product').attr('disabled', 'true');
|
|
|
14 |
|
|
|
15 |
jQuery.ajax({
|
|
|
16 |
type: "GET",
|
|
|
17 |
url: "/contact-us/to_return",
|
|
|
18 |
success: function(data) {
|
|
|
19 |
$("#order_id").html(data);
|
|
|
20 |
}
|
|
|
21 |
});
|
|
|
22 |
lastQueryType = 1;
|
|
|
23 |
break;
|
|
|
24 |
|
|
|
25 |
case 2:
|
|
|
26 |
$('#orderComponent, #subjectComponent, #msgComponent').show();
|
|
|
27 |
$('#lblSubject').html('Reason');
|
|
|
28 |
$('#subject').attr('name', 'subject').show();
|
|
|
29 |
$('#delivery_problem, #reason_to_return').removeAttr('name').hide();
|
|
|
30 |
|
|
|
31 |
jQuery.ajax({
|
|
|
32 |
type: "GET",
|
|
|
33 |
url: "/contact-us/to_cancel",
|
|
|
34 |
success: function(data) {
|
|
|
35 |
$("#order_id").html(data);
|
|
|
36 |
}
|
|
|
37 |
});
|
|
|
38 |
lastQueryType = 2;
|
|
|
39 |
break;
|
|
|
40 |
|
|
|
41 |
case 3:
|
|
|
42 |
$('#orderComponent, #subjectComponent, #msgComponent').show();
|
|
|
43 |
$('#lblSubject').html('Problem Type');
|
|
|
44 |
$('#delivery_problem').attr('name', 'subject').show();
|
|
|
45 |
$('#reason_to_return, #subject').removeAttr('name').hide();
|
|
|
46 |
checkAndUpdateOrderSelector();
|
|
|
47 |
lastQueryType = 3;
|
|
|
48 |
break;
|
|
|
49 |
|
|
|
50 |
case 4:
|
|
|
51 |
$('#orderComponent, #msgComponent').show();
|
|
|
52 |
checkAndUpdateOrderSelector();
|
|
|
53 |
lastQueryType = 4;
|
|
|
54 |
break;
|
|
|
55 |
|
|
|
56 |
case 5:
|
|
|
57 |
$('#orderComponent, #msgComponent').show();
|
|
|
58 |
checkAndUpdateOrderSelector();
|
|
|
59 |
lastQueryType = 5;
|
|
|
60 |
break;
|
|
|
61 |
|
|
|
62 |
case 6:
|
|
|
63 |
$('#subjectComponent, #msgComponent').show();
|
|
|
64 |
$('#lblSubject').html('Product Title');
|
|
|
65 |
$('#subject').attr('name', 'subject').show();
|
|
|
66 |
$('#delivery_problem, #reason_to_return').removeAttr('name').hide();
|
|
|
67 |
checkAndUpdateOrderSelector();
|
|
|
68 |
lastQueryType = 6;
|
|
|
69 |
break;
|
|
|
70 |
|
|
|
71 |
case 7:
|
|
|
72 |
$('#subjectComponent, #msgComponent').show();
|
|
|
73 |
$('#lblSubject').html('Subject');
|
|
|
74 |
$('#subject').attr('name', 'subject').show();
|
|
|
75 |
$('#delivery_problem, #reason_to_return').removeAttr('name').hide();
|
|
|
76 |
checkAndUpdateOrderSelector();
|
|
|
77 |
lastQueryType = 7;
|
|
|
78 |
break;
|
|
|
79 |
|
|
|
80 |
default:
|
|
|
81 |
$('#orderComponent, #awbComponent, #productComponent, #subjectComponent, #msgComponent').hide();
|
|
|
82 |
$('#submit').attr('disabled', 'disabled');
|
|
|
83 |
break;
|
|
|
84 |
}
|
|
|
85 |
});
|
|
|
86 |
function checkAndUpdateOrderSelector() {
|
|
|
87 |
if (lastQueryType == 1 || lastQueryType == 2) {
|
|
|
88 |
jQuery.ajax({
|
|
|
89 |
type: "GET",
|
|
|
90 |
url: "/contact-us/all_orders",
|
|
|
91 |
success: function(data) {
|
|
|
92 |
$("#order_id").html(data);
|
|
|
93 |
}
|
|
|
94 |
});
|
|
|
95 |
}
|
|
|
96 |
}
|
|
|
97 |
|
|
|
98 |
$('#order_id').change(function(){
|
|
|
99 |
var orderId = parseInt($(this).val());
|
|
|
100 |
|
|
|
101 |
if(isNaN(orderId)) {
|
|
|
102 |
alert("Order Id must be an integer");
|
|
|
103 |
} else {
|
|
|
104 |
jQuery.ajax({
|
|
|
105 |
type: "GET",
|
|
|
106 |
url: "/contact-us/" + orderId + "",
|
|
|
107 |
success: function(data) {
|
|
|
108 |
$("#product").removeAttr('disabled').html(data);
|
|
|
109 |
}
|
|
|
110 |
});
|
|
|
111 |
}
|
|
|
112 |
});
|
|
|
113 |
|
|
|
114 |
$('form[name="frmContactUs"]').validate({
|
|
|
115 |
rules: {
|
|
|
116 |
email: {
|
|
|
117 |
required: true,
|
|
|
118 |
email: true
|
|
|
119 |
},
|
|
|
120 |
order_id: {
|
|
|
121 |
required: true,
|
|
|
122 |
digits: true
|
|
|
123 |
}
|
|
|
124 |
}
|
|
|
125 |
});
|
|
|
126 |
});
|