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