| 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>");
|
| 7427 |
anupam.sin |
56 |
if(msg.min_advance_amount > parseFloat($('#shippingAddress input[name=price]').val())) {
|
|
|
57 |
$('#shippingAddress input[name=advanceAmount]').val($('#shippingAddress input[name=price]').val());
|
|
|
58 |
$('#editPriceBox').val($('#shippingAddress input[name=price]').val());
|
|
|
59 |
} else {
|
|
|
60 |
$('#shippingAddress input[name=advanceAmount]').val(msg.min_advance_amount);
|
|
|
61 |
$('#editPriceBox').val(msg.min_advance_amount);
|
|
|
62 |
}
|
| 7293 |
anupam.sin |
63 |
$('#shippingAddress input[name=deliveryDate]').val(msg.delivery_estimate);
|
|
|
64 |
$('#shippingAddress input[name=minPrice]').val(msg.min_selling_price);
|
|
|
65 |
$('#shippingAddress input[name=maxPrice]').val(msg.max_selling_price);
|
| 7323 |
anupam.sin |
66 |
$('#shippingAddress input[name=bestDealText]').val(msg.best_deal_text);
|
|
|
67 |
$('#bestDealText').text(msg.best_deal_text);
|
|
|
68 |
$('#bestDealContainer').show();
|
| 7293 |
anupam.sin |
69 |
$('#pincodeInput').val($('#pincodeText').val());
|
|
|
70 |
$('#editPriceButton').show();
|
| 7427 |
anupam.sin |
71 |
|
| 7293 |
anupam.sin |
72 |
}
|
|
|
73 |
|
| 7226 |
anupam.sin |
74 |
} else {
|
|
|
75 |
$('#priceDiv').html("<div class='error'>No info found for this pincode. Please try again.</div>");
|
|
|
76 |
}
|
|
|
77 |
},
|
|
|
78 |
error : function(msg) {
|
|
|
79 |
$('#loading').hide();
|
|
|
80 |
$('#shippingAddress').hide();
|
|
|
81 |
$('#priceDiv').html("<div class='error'>There was some error. Please try again.</div>");
|
|
|
82 |
$('#pincodeSubmit').show();
|
|
|
83 |
},
|
|
|
84 |
complete : function() {
|
|
|
85 |
$('#pinSpan').html($('#pincodeText').val());
|
|
|
86 |
|
|
|
87 |
}
|
|
|
88 |
});
|
|
|
89 |
return false;
|
|
|
90 |
});
|
|
|
91 |
|
|
|
92 |
function showLoading() {
|
|
|
93 |
$('#pincodeSubmit').hide();
|
|
|
94 |
$('#shippingAddress').hide();
|
|
|
95 |
$('#loading').show();
|
|
|
96 |
}
|
|
|
97 |
|
|
|
98 |
function hideLoading() {
|
|
|
99 |
$('#loading').hide();
|
|
|
100 |
$('#shippingAddress').show();
|
|
|
101 |
}
|
|
|
102 |
|
|
|
103 |
$('#changePincode').click(function() {
|
| 7323 |
anupam.sin |
104 |
window.location.reload();
|
| 7226 |
anupam.sin |
105 |
});
|
| 7248 |
anupam.sin |
106 |
|
| 7386 |
anupam.sin |
107 |
$('#reloadSuccessPage').click(function() {
|
|
|
108 |
window.location.reload();
|
|
|
109 |
});
|
|
|
110 |
|
| 7248 |
anupam.sin |
111 |
$('#pincodeEdit').click(function(event){
|
|
|
112 |
event.preventDefault();
|
|
|
113 |
var newForm = jQuery('<form>', {
|
|
|
114 |
'action': '/storewebsite/order-details',
|
|
|
115 |
'target': '_top'
|
|
|
116 |
}).append(jQuery('<input>', {
|
|
|
117 |
'name': 'product_id',
|
| 7323 |
anupam.sin |
118 |
'value': $('#createOrderForm input[name=product_id]').val(),
|
| 7248 |
anupam.sin |
119 |
'type': 'hidden'
|
| 7323 |
anupam.sin |
120 |
})).append(jQuery('<input>', {
|
|
|
121 |
'name': 'price',
|
|
|
122 |
'value': $('#createOrderForm input[name=price]').val(),
|
|
|
123 |
'type': 'hidden'
|
| 7248 |
anupam.sin |
124 |
}));
|
|
|
125 |
newForm.submit();
|
|
|
126 |
});
|
|
|
127 |
|
|
|
128 |
$('#addressEdit').click(function() {
|
|
|
129 |
$('#createOrder, #showPinDiv, #showAddDiv').hide();
|
|
|
130 |
$('#editAddBlock').show();
|
|
|
131 |
});
|
|
|
132 |
|
|
|
133 |
$('#saveEditedAdd').click(function() {
|
|
|
134 |
var editedFields = $('#editAddBlock input');
|
|
|
135 |
editedFields.each(function(i, inputField) {
|
|
|
136 |
if($(inputField).val() == "") {
|
|
|
137 |
alert("Please enter correct " + $(inputField).attr('name'));
|
|
|
138 |
return false;
|
|
|
139 |
}
|
|
|
140 |
|
|
|
141 |
if ($(inputField).attr('name') == "phone") {
|
|
|
142 |
if ($(inputField).val().length != 10) {
|
|
|
143 |
alert('Please enter a 10 digit mobile number');
|
|
|
144 |
return false;
|
|
|
145 |
}
|
|
|
146 |
|
|
|
147 |
var result = $(inputField).val().match(/^\d*$/);
|
|
|
148 |
if(result == null || result.length == 0) {
|
|
|
149 |
alert('Please enter a valid mobile number');
|
|
|
150 |
return false;
|
|
|
151 |
}
|
|
|
152 |
}
|
|
|
153 |
|
|
|
154 |
var nameToSearch = $(inputField).attr("name");
|
|
|
155 |
$('#showAddDiv [name="' + nameToSearch + '"]').html($(inputField).val());
|
|
|
156 |
$('#createOrderForm input[name="' + nameToSearch + '"]').val($(inputField).val());
|
|
|
157 |
});
|
|
|
158 |
|
|
|
159 |
$('#editAddBlock').hide();
|
|
|
160 |
$('#createOrder, #showPinDiv, #showAddDiv').show();
|
|
|
161 |
});
|
|
|
162 |
|
| 7293 |
anupam.sin |
163 |
$('#editPriceButton').click(function() {
|
|
|
164 |
$('#editPriceButton').hide();
|
|
|
165 |
$('#editPriceSpan').show();
|
|
|
166 |
});
|
|
|
167 |
|
|
|
168 |
$('#priceFixButton').click(function() {
|
|
|
169 |
var result = $('#editPriceBox').val().match(/^\d*$/);
|
|
|
170 |
if(result == null || result.length == 0) {
|
|
|
171 |
alert('Please enter a valid amount');
|
|
|
172 |
return false;
|
|
|
173 |
}
|
|
|
174 |
|
| 7427 |
anupam.sin |
175 |
if(parseFloat($('#editPriceBox').val()) > parseFloat($('#shippingAddress input[name=price]').val())) {
|
| 7358 |
anupam.sin |
176 |
alert('Advance cannot be more than Rs.' + $('#shippingAddress input[name=price]').val());
|
| 7293 |
anupam.sin |
177 |
return false;
|
|
|
178 |
}
|
|
|
179 |
|
|
|
180 |
if(parseFloat($('#editPriceBox').val()) < parseFloat($('#shippingAddress input[name=advanceAmount]').val())) {
|
| 7323 |
anupam.sin |
181 |
alert('Advance cannot be below Rs. ' + $('#shippingAddress input[name=advanceAmount]').val());
|
| 7293 |
anupam.sin |
182 |
return false;
|
|
|
183 |
}
|
|
|
184 |
|
| 7323 |
anupam.sin |
185 |
$('#editPriceButton').show();
|
|
|
186 |
$('#editPriceSpan').hide();
|
|
|
187 |
$('#advPrice').empty();
|
|
|
188 |
$('#advPrice').text(' Rs. ' + parseFloat($('#editPriceBox').val()).toFixed(1));
|
|
|
189 |
$('#shippingAddress input[name=advanceAmount]').val($('#editPriceBox').val());
|
|
|
190 |
});
|
|
|
191 |
|
|
|
192 |
$('#editSellingPriceButton').click(function() {
|
|
|
193 |
$('#editSellingPriceButton').hide();
|
|
|
194 |
$('#pricePopupBox').show();
|
|
|
195 |
});
|
|
|
196 |
|
|
|
197 |
$('#cancelPriceEdit').click(function() {
|
|
|
198 |
$('#pricePopupBox').hide();
|
|
|
199 |
$('#editSellingPriceButton').show();
|
|
|
200 |
});
|
|
|
201 |
|
|
|
202 |
$('#savePriceEdit').click(function() {
|
|
|
203 |
var result = ($('#sellingPriceBox').val().split('.')[0]).match(/^\d*$/);
|
|
|
204 |
if(result == null || result.length == 0) {
|
|
|
205 |
alert('Please enter a valid amount');
|
|
|
206 |
return false;
|
|
|
207 |
}
|
|
|
208 |
|
|
|
209 |
if(parseFloat($('#sellingPriceBox').val()) > parseFloat($('#maxPrice').text())) {
|
|
|
210 |
alert('You cannot sell this product at more than Rs.' + $('#maxPrice').text());
|
|
|
211 |
return false;
|
|
|
212 |
}
|
|
|
213 |
|
| 7358 |
anupam.sin |
214 |
if(parseFloat($('#sellingPriceBox').val()) < parseFloat($('#absMin').val())) {
|
|
|
215 |
alert('You cannot sell below Rs.' + $('#absMin').val());
|
|
|
216 |
return false;
|
|
|
217 |
}
|
|
|
218 |
|
| 7323 |
anupam.sin |
219 |
if(parseFloat($('#sellingPriceBox').val()) < parseFloat($('#minPrice').text())) {
|
| 7427 |
anupam.sin |
220 |
alert('You will need permission of the zonal head to sell at this price');
|
| 7293 |
anupam.sin |
221 |
}
|
|
|
222 |
|
| 7323 |
anupam.sin |
223 |
$('#editSellingPriceButton').show();
|
|
|
224 |
$('#pricePopupBox').hide();
|
|
|
225 |
|
|
|
226 |
$('#mrp').html(parseFloat($('#sellingPriceBox').val()).toFixed(2));
|
| 7293 |
anupam.sin |
227 |
});
|
| 7343 |
anupam.sin |
228 |
|
|
|
229 |
$("#dateselector").change(function() {
|
|
|
230 |
if($(this).val()=="3"){
|
|
|
231 |
$("#daterange").show();
|
|
|
232 |
}else {
|
|
|
233 |
$("#daterange").hide();
|
|
|
234 |
}
|
|
|
235 |
});
|
| 7348 |
anupam.sin |
236 |
|
| 7427 |
anupam.sin |
237 |
$("#dateselector1").change(function() {
|
|
|
238 |
if($(this).val()=="3"){
|
|
|
239 |
$("#daterange1").show();
|
|
|
240 |
}else {
|
|
|
241 |
$("#daterange1").hide();
|
|
|
242 |
}
|
|
|
243 |
});
|
|
|
244 |
|
| 7348 |
anupam.sin |
245 |
$(".cancelButton").click(function() {
|
| 7386 |
anupam.sin |
246 |
var r = confirm("Press OK to cancel this order");
|
|
|
247 |
if (r == true) {
|
|
|
248 |
var newForm = jQuery('<form>', {
|
|
|
249 |
'action': '/storewebsite/report!cancelRequest',
|
|
|
250 |
'target': '_top'
|
|
|
251 |
}).append(jQuery('<input>', {
|
|
|
252 |
'name': 'orderId',
|
|
|
253 |
'value': $(this).attr('order'),
|
|
|
254 |
'type': 'hidden'
|
|
|
255 |
}));
|
|
|
256 |
newForm.submit();
|
|
|
257 |
} else {
|
|
|
258 |
return false;
|
|
|
259 |
}
|
| 7348 |
anupam.sin |
260 |
});
|
| 7386 |
anupam.sin |
261 |
|
| 7348 |
anupam.sin |
262 |
$(".returnButton").click(function() {
|
|
|
263 |
$("#returnPopupOrder").val($(this).attr("order"));
|
|
|
264 |
$("#returnPopupBox").show();
|
|
|
265 |
});
|
|
|
266 |
|
|
|
267 |
$("#cancelReturnRequest").click(function() {
|
|
|
268 |
$("#returnPopupOrder").val("");
|
|
|
269 |
$("#returnPopupBox").hide();
|
|
|
270 |
});
|
| 7349 |
anupam.sin |
271 |
|
|
|
272 |
$(".refundButton").click(function() {
|
|
|
273 |
$("#refundPopupOrder").val($(this).attr("order"));
|
|
|
274 |
$("#refundPopupBox").show();
|
|
|
275 |
});
|
|
|
276 |
|
|
|
277 |
$("#cancelRefundRequest").click(function() {
|
|
|
278 |
$("#refundPopupOrder").val("");
|
|
|
279 |
$("#refundPopupBox").hide();
|
|
|
280 |
});
|
|
|
281 |
|
| 7386 |
anupam.sin |
282 |
$('#createOrderForm input[name=cardAmount]').focusin(function() {
|
|
|
283 |
$('#bankSelector').show();
|
|
|
284 |
});
|
|
|
285 |
|
|
|
286 |
$('#createOrderForm input[name=cardAmount]').focusout(function() {
|
|
|
287 |
tmp = parseFloat($('#createOrderForm input[name=cardAmount]').val());
|
|
|
288 |
if(isNaN(tmp) || tmp < 1) {
|
|
|
289 |
$('#bankSelector').hide();
|
|
|
290 |
}
|
|
|
291 |
else {
|
|
|
292 |
$('#bankSelector').show();
|
|
|
293 |
}
|
|
|
294 |
});
|
| 7226 |
anupam.sin |
295 |
});
|
|
|
296 |
|
|
|
297 |
function validateAddress() {
|
| 7248 |
anupam.sin |
298 |
if ($('input[name=name]').val() == "") {
|
|
|
299 |
alert("Please enter the customer's name");
|
|
|
300 |
return false;
|
|
|
301 |
}
|
|
|
302 |
|
|
|
303 |
if ($('input[name=phone]').val().length != 10) {
|
|
|
304 |
alert('Please enter a 10 digit mobile number');
|
|
|
305 |
return false;
|
|
|
306 |
}
|
|
|
307 |
|
|
|
308 |
var result = $('input[name=phone]').val().match(/^\d*$/);
|
|
|
309 |
if(result == null || result.length == 0) {
|
|
|
310 |
alert('Please enter a valid mobile number');
|
|
|
311 |
return false;
|
|
|
312 |
}
|
|
|
313 |
|
| 7226 |
anupam.sin |
314 |
if ($('input[name=line1]').val() == "") {
|
|
|
315 |
alert('Please enter a shipping address');
|
|
|
316 |
return false;
|
|
|
317 |
}
|
| 7358 |
anupam.sin |
318 |
|
| 7226 |
anupam.sin |
319 |
if ($('input[name=city]').val() == "") {
|
|
|
320 |
alert('Please enter the name of the city');
|
|
|
321 |
return false;
|
|
|
322 |
}
|
| 7386 |
anupam.sin |
323 |
if ($('#shipState').val() == "") {
|
| 7226 |
anupam.sin |
324 |
alert('Please enter the name of the state');
|
|
|
325 |
return false;
|
|
|
326 |
}
|
| 7386 |
anupam.sin |
327 |
|
|
|
328 |
if ($('input[name=email]').val() == "") {
|
|
|
329 |
alert("Please enter the customer's name");
|
|
|
330 |
return false;
|
|
|
331 |
}
|
|
|
332 |
|
| 7226 |
anupam.sin |
333 |
return true;
|
| 7248 |
anupam.sin |
334 |
}
|
|
|
335 |
|
|
|
336 |
function validatePaymentDetails() {
|
| 7386 |
anupam.sin |
337 |
if($('#createOrderForm input[name=advanceAmount]').val() == ""){
|
|
|
338 |
total = 0;
|
|
|
339 |
} else {
|
|
|
340 |
total = parseFloat($('#createOrderForm input[name=advanceAmount]').val());
|
|
|
341 |
}
|
|
|
342 |
|
|
|
343 |
if($('#createOrderForm input[name=cashAmount]').val() == ""){
|
|
|
344 |
cashAmount = 0;
|
|
|
345 |
} else {
|
|
|
346 |
cashAmount = parseFloat($('#createOrderForm input[name=cashAmount]').val());
|
|
|
347 |
}
|
|
|
348 |
|
|
|
349 |
if($('#createOrderForm input[name=cardAmount]').val() == ""){
|
|
|
350 |
cardAmount = 0;
|
|
|
351 |
} else {
|
|
|
352 |
cardAmount = parseFloat($('#createOrderForm input[name=cardAmount]').val());
|
|
|
353 |
}
|
|
|
354 |
|
|
|
355 |
if(isNaN(total) || isNaN(cashAmount) || isNaN(cardAmount)) {
|
|
|
356 |
alert("Please enter valid amounts");
|
|
|
357 |
return false;
|
|
|
358 |
}
|
|
|
359 |
|
|
|
360 |
if(total != cashAmount + cardAmount) {
|
|
|
361 |
alert("Sum of cash and card is not equal to advance amount");
|
|
|
362 |
return false;
|
|
|
363 |
}
|
|
|
364 |
|
|
|
365 |
if(cardAmount > 0) {
|
|
|
366 |
if($('#edcSelector').val() == "") {
|
|
|
367 |
alert('Please select the name of EDC bank');
|
| 7248 |
anupam.sin |
368 |
return false;
|
|
|
369 |
}
|
| 7426 |
anupam.sin |
370 |
|
|
|
371 |
if($('#createOrderForm input[name=approvalCode]').val() == "") {
|
|
|
372 |
alert("Please enter approval code");
|
|
|
373 |
return false;
|
|
|
374 |
}
|
| 7248 |
anupam.sin |
375 |
}
|
| 7349 |
anupam.sin |
376 |
}
|
|
|
377 |
|
|
|
378 |
function validateAmount() {
|
|
|
379 |
var result = $('#refundAmountText').val().match(/^\d*$/);
|
|
|
380 |
if(result == null || result.length == 0) {
|
|
|
381 |
alert('Please enter a valid amount');
|
|
|
382 |
return false;
|
|
|
383 |
}
|
| 7226 |
anupam.sin |
384 |
}
|