| 7226 |
anupam.sin |
1 |
$(function() {
|
| 7255 |
amit.gupta |
2 |
|
|
|
3 |
$("#query").autocomplete({ autoFocus: true, minLength: 3,
|
| 7323 |
anupam.sin |
4 |
source: "/storewebsite/auto-suggest",
|
| 7255 |
amit.gupta |
5 |
select: function( event, ui ) {
|
|
|
6 |
this.value = ui.item.value;
|
|
|
7 |
$('#formSearch').submit();
|
|
|
8 |
return false;
|
|
|
9 |
}
|
|
|
10 |
});
|
|
|
11 |
|
| 7323 |
anupam.sin |
12 |
$("#formSearch").submit(function() {
|
|
|
13 |
if($("#query").val() == "" || $("#query").val() == "Search for more items...") {
|
|
|
14 |
return false;
|
|
|
15 |
}
|
|
|
16 |
});
|
|
|
17 |
|
| 7226 |
anupam.sin |
18 |
$('#pincodeForm').submit(function() {
|
|
|
19 |
|
|
|
20 |
if($('#pincodeSubmit:hidden').length == 1) {
|
|
|
21 |
return false;
|
|
|
22 |
}
|
|
|
23 |
|
|
|
24 |
if ($('#pincodeText').val().length != 6) {
|
|
|
25 |
alert('Please enter 6 digit pin code');
|
|
|
26 |
return false;
|
|
|
27 |
}
|
|
|
28 |
|
|
|
29 |
var result = $('#pincodeText').val().match(/^\d*$/);
|
|
|
30 |
if(result == null || result.length == 0) {
|
|
|
31 |
alert('Please enter a valid pin code');
|
|
|
32 |
return false;
|
|
|
33 |
}
|
|
|
34 |
|
| 7293 |
anupam.sin |
35 |
$('#priceDiv').empty();
|
| 7226 |
anupam.sin |
36 |
showLoading();
|
|
|
37 |
$.ajax({
|
|
|
38 |
type: "POST",
|
| 7268 |
anupam.sin |
39 |
url: "/storewebsite/estimate",
|
| 7226 |
anupam.sin |
40 |
dataType:"json",
|
| 7268 |
anupam.sin |
41 |
data:$('#pincodeForm').serialize(),
|
|
|
42 |
// timeout: 10000,
|
| 7226 |
anupam.sin |
43 |
success:function(msg) {
|
|
|
44 |
hideLoading();
|
|
|
45 |
if(msg.length != 0) {
|
| 7293 |
anupam.sin |
46 |
if(msg.selling_price == 0.0) {
|
|
|
47 |
$('#loading').hide();
|
|
|
48 |
$('#shippingAddress').hide();
|
|
|
49 |
$('#priceDiv').html("<div class='error'>There was some error. Please try again.</div>");
|
|
|
50 |
$('#pincodeSubmit').show();
|
|
|
51 |
} else {
|
|
|
52 |
$('#priceDiv').html(
|
|
|
53 |
"<div class='date'><span class='infoText'>Get this product by </span><span class='infoValue'>" + msg.delivery_estimate + "</span></div>" +
|
| 7323 |
anupam.sin |
54 |
"<div class='price'><span class='infoText'>Total Price</span><span class='infoValue'> Rs. " + $('#shippingAddress input[name=price]').val() + "</span></div>" +
|
|
|
55 |
"<div class='advance'><span class='infoText'>Advance to be paid</span><span id='advPrice' class='infoValue'> Rs. " + msg.min_advance_amount + "</span></div>");
|
| 7293 |
anupam.sin |
56 |
$('#shippingAddress input[name=advanceAmount]').val(msg.min_advance_amount);
|
|
|
57 |
$('#shippingAddress input[name=deliveryDate]').val(msg.delivery_estimate);
|
|
|
58 |
$('#shippingAddress input[name=minPrice]').val(msg.min_selling_price);
|
|
|
59 |
$('#shippingAddress input[name=maxPrice]').val(msg.max_selling_price);
|
| 7323 |
anupam.sin |
60 |
$('#shippingAddress input[name=bestDealText]').val(msg.best_deal_text);
|
|
|
61 |
$('#bestDealText').text(msg.best_deal_text);
|
|
|
62 |
$('#bestDealContainer').show();
|
| 7293 |
anupam.sin |
63 |
$('#pincodeInput').val($('#pincodeText').val());
|
|
|
64 |
$('#editPriceButton').show();
|
| 7323 |
anupam.sin |
65 |
$('#editPriceBox').val(msg.min_advance_amount);
|
| 7293 |
anupam.sin |
66 |
}
|
|
|
67 |
|
| 7226 |
anupam.sin |
68 |
} else {
|
|
|
69 |
$('#priceDiv').html("<div class='error'>No info found for this pincode. Please try again.</div>");
|
|
|
70 |
}
|
|
|
71 |
},
|
|
|
72 |
error : function(msg) {
|
|
|
73 |
$('#loading').hide();
|
|
|
74 |
$('#shippingAddress').hide();
|
|
|
75 |
$('#priceDiv').html("<div class='error'>There was some error. Please try again.</div>");
|
|
|
76 |
$('#pincodeSubmit').show();
|
|
|
77 |
},
|
|
|
78 |
complete : function() {
|
|
|
79 |
$('#pinSpan').html($('#pincodeText').val());
|
|
|
80 |
|
|
|
81 |
}
|
|
|
82 |
});
|
|
|
83 |
return false;
|
|
|
84 |
});
|
|
|
85 |
|
|
|
86 |
function showLoading() {
|
|
|
87 |
$('#pincodeSubmit').hide();
|
|
|
88 |
$('#shippingAddress').hide();
|
|
|
89 |
$('#loading').show();
|
|
|
90 |
}
|
|
|
91 |
|
|
|
92 |
function hideLoading() {
|
|
|
93 |
$('#loading').hide();
|
|
|
94 |
$('#shippingAddress').show();
|
|
|
95 |
}
|
|
|
96 |
|
|
|
97 |
$('#changePincode').click(function() {
|
| 7323 |
anupam.sin |
98 |
window.location.reload();
|
| 7226 |
anupam.sin |
99 |
});
|
| 7248 |
anupam.sin |
100 |
|
|
|
101 |
$('#pincodeEdit').click(function(event){
|
|
|
102 |
event.preventDefault();
|
|
|
103 |
var newForm = jQuery('<form>', {
|
|
|
104 |
'action': '/storewebsite/order-details',
|
|
|
105 |
'target': '_top'
|
|
|
106 |
}).append(jQuery('<input>', {
|
|
|
107 |
'name': 'product_id',
|
| 7323 |
anupam.sin |
108 |
'value': $('#createOrderForm input[name=product_id]').val(),
|
| 7248 |
anupam.sin |
109 |
'type': 'hidden'
|
| 7323 |
anupam.sin |
110 |
})).append(jQuery('<input>', {
|
|
|
111 |
'name': 'price',
|
|
|
112 |
'value': $('#createOrderForm input[name=price]').val(),
|
|
|
113 |
'type': 'hidden'
|
| 7248 |
anupam.sin |
114 |
}));
|
|
|
115 |
newForm.submit();
|
|
|
116 |
});
|
|
|
117 |
|
|
|
118 |
$('#addressEdit').click(function() {
|
|
|
119 |
$('#createOrder, #showPinDiv, #showAddDiv').hide();
|
|
|
120 |
$('#editAddBlock').show();
|
|
|
121 |
});
|
|
|
122 |
|
|
|
123 |
$('#saveEditedAdd').click(function() {
|
|
|
124 |
var editedFields = $('#editAddBlock input');
|
|
|
125 |
editedFields.each(function(i, inputField) {
|
|
|
126 |
if($(inputField).val() == "") {
|
|
|
127 |
alert("Please enter correct " + $(inputField).attr('name'));
|
|
|
128 |
return false;
|
|
|
129 |
}
|
|
|
130 |
|
|
|
131 |
if ($(inputField).attr('name') == "phone") {
|
|
|
132 |
if ($(inputField).val().length != 10) {
|
|
|
133 |
alert('Please enter a 10 digit mobile number');
|
|
|
134 |
return false;
|
|
|
135 |
}
|
|
|
136 |
|
|
|
137 |
var result = $(inputField).val().match(/^\d*$/);
|
|
|
138 |
if(result == null || result.length == 0) {
|
|
|
139 |
alert('Please enter a valid mobile number');
|
|
|
140 |
return false;
|
|
|
141 |
}
|
|
|
142 |
}
|
|
|
143 |
|
|
|
144 |
var nameToSearch = $(inputField).attr("name");
|
|
|
145 |
$('#showAddDiv [name="' + nameToSearch + '"]').html($(inputField).val());
|
|
|
146 |
$('#createOrderForm input[name="' + nameToSearch + '"]').val($(inputField).val());
|
|
|
147 |
});
|
|
|
148 |
|
|
|
149 |
$('#editAddBlock').hide();
|
|
|
150 |
$('#createOrder, #showPinDiv, #showAddDiv').show();
|
|
|
151 |
});
|
|
|
152 |
|
|
|
153 |
$('#paymode').change(function() {
|
|
|
154 |
if($('#paymode input:radio[name="paymode"]:checked').val() == "card") {
|
|
|
155 |
$('#bankSelector').show();
|
|
|
156 |
} else {
|
|
|
157 |
$('#bankSelector').hide();
|
|
|
158 |
}
|
|
|
159 |
});
|
| 7293 |
anupam.sin |
160 |
|
|
|
161 |
$('#editPriceButton').click(function() {
|
|
|
162 |
$('#editPriceButton').hide();
|
|
|
163 |
$('#editPriceSpan').show();
|
|
|
164 |
});
|
|
|
165 |
|
|
|
166 |
$('#priceFixButton').click(function() {
|
|
|
167 |
var result = $('#editPriceBox').val().match(/^\d*$/);
|
|
|
168 |
if(result == null || result.length == 0) {
|
|
|
169 |
alert('Please enter a valid amount');
|
|
|
170 |
return false;
|
|
|
171 |
}
|
|
|
172 |
|
| 7358 |
anupam.sin |
173 |
if(parseFloat($('#editPriceBox').val()) > parseFloat($('#shippingAddress input[name=price]').val()) + 1) {
|
|
|
174 |
alert('Advance cannot be more than Rs.' + $('#shippingAddress input[name=price]').val());
|
| 7293 |
anupam.sin |
175 |
return false;
|
|
|
176 |
}
|
|
|
177 |
|
|
|
178 |
if(parseFloat($('#editPriceBox').val()) < parseFloat($('#shippingAddress input[name=advanceAmount]').val())) {
|
| 7323 |
anupam.sin |
179 |
alert('Advance cannot be below Rs. ' + $('#shippingAddress input[name=advanceAmount]').val());
|
| 7293 |
anupam.sin |
180 |
return false;
|
|
|
181 |
}
|
|
|
182 |
|
| 7323 |
anupam.sin |
183 |
$('#editPriceButton').show();
|
|
|
184 |
$('#editPriceSpan').hide();
|
|
|
185 |
$('#advPrice').empty();
|
|
|
186 |
$('#advPrice').text(' Rs. ' + parseFloat($('#editPriceBox').val()).toFixed(1));
|
|
|
187 |
$('#shippingAddress input[name=advanceAmount]').val($('#editPriceBox').val());
|
|
|
188 |
});
|
|
|
189 |
|
|
|
190 |
$('#editSellingPriceButton').click(function() {
|
|
|
191 |
$('#editSellingPriceButton').hide();
|
|
|
192 |
$('#pricePopupBox').show();
|
|
|
193 |
});
|
|
|
194 |
|
|
|
195 |
$('#cancelPriceEdit').click(function() {
|
|
|
196 |
$('#pricePopupBox').hide();
|
|
|
197 |
$('#editSellingPriceButton').show();
|
|
|
198 |
});
|
|
|
199 |
|
|
|
200 |
$('#savePriceEdit').click(function() {
|
|
|
201 |
var result = ($('#sellingPriceBox').val().split('.')[0]).match(/^\d*$/);
|
|
|
202 |
if(result == null || result.length == 0) {
|
|
|
203 |
alert('Please enter a valid amount');
|
|
|
204 |
return false;
|
|
|
205 |
}
|
|
|
206 |
|
|
|
207 |
if(parseFloat($('#sellingPriceBox').val()) > parseFloat($('#maxPrice').text())) {
|
|
|
208 |
alert('You cannot sell this product at more than Rs.' + $('#maxPrice').text());
|
|
|
209 |
return false;
|
|
|
210 |
}
|
|
|
211 |
|
| 7358 |
anupam.sin |
212 |
if(parseFloat($('#sellingPriceBox').val()) < parseFloat($('#absMin').val())) {
|
|
|
213 |
alert('You cannot sell below Rs.' + $('#absMin').val());
|
|
|
214 |
return false;
|
|
|
215 |
}
|
|
|
216 |
|
| 7323 |
anupam.sin |
217 |
if(parseFloat($('#sellingPriceBox').val()) < parseFloat($('#minPrice').text())) {
|
| 7293 |
anupam.sin |
218 |
alert('You will need permission of the zonal head to to sell at this price');
|
|
|
219 |
}
|
|
|
220 |
|
| 7323 |
anupam.sin |
221 |
$('#editSellingPriceButton').show();
|
|
|
222 |
$('#pricePopupBox').hide();
|
|
|
223 |
|
|
|
224 |
$('#mrp').html(parseFloat($('#sellingPriceBox').val()).toFixed(2));
|
| 7293 |
anupam.sin |
225 |
});
|
| 7343 |
anupam.sin |
226 |
|
|
|
227 |
$("#dateselector").change(function() {
|
|
|
228 |
if($(this).val()=="3"){
|
|
|
229 |
$("#daterange").show();
|
|
|
230 |
}else {
|
|
|
231 |
$("#daterange").hide();
|
|
|
232 |
}
|
|
|
233 |
});
|
| 7348 |
anupam.sin |
234 |
|
|
|
235 |
$(".cancelButton").click(function() {
|
|
|
236 |
var newForm = jQuery('<form>', {
|
|
|
237 |
'action': '/storewebsite/report!cancelRequest',
|
|
|
238 |
'target': '_top'
|
|
|
239 |
}).append(jQuery('<input>', {
|
|
|
240 |
'name': 'orderId',
|
|
|
241 |
'value': $(this).attr('order'),
|
|
|
242 |
'type': 'hidden'
|
|
|
243 |
}));
|
|
|
244 |
newForm.submit();
|
|
|
245 |
});
|
|
|
246 |
|
|
|
247 |
$(".returnButton").click(function() {
|
|
|
248 |
$("#returnPopupOrder").val($(this).attr("order"));
|
|
|
249 |
$("#returnPopupBox").show();
|
|
|
250 |
});
|
|
|
251 |
|
|
|
252 |
$("#cancelReturnRequest").click(function() {
|
|
|
253 |
$("#returnPopupOrder").val("");
|
|
|
254 |
$("#returnPopupBox").hide();
|
|
|
255 |
});
|
| 7349 |
anupam.sin |
256 |
|
|
|
257 |
$(".refundButton").click(function() {
|
|
|
258 |
$("#refundPopupOrder").val($(this).attr("order"));
|
|
|
259 |
$("#refundPopupBox").show();
|
|
|
260 |
});
|
|
|
261 |
|
|
|
262 |
$("#cancelRefundRequest").click(function() {
|
|
|
263 |
$("#refundPopupOrder").val("");
|
|
|
264 |
$("#refundPopupBox").hide();
|
|
|
265 |
});
|
|
|
266 |
|
| 7226 |
anupam.sin |
267 |
});
|
|
|
268 |
|
|
|
269 |
function validateAddress() {
|
| 7248 |
anupam.sin |
270 |
if ($('input[name=name]').val() == "") {
|
|
|
271 |
alert("Please enter the customer's name");
|
|
|
272 |
return false;
|
|
|
273 |
}
|
|
|
274 |
|
|
|
275 |
if ($('input[name=phone]').val().length != 10) {
|
|
|
276 |
alert('Please enter a 10 digit mobile number');
|
|
|
277 |
return false;
|
|
|
278 |
}
|
|
|
279 |
|
|
|
280 |
var result = $('input[name=phone]').val().match(/^\d*$/);
|
|
|
281 |
if(result == null || result.length == 0) {
|
|
|
282 |
alert('Please enter a valid mobile number');
|
|
|
283 |
return false;
|
|
|
284 |
}
|
|
|
285 |
|
| 7226 |
anupam.sin |
286 |
if ($('input[name=line1]').val() == "") {
|
|
|
287 |
alert('Please enter a shipping address');
|
|
|
288 |
return false;
|
|
|
289 |
}
|
| 7358 |
anupam.sin |
290 |
|
| 7226 |
anupam.sin |
291 |
if ($('input[name=city]').val() == "") {
|
|
|
292 |
alert('Please enter the name of the city');
|
|
|
293 |
return false;
|
|
|
294 |
}
|
|
|
295 |
if ($('input[name=state]').val() == "") {
|
|
|
296 |
alert('Please enter the name of the state');
|
|
|
297 |
return false;
|
|
|
298 |
}
|
|
|
299 |
return true;
|
| 7248 |
anupam.sin |
300 |
}
|
|
|
301 |
|
|
|
302 |
function validatePaymentDetails() {
|
|
|
303 |
if($('#paymode input:radio[name="paymode"]:checked').val() == "card") {
|
|
|
304 |
if($('#bankSelector input:radio[name="bank"]:checked').length == 0) {
|
|
|
305 |
alert('Please select the name of the bank of card terminal');
|
|
|
306 |
return false;
|
|
|
307 |
}
|
|
|
308 |
}
|
| 7349 |
anupam.sin |
309 |
}
|
|
|
310 |
|
|
|
311 |
function validateAmount() {
|
|
|
312 |
var result = $('#refundAmountText').val().match(/^\d*$/);
|
|
|
313 |
if(result == null || result.length == 0) {
|
|
|
314 |
alert('Please enter a valid amount');
|
|
|
315 |
return false;
|
|
|
316 |
}
|
| 7226 |
anupam.sin |
317 |
}
|